RPC Guide
This page is generated from the Open Location Hub source documentation and should not be edited in the website repository.
What RPC is
RPC is the hub’s command and diagnostics interface.
Use it when you need to ask the hub or a downstream RTLS device/controller to do something right now. Examples:
- check whether the control path is alive
- identify a reachable handler
- send an OMLOX core command through the hub
Do not use RPC for normal CRUD resource management. Use:
- REST CRUD for zones, trackables, providers, and fences
- MQTT/WebSocket streams for ongoing updates and events
- RPC for targeted commands and diagnostics
The simple mental model
Applications call open-rtls-hub. They do not call MQTT devices directly.
Flow:
- The client calls
GET /v2/rpc/availableto see what methods are reachable. - The client calls
PUT /v2/rpcwith a JSON-RPC request. - The hub either handles the method locally or forwards it to the right MQTT handler.
- The hub applies authorization, logging, timeout, and aggregation rules.
- The hub returns the JSON-RPC result or error to the client.
This makes the hub the control-plane front door and audit point.
Available methods
The hub exposes these OMLOX-reserved methods locally:
com.omlox.pingcom.omlox.identifycom.omlox.core.xcmd
The hub also exposes methods announced by external MQTT handlers when those handlers are reachable.
Use:
curl -sS http://localhost:8080/v2/rpc/available \
-H "Authorization: Bearer $TOKEN"
The response maps method names to the reachable handler ids known to the hub.
Calling methods
Call PUT /v2/rpc with a JSON-RPC 2.0 request body.
Example: ping the hub
curl -sS -X PUT http://localhost:8080/v2/rpc \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "ping-1",
"method": "com.omlox.ping",
"params": {
"_aggregation": "_return_first_success"
}
}'
Example: identify a specific handler
curl -sS -X PUT http://localhost:8080/v2/rpc \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "identify-1",
"method": "com.omlox.identify",
"params": {
"_handler_id": "open-rtls-hub"
}
}'
Example: send an OMLOX core command through the hub
curl -sS -X PUT http://localhost:8080/v2/rpc \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "xcmd-1",
"method": "com.omlox.core.xcmd",
"params": {
"_handler_id": "open-rtls-hub",
"command": "XCMD_REQ",
"payload": {
"example": true
}
}
}'
Note:
com.omlox.core.xcmdalready exists at the hub control-plane layer- device execution is provided through the adapter configured for the target deployment
- if no adapter is configured, the hub returns a deterministic unsupported JSON-RPC error
What the built-in methods mean
com.omlox.ping
Use it to prove the RPC path is alive. It returns a small result containing the
hub handler id, the message pong, and a timestamp.
com.omlox.identify
Use it to learn what the hub exposes. It returns the service name, build
version, auth mode, stable hub_id, and built-in method list.
Hub behavior:
nameis the persisted hub label from Postgres-backed hub metadatahub_idis the stable persisted hub UUID used for internal provenance
com.omlox.core.xcmd
Use it when you need to send OMLOX core-zone commands through the hub instead of opening direct MQTT control access to devices. The hub validates and logs the call, then routes it through the configured adapter.
_handler_id, _timeout, and _aggregation
_handler_id
Use _handler_id when one specific handler must receive the command.
Examples:
- target the hub itself with
open-rtls-hub - target a specific external handler discovered from
GET /v2/rpc/available
_timeout
Use _timeout to override the default wait time in milliseconds for a specific
request.
_aggregation
Use _aggregation only when the call may have multiple responders.
Supported values:
_all_within_timeout_return_first_success_return_first_error
Rules:
_handler_idand_aggregationcannot be combined- if
_aggregationis omitted, the hub defaults to_all_within_timeout
What happens when multiple handlers answer
The hub collects responses according to _aggregation.
_all_within_timeout: return one result whoseresponsesarray contains all responses received before timeout_return_first_success: return as soon as a non-error response arrives_return_first_error: return as soon as an error response arrives
If no suitable response arrives, the hub returns a JSON-RPC error.
Authorization
RPC uses two layers of control:
- normal REST bearer-token authentication and route authorization
- RPC-specific method authorization inside the hub
That means a caller can be allowed to reach /v2/rpc and still be denied for a
specific method.
Recommended policy shape:
- allow discovery only to trusted operators or automation
- allow
com.omlox.pingandcom.omlox.identifyto a small support audience if needed - allow
com.omlox.core.xcmdonly to tightly controlled roles - deny unknown/custom methods by default until explicitly approved
How to secure it
Plain language rule:
Do not let every application talk directly to MQTT devices. Let them talk to the hub. The hub checks identity, checks permissions, logs what was called, and only then forwards the command.
Operational guidance:
- require JWT auth for RPC in production
- treat
GET /v2/rpc/availableas sensitive because it shows reachable control functions - grant invoke permission per method, not just generic RPC access
- restrict
com.omlox.core.xcmdmore tightly thanpingoridentify - keep MQTT broker access narrow to the hub and trusted adapters/devices
- use the hub as the audit and policy boundary
- fail closed when authorization or handler selection is uncertain
Logging and audit expectations
The hub logs:
- the method name
- whether the call was accepted or rejected
- handler selection and timeout/failure paths
Operators should treat those logs as the primary audit trail for RPC use.
Repository behavior
- the available-method response exposes handler ids for the methods the hub can reach
- the hub publishes retained MQTT availability announcements for hub-owned methods
com.omlox.core.xcmdexecutes through the deployment adapter configured for the hub and returns a deterministic unsupported error when no adapter is configured