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

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();
主站蜘蛛池模板: 南通市| 如东县| 西安市| 鄂托克旗| 法库县| 内丘县| 聂拉木县| 盐源县| 竹溪县| 吉林省| 水富县| 龙口市| 商南县| 定陶县| 容城县| 长泰县| 喀什市| 广水市| 微博| 龙泉市| 内江市| 南郑县| 朝阳县| 仁怀市| 斗六市| 通化县| 资兴市| 特克斯县| 玉山县| 河池市| 龙门县| 禄劝| 肥乡县| 霍邱县| 新郑市| 沭阳县| 满城县| 扎兰屯市| 伊春市| 友谊县| 鄄城县|