概述
-
设备端 ==> 物影子 (Update)
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/update/accepted
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/update/rejected
设备==>IOT Hub :Publish : $baidu/iot/shadow/MyMonitor/update
IOT Hub==>设备 :$baidu/iot/shadow/MyMonitor/update/accepted (If succeeded)
IOT Hub==>设备 :$baidu/iot/shadow/MyMonitor/update/rejected(If failed)
{
"requestId":"83f5ce6c-80f3-4260-a76f-9533c0d9b5b4",
"reported":
{"temperature":30,"humidity":60},
"desired":
{},
"lastUpdatedTime":
{
"reported":
{"temperature":1569738824939,"humidity":1569738824939},
"desired":{}
},
"profileVersion":6
}
-
设备端 ==> 物影子 (Get)
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/get/accepted
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/get/rejected
设备==>IOT Hub : Publish : $baidu/iot/shadow/MyMonitor/get
IOT Hub==>设备 : $baidu/iot/shadow/MyMonitor/get/accepted (If succeeded)
IOT Hub==>设备 : $baidu/iot/shadow/MyMonitor/get/rejected (If failed)
{"requestId":"11111111111",
"reported":{"temperature":30,"humidity":60},
"desired":{"Temperature":90,"Humidity":100,"LED":"RED"},
"lastUpdatedTime":{
"reported":{"temperature":1569738824939,"humidity":1569738824939},
"desired":{"Temperature":1569491866406,"Humidity":1569491866406,"LED":1569486183149}},
"profileVersion":6}
-
物影子 ==> 设备 反控
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/delta
{"requestId":"9df9da8d-b41a-4464-ba65-c9befd2444b5","desired":{"Temperature":100,"Humidity":200}}
-
订阅设备影子的变化
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/update/documents
设备==>IOT Hub :Publish : $baidu/iot/shadow/MyMonitor/update
{"requestId":"4e1c93e0-69b3-4d43-bdde-5c8633f4bff4",
"reported":{"temperature":40,"humidity":80},
"desired":{},
"lastUpdatedTime":{"reported":{"temperature":1569740623020,"humidity":1569740623020},"desired":{}},
"profileVersion":8}
{"requestId":"4e1c93e0-69b3-4d43-bdde-5c8633f4bff4",
"current":{"temperature":40,"humidity":80},
"previous":{"temperature":30,"humidity":60},
"profileVersion":8}
-
订阅设备快照
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/update/snapshot
设备==>IOT Hub :Publish : $baidu/iot/shadow/MyMonitor/update
Result :
-
$baidu/iot/shadow/MyMonitor/update/accepted
{"requestId":"295fc2e4-4fed-4170-89df-ef24e1618b8b",
"reported":{"temperature":50,"humidity":90},
"desired":{},
"lastUpdatedTime":{"reported":{"temperature":1569740990594,"humidity":1569740990594},"desired":{}},
"profileVersion":9}
-
$baidu/iot/shadow/MyMonitor/update/documents
{"requestId":"295fc2e4-4fed-4170-89df-ef24e1618b8b",
"current":{"temperature":50,"humidity":90},
"previous":{"temperature":40,"humidity":80},
"profileVersion":9}
-
$baidu/iot/shadow/MyMonitor/update/snapshot
{"requestId":"295fc2e4-4fed-4170-89df-ef24e1618b8b",
"profileVersion":9,
"reported":{"temperature":50,"humidity":90},
"lastUpdatedTime":{"reported":{"temperature":1569740990594,"humidity":1569740990594}}}
-
清空设备影子
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/delete/accepted
设备==>IOT Hub : Subscribe : $baidu/iot/shadow/MyMonitor/delete/rejected
设备==>IOT Hub : Publish : $baidu/iot/shadow/MyMonitor/delete
pub $baidu/iot/shadow/myDeviceName/delete
{"requestId": "{requestId}"}
{"requestId":"222222222222",
"reported":{"temperature":50,"humidity":90},
"desired":{"Temperature":100,"Humidity":200,"LED":"RED"},
"lastUpdatedTime":{
"reported":{"temperature":1569740990594,"humidity":1569740990594},
"desired":{"Temperature":1569739957363,"Humidity":1569739957363,"LED":1569486183149}},
"profileVersion":9}
Note.1 : 清空物影子,并不是删除物影子,仅仅是删除Reported & Desired属性值。
Note.2 : IOT Hub不会对Update操作的payload,对比物影子对应的物模型做meta级别校验,比如update涉及的属性名大小写,属性名不存在与物模型meta中,等等。仅仅做消息格式的检查。
Note.3 : 只有同一个物影子的不同Client,才允许订阅Update/accepted & rejected事件。
最后
以上就是有魅力哈密瓜为你收集整理的百度IOT Hub (七) 设备与物影子交互流程设备端 ==> 物影子 (Update)设备端 ==> 物影子 (Get)物影子 ==> 设备 反控订阅设备影子的变化订阅设备快照清空设备影子的全部内容,希望文章能够帮你解决百度IOT Hub (七) 设备与物影子交互流程设备端 ==> 物影子 (Update)设备端 ==> 物影子 (Get)物影子 ==> 设备 反控订阅设备影子的变化订阅设备快照清空设备影子所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复