RoboHub

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

robohub-provider-mesh

The provider of the gateway interface (robohub.gateway) that reaches Mesh:
an application such as aquarium or energy asks the interface for sources,
readings, history and the live feed, and this provider answers them from the
Mesh project the application is set to. It owns the Mesh paths; the application
calls the interface, never the provider (see
robohub-gateway-contract/index). It never talks to a gateway directly:
Mesh does that.

Binding it

deps:
  robohub:
    robohub-gateway: ">=1.1.0"
    robohub-provider-mesh: ">=0.5.0"

bind:
  robohub.gateway:
    providers: [robohub-provider-mesh]
    config:
      robohub-provider-mesh:
        url: "http://127.0.0.1:8478"
        project: "default"
        transport: auto

Settings

SettingDefaultWhat it is
url—Mesh's address, for an application started by hand. When the keeper starts the application, its RHO_SERVICE_MESH_URL wins
project—The Mesh project whose gateway and sources are used; without one the provider answers nothing
transportautoHow follow gets the live feed: auto (the broker when the keeper gave the application one in ROBOHUB_BUS_*, Mesh's HTTP stream otherwise), bus (the broker or nothing) or http
enabledon"false" keeps it bound but not answering; the settings page's gateway tab sets it through gateway.choose

project and transport are what the gateway tab of an application's settings
page changes (see appshell/index); they are written to the application's
bind.conf. No token is configured: every request carries a short-lived
service token for Mesh, scoped to the project (mesh:<project>), and a token is
only ever sent to Mesh's own address, never to a URL a person stored.

What it calls

Interface functionWhat the provider calls
projects()GET /mesh/api/projects
gateway()GET /mesh/api/projects/{project}/gateway
sources()GET /mesh/api/projects/{project}/sources?base={url}
nodes()GET /mesh/api/projects/{project}/nodes
device_states()nothing: a device's state is a source's value, read by source_state
source_state(source)the source's /value path
source_latest(source)the source's /value path, as a reading
source_history(source, from, to, step)GET /mesh/api/projects/{project}/telemetry/series
telemetry_status()GET /mesh/api/projects/{project}/telemetry/status
follow(path)the project's live feed, into path: the broker topic mesh/{project}/telemetry Mesh relays, or GET /mesh/api/projects/{project}/telemetry/stream
transport()which of the two follow uses: bus, http or none
action(source, state)`POST /mesh/api/projects/{project}/sources/{id}/action?state=onoff`
register_client, client_heartbeat, publishPOST /mesh/api/clients/...

Both transports write the same lines, so an application reads one file either
way. The broker needs the application to bind robohub.bus and to be allowed to
read mesh/+/telemetry (its manifest's bus.subscribe).

A source may be named by ID, by the value or action URL a widget stored, or by a
URL carrying source=. The provider extracts the same ID for all three.

Fetch failures are written to the host application log under the gateway.mesh
subject.

Release history

[0.1.0] - 2026-11-04

The Mesh provider for the gateway contract: projects, a project's gateway, sources, device states and a source's state.

[0.1.1] - 2026-11-04

The provider sends the gateway service token on Mesh requests, so protected Mesh APIs accept its reads and actions.

[0.2.0] - 2026-11-05

The provider serves Mesh telemetry: a source's newest reading, a time-range series and the store status. A source may be named by ID, by the value or action URL a widget stored, or by a URL carrying source=; the provider extracts the ID and asks /mesh/api/projects/{project}/telemetry/series.

[0.2.1] - 2026-11-06

Provider now resolves source IDs from URLs, value URLs, and source= params. Latest and history calls work with any stored form.

[0.2.2] - 2026-11-12

The provider declares rho-log, which it imports, and calls the language's string functions rather than runtime functions its includer had to declare.

[0.3.0] - 2026-11-12

A provider of the gateway interface: it lists robohub.gateway under implements, exports the interface's functions by their own names, and reads Mesh's address and the project from the application's binding (url, project). The provider: block, the configuration string each function took, and the contract helpers it borrowed are gone.

[0.4.0] - 2026-11-13

Implements robohub-gateway 1.1.0. action posts to the source's action path with the project-scoped service token. A transport setting (auto, bus, http; auto by default) chooses how follow gets the live stream: over the broker, from Mesh's relayed mesh/<project>/telemetry topic, when the installation has one (ROBOHUB_BUS_*) — or from Mesh's HTTP stream otherwise. Both write the same lines, so the application reads one file either way. The data directory the answers are written to is made once, not by a mkdir child process on every request.

[0.5.0] - 2026-11-13

Implements robohub-gateway 1.2.0's nodes(), from Mesh's /mesh/api/projects/<project>/nodes (Mesh 0.18).

[0.5.1] - 2026-11-13

A reading is returned as the response body (rho_http_body, rho 0.6.0) instead of through one mesh-source-latest file every caller shared: a page and the background loop asking at once could be handed each other's reading, so a load's switch could read another source's value. A source id in a URL is encoded, including %, # and +, and a value ending in a line break is trimmed ("on\n" is "on").

[0.5.2] - 2026-11-14

Trimming, URL escapes, form fields and decimals come from the toolchain (rho 0.7.0: str_trim, str_url_encode/str_url_decode, form_field, milli_*) rather than this module's own copy, the same on both backends. Needs rho 0.7.0. A query value escapes every reserved byte, and a line break is escaped rather than dropped.

[0.5.3] - 2026-11-14

Its data is kept where app_workspace() says (rho 0.8.0) — the application's workspace, else ~/.rho/apps/<app> — so two applications started by hand no longer share this module's records. Copies of helpers the toolchain now provides (i64_to_str, str_lower, str_field, json_str_field, escape_html) are gone. Needs rho 0.8.0.

[0.5.4] - 2026-11-14

token is no longer listed among its settings: it never read one (every request carries a service token from the issuer). A bind.conf that still has the line is unaffected; the line is ignored.