首页 > 解决方案 > DeviceTwin 时间戳

问题描述

我提交了UpdateReportedPropertiesAsync 不会更新azure-iot-sdk-csharp 的 github 中的 Device Twin 时间戳,但我想知道我是否只是不知道一些事情,所以我决定也在这里问一下。

是否有文档解释 IoT 中心设备孪生的statusUpdateTimeconnectionState和何时lastActivityTime更新?


我的问题:

我有一个使用DeviceClient's定期更新报告属性的设备,UpdateReportedPropertiesAsync但时间戳保持为空:

"statusUpdateTime": "0001-01-01T00:00:00",
"connectionState": "Connected",
"lastActivityTime": "0001-01-01T00:00:00",

标签: azureazure-iot-hubwindows-iot-core-10

解决方案


是否有说明 IoT 中心设备孪生的 statusUpdateTime、connectionState 和 lastActivityTime 何时更新的文档?

您可以参考“设备标识属性”部分。

在此处输入图像描述

我有一个使用 DeviceClient 的 UpdateReportedPropertiesAsync 定期更新报告属性的设备,但时间戳保持为空:

这似乎是旧 SDK 的问题,并且已经修复。我使用 Microsoft.Azure.Devices.Client 1.18.0,它对我有用。你可以试一试。

            TwinCollection reportedProperties = new TwinCollection();
            reportedProperties["DateTimeLastDesiredPropertyChangeReceived"] = DateTime.Now;

            await deviceClient.UpdateReportedPropertiesAsync(reportedProperties).ConfigureAwait(false);

在此处输入图像描述


推荐阅读