一、接发数据走向 设备->服务器
1、心跳
设备->服务器 发送心跳数据,默认60S,范围15-360S
示例
{
"operate": "heartbeat",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn": "200000000001"
}
{
"operate": "heartbeat_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": ""
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
heartbeat |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
heartbeat_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
2、抓拍图投递数据
设备->服务器 上传抓拍图
示例
{
"operate": "upload_snapshot",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn" : "290200001002",
"data" : ""
}
{
"operate": "upload_snapshot_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": ""
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
upload_snapshot |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
data |
string |
是 |
base64 |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
upload_snapshot_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
二、接发数据走向 服务器->设备
1、获取设备信息
服务器->设备 发送获取命令
示例
{
"operate": "get_dev_config",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn": "200000000001"
}
{
"operate": "get_dev_config_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": "",
"mac": "11:22:33",
"upload_type": 0,
"upload_addr": "http://bd.com/api",
"hb_interval": 60,
"run_time": 1000
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
get_dev_config |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
get_dev_config_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
mac |
string |
设备mac地址 |
upload_type |
int |
抓拍图投递方式:0-默认http 1-mqtt |
upload_addr |
string |
第三方投递地址 |
hb_interval |
int |
心跳间隔 |
run_time |
int64 |
连续运行时间S |
2、设置设备信息
服务器->设备 发送设置命令
示例
{
"operate": "set_dev_config",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn": "200000000001",
"upload_type": 0,
"upload_addr": "http://bd.com/api",
"hb_interval": 10
}
{
"operate": "set_dev_config_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": ""
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
set_dev_config |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
upload_type |
int |
是 |
抓拍图投递方式:0-默认http 1-mqtt |
upload_addr |
string |
是 |
抓拍图第三方投递地址 |
hb_interval |
int |
是 |
心跳间隔 |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
set_dev_config_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
3、推送设备升级
服务器->设备 发送升级命令
示例
{
"operate": "upgrade_dev",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn": "200000000001",
"package_url": "http://app.bin"
}
{
"operate": "upgrade_dev_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": ""
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
upgrade_dev |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
package_url |
string |
是 |
升级包地址 |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
upgrade_dev_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
4、控制指令集下发
服务器->设备 发送控制指令集
示例
{
"operate": "control_cmd",
"request_id": "xxxxxx",
"timestamp": 123456789,
"sn": "200000000001",
"cmd_data": {
"type": "take_snapshot"
}
}
{
"operate": "control_cmd_rsp",
"request_id": "xxxxxx",
"sn": "200000000001",
"ret": 0,
"msg": ""
}
请求参数
字段名 |
类型 |
是否必传 |
说明 |
operate |
string |
是 |
control_cmd |
request_id |
string |
是 |
请求id,区分每一条消息 |
timestamp |
int64 |
是 |
请求时间,单位:秒。相差五分钟内有效 |
sn |
string |
是 |
设备SN |
cmd_data |
json |
是 |
数据说明如下 |
cmd_data说明
type |
请求json格式,没有特殊说明字段都是string、int |
返回数据 |
take_snapshot |
{"type": "take_snapshot",} 触发抓拍 |
data=base64图片数据 |
io_control |
{"type": "io_control", "io0": 0, "io1": 1,} IO控制 |
data=null |
返回参数
字段名 |
类型 |
说明 |
operate |
string |
control_cmd_rsp |
request_id |
string |
请求id,区分每一条消息 |
sn |
string |
设备SN |
ret |
int |
返回码 |
msg |
string |
返回消息 |
cmd_data |
json |
返回{"type": "**", data: ""}是否有数据根据type来定 |