首页 > 解决方案 > Updating reported twin from on-premise tool and keeping desired twin in sync

问题描述

I have a relatively complex IoT device, for which I intend to use IoT hub as gateway, consider the following prerequisites:

Reported properties

The purpose of using the reported properties to report back configuration changes is to be able to acknowledge changes made to the device from the backend. In this regard, one could imagine that there is a web application, through which, users can configure the device in various ways (Through the desired twin) - In order to be able to validate that a change has taken place, I would need the reported twin, i.e. in order to tell the user that the "changes were successful".

Additionally, I would need the reported properties to recognize if an "on-premise" configuration change has taken place, through the BLE 4.0 interface.


The problem

Consider the following:

  1. A user has made a critical change in the configuration through the on-premise BLE 4.0 interface
  2. The reported device twin properties changes in IoT hub
  3. Desired twin does not reflect this change, as the change didn't occur from the backend
  4. Device somehow goes offline or looses the configuration
  5. Device gets online again and gets the entire Desired twin properties
  6. The configuration from the Desired twin properties does not reflect the latest critical changes, which were made through the on-premise tool.

My preliminary considerations

As you can see, there is a clear problem, based on the fact that the desired twin does not reflect the latest configuration on the device, given that a configuration change was made through the BLE 4.0 interface - It is "out of sync".

This is sub-optimal, as the desired twin properties (in my view) should always represent the contemporary configuration on the device - in order to avoid the scenario depicted above (one of many). The following leads me to think that I need to:

However, the most natural way for me to do this, would be to listen (IoT Eventhub endpoint) on the reported twin properties through a serverless function (Serverless function will be a part of this setup regardless) and make it alter the desired twin if it isn't in "sync" with the reported twin.

This does however also present a problem, as it would cause IoT hub to think, that the change made to the desired twin is a new change, which it will then push to the device. (Waste of data and processing power)

Therefore, my question can be boiled down to the following:

标签: c#azureazure-iot-hub

解决方案


推荐阅读