有没有办法从 Azure IoT-Hub 获取设备的设备双胞胎,使用 Azure SDK for C?据我所知,我能够使用 Azure SDK for NodeJS 获取设备双胞胎。
在 nodejs 中,我们这样做。
const = require('azure-iot-device').;
cosnt Protocol = require('azure-iot-device-mqtt').Mqtt;
var client = .fromConnectionString(connectionString, Protocol);
function main() {
client.open(function (err) {
//If connection is success
client.getTwin();
}
});
有没有办法获得设备的双胞胎数据,并在 Azure SDK for C 中获得 twinchange 通知,即在双胞胎数据发生变化时的回调函数?
有没有办法获得设备的双胞胎数据,并在 Azure SDK for C 中获得 twinchange 通知,即在双胞胎数据发生变化时的回调函数?
是的,你可以参考回调函数的例子Get updates on the device side:
尝试从文档中获取以下代码段:
static void deviceTwinCallback(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char* payLoad, size_t size, void* userContextCallback)
{
(void)userContextCallback;
printf("Device Twin update received (state=%s, size=%zu): %s\r\n",
MU_ENUM_TO_STRING(DEVICE_TWIN_UPDATE_STATE, update_state), size, payLoad);
}
Linux 上有一个 SDK for C 示例,展示了如何处理 Device Twin:https://github.com/Azure/azure-sdk-for-c/blob/main/sdk/samples/iot/docs/how_to_iot_hub_samples_linux.md#iot-hub-twin-sample
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(10条)