gpt4 book ai didi

AzureIoTHub : How to send telemetry data in JSON format?

转载 作者:行者123 更新时间:2023-12-03 02:26:51 28 4
gpt4 key购买 nike

我使用 Azure 的示例存储库来发送遥测数据:https://github.com/Azure/azure-iot-arduino/tree/master/examples/esp8266/iothub_ll_telemetry_sample

我没有修改任何代码。这是重要的部分:

const char* telemetry_msg = "test_message";
message_handle = IoTHubMessage_CreateFromString(telemetry_msg);
result = IoTHubDeviceClient_LL_SendEventAsync(device_ll_handle, message_handle, send_confirm_callback, NULL);

为什么我的 body-result 看起来像一个 ASCII 数组? (注:使用Azure IoT资源管理器)

它应该是这样的数组吗?我必须在另一侧解压该数组吗?

enter image description here

我希望能够像 azure 设备模拟器那样以 JSON 格式发送数据:

enter image description here

最佳答案

没关系,想通了。以下示例将以 JSON 格式发送数据:

char telemetry_msg_buffer[80];
sprintf(telemetry_msg_buffer, "{\"temperature\":11.11,\"humidity\":12.12,\"scale\":\"13.13\"}");
message_handle = IoTHubMessage_CreateFromString(telemetry_msg_buffer);

关于AzureIoTHub : How to send telemetry data in JSON format?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66625334/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com