CoAP server for VirtualCopernicus
- Python 3.7
virtualenvwrapper
(optional)
With virtualenvwrapper
installed:
mkvirtualenv agh-coap-copernicus
pip install -r requirements.txt
It may be required to install portaudio
library in system:
apt install libportaudio2
On Raspberry pi you may need to install additional dependencies:
sudo apt install libatlas3-base
pip install <name>
pip freeze > requirements.txt
workon agh-coap-copernicus
python server/server.py virtual
python client/client.py
CoAP server allows to create following types of resources:
- Generic GPIO
- LED
- Buzzer
- AngularServo
- Button
Resources can be added in the following way:
root.add_resource(['.well-known', 'core'],
resource.WKCResource(root.get_resources_as_linkheader))
root.add_resource(['servo'], ServoResource(17))
root.add_resource(['led1'], LEDResource(21))
root.add_resource(['button1'], ButtonResource(11, lambda: print("Pressed")), lambda: print("Released")))
root.add_resource(['buzzer'], BuzzerResource(16))
root.add_resource(['gpio_buzzer'], GPIOResource(15))
g <resource_name>
s <resource_name> <options>
0
,off
1
,on
<angle>
- must be betweenmin_angle
andmax_angle
0
,off
1
,on
-1
,toggle
beep <on_time> <off_time> <n>
for buzzerblink <on_time> <off_time> <n>
for LED
Install using the following commands:
sudo cp agh-coap-copernicus.service /etc/systemd/system
sudo systemctl enable agh-coap-copernicus
sudo systemctl start agh-coap-copernicus
View logs:
sudo journalctl -xfu agh-coap-copernicus