locked
Bi directional communication between web app and IOT Hub RRS feed

  • Question

  • Hi,

    My Asp.net core/ Angular web app is hosted on the Azure cloud. I would like to provide bi-directional communication (IoT hub to the web app and web app to IoT hub) with the cloud/IoT hub so that the status shown on the web is actually the status of the device.
    For example, when I modify the LED status of the MXCHIP device on the web interface, in the background it calls Azure function that modifies the LED  status property in device twin. now, I would like to get the status from the device on to the web after the LED status changed. How do I achieve this? Do I need to integrate signalR to push the status on the web app or is there any IoT Hub SDK that achieves the same?

    Best Regards,

    Chandra Mohan

    Wednesday, December 18, 2019 4:53 AM

Answers

  • Hello RaysApp,

    Thanks for the great question! 

    From the description provided and since you are already modifying the status property in device twin, you could subscribe to Receive twin notifications like described here.

    "This operation allows the solution back end to be notified when the twin is modified. To do so, your IoT solution needs to create a route and to set the Data Source equal to twinChangeEvents. By default, no such routes pre-exist, so no twin notifications are sent. If the rate of change is too high, or for other reasons such as internal failures, the IoT Hub might send only one notification that contains all changes. Therefore, if your application needs reliable auditing and logging of all intermediate states, you should use device-to-cloud messages. The twin notification message includes properties and body."

    As stated, if the rate of change is too high and you need immediate and reliable device status then I would advise you to implement the heartbeat pattern

    Hope it helps!

    Wednesday, December 18, 2019 3:14 PM

All replies

  • Hello RaysApp,

    Thanks for the great question! 

    From the description provided and since you are already modifying the status property in device twin, you could subscribe to Receive twin notifications like described here.

    "This operation allows the solution back end to be notified when the twin is modified. To do so, your IoT solution needs to create a route and to set the Data Source equal to twinChangeEvents. By default, no such routes pre-exist, so no twin notifications are sent. If the rate of change is too high, or for other reasons such as internal failures, the IoT Hub might send only one notification that contains all changes. Therefore, if your application needs reliable auditing and logging of all intermediate states, you should use device-to-cloud messages. The twin notification message includes properties and body."

    As stated, if the rate of change is too high and you need immediate and reliable device status then I would advise you to implement the heartbeat pattern

    Hope it helps!

    Wednesday, December 18, 2019 3:14 PM
  • Hello RaysApps,

    If the answer above helped you moving forward please mark it as answer, otherwise let us know if you still have related questions.

    Appreciate your time.

    All Best

    Tuesday, December 24, 2019 1:00 AM
  • Sorry that I could not respond earlier as I was away.The references you have provided are very helpful. I will go through them and will implement as required.


    • Edited by RaysApps Wednesday, January 8, 2020 7:20 AM
    Wednesday, January 8, 2020 1:20 AM