RoboHub build 0.2.0

This page was generated from the source of RoboHub. Edit the source, not this page.

RoboHub Gateway

robohub-gateway

Version: 0.2.0

The edge gateway for RoboHub firmware nodes.

A node writes telemetry as COBS frames over serial. The gateway reads them,
keeps each board's latest values where an HTTP client can read them, forwards
every reading to PlotJuggler over UDP, and answers a REST call that asks a node
to change its sampling rate — an RPC over the same link.

It is written in Rho and generated into a Go server by rho build. The only
host-side parts are the ones Rho cannot express, and they are one port: opening
the serial link, sending a datagram, reading a monotonic clock, remembering
which boards have been heard from, and holding the state a reader and an HTTP
handler share.

What it answers

  • GET /api/v1/telemetry/temperature — the latest reading, from whichever device
    sent it last.
  { "area_id": 7, "node_id": 1, "temperature_c": 24.38, "status": "OK", "last_updated_ms": 186095 }
  • GET /api/v1/nodes — every device a frame has come from, each with its newest
    values. A reading names its own device — an area and a node — so two boards
    numbered 2 in different areas are two devices.
  • GET /api/v1/diagnostics — what the gateway itself is doing: the mode it was
    deployed in, the area it speaks for, its uptime and what it has carried.
  • POST /api/v1/telemetry/sampling-rate — an RPC that changes a node's
    reporting interval, answered 200 with the node's acknowledgement or 504
    when the node does not reply in time. A node may clamp the interval it can
    meet and reports what it actually set.
  • GET / — the gateway page: mode, area, uptime, devices, frames, the latest
    values per node, and a frame history whose first row is newest. A node's
    last_updated_ms is its own uptime; the gateway's wall-clock
    received_at_ms is recorded beside it, and the page renders that locally. The history
    window is /frames/{10|25|50|100|500|1000}; /export/frames/<count>/csv
    exports it. Every node record carries both last_updated_ms (the node's
    uptime) and the gateway's wall-clock received_at_ms.
  • GET /healthz — a liveness probe, registered for every service.

What it emits

Each valid telemetry frame becomes one newline-delimited JSON object on the UDP
collector, naming the device it came from:

{"area_id":7,"node_id":1,"timestamp_ms":186095,"temperature_c":24.38,"status":0}

The wire

A frame is robohub-transport's, the same one a C firmware node writes: a six-byte
header (msg_id, tx_id, payload_len), the payload, and a Fletcher-16 check,
COBS-encoded and closed with a 0x00 delimiter. The payloads and the framing in
this gateway are generated from schemas/gateway.rho, which includes the same
common.rho and link.rho a board's C is generated from, so the two ends are
one description.

A Pico as the gateway

A Pico 2W can be the gateway itself. The robohub-drivers example
examples/gateway/c/repeater is the measuring node plus a downstream UART:
boards wired to it publish the same Telemetry event, and the readings stream
up the USB CDC — to this program when a host is present, or to whatever listens
when there is not.

Configuration

VariableDefaultMeaning
SERIAL_PORT/dev/ttyACM0the node's serial device
SERIAL_BAUD115200the line speed
PLOTJUGGLER_ADDR127.0.0.1:9870the UDP collector, host:port
REST_PORT8080the REST listener, a port; RHO_HTTP_ADDR overrides it
GATEWAY_MODEmasternode, edge, relay or master
GATEWAY_AREA1the area this gateway speaks for

Release history

All notable changes to this module are recorded here, one section per release.

[0.2.0] - 2026-11-01

The gateway page shows a frame history, newest first, with selectable windows
of 10, 25, 50, 100, 500 and 1000 rows and CSV export. A node's timestamp_ms
is its own uptime; the gateway records the wall-clock received_at_ms beside
it and renders that as local date/time. Page and API carry both.