属性上报&事件上报(BVJSON)
接口说明
通过属性上报 或事件上报 的方式,向 DTS 平台推送设备状态变化数据;支持两种上报类型按需选择,接口接收设备标识、上报类型及自定义参数,返回上报结果。
接口
| 项目 | 具体说明 |
|---|---|
| 请求方式 | POST |
| 接口路径 | /bv-universal-gateway/api/accessGateway/rawDataToProtocol |
| 访问地址 | http://{IP地址}:{端口} 或 http://{域名}:{端口}(以实际部署为准) |
| Content-Type | application/json(必填) |
| 字符编码 | UTF-8 |
请求体
整体格式
请求体为 JSON 对象 ,单条请求仅支持上报一种类型数据(属性/事件),不可同时上报两种类型。
请求参数
| 字段名称 | 字段类型 | 是否必传 | 默认值 | 说明 |
|---|---|---|---|---|
| method | number | 是 | - | 上行数据类型标识(不可传其他值): |
| 0 = 属性上报;1 = 事件上报 | ||||
| productId | string | 是 | - | 产品唯一标识符,由平台分配,不可为空、不可传无效值 |
| deviceId | string | 是 | - | 设备在对应产品下的唯一标识符,不可为空、不可传无效值 |
| deviceSecret | string | 否 | - | 设备密钥,需与 deviceId 同时传入(按需使用,非必传) |
| deviceName | string | 否 | - | 设备名称,自定义填写(无需与注册时完全一致,仅作标识补充) |
| deviceStatus | number | 否 | 1 | 设备状态:0 = 未启用,1 = 已启用(默认值可无需手动传递) |
| identifier | string | 否 | - | 特殊说明:事件上报(method=1)时必传 ,属性上报可忽略;为事件唯一标识符,需与产品事件模型配置一致 |
| location | string | 否 | “0 0 0” | 设备位置纬经度,格式为 纬度 经度 海拔(空格分隔,单位:度/米) |
| timestamp | number | 否 | 当前时间戳 | 上行数据传输时间,格式为GMT 1970-01-01 00:00:00 至今的毫秒数 |
| version | string | 否 | “default” | 版本号,自定义填写(如”v1.0.0”),不传递则使用默认值 |
| payload | object | 否 | {} | 上报的自定义参数(按需传递,非必传): |
| - 属性上报:设备属性参数(如温度、电压等) | ||||
| - 事件上报:事件输出参数(如告警相关数据) |
请求示例
属性上报示例(method=0)
// 属性上报
curl --location --request POST 'http://{访问地址}/bv-universal-gateway/api/accessGateway/rawDataToProtocol' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw '{
"method": 0,
"productId":"ovw9GOl46TSqbedc",
"deviceId": "b28baf9c-40cc-4fe7-9488-8bc28f28717f",
"deviceStatus": 0,
"payload": {
"ipAddress": "142.82.172.41",
"switchStatus": false,
"brandInformation": "出少素格",
"scheduledOnTime": "14:00:00",
"scheduledOffTime": "14:31:29",
"humidity": "0.84°",
"temperature": "0.43°",
"networkType": "IPv4",
"connectionStatus": "已连接",
"productModel": "技特国",
"currentAndVoltage": {
"realTimeVoltage": 220,
"realTimeCurrent": 0.57
},
"powerRelated": {},
}
}'
事件上报示例(method=1)
// 事件上报
curl --location --request POST 'http://{访问地址}/bv-universal-gateway/api/accessGateway/rawDataToProtocol' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw '{
"method": 1,
"productId": "ovw9GOl46TSqbedc",
"deviceId": "b28baf9c-40cc-4fe7-9488-8bc28f28717f",
"identifier": "PowerOverload",
"deviceStatus": 0,
"payload": {
"ratedPower": 2313,
"currentPower": 549
}
}'
响应说明
响应体格式
| 字段名称 | 字段类型 | 说明 |
|---|---|---|
| code | number | 响应状态码:0 = 成功,非 0 = 失败 |
| message | string | 响应描述:成功返回 “success”,失败返回具体错误信息 |
| info | object | 扩展信息:成功时为 null,失败时可能返回参数错误明细等具体内容 |
响应状态码
| code | message | 排查建议 |
|---|---|---|
| 0 | success | - |
| 10000 | 未知错误 | |
| 10001 | 参数错误 | 校验参数类型与格式(如 timestamp 需为毫秒级数字、location 格式是否合规) |
| 10024 | 缺少必传参数或参数内容为空 | 检查 productId、deviceId、deviceName 是否为空或未传递 |
| 20018 | 上报数据,获取产品Profile失败,请稍后重试 | 确认 productId 正确性,检查产品是否已在平台完成创建,是否有发布 |
| 20020 | 上报数据失败,获取产品Profile属性列表为空 | 确认目标产品已配置产品Profile |
| 20022 | 实体上报失败,实体数据列表为空 | 检查请求体是否为非空 JSON 数组,禁止传递空数组或非数组格式 |
| 20023 | 上报数据失败,获取产品数据解析脚本为空 | 确认是否配置产品的数据解析脚本 |
响应示例
成功响应
{
"code": 0,
"message": "success",
"info": null
}
失败响应
{
"code": 20024,
"message": "上行数据中的设备,与当前接入网关所关联的全部产品设备均不匹配,或该设备根本不存在。若您确定该网关关联的产品中确实存在此设备,请检查报文或前往DTS验证数据解析规则后发布重试。网关标识:1ca63711968e430c,产品编号:OWqrR0cJzMLvx8DJ,设备编号:760a1d89-5f16-4aa3-bd2a-802e454bf425",
"info": null
}
作者:北京-产品-yantings 创建时间:2021-12-23 11:13
最后编辑:北京-产品-yantings 更新时间:2026-07-07 18:14
最后编辑:北京-产品-yantings 更新时间:2026-07-07 18:14