Azure IoT - 重置和清除设备孪生

问题描述

我正在使用适用于 C 的 Azure IoT SDK。我需要我的设备能够不时完全清除设备孪生上报告的属性

在我的设备孪生中,我在报告的属性中有一个小的层次结构,其中包含一个项目列表。例如 items.item1.temperature,items.item2.humidity

我似乎可以删除项目的个别属性,例如“湿度”,甚至可以删除单个项目,例如“item1”,但不能一次删除完整的项目列表。

JSON_Value*  root_value  = json_value_init_object();
JSON_Object* root_object = json_value_get_object(root_value);

// delete all items from twin
char* items= "items";
(void)json_object_dotset_null(root_object,items);

char* result = json_serialize_to_string(root_value);
json_value_free(root_value);
(void)IoTHubDeviceClient_SendReportedState(_device_handle,(const unsigned char*)result,strlen(result),ReportedStateCallback,NULL);
 

执行此代码时,我收到以下错误

Error: Time:Thu Feb 18 13:09:48 2021 File:/azure-iot-sdk-c/iothub_client/src/iothub_client_core.c Func:IoTHubClientCore_SendReportedState Line:1860 invalid arg (NULL)

在此先感谢您对此的任何支持

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)