c# - 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:
- IoT Device is connected to IoT Hub
- IoT Device can receive configuration changes through the Desired twin properties from IoT hub
- IoT Device can receive configuration changes from an on-premise tool, which connects to it through a BLE 4.0 interface
- IoT device should report back configuration changes to IoT hub with the reported twin properties
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:
- A user has made a critical change in the configuration through the on-premise BLE 4.0 interface
- The reported device twin properties changes in IoT hub
- Desired twin does not reflect this change, as the change didn't occur from the backend
- Device somehow goes offline or looses the configuration
- Device gets online again and gets the entire Desired twin properties
- 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:
- Keep the reported - and desired twin properties in sync
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:
- Can I keep the desired twin in sync with the reported twin properties (in a pretty way), provided that a change has been made "on-premise" - And not through the backend desired twin properties
解决方案
推荐阅读
- javascript - 更改正文中所有文本元素的字体大小
- spring - Spring Boot Async 函数问题 AsyncRequestTimeoutException 然后下一个连接失败
- javascript - javascript数组将一个对象移到前面
- mysql - MacBook Catalina 上的 MySQL 和 Workbench - 未建立连接 3306 127.0.0.1
- reactjs - 在反应式中每个文本输入多次获取
- java - 如何使用 JNI 从 C 中的 Oobject 获取 Object 的 fieldID?
- excel - VBA - 每次单击按钮时复制不同单元格中的值
- http - NoSuchMethodError:在 null 上调用了方法“get”。http请求
- r - R的新手,想知道是否有人可以帮助我
- python - 使用 ast 创建具有默认值的仅关键字参数的函数