Compare commits

...

1 Commits

Author SHA1 Message Date
jpmeijers
094756c414 Download and run cayenne script in foreground 2017-06-13 19:32:42 +02:00
2 changed files with 18 additions and 1 deletions

View File

@ -31,6 +31,8 @@
Forward packets with a valid CRC.
* GW_ANTENNA_GAIN optional - default 0.
Set this to the dBd gain of your antenna. The dBd value is the dBi value minus 2.15dB, ie. dBd = dBi-2.15. This is used to reduce the TX power of the concentrator to stay within the legal limits.
* CAYENNE_SCRIPT optional
When this variable is set to a Raspberry Pi Cayenne monitoring script, the script will be downloaded and executed. This allows monitoring of your gateway on Cayenne.
##Server variables
All server variables are optional, but when a server is enabled, it is recommended to set all variables to configure it completely.

17
run.py
View File

@ -7,6 +7,7 @@ Based on: https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/run.sh
import os
import os.path
import sys
import stat
import urllib2
import time
import uuid
@ -273,7 +274,21 @@ with open('global_conf.json', 'w') as the_file:
the_file.write(json.dumps(local_conf, indent=4))
# TODO: Cayenne monitoring script
# Cayenne monitoring script
"""
wget https://cayenne.mydevices.com/dl/rpi_lv7d88b029.sh
sudo bash rpi_lv7d88b029.sh -v
"""
if(os.environ.get("CAYENNE_SCRIPT")!=None):
try:
response = urllib2.urlopen(os.environ.get("CAYENNE_SCRIPT"), timeout=30)
cayenne_script = response.read()
with open('rpi_cayenne.sh', 'w') as the_file:
the_file.write(cayenne_script)
os.chmod('rpi_cayenne.sh', stat.S_IEXEC)
subprocess.call(["./rpi_cayenne.sh"])
except urllib2.URLError as err:
print ("Unable to fetch Cayenne script")
# Endless loop to reset and restart packet forwarder