当前位置:网站首页>08. Tencent cloud IOT device side learning - device shadow and attributes

08. Tencent cloud IOT device side learning - device shadow and attributes

2022-06-24 11:02:00 fancyxu

The main purpose of this series is to record the learning notes of Tencent cloud Internet of things device , And on the device side SDK Make a supplementary explanation .

brief introduction

Device shadow and attributes

Device shadow and attributes are used for server and device communication , It mainly realizes the reliable transmission of the application layer ( Can be based on QoS0)、 Solve the problem of message storage and distribution when messages are offline .

The difference in QoS1 Full message store for , The device shadow is through get Method , Property is through get status To get the difference between states , This reduces message delivery and device status updates .

IoT Explorer The internal test phase attribute is also implemented through the device shadow message , Subsequently, it is abstracted into the attributes of the data template , Make it easier to understand .

Development considerations

Device shadow and attributes are the basic functions of Tencent cloud IOT platform , In the actual development process, we generally need to pay attention to the following points :

1. Offline message acquisition : Offline messages for many devices do not always take effect , For example, real-time control messages ( Such as shutdown command ), If the device fails to reply , adopt get status You can still get , If the response , It may cause equipment failure ( Such as shutdown , It may cause the power on receiver to shut down immediately , To form a dead cycle ), At this point, you need to make filtering options in the received message . Development process , The subscription receiving method is often taken over , The subsequent iterations will enter sdk.

2. Message level setting : Due to the existence of the application layer confirmation mechanism , Therefore, the general uplink message adopts QoS0 To reduce the number of servers PUBACK reply ; But when subscribing , Should use QoS1 To ensure that the server supports sending messages QoS1 The retransmission mechanism , At the same time open packet id The filter , To achieve a better success rate of message distribution .

3. Message type settings : There is the concept of read-only attribute in the attribute ( This means that the value only depends on the equipment report ), Setting to read-only can avoid invalid property modification , This leads to the avoidance of readable properties in control messages , A device side parsing exception is thrown .

原网站

版权声明
本文为[fancyxu]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/06/20210609215643683o.html