# 数据格式
# 1 公共参数
- 通用数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "xxxx", //业务标识
"data": {...} //业务数据
} - 参数说明:
参数 | 类型 | 说明 |
product_key | string | 产品标识 |
device_name | string | 设备名称 |
device_id | string | 设备唯一标识 |
timestamp | int64 | 时间戳,单位毫秒 |
biz_code | string | 业务标识 |
data | json 对象 | 详细业务数据 |
# 2 业务类型
biz_code(字符串类型) | 说明 |
device_data | 设备状态及事件上报 |
device_status | 设备在线状态变更 |
device_lifecycle | 设备生命周期变更 |
device_topo | 设备拓扑结构变更 |
ota_progress | ota 升级进度 |
ota_version | ota 模块版本号上报 |
thing_model | 物模型变更通知 |
# 3 数据格式
# 3.1 设备属性,事件和服务
- 设备属性变更
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_data", //业务标识
"data": {
"properties": {
"prop1": "val1",
"prop2": "val2"
}
}
} - 设备事件通知
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_data", //业务标识
"data": {
"events": {
"event1": {
"value": {
"param1": "xxx",
"param2": 1
},
"timestamp": 1635146586
},
"event2": {
"value": {
"param1": "xxx",
"param2": 1
},
"timestamp": 1635146586
}
}
}
} - 设备服务调用返回
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_data", //业务标识
"data": {
"services": {
"service1": { //设备服务identifier
"value": {
"param1": 1, //输出参数1
"param2": 2 //输出参数2
},
"message_id": 10 //消息id
}
}
}
} # 3.2 设备在线状态
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_status", //业务标识
"data": {
"status": "online" //online-在线,offline-离线
}
} - 参数说明:
参数 | 类型 | 说明 |
status | string | online-在线,offline-离线 |
# 3.3 设备生命周期变更
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_lifecycle", //业务标识
"data": {
"action": "bind",
"random": "xxxx" //用于业务服务器配网设备身份识别
}
} - 参数说明:
参数 | 类型 | 说明 |
aciton | string | bind-设备绑定, unbind-设备解绑, delete-设备删除, enable-设备启用, disable-设备禁用, |
random | string | 设备配网唯一标识 |
# 3.4 设备拓扑关系变更
- 数据格式:
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "device_topo", //业务标识
"data": {
"action": "add",
"success": [
{
"device_name": "xxx",
"product_key": "xxx",
"device_id": "xxx",
"session_id": "xxx" //配网请求唯一标识
}
],
"failure": [
{
"device_name": "xxx",
"product_key": "xxx",
"session_id": "xxx"
}
]
}
} - 参数说明:
参数 | 类型 | 说明 |
aciton | string | add-新增拓扑关系, delete-删除拓扑关系 |
success | array | 操作成功的子设备身份列表 |
failure | array | 操作失败的子设备身份列表 |
# 3.5 ota 升级进度通知
- 数据格式
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "ota_progress", //业务标识
"data": {
"step": 10,
"module": "default",
"task_id": "xxx"
}
} - 参数说明:
参数 | 类型 | 说明 |
step | int32 | 0~100:升级进度, -1:升级失败, |
module | string | 固件模块标识 |
task_id | string | 对应升级任务标识 |
# 3.6 ota 模块版本号通知
- 数据格式
{
"product_key": "xxx",
"device_name": "xxx",
"device_id": "xxxx", //设备唯一id
"timestamp": 1635146586120, //时间戳,单位:毫秒
"biz_code": "ota_version", //业务标识
"data": {
"version": "1.5.1",
"module": "default"
}
} - 参数说明:
参数 | 类型 | 说明 |
version | string | 设备当前模块版本号,格式:"x.y.z" |
module | string | 固件模块标识 |
# 3.7 物模型变更通知
- 数据格式
{
"product_key":"xxxxx",
"biz_code":"thing_model",
"timestamp":1648802119362,
"data":{
"action":"POST", // 操作类型 POST/PUT/DELETE
"element_id":"", // 物模型元素id
"element_type":"event", // 物模型元素类型:property/event/service
"element_data":{ // 物模型元素数据
"id":"xxxxx",
"name":"xxxxx",
"required":false,
"standard":false,
"eventType":"alert",
"desc":"",
"outputData":{
"event_param":{
"id":"xxxxx",
"name":"xxxxx",
"dataType":{
"min":"1",
"max":"99",
"step":"1",
"type":"int"
}
}
}
}
}
}