大小丑USB网关

bcg的Python项目详细描述


BigClown Logo

Big小丑USB网关的集线器服务

TravisReleaseLicensePyPITwitter

此存储库包含用于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;制成。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java测试SpringAOP方面   java在使用groovy访问JSON字段时遇到问题   java需要但没有被调用:<Capturing argument>实际上,与这个mock没有任何交互   java在O(n)时间内遍历LinkedList并删除k个元素   java在Hibernate中执行条件查询后,是否需要提交/关闭会话?   java提供apacheshiro作为JBoss7、WildFly8的模块   使用标头读取CSV,同时忽略JAVA中的某些行   java如何验证kotlin中的数据类是否为null   java墙纸未缩放到设备的显示   java以独立于实现的方式列出所有注册的JAXRS 2提供程序   java Apache ANT Exec Handle Exec/CakePHP控制台提示   java无法从dropwizard项目中排除logbackclassic依赖项   java如何通过对象向构造函数发送日期值,以及如何返回该日期值?   java为什么使用静态记录器比不使用它花费更多的时间   JavaAndroid:解析webview的内容而不重新加载和发布   java如何仅捕获异常类型   eclipse无法从Java独立项目中的ATL EMFTVM转换中读取模块   另一个路由中的java Apache camel blueprint web服务响应