# TCP协议连接
# 1 设备连接
# 1.1 连接地址
socket.huadong2.fenydata.com:9988
# 1.2 登录认证
(1)报文格式
{
"timestamp": 1749436744000,
"type": "auth",
"content": {
"clientId": "sLe********.88***|signmethod=hmacsha256,timestamp=1746686968850|",
"password": "aa390e1*****************************************************",
"username": "88***&sLe*******"
}
}
(2)字段说明
| 名称 | 类型 | 示例 | 描述 |
|---|---|---|---|
| timestamp | Long | 1749436744000 | 登录时间,13位时间戳 |
| type | String | auth | 登录报文类型码。固定为auth |
| content | Struct | 认证信息结构体 | |
| clientId | String | sLe****.88****|signmethod=hmacsha256,timestamp=1746686968850 | 设备登录客户端ID |
| username | String | 88****&sLe**** | 设备登录用户名 |
| password | String | aa390e1***************************************************** | 设备登录密码 |
(3)返回内容
| 返回字符串 | 说明 |
|---|---|
| ack:auth:error:content can not be empty! | 认证信息不能为空 |
| ack:auth:error:clientId can not be empty! | 客户端id不能为空 |
| ack:auth:error:username can not be empty! | 用户名不能为空 |
| ack:auth:error:password can not be empty! | 密码不能为空 |
| ack:auth:error | 密码鉴权失败 |
| ack:auth:success | 登录成功 |
# 1.3 心跳上报
(1)报文格式
{
"type": "heart",
"timestamp": 1749447944768
}
(2)字段说明
| 名称 | 类型 | 示例 | 描述 |
|---|---|---|---|
| timestamp | Long | 1749436744000 | 上报时间,13位时间戳 |
| type | String | heart | 心跳上报的报文类型码。固定为heart |
(3)返回内容
- 上报成功,平台返回"ack:heart";
- 注意:设备心跳超时时间为60秒;
- 注意:上报物模型属性和事件时,也会刷新设备的心跳时间;
# 2 设备通信
# 2.1 物模型属性上报
(1)报文格式
{
"timestamp": 1749436744000,
"type": "property",
"content": {
"id": "123",
"list": [
{
"name": "ia",
"value": 0.36,
"time": 1749436744000
},
{
"name": "ib",
"value": 0.28,
"time": 1749436744000
}
]
}
}
(2)字段说明
| 名称 | 类型 | 示例 | 描述 |
|---|---|---|---|
| timestamp | Long | 1749436744000 | 上报时间,13位时间戳 |
| type | String | property | 物模型属性上报的报文类型码。固定为property |
| content | Struct | 上报信息结构体 | |
| id | String | 123 | 消息ID号。String类型的数字,每个消息ID在当前设备中具有唯一性 |
| list | Array | 物模型属性数据数组 | |
| name | String | ia | 物模型属性的标识符,可在平台新增物模型属性时设置以及查看 |
| value | Object | 0.28 | 物模型属性上报的属性值,目前支持的数据类型有int、float、double、string |
| time | Long | 1749436744000 | 物模型属性上报的时间,13位时间戳,注意:时间不能早于7天前 |
(3)返回内容
- 上报成功,平台返回"ack:property";
# 2.2 物模型事件上报
(1)报文格式
{
"timestamp": 1749436744000,
"type": "event",
"content": {
"id": "123",
"eventName": "temp_alert",
"params": {
"value": {
"Power": "on",
"WF": "2"
},
"time": 1749436744000
}
}
}
(2)字段说明
| 名称 | 类型 | 示例 | 描述 |
|---|---|---|---|
| timestamp | Long | 1749436744000 | 上报时间,13位时间戳 |
| type | String | event | 物模型事件上报的报文类型码。固定为event |
| content | Struct | 上报信息结构体 | |
| id | String | 123 | 消息ID号。String类型的数字,每个消息ID在当前设备中具有唯一性 |
| eventName | String | temp_alert | 物模型事件的标识符,可在平台新增物模型事件时设置以及查看 |
| params | Struct | 物模型事件的输出参数 | |
| value | Map<String, Object> | { "Power": "on", "WF": "2" } | 物模型事件的输出参数信息,如以上示例中的两个参数Power(电源)和WF(工作电流)的信息,目前支持的数据类型有int、float、double、string |
| time | Long | 1749436744000 | 物模型事件上报的时间,13位时间戳,注意:时间不能早于7天前 |
(3)返回内容
- 上报成功,平台返回"ack:event";
← http动态注册示例 调用API →