大小丑USB网关
bcg的Python项目详细描述
Big小丑USB网关的集线器服务
此存储库包含用于big小丑usb网关的cli服务。
简介
该服务连接到连接big小丑usb网关的串行端口。
它将消息从串行端口转换为MQTT代理,反之亦然。
使用--help
参数运行以查看可用选项。
它与Python2.7+和Python3.5+环境一起工作,并且已经在Linux、MacOS和Windows下进行了测试。
设置
pip3 install -U bcg
作为系统范围内的本地python包安装。
git clone https://github.com/bigclownlabs/bch-gateway.git
cd bch-gateway
sudo pip3 install -e .
Note: Parameter
-e
instructs to install files as symlinks, so changes to the source files will be immediately available to other users of the package on the host.
mqtt
获取有关所有已连接网关的信息
mosquitto_pub -t 'gateway/all/info/get' -n
响应:
gateway/{name}/info {"id": "836d19839c3b", "firmware": "bcf-gateway-...."}
成对节点列表
mosquitto_pub -t 'gateway/{name}/nodes/get' -n
响应:
gateway/{name}/nodes ["{id-node-0}", "{id-node-id1}", "{id-node-id2}"]
配对模式
开始
mosquitto_pub -t 'gateway/{name}/pairing-mode/start' -n
网关启动指示灯闪烁
响应:
gateway/{name}/pairing-mode "start"
网关正在等待配对节点。要减少节点,长按核心模块上的按钮。
成功添加节点时的响应:
gateway/{name}/attach "{id-node-0}" gateway/{name}/attach "{id-node-1}" ...
如果空间不足,则错误响应:
gateway/{name}/attach-failure "{id-node-1}"
停止
mosquitto_pub -t 'gateway/{name}/pairing-mode/stop' -n
网关上的LED熄灭
响应:
gateway/{name}/pairing-mode "stop"
清除所有节点
mosquitto_pub -t 'gateway/{name}/nodes/purge' -n
响应:
gateway/{name}/nodes []
手动添加/配对节点
mosquitto_pub -t 'gateway/{name}/nodes/add' -m '"{id-node}"'
响应:
gateway/{name}/attach "{id-node}"
如果空间不足,则错误响应:
gateway/{name}/attach-failure "{id-node-1}"
手动删除/取消配对节点
mosquitto_pub -t 'gateway/{name}/nodes/remove' -m '"{id-node}"'
响应:
gateway/{name}/detach "{id-node}"
设置节点别名
mosquitto_pub -t 'gateway/usb-dongle/alias/set' -m '{"id": "id-node", "alias": "new-alias"}'
响应:
gateway/usb-dongle/alias/set/ok {"id": "id-node", "alias": "new-alias"}
删除节点别名
mosquitto_pub -t 'gateway/usb-dongle/alias/remove' -m '"{id-node}"'
mosquitto_pub -t 'gateway/usb-dongle/alias/set' -m '{"id": "id-node", "alias": null}'
扫描开始
开始
mosquitto_pub -t 'gateway/{name}/scan/start' -n
响应:
gateway/{name}/scan "start"
未知节点的响应
gateway/{name}/found "{id-node-0}" gateway/{name}/found "{id-node-1}" gateway/{name}/found "{id-node-2}" ...
停止
mosquitto_pub -t 'gateway/{name}/scan/stop' -n
响应:
gateway/{name}/scan "stop"
所有可见节点的自动配对
啊!!!这是实验性功能,并非所有功能都有效
开始
mosquitto_pub -t 'gateway/{name}/automatic-pairing/start' -n
网关启动指示灯闪烁
响应:
gateway/{name}/automatic-pairing "start"
成功添加节点时的响应:
gateway/{name}/attach "{id-node-0}" gateway/{name}/attach "{id-node-1}" ...
停止
mosquitto_pub -t 'gateway/{name}/automatic-pairing/stop' -n
LED on gateway turns off response: ``` gateway/{name}/automatic-pairing "stop" ```
配置文件
名称:字符串
支持变量:
- {ip}-ip地址
- {id}-连接的USB加密狗或核心模块的ID
默认值:空-从网关固件自动检测名称
示例:“{ip}-ttyusb0”
节点红色按钮
如果使用node red,则可以导入下面的文本以在流中创建按钮。单击鼠标即可列出、配对和删除节点。
用于BCF网关USB加密狗
[{"id":"83c6c60c.209d78","type":"mqtt in","z":"97027127.a55f7","name":"","topic":"#","qos":"2","broker":"de273190.7f6f2","x":610,"y":80,"wires":[["454a64bc.50f77c"]]},{"id":"454a64bc.50f77c","type":"debug","z":"97027127.a55f7","name":"","active":true,"console":"false","complete":"false","x":790,"y":80,"wires":[]},{"id":"9e87ab30.a50be8","type":"inject","z":"97027127.a55f7","name":"All gateway info","topic":"gateway/all/info/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":639,"y":172,"wires":[["504dd396.bb5b4c"]]},{"id":"504dd396.bb5b4c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":824,"y":173,"wires":[]},{"id":"f447966d.ed0cb8","type":"inject","z":"97027127.a55f7","name":"Pairing mode start","topic":"gateway/usb-dongle/pairing-mode/start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":660,"y":280,"wires":[["ae043e16.df77c"]]},{"id":"ae043e16.df77c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":281,"wires":[]},{"id":"80092576.c83998","type":"inject","z":"97027127.a55f7","name":"Pairing mode stop","topic":"gateway/usb-dongle/pairing-mode/stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":660,"y":320,"wires":[["86c93689.7d0e58"]]},{"id":"86c93689.7d0e58","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":321,"wires":[]},{"id":"8f7b14c7.898c38","type":"inject","z":"97027127.a55f7","name":"List of paired nodes","topic":"gateway/usb-dongle/nodes/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":220,"wires":[["75f5e8db.ed19a8"]]},{"id":"75f5e8db.ed19a8","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":221,"wires":[]},{"id":"ed3cfe08.3321b","type":"inject","z":"97027127.a55f7","name":"purge all nodes","topic":"gateway/usb-dongle/nodes/purge","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":640,"y":380,"wires":[["2acde0de.0d9de"]]},{"id":"2acde0de.0d9de","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":381,"wires":[]},{"id":"de273190.7f6f2","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
对于BCF网关核心模块
[{"id":"47ab49a8.0a88f8","type":"mqtt in","z":"97027127.a55f7","name":"","topic":"#","qos":"2","broker":"deefb40d.51f818","x":370,"y":100,"wires":[["7208a9c6.a8d3e8"]]},{"id":"7208a9c6.a8d3e8","type":"debug","z":"97027127.a55f7","name":"","active":true,"console":"false","complete":"false","x":550,"y":100,"wires":[]},{"id":"3e634a0c.8e15e6","type":"inject","z":"97027127.a55f7","name":"All gateway info","topic":"gateway/all/info/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":399,"y":192,"wires":[["84e9ef97.a81d5"]]},{"id":"84e9ef97.a81d5","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":584,"y":193,"wires":[]},{"id":"6d1a6395.7b49ac","type":"inject","z":"97027127.a55f7","name":"Pairing mode start","topic":"gateway/core-module/pairing-mode/start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":320,"wires":[["6bb142ef.da565c"]]},{"id":"6bb142ef.da565c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":321,"wires":[]},{"id":"191cf80e.901568","type":"inject","z":"97027127.a55f7","name":"Pairing mode stop","topic":"gateway/core-module/pairing-mode/stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":360,"wires":[["11669b55.138775"]]},{"id":"11669b55.138775","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":361,"wires":[]},{"id":"de1bca38.1214f8","type":"inject","z":"97027127.a55f7","name":"List of paired nodes","topic":"gateway/core-module/nodes/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":410,"y":240,"wires":[["7cb77d25.465514"]]},{"id":"7cb77d25.465514","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":241,"wires":[]},{"id":"ec929b66.dddbb8","type":"inject","z":"97027127.a55f7","name":"purge all nodes","topic":"gateway/core-module/nodes/purge","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":420,"wires":[["afe70282.f5ead"]]},{"id":"afe70282.f5ead","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":421,"wires":[]},{"id":"deefb40d.51f818","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
许可证
此项目在MIT License下获得许可-有关详细信息,请参阅LICENSE文件。
由{a9}在欧洲中心用{a10084;制成。