All Products
Search
Document Center

Device Tag

Last Updated: May 13, 2020

Device tags are static extended information of a device, they are stored as key-value pairs on IoT Platform.

Send a message to the cloud to update the device tag


When reporting a message that the device tags information has been updated, the tag information is placed in one or more groups of paired attrKeys and attrValues. By definition, attrKey supports uppercase and lowercase letters and numbers, but cannot begin with a number. The length is 2~32 bytes and the payload is of JSON array type. It can contain multiple pairs of {"attrKey":"","attrValue":""}. Examples are as follows:

  1. /* There are two groups of device tags. For the first group, the attrKey is abc and the attrValue is Hello,World. For the second group, the attrKey is def and the attrValue is Hello,Aliyun */
  2. char *payload = "[{\"attrKey\":\"abc\",\"attrValue\":\"Hello,World\"},{\"attrKey\":\"def\",\"attrValue\":\"Hello,Aliyun\"}]";
  3. /* When the payload of the device tag is ready, it can be reported by using the following interfaces*/
  4. IOT_Linkkit_Report(devid, ITM_MSG_DEVICEINFO_UPDATE, (unsigned char *)payload, strlen(payload));

Send a message to the cloud to delete the device tag


When reporting a message that the device tag information has been deleted, the attrKey of the tag information is placed in one or more attrKeys

  1. /* There are two attrKeys for the device tag. The first one is abc. The second one is def */
  2. char *payload = "[{\"attrKey\":\"abc\"},{\"attrKey\":\"def\"}]";
  3. /* When the payload of the device tag is ready, it can be reported by using the following interfaces*/
  4. IOT_Linkkit_Report(devid, ITM_MSG_DEVICEINFO_DELETE, (unsigned char *)payload, strlen(payload));