数据上报结构

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

需要在规则链中通过函数键 进行解析脚本

/*直连设备: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

属性上报格式

{
   "attribute1": "value1",
   "attribute2": 0
}
1
2
3
4

遥测上报格式

{
  "ts": 1689837909000,
  "values": {
    "telemetry1": "value1",
    "telemetry2": 0
  }
}
1
2
3
4
5
6
7

如果边缘无法获取时间

{
    "telemetry1": "value1",
    "telemetry2": 0
}
1
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

网关子设备遥测上报格式

devA 为设备标识

{
  "devA": {
      "ts": 1689837909000,
      "values": {
        "telemetry1": "value1",
        "telemetry2": 0
      }
    }
}
1
2
3
4
5
6
7
8
9

或者

{
  "devA": {
    "telemetry1": "value1",
    "telemetry2": 0
  }
}
1
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

注意

使用子设备产品ID加上设备Key,将会在平台上自动创建设备,无需手动创建了

RPC调用

无论设备端还是平台侧请求数据格式相同

{
   "method": "getCurrentTime",
   "params": {}
}
1
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

属性下发默认的方法名setAttributes

{
  "method": "setAttributes",
  "params": {
     "aa": "2"
   }
}
1
2
3
4
5
6

原始数据下发默认的方法名setRow

{
  "method": "setRow",
  "params": 1111
}
1
2
3
4

命令响应的格式

{
  "method": "restart",
  "params": {
     "aa": "2"
   }
}
1
2
3
4
5
6
上次更新: 2024/12/21 19:07:06
贡献者: XM-GO, PandaX-Go, tfl