- 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();
推薦閱讀
- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- Progressive Web Apps with React
- 樂學Web編程:網站制作不神秘
- 動手玩轉Scratch3.0編程:人工智能科創教育指南
- Data Analysis with Stata
- Windows內核編程
- 微服務架構深度解析:原理、實踐與進階
- D3.js By Example
- Test-Driven Machine Learning
- Java7程序設計入門經典
- OpenCV 3.0 Computer Vision with Java
- C/C++代碼調試的藝術
- Elastix Unified Communications Server Cookbook
- 深入大型數據集:并行與分布化Python代碼
- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)