Skip to main content

Commands

The Commands feature in Anedya allows you to send instructions and data payloads directly to your connected IoT devices in realtime. This powerful capability enables you to control and manage your device fleet remotely with ease.

How It Works

1. Creating Commands: Use the Anedya API or dashboard to create a new command containing a name which is used to identify the command by devices and data payload (string or binary format). You can send up to 1KB of payload along with the command. Please note that you can pass a string as well, but in the case of the string, the special characters are escaped automatically to maintain compatibility in a JSON payload.

Each command you create can have a maximum expiry of 7 days, after which it is marked as expired and is no longer available to the device for execution.

2. Real-Time Delivery: As soon as you submit a command, Anedya instantly delivers it to the device for which the command is issued, given it is connected via the MQTT protocol and has subscribed to the command topic. The device receives the command in JSON format. An example is given below:

{
"command": "command-name",
"commandId": "018e9d91-4c70-73e4-a0c8-49cb9fab1cc3",
"data": "command-data",
"datatype": "string",
"exp": 1712601000000
}

The data field contains string if the datatype specified is string, and contains base64 encoded binary data if the type is binary

3. Command Queue: Every command is also stored in a reliable queue, ensuring no instructions are lost if a device is temporarily offline.

4. Device Execution: On receiving the command, the device can execute the command and give acknowledgment. If your devices missed the real-time command message due to any of the:

  • Network issue
  • The device has not subscribed to the command topic
  • Your devices don't use MQTT

the device can fetch and execute commands from MQTT or HTTP APIs. The Device can execute commands either one by one in the order they arrived or retrieve the full list to run multiple commands in parallel according to your custom logic and requirements.

Command Statuses

After submitting a command, you can track its status which will automatically update based on the device's acknowledgments:

  • Pending pending: The initial status when a command is created.
  • Received received: The device has received the command.
  • Processing processing: The device is currently executing the command.
  • Success success: The device has successfully executed the command.
  • Failure failure: There was an error executing the command on the device.
  • Invalidated invalidated: You can manually invalidate a pending command to stop it from being executed. Commands can be invalidated in pending status only. Invalidated commands will be inaccessible to the device. Commands are also invalidated on expiry.
⚠️Status change constraints!

The status can only move in a forward direction. i.e status can not be changed from processing to received.

Device Integration

To receive commands in real-time, devices must subscribe to Anedya's MQTT topic given below for commands.

$anedya/device/{deviceid}/commands

If a device misses any real-time commands, it can use the MQTT or HTTP APIs to fetch and execute pending commands one by one or retrieve the full list. Refer to the Commands APIs for more details on how to do that.

With the powerful Commands feature, you gain precise control over your IoT fleet, sending instructions effortlessly that devices can execute on-demand or on a schedule according to your needs.