Important note Please note that this guide is for ThingsBoard versions prior v2.0. Old rules and plugins functionality is replaced by new rule engine components (rule chains and rule nodes). Please review new rule engine documentation to learn how to adopt new functionality. We are doing our best to modify this guide to v2.0 components. Contributions are welcome. |
This RPC plugin enables communication between various IoT devices through the ThingsBoard cluster. The plugin introduces basic security features: devices are able to exchange messages only if they belong to the same customer. The plugin implementation can be customized to cover more complex security features.
You can specify following configuration parameters:
The plugin handles two rpc methods: getDevices and sendMsg. The examples listed below will be based on demo account and MQTT protocol. Please note that you are able to use other protocols - CoAP and HTTP.
In order to send a message to other devices, you will need to know their identifiers. A device can request a list of other devices that belong to the same customer using getDevices RPC call.
resources/mqtt-get-device-list.sh |
---|
|
resources/mqtt-get-device-list.js |
---|
|
resources/mqtt-get-device-list.json |
---|
|
A device can send a message to other device that belongs to the same customer using sendMsg RPC call.
The example below will attempt to send a message from device “Test Device A1” to device “Test Device A2”.
resources/mqtt-send-msg.sh |
---|
|
resources/mqtt-send-msg.js |
---|
|
As a result, you should receive the following error:
{"error":"No active connection to the remote device!"}
Let’s launch emulator of target device and send message again:
resources/mqtt-receive-msg.sh |
---|
|
resources/mqtt-receive-msg.js |
---|
|
As a result, you should receive following response from device:
{"status":"ok"}
Note that target device id, access tokens, request and response bodies are hardcoded into scripts and correspond to the demo devices.
As a tenant administrator, you are able to review plugin example inside Plugins->Demo Device Messaging RPC Plugin.