库珀网关
cpgw的Python项目详细描述
Cooper控制工具
这是Cooper软件狗的网关工具
安装
您可以直接从pypi安装cpgw:
sudo pip3 install -U cpgw
Note: You may need to use
sudo
before the command - it depends on the operating system used...
配置
将此片段插入文件/etc/cooper/cpgw.yml:
device: /dev/ttyUSB0
zmq:
publisher:
host: 127.0.0.1
port: 5680
dispatcher:
host: 127.0.0.1
port: 5681
用法
作为cli工具
cpgw -c /etc/cooper/cpgw.yml
系统d
将此代码片段插入文件/lib/systemd/system/cpgw。服务:
[Unit]
Description=COOPER cpgw
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/cpgw -c /etc/cooper/cpgw.yml
Restart=always
RestartSec=5
StartLimitIntervalSec=0
[Install]
WantedBy=multi-user.target
启动服务:
systemctl start cpgw.service
启动时启用服务启动:
systemctl enable cpgw.service
查看服务日志:
journalctl -u cpgw.service -f
pm2
pm2 start `which python3` --name "cpgw" -- `which cpgw` -c /etc/cooper/cpgw.yml
作为库
fromcpgw.gatewayimportGatewaydefon_recv(payload):print(payload)gw=Gateway("/dev/ttyUSB0")gw.on_recv=on_recvgw.run()
许可证
此项目在MIT License下获得许可-有关详细信息,请参阅LICENSE文件。