- 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();
推薦閱讀
- Puppet 4 Essentials(Second Edition)
- Hands-On Data Structures and Algorithms with JavaScript
- 程序員數學:用Python學透線性代數和微積分
- Quarkus實踐指南:構建新一代的Kubernetes原生Java微服務
- Mastering ServiceNow(Second Edition)
- Java EE 7 Performance Tuning and Optimization
- Getting Started with Laravel 4
- RISC-V體系結構編程與實踐(第2版)
- Python第三方庫開發應用實戰
- UI動效設計從入門到精通
- 從零開始學UI設計·基礎篇
- 軟技能2:軟件開發者職業生涯指南
- 區塊鏈:技術與場景
- Real-time Web Application Development using Vert.x 2.0
- App Inventor開發實戰