loader

地址: ws://localhost:8765

协议:WebSocket

说明:本服务用于AICOIOT RFID系列读卡器设备检测、连接、断开、升级等功能的客户端交互。

🔄 通用消息结构

{ "type": "command", "command": "..." }

📥 客户端 → 服务端 消息类型

1. 扫描设备 - scan

{ "type": "command", "command": "scan" }
响应成功:
{ "type": "status", "status": "connected", "port": "COM3", "info": "DvicesModel=...;Facturer=...;..." }
响应失败:
{ "type": "status", "status": "not_found" }

2. 连接指定设备 - connect

{ "type": "command", "command": "connect", "device": "COM3" }

3. 断开设备 - disconnect

{ "type": "command", "command": "disconnect", "device": "COM3" }

4. 获取设备列表 - getlist

{ "type": "command", "command": "getlist" }
返回数据
{"type": "status", "status": "device_list", "devices": [{"port": "COM10", "description": "USB-SERIAL CH340 (COM10)"}]}

5. 固件更新 - update

{ "type": "command", "command": "update", "device": "COM3" }

6. 关闭服务 - exit

{ "type": "command", "command": "exit" }

📤 服务端 → 客户端 消息类型

实时串口数据:
{ "type": "data", "port": "COM3", "payload": "DATA LINE" }
设备断开通知:
{ "type": "disconnect", "port": "COM3", "message": "设备已断开" }
通用错误格式:
{ "type": "error", "message": "错误描述" }

🧩 可用命令列表

命令 说明
scan 扫描并连接设备
connect 连接指定端口
disconnect 断开指定端口
getlist 获取串口设备列表
update 下载并烧录固件
exit 关闭 WebSocket 服务