官术网_书友最值得收藏!

How to do it...

Let's follow the following steps to use the device twin operation:

  1. Store the device metadata:
var patch = new
{
properties = new
{
desired = new
{
deviceConfig = new
{
configId = Guid.NewGuid().ToString(),
DeviceOwner = "yatish",
latitude = "17.5122560",
longitude = "70.7760470"

}
},
reported = new
{
deviceConfig = new
{
configId = Guid.NewGuid().ToString(),
DeviceOwner = "yatish",
latitude = "17.5122560",
longitude = "70.7760470"

}
}
},
tags = new
{
location = new
{
region = "US",
plant = "Redmond43"
}
}

};

await registryManager.UpdateTwinAsync(deviceTwin.DeviceId, JsonConvert.SerializeObject(patch), deviceTwin.ETag);
  1. Query the device metadata:
var query = registryManager.CreateQuery("SELECT * FROM devices WHERE deviceId = '" + deviceTwin.DeviceId + "'");
  1. Report the current state of the device:
var results = await query.GetNextAsTwinAsync();
主站蜘蛛池模板: 微博| 隆子县| 和顺县| 商水县| 灵宝市| 公安县| 黔西| 北辰区| 石泉县| 宣城市| 鱼台县| 涟源市| 连南| 获嘉县| 衢州市| 平山县| 贵港市| 平江县| 绥棱县| 高淳县| 瑞丽市| 体育| 涿州市| 交城县| 台东县| 湟源县| 孝昌县| 邯郸县| 柘城县| 密云县| 扬州市| 塘沽区| 武宁县| 南宁市| 惠安县| 高尔夫| 山阳县| 资源县| 英吉沙县| 怀来县| 灵石县|