RPC
Subscribe to Server-Side RPC Commands
Section titled “Subscribe to Server-Side RPC Commands”Subscribe to the RPC topic to receive commands targeted at downstream devices.
Topic: v1/gateway/rpc (subscribe + publish)
mosquitto_sub -h "mqtt.thingsboard.cloud" -t "v1/gateway/rpc" -u "$ACCESS_TOKEN"Incoming command format:
{ "device": "Device A", "data": {"id": 1, "method": "toggle_gpio", "params": {"pin": 1}}}| Field | Description |
|---|---|
device | The target device name |
data.id | Request identifier — must be echoed in the reply |
data.method | RPC method name |
data.params | Method parameters (arbitrary JSON) |
Send RPC Reply
Section titled “Send RPC Reply”Send the reply to the same topic:
{"device": "Device A", "id": 1, "data": {"success": true}}mosquitto_pub -h "mqtt.thingsboard.cloud" -t "v1/gateway/rpc" -u "$ACCESS_TOKEN" -m '{"device":"Device A","id":1,"data":{"success":true}}'