- 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();
推薦閱讀
- C程序設計簡明教程(第二版)
- 自己動手實現Lua:虛擬機、編譯器和標準庫
- Java 9 Programming Blueprints
- Scratch真好玩:教小孩學編程
- SAS數據統計分析與編程實踐
- Python數據可視化之Matplotlib與Pyecharts實戰
- 數據結構習題解析與實驗指導
- 區塊鏈項目開發指南
- Java EE 7 with GlassFish 4 Application Server
- Scala Functional Programming Patterns
- iOS開發項目化入門教程
- 深度學習程序設計實戰
- Robot Framework Test Automation
- Isomorphic Go
- Mastering Magento Theme Design