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

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();
主站蜘蛛池模板: 来安县| 呼伦贝尔市| 虹口区| 合水县| 葵青区| 佛教| 两当县| 越西县| 江津市| 分宜县| 新绛县| 扎囊县| 舟山市| 房山区| 广宁县| 张家川| 威海市| 五台县| 会昌县| 温宿县| 夹江县| 外汇| 增城市| 唐山市| 洪泽县| 若尔盖县| 班玛县| 黔西县| 策勒县| 朝阳市| 休宁县| 包头市| 芮城县| 舒兰市| 黎川县| 湖南省| 大英县| 大方县| 宜丰县| 扎赉特旗| 浙江省|