Is there a way to get the device twin of a device from Azure IoT-Hub, using Azure SDK for C? As far as I know, I am able to get the device twin using the Azure SDK for NodeJS.
In nodejs we do it like.
const Client = require('azure-iot-device').Client;
cosnt Protocol = require('azure-iot-device-mqtt').Mqtt;
var client = Client.fromConnectionString(connectionString, Protocol);
function main() {
client.open(function (err) {
//If connection is success
client.getTwin();
}
});
Is there any way to get the twin data for a device and get twinchange notification in Azure SDK for C i.e A callback function when there is a change in twin data?
2
Answers
Yes, you can refer to example of callback function as per Get updates on the device side:
Try the following code snippet taken from the document:
You can also refer to iothub_devicetwin_sample.c and iothub_device_client.c
There is a sample on Linux with the SDK for C showing how to deal with 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