主题
半实物设备通信协议
类型定义
设备类型
设备名称 | 值 | 添加版本 |
---|---|---|
所有设备 | 255 | 0 |
风扇 | 1 | 0 |
喷气 | 2 | 0 |
热感 | 3 | 0 |
音震 | 4 | 0 |
电梯 | 5 | 0 |
门 | 6 | 0 |
阀门 | 7 | 0 |
发射器 | 8 | 0 |
手电筒 | 9 | 0 |
按钮 | 10 | 0 |
开关 | 11 | 0 |
喷淋 | 12 | 0 |
气味 | 13 | 1 |
旋钮 | 14 | 2 |
消息类型
消息类型 | 值 | 添加版本 |
---|---|---|
获取设备列表 | 1 | 0 |
开启 | 2 | 0 |
关闭 | 3 | 0 |
重置 | 4 | 0 |
移动 | 5 | 0 |
预设 | 6 | 0 |
设备列表 | 100 | 0 |
开关状态 | 101 | 0 |
角度状态 | 102 | 0 |
预设状态 | 103 | 1 |
数字状态 | 104 | 2 |
设备-消息映射表
获取设备列表[1] | 开启[2] | 关闭[3] | 重置[4] | 移动[5] | 预设[6] | 设备列表[100] | 开关状态[101] | 角度状态[102] | 预设状态[103] | 数字状态[104] | |
---|---|---|---|---|---|---|---|---|---|---|---|
所有设备[255] | √ | √ | |||||||||
风扇[1] | √ | √ | √ | ||||||||
喷气[2] | √ | √ | √ | ||||||||
热感[3] | √ | √ | √ | ||||||||
音震[4] | √ | √ | √ | ||||||||
电梯[5] | √ | √ | √ | √ | |||||||
门[6] | √ | √ | |||||||||
阀门[7] | √ | √ | |||||||||
发射器[8] | √ | ||||||||||
手电筒[9] | √ | ||||||||||
按钮[10] | √ | ||||||||||
开关[11] | √ | √ | √ | ||||||||
喷淋[12] | √ | √ | √ | ||||||||
气味[13] | √ | √ | √ | ||||||||
旋钮[14] | √ | √ |
UDP 广播连接
客户端发送广播消息
端口 33666
json
{
"type": 1,
"name": "xxx",
"protocol": "tcp"
}
中控端回应消息
json
{
"type": 2,
"ip": "x.x.x.x",
"tcp_port": 33600,
"version": 1
}
- 如果
ip
为0.0.0.0
则需要客户端通过解析 UDP 包的源地址来获取中控 IP - 如果检测不到
version
字段,则默认为 0
TCP 通信
消息结构
字段 | 长度 | 默认值 | 含义 |
---|---|---|---|
flag | 4Byte | 0xCACACACA | 固定值 |
length | 4Byte | 消息体长度 | |
data | length | 消息体(Json 格式) |
消息类型
获取设备列表【1】
会触发设备列表消息[100]
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 255 | 设备类型 |
msg_type | int | 0 | 1 | 消息类型 |
示例
json
{
"device_type": 255,
"msg_type": 1
}
开启【2】
可能触发开关状态消息[101]
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 0 | 2 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
index | int | 1 | -1 | 子设备索引,-1 代表无效 |
示例
json
{
"device_type": 1,
"msg_type": 2,
"sn": "xxx",
"index": -1
}
关闭【3】
可能触发开关状态消息[101]
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 0 | 3 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
index | int | 1 | -1 | 子设备索引,-1 代表无效 |
示例
json
{
"device_type": 1,
"msg_type": 3,
"sn": "xxx",
"index": -1
}
重置【4】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 0 | 4 | 消息类型 |
sn | string | 0 | 设备 SN 号 |
示例
json
{
"device_type": 5,
"msg_type": 4,
"sn": "xxx"
}
移动【5】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 0 | 5 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
data | object | 0 | 移动结构体 |
- data
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
height_mm | int | 0 | 高度(毫米) | |
pitch_radian | float | 0 | 偏航角(弧度) | |
roll_radian | float | 0 | 翻滚角(弧度) | |
time_ms | int | 0 | 时间(毫秒) |
示例
json
{
"device_type": 5,
"msg_type": 5,
"sn": "xxx",
"data": {
"height_mm": 1000,
"pitch_radian": 0.39,
"roll_radian": 0.39,
"time_ms": 100
}
}
预设【6】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 0 | 6 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
name | string | 0 | 预设名称 | |
enable | bool | 0 | 开始/停止预设 |
示例
json
{
"device_type": 5,
"msg_type": 6,
"sn": "xxx",
"name": "预设名称",
"enable": true
}
设备列表【100】
TCP 连接成功后,硬件中控会自动发送一次该消息
设备上下线以后,也会触发该消息
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 255 | 设备类型 |
msg_type | int | 1 | 100 | 消息类型 |
devices | array | 0 | 设备列表 |
- 开关设备(风扇、喷气、热感、音震、发射器、手电筒、按钮、开关、喷淋)
json
{
"sn": "xxx",
"device_type": 1,
"online": true,
"enabled": true,
"pressed": true
}
- 角度设备(门、阀门)
json
{
"sn": "xxx",
"device_type": 6,
"online": false,
"angle": 45.0
}
- 电梯设备(电梯)
json
{
"sn": "xxx",
"device_type": 5,
"online": false,
"min_pitch_radian": -0.39,
"max_pitch_radian": 0.39,
"min_roll_radian": -0.39,
"max_roll_radian": 0.39,
"min_height_mm": -50,
"max_height_mm": 50,
"presets": [
"高频震动-短促",
"高频震动-持续",
"上下晃动-短促",
"上下晃动-持续",
"左右晃动-短促",
"左右晃动-持续",
"突然下坠",
"突然上顶"
],
"floor_height_mm": -50
}
- 气味设备(气味)
json
{
"sn": "xxx",
"device_type": 1,
"online": true,
"num_port": 12,
"enabled": [
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false
]
}
- 数字设备(旋钮)
json
{
"sn": "xxx",
"device_type": 14,
"online": true,
"range": [0, 5],
"step": 1
}
示例
json
{
"device_type": 255,
"msg_type": 100,
"devices": [
{
"sn": "开关设备",
"device_type": 1,
"online": true,
"enabled": true,
"pressed": true
}
]
}
开关状态【101】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 1 | 101 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
online | bool | 0 | 是否在线 | |
pressed | bool | 0 | 与`enabled`保持一致 | 开关状态 |
index | int | 1 | -1 | 子设备索引 |
enabled | bool | 1 | 开关状态 |
示例
json
{
"device_type": 1,
"msg_type": 101,
"sn": "xxx",
"online": true,
"pressed": true,
"index": -1,
"enabled": true
}
角度状态【102】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 0 | 设备类型 | |
msg_type | int | 1 | 102 | 消息类型 |
sn | string | 0 | 设备 SN 号 | |
online | bool | 0 | 是否在线 | |
angle | float | 0 | 角度(角度) |
示例
json
{
"device_type": 6,
"msg_type": 102,
"sn": "xxx",
"online": true,
"angle": 45.0
}
预设状态【103】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 1 | 设备类型 | |
msg_type | int | 1 | 103 | 消息类型 |
sn | string | 1 | 设备 SN 号 | |
state | int | 1 | 状态 | |
preset | string | 1 | 预设名称 |
- state
1
预设开始2
预设结束
示例
json
{
"device_type": 5,
"msg_type": 103,
"sn": "xxx",
"state": 1,
"preset": "高频震动"
}
数字状态【104】
参数 | 类型 | 添加版本 | 默认值 | 含义 |
---|---|---|---|---|
device_type | int | 2 | 设备类型 | |
msg_type | int | 2 | 104 | 消息类型 |
sn | string | 2 | 设备 SN 号 | |
state | int | 2 | 数字状态 |
示例
json
{
"device_type": 14,
"msg_type": 104,
"sn": "xxx",
"state": 1,
}