- Azure IoT Development Cookbook
- Yatish Patil
- 125字
- 2021-07-02 20:50:36
How to do it...
Let's follow the following steps to use the device twin operation:
- 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);
- Query the device metadata:
var query = registryManager.CreateQuery("SELECT * FROM devices WHERE deviceId = '" + deviceTwin.DeviceId + "'");
- Report the current state of the device:
var results = await query.GetNextAsTwinAsync();
推薦閱讀
- 黑客攻防從入門到精通(實戰秘笈版)
- Building a Game with Unity and Blender
- PHP+MySQL網站開發技術項目式教程(第2版)
- Neo4j Essentials
- Java游戲服務器架構實戰
- DevOps Automation Cookbook
- 手把手教你學C語言
- 精通Python自然語言處理
- Clojure Reactive Programming
- Python 3 Object:oriented Programming(Second Edition)
- Anaconda數據科學實戰
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- Learning Ionic(Second Edition)
- HTML5+CSS3+jQuery Mobile+Bootstrap開發APP從入門到精通(視頻教學版)
- Python實戰指南:手把手教你掌握300個精彩案例