数据上报结构
Topic列表
分组 | Topic | 数据流向 | 平台 | 设备 | 描述 |
---|---|---|---|---|---|
原始数据 | v1/devices/me/raw | 上行 | 订阅 | 发布 | 设备端上报原始数据到服务端 |
设备属性 | v1/devices/me/attributes | 上行 | 订阅 | 发布 | 设备端上报属性到服务端 |
设备遥测 | v1/devices/me/telemetry | 上行 | 订阅 | 发布 | 设备遥测上报到服务端 |
网关子设备 | v1/gateway/attributes | 上行 | 订阅 | 发布 | 网关上报子设备客户端属性 |
网关子设备 | v1/gateway/telemetry | 上行 | 订阅 | 发布 | 网关上报子设备客户端遥测 |
设备命令 | v1/devices/me/rpc/request/$request_id | 上行、下行 | 订阅、发布 | 发布、订阅 | 设备调用服务端方法,服务端命令下发到设备 |
设备命令 | v1/devices/me/rpc/response/$request_id | 下行、上行 | 发布、订阅 | 订阅、发布 | 服务端响应调用方法结果,设备端响应命令执行结果 |
原始数据上报格式
010304026C00883BF0
1
iothub将原始数据序列化成下面的格式,在规则链中 msg就是以下数据。
{
"rowdata": "010304026C00883BF0"
}
1
2
3
2
3
需要在规则链中通过函数键 进行解析脚本
/*直连设备:tempVal是产品物模型中所定义属性的标识符*/
var tempVal = msg.rowdata;
/*物模型温度标识符*/
msg.temperature = (parseInt('0x'+tempVal.substr(10, 4))*0.1).toFixed(2);
/*物模型湿度标识符*/
msg.humidity = (parseInt('0x'+tempVal.substr(6, 4))*0.1).toFixed(2);
return {msg: msg, metadata: metadata, msgType: msgType};
1
2
3
4
5
6
7
2
3
4
5
6
7
属性上报格式
{
"attribute1": "value1",
"attribute2": 0
}
1
2
3
4
2
3
4
遥测上报格式
{
"ts": 1689837909000,
"values": {
"telemetry1": "value1",
"telemetry2": 0
}
}
1
2
3
4
5
6
7
2
3
4
5
6
7
如果边缘无法获取时间
{
"telemetry1": "value1",
"telemetry2": 0
}
1
2
3
4
2
3
4
网关子设备属性上报格式
devA 为设备ID
{
"devA": {
"attribute1": "value1",
"attribute2": 0
},
"devB": {
"attribute1": "value1",
"attribute2": 0
}
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
网关子设备遥测上报格式
devA 为设备标识
{
"devA": {
"ts": 1689837909000,
"values": {
"telemetry1": "value1",
"telemetry2": 0
}
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
或者
{
"devA": {
"telemetry1": "value1",
"telemetry2": 0
}
}
1
2
3
4
5
6
2
3
4
5
6
网关子设备,自动创建设备
{
"子设备产品ID_devA": {
"telemetry1": "value1",
"telemetry2": 0
},
"devB": {
"telemetry1": "value1",
"telemetry2": 0
}
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
注意
使用子设备产品ID加上设备Key,将会在平台上自动创建设备,无需手动创建了
RPC调用
无论设备端还是平台侧请求数据格式相同
{
"method": "getCurrentTime",
"params": {}
}
1
2
3
4
2
3
4
命令下发,设备请求格式,
method为要下发的命令方法,以restart重启为例
{
"method": "restart",
"params": {
"version": "v1.4",
"url": "http://127.0.0.1:7788/upload/get/0ab71ae4a9b9b6f045d43be8de89344d_20231005105659.zip",
"module": "main",
"check": "1586515d5f0216eb7d2d28204321edf5"
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
属性下发默认的方法名setAttributes
{
"method": "setAttributes",
"params": {
"aa": "2"
}
}
1
2
3
4
5
6
2
3
4
5
6
原始数据下发默认的方法名setRow
{
"method": "setRow",
"params": 1111
}
1
2
3
4
2
3
4
命令响应的格式
{
"method": "restart",
"params": {
"aa": "2"
}
}
1
2
3
4
5
6
2
3
4
5
6