Remote device control over RPC

mDash provides several ways of remote device control:

  • low level MQTT
  • device shadow, built on top of MQTT
  • RPC, built on top of MQTT

Device shadow vs RPC

Thus, both device shadow and RPC provide remote control capability. What is the difference?

The main difference is this:

  • device shadow is a state management
  • RPC is request-response, similar to REST

Thus, depending on a task, one or another could suit better. For example, a smart light application better use device shadow, because it fits perfectly with the concept "switch state: on or off". While an ability to reboot the device occasionally, or get the current sensor reading, is easier done with RPC.

Said that, any functionality could be implemented with either, so choose what is best for the task.


RPC means Remote Procedure Call. This is the way to send commands to devices and receive replies, i.e. call remote procedures. It is similar to the RESTful API, but instead of using HTTP protocol for requests and replies, mDash uses JSON-RPC 2.0 over MQTT. The diagram below describes how it works:

+--------+     request MQTT topic:   DEVICE_ID/rpc        +---------+
|        |    <-----------------------------------------  |         |
|        |     {"id":5, "method":"sum","params":[3,4]}    |         |
|        |                                                |         |
| device |                                                |  mDash  |
|        |                                                |         |
|        |              {"id":5, "result": 7}             |         |
|        |   ----------------------------------------->   |         |
+--------+    response MQTT topic: DEVICE_ID/r/rpc     +---------+

How to call an RPC function using mDash UI

  • Login to mDash
  • Click on the "manage" link. NOTE: a device should be online!
  • A management dialog appears. Click on RPC tab
  • In the dropdown, select a method to call, for example Sys.GetInfo
  • Click on "Call" button, see the response

mDash device library provides many built-in RPC functions - for managing files, rebooting, getting information, OTA, etc. It is possible to create any number of custom functions. Here is a list of relevant howtos: