https://github.com/hardwario/cpgw
COOPER Gateway Service
https://github.com/hardwario/cpgw
iot multisensor python usb zeromq
Last synced: about 2 months ago
JSON representation
COOPER Gateway Service
- Host: GitHub
- URL: https://github.com/hardwario/cpgw
- Owner: hardwario
- License: mit
- Created: 2018-09-11T08:05:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-25T09:19:03.000Z (over 4 years ago)
- Last Synced: 2025-12-31T15:17:27.795Z (3 months ago)
- Topics: iot, multisensor, python, usb, zeromq
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# COOPER Control Tool
[](https://travis-ci.org/hardwario/cpgw)
[](https://github.com/hardwario/cpgw/releases)
[](https://github.com/hardwario/cpgw/blob/master/LICENSE)
[](https://pypi.org/project/cpgw/)
This is the Gateway tool for cooper dongle
## Installation
You can install **cpgw** directly from PyPI:
```sh
sudo pip3 install -U cpgw
```
> Note: You may need to use `sudo` before the command - it depends on the operating system used...
## Configuration
Insert this snippet to the file /etc/cooper/cpgw.yml:
```
device: /dev/ttyUSB0
zmq:
publisher:
host: 127.0.0.1
port: 5680
dispatcher:
host: 127.0.0.1
port: 5681
```
## Usage
```sh
cpgw -c /etc/cooper/cpgw.yml
```
### Start using systemd
Insert this snippet to the file `/etc/systemd/system/cpgw.service`:
```
[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
```
Start the service:
systemctl start cpgw.service
Enable the service start on boot:
systemctl enable cpgw.service
View the service log:
journalctl -u cpgw.service -f
### Start using PM2
```sh
pm2 start `which python3` --name "cpgw" -- `which cpgw` -c /etc/cooper/cpgw.yml
```
### Usage as Python module
```python
from cpgw.gateway import Gateway
def on_recv(payload):
print(payload)
gw = Gateway("/dev/ttyUSB0")
gw.on_recv = on_recv
gw.run()
```
## License
This project is licensed under the [**MIT License**](https://opensource.org/licenses/MIT/) - see the [**LICENSE**](LICENSE) file for details.