0
votes

properties.reported in my device-twins are not updating.

I have a running project that follows this Azure IOT SDK tutorial (complete with same hardware): https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-arduino-huzzah-esp8266-get-started

D2C messages are being sent from device and acknowledged by azure. I can monitor message arrival through Device Explorer and iothub-explorer, and I can see them accumulating in the table store, thanks to another tutorial I did to try to further prove messages were actually arriving. However, the contents of the messages (reported properties) are not reflected in the device twin. properties.reported is empty except for the metadata timestamp from the day the device was registered. Do I need to write an azure function to explicitly copy data from the message into the twin's reported properties?

FYI, C2D messages (properties.desired in the twin) are communicating just fine.

1
Where and how do you add these reported properties?Rita Han
@Rita Han, down in the bowels of the tutorial code is a call to IoTHubMessage_CreateFromByteArray() which takes a JSON string as input. The result is later sent to IoTHubClient_LL_SendEventAsync(), and delivered during a call to IoTHubClient_LL_DoWork(). The messages arrive in hub and are logged (via function that merely copies them into azure storage table). Example direct from the log: {"deviceId":"new-device","messageId":2,"temperature":22.29999,"humidity":47.2} ...and yes I have a registered deviceId of "new-device".zoidicus

1 Answers

0
votes

Help arrived in another forum, so I'm adding the relevant details here.
The sample I linked above, and the other samples I tried, all were sending events, instead of properties, even though they were reading and reacting to (desired) properties sent from the cloud. Reported properties must be sent with a call to IoTHubClient_LL_SendReportedState (C) or Client.UpdateReportedPropertiesAsync (C#).