当前位置:网站首页>07. Tencent cloud IOT device side learning - Data Template

07. Tencent cloud IOT device side learning - Data Template

2022-06-24 15:19: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 .

Introduction to data template

Data template protocol

The data template protocol is IoT Explorer Current major agreements , It is also the main protocol used in most projects , The agreement consists of three parts :

  • attribute (property): Equipment report 、 Cloud distribution control
  • event (event): Equipment report , Cloud reply
  • Behavior (action): Cloud distribution control , Device reply

Data template use

Use according to the actual project , There are several common ways to use the project :

  1. Equipment collection information reporting , Including temperature and humidity 、 light 、 Equipment status, etc . here , Generally, the reported information is abstracted into Read-only property Report .
  2. The equipment reports a one-time event , Different from collecting information ( Temperature and humidity , A long-term state ), Events are usually one-off , It means that the event happened at that time ( Such as alarm , Instantaneous change of state ). here , Will use event To report .
  3. Equipment control , Like a switch 、 Air conditioning temperature setting, etc . here , Generally, the distribution control is abstracted into Read write properties perhaps Behavior . Among them, the behavior must reply (5s Inside , cloud API Limit ), If the control duration is 5S Inside , Those who are sensitive to the results can adopt behavior ; The rest can be used Read write properties + Readable properties / event The form of cooperation .
  4. Device offline synchronization , When the device is offline , If a command is issued , Expect to respond immediately after the launch , You need to use it get_status Method to get the offline distribution control news .

Take the common smart lamp as an example : Smart lights can contain the following elements : brightness 、 switch 、 Color 、 fault 、 Electric quantity .

The following can provide a feasible design :

  • brightness 、 Color 、 The switches are in a long-term state , Can be designed as attribute .
  • Faults and low battery are events triggered at a certain time , Can be designed as event .
  • Realize the combination change of color and brightness of intelligent lamp , Can be designed as Behavior .

Data template is IoT Explorer Most basic functions , It is also the content that Tencent cloud IOT device development must understand .

原网站

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