locked
Do I need to explicitly,within azure portal, copy reported properties into the device twin? RRS feed

  • Question

  • I thought the SDKs worked together with hub to capture reported properties in the device twin, but it's not happening.  The messages are being sent from device (esp8266 running the azure tutorial code), and acknowledged by azure.  I can see them accumulating in the table store, and I can monitor their arrival through Device Explorer or iothub-explorer.  However, the contents of the message (reported properties) are not reflected in the device twin.  Do I need to write an azure function to explicitly copy data from the message into the twin's reported properties?

    Additional detail here:  https://stackoverflow.com/questions/45219527/in-azure-iot-hub-do-i-need-to-explicitly-copy-reported-properties-into-the-devi

    Wednesday, July 19, 2017 10:56 PM

Answers

  • Hi,

    Answering your questions:

    1. "Do I need to explicitly, within the azure portal, copy reported properties into the device twin?"

    No, reported properties are set by the device.  See lines 71-74 on this .NET Sample (https://github.com/Azure/azure-iot-sdk-csharp/blob/master/device/samples/DeviceClientTwinSample/Program.cs) or lines 183-192 in the Node.js sample (https://github.com/Azure/azure-iot-sdk-node/blob/master/device/samples/simple_sample_device_twin.js).

    2. From your question, I believe you may be expecting the IoT Hub to parse the message that you send (using SendEvent).  Twin properties are not set using SendEvent.  In .NET twin properties are updated using Client.UpdateReportedPropertiesAsync(...), in Node.js, properties are updated using twin.properties.reported.update(...).

    Hope this helps.  Let me know if you need anything else.

    Friday, July 21, 2017 5:50 PM

All replies

  • Hi,

    Answering your questions:

    1. "Do I need to explicitly, within the azure portal, copy reported properties into the device twin?"

    No, reported properties are set by the device.  See lines 71-74 on this .NET Sample (https://github.com/Azure/azure-iot-sdk-csharp/blob/master/device/samples/DeviceClientTwinSample/Program.cs) or lines 183-192 in the Node.js sample (https://github.com/Azure/azure-iot-sdk-node/blob/master/device/samples/simple_sample_device_twin.js).

    2. From your question, I believe you may be expecting the IoT Hub to parse the message that you send (using SendEvent).  Twin properties are not set using SendEvent.  In .NET twin properties are updated using Client.UpdateReportedPropertiesAsync(...), in Node.js, properties are updated using twin.properties.reported.update(...).

    Hope this helps.  Let me know if you need anything else.

    Friday, July 21, 2017 5:50 PM
  • Thank you.  That got my simulated device working.  Strange that all of the samples I found send events.  Now I just need to sort out the usage of IoTHubClient_LL_SendReportedState (GCC).

    Friday, July 21, 2017 6:28 PM
  • You're very welcome!  You may have already seen this, but just in case you haven't- there's a sample that shows how to report properties in C: line 281 of https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/samples/iothub_client_sample_mqtt_dm/iothub_client_sample_mqtt_dm.c

    This should work similar to the _LL version of that API - slightly different signatures.

    IoTHubClient_SendReportedSate is in https://github.com/Azure/azure-iot-sdk-c/blob/46bb28afd7bbe31e079feac4b5f2059b8f5a6c71/iothub_client/src/iothub_client.c (line 1481) and IoTHubClient_LL_SendReportedState is in https://github.com/Azure/azure-iot-sdk-c/blob/a4554eea75234b067c132cbd156a423350b067a2/iothub_client/src/iothub_client_ll.c (line 1657). 

    Friday, July 21, 2017 7:33 PM
  • Calling IoTHubClient_LL_SendReportedState() is successful at sending a single twin update, but it also triggers a lockup that happens 1-2 seconds later, during a call to delay(1).  WDT then reboots the module and everything repeats.  

    So then I tried the non _LL versions of everything.  Unfortunately the non _LL functions rely on a (non _LL) datatype that is deliberately(?) excluded from the Arduino version of the SDK.  The weeds are getting pretty tall.

    I sure wish there was a working demo of IoTHubClient_LL_SendReportedState
    Saturday, July 22, 2017 1:15 AM