RPC over MQTT¶
RPC api is reachable over MQTT messages. This communication protocol require an MQTT broker.
Topics¶
Device connect to the broker that is set in configuration mqtt.server
and the topic used for request/response is by default set in mqtt.client_id
.
You can edit topic for request/response editing rpc.mqtt.pub_topic``and ``rpc.mqtt.sub_topic
.
To edit configuration see :ref:` Configuration RPC <configuration-api>`.
Example¶
In this example, we use a command line tools (Mqtt CLI)to publish mqtt messages, but you can use any other mqtt client.
mqtt pub -t <device-id>/rpc -q 1 -m '{"src": "<choose-a-client-id>", "id": <choose-a-message-id>, "method": "Totem.Layer.Steady", "params": { "layer": 0, "color": "005555" }}' -h <broker-url> -u <broker-username> -pw
To check which topic your device is listening on, you can call check the configuration (Config.Get) at path: rpc.mqtt.sub_topic
. By default, device listen on topic <device_id>/rpc
.