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

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();
主站蜘蛛池模板: 通江县| 赣州市| 石棉县| 大丰市| 辛集市| 上饶县| 泗水县| 南部县| 惠水县| 和田市| 涞源县| 马鞍山市| 隆回县| 广宁县| 屏山县| 揭西县| 乐昌市| 威海市| 锡林浩特市| 长岛县| 东宁县| 清苑县| 白朗县| 孟村| 平利县| 陆川县| 南通市| 馆陶县| 南溪县| 芜湖县| 左贡县| 明水县| 铜梁县| 岱山县| 曲松县| 肃宁县| 衡阳县| 盈江县| 隆子县| 长丰县| 光山县|