IoT Offline Device Cloud Control Command Message Reaching Solution

foreword
Due to the unstable network and limited battery capacity, many IoT devices cannot be online 24 hours a day. The devices frequently go online and offline, and the devices sleep regularly and go offline, which brings a new problem: how to send the cloud control commands to the devices when the devices are offline , after the device goes online, can it execute business logic according to new instructions?

Architecture plan
Based on the above requirements, we have two general solutions:

The cloud sends the message of MQTT protocol QoS=1
Using the device shadow function of the IoT platform
Solution 1: Send QoS=1 message
In order to receive offline messages, the cooperation between the device and the cloud is required.

Device side configuration
When the device side establishes an mqtt connection, it needs to configure the CONNECT parameter. The CleanSession flag is set to 0, that is, the previously established session state is retained, including:

Client subscription information
Messages with QoS=1 that have not completed acknowledgment.
Messages with QoS=1 not sent to clients.
Operations in the cloud
Cloud Send Control Command API Documentation https://help.aliyun.com/document_detail/69793.html
image.png

Solution 2: Device shadow function
We take updating the running configuration parameters of the cloud printer as an example to introduce the process of updating the configuration parameters through the device shadow function.
image.png

Device side configuration
The device side needs to subscribe to /shadow/get/${YourProductKey}/${YourDeviceName} to obtain cloud control command messages in real time.
After successful CONNECT on the device side, actively query the device shadow command, Pub message to /shadow/update/${YourProductKey}/${YourDeviceName}, the payload structure is as follows:
{
"method": "get"
}
Operations in the cloud
The cloud uses the device shadow interface UpdateDeviceShadow to send control commands: https://help.aliyun.com/document_detail/69954.html

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us