Azure IOT集线器双设备中的更改通知



我正在开发IOT Hub设备双胞胎,当双胞胎中的属性发生更改时,我找不到在设备上获得通知的方法。

我知道在物联网集线器方面有一个解决方案,使用专用路由,但当双胞胎发生变化时,我如何在设备上获得通知?

我已经查看了DeviceClient类,但找不到任何相关的内容。

我错过了什么?

取决于SDK或MQTT库。

对于C、C#、Java、JS和Python,您可以从这里开始:

https://learn.microsoft.com/en-us/azure/iot-pnp/concepts-developer-guide-device?pivots=programming-csharp#语言实现遥测、-属性、-和命令

来自C#文档

await client.SetDesiredPropertyUpdateCallbackAsync(async (desired, ctx) => { JValue targetTempJson = desired["targetTemperature"]; double targetTemperature = targetTempJson.Value();

TwinCollection reportedProperties = new TwinCollection(); TwinCollection ackProps = new TwinCollection(); ackProps["value"] = targetTemperature; ackProps["ac"] = 200; ackProps["av"] = desired.Version; ackProps["ad"] = "desired property received"; reportedProperties["targetTemperature"] = ackProps;

await client.UpdateReportedPropertiesAsync(reportedProperties); }, null);

有关原始MQTT客户端,请参阅https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#receiving-所需属性更新通知

注意:你会发现术语";改变通知事件";通常指服务侧事件。

最新更新