阿里云IoT物模型-属性,服务,事件通信的topic和payload详解

0.阿里云IoT物模型

 
物模型定义了产品的属性、服务、事件通信协议,IoT设备和云端需要按约定规则通信,才能实现物模型转化。
 
 

1.设备属性通信

1.1 设备上报属性

设备上报pubTopic

/sys/{productKey}/{deviceName}/thing/event/property/post
设备上报payload格式
{
"id": 3536123,
"version": "1.0",
"params": {
"属性key1": "属性value1",
"属性key2": "属性value2"
},
"method": "thing.event.property.post"
}
 

IoT云端响应replyTopic

/sys/{productKey}/{deviceName}/thing/event/property/post_reply
云端响应payload格式
{
"id": 3536123,
"code": 200,
"data": {}
}
 
 

1.2 云端设置设备属性

设备订阅subTopic

/sys/{productKey}/{deviceName}/thing/service/property/set
IoT云端下行的payload格式
{
"id": 3536123,
"version": "1.0",
"params": {
"属性key1": "属性value1",
"属性key2": "属性value2"
},
"method": "thing.service.property.set"
}
 
 

设备响应replyTopic

/sys/{productKey}/{deviceName}/thing/service/property/set_reply
设备响应payload格式
{
"id": 3536123,
"code": 200,
"data": {}
}
 
 

1.3 云端获取设备属性

设备订阅subTopic

/sys/{productKey}/{deviceName}/thing/service/property/get
IoT云端下行的payload格式
{
"id": 3536123,
"version": "1.0",
"params": [
"属性key1",
"属性key2"
],
"method": "thing.service.property.get"
}
 
 

设备响应replyTopic

/sys/{productKey}/{deviceName}/thing/service/property/get_reply
设备响应payload格式
{
"id": 3536123,
"code": 200,
"data": {
"属性key1": "属性value1",
"属性key2": "属性value2"
}
}
 
 
 

2.设备服务调用

2.1 服务的异步调用

设备订阅subTopic

注意:服务订阅Topic这里不支持+通配符
/sys/{productKey}/{deviceName}/thing/service/{tsl.service.identifier}
或者订阅指定service
/sys/{productKey}/{deviceName}/thing/service/{tsl.service.identifier}
IoT云端下行的payload格式
{
"id": 3536123,
"version": "1.0",
"params": {
"入参key1": "入参value1",
"入参key2": "入参value2"
},
"method": "thing.service.{tsl.service.identifier}"
}
 
 

设备响应replyTopic

/sys/{productKey}/{deviceName}/thing/service/{tsl.service.identifier}_reply
设备响应payload格式
{
"id": 3536123,
"code": 200,
"data": {
"出参key1": "出参value1",
"出参key2": "出参value2"
}
}
 

2.2 服务的同步调用

 

设备订阅subTopic

注意:服务同步调用API是InvokeThingService
/sys/${productKey}/${deviceName}/rrpc/request/+
IoT云端下行的payload格式
{
"id": 3536123,
"version": "1.0",
"params": {
"入参key1": "入参value1",
"入参key2": "入参value2"
},
"method": "thing.service.{tsl.service.identifier}"
}
 
 

设备响应replyTopic

/sys/${productKey}/${deviceName}/rrpc/response/request的消息Id
 
设备响应payload格式
{
"id": 3536123,
"code": 200,
"data": {
"出参key1": "出参value1",
"出参key2": "出参value2"
}
}
 
 

3.设备事件上报

3.1 事件上报

设备上报pubTopic

/sys/{productKey}/{deviceName}/thing/event/{tsl.event.identifier}/post
设备上报payload格式
{
"id": 3536123,
"version": "1.0",
"params": {
"入参key1": "入参value1",
"入参key2": "入参value2"
},
"method": "thing.event.{tsl.event.identifier}.post"
}
 
 

IoT云端响应replyTopic

/sys/{productKey}/{deviceName}/thing/event/{tsl.event.identifier}/post_reply
云端响应payload格式
{
"id": 3536123,
"code": 200,
"data": {}
}
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页