Azure-Samples / iot-middleware-freertos-samples

This repo has samples for dev kits using the Azure IoT middleware for FreeRTOS
MIT License
76 stars 46 forks source link

How to receive desired properties from IoT hub from device twin #381

Open amolchor20 opened 1 year ago

amolchor20 commented 1 year ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. update the device twin properties from azure IoT hub.
  2. wait on device side to receive the updated desired properties from IoT hub.
  3. there is no debug print for payload indicate that payload received from IoT hub for the change of desired properties.

Any log messages given by the failure

No logs for desired properties from IoT hub.

Expected/desired behavior

Get the debug print of desired properties as payload in callback function/simple debug print of all the properties from device twin.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?) freeRTOS

Versions

azure middleware version 1.1.0

Mention any other details that might be useful

I am using azure iot middleware on stm32u585 (B-U585I-IOT02A) board. I am able to send telemetry messages to IoT devices and also cloud to device. when I am changing the desired properties from IoT hub, how can I verify the desired properties are changed from device side?


Thanks! We'll be in touch soon.

NikaChikovani commented 11 months ago

I think first of all you have to subscribe to the properties topic in order to get notifications about the update. Use function called AzureIoTHubClient_SubscribeProperties() after connecting to the IoT Hub.

ericwolz commented 11 months ago

Please look at sample aziotkit for ESP32.

vHandleWritableProperties is called for twin property updates.

Output should look as follows:

I (24569) MQTT: Packet received. ReceivedBytes=3470. I (24569) MQTT: De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. I (24569) MQTT: State record updated. New state=MQTTPublishDone. I (24579) AZ IOT: $iothub/twin/PATCH/properties/desired/?$version=24 I (24599) sample_azureiotkit: Telemetry frequency set to once every 10 seconds. I (24619) AZ IOT: Successfully parsed properties

amolchor20 commented 10 months ago

Thanks for reply !!

currently my board stm32u585 is connected with cellular board for internet connectivity. And I have integrated adu code from middleware. for device update the desired properties is changed when i deploy the update from Hub. image but the changed desired property is not received on device side. Although the freeRTOS middleware code is using the image Api shown in Image. Could you please guide me on regarding desired properties update?

Thanks in advance !!

amolchor25 commented 9 months ago

Why I am not receiving the device twin notification, because of "AzureIoTHubClient_ProcessLoop" function.

If there is an update notification present from Azure IoT hub then the "AzureIoTHubClient_ProcessLoop" function gives device twin notification, when there is no notification from Azure IoT Hub then it will throw below error

image

and another error is

image

because of above two error I have removed the "AzureIoTHubClient_ProcessLoop" function from my code.

these two errors are reproduce constantly.