Update run script to support new router format in json from account server.

This commit is contained in:
jpmeijers 2017-03-09 01:21:43 +01:00
parent a450a654a0
commit e97dce7127

12
run.py
View File

@ -29,14 +29,14 @@ if os.environ.get('HALT') != None:
# Show info about the machine we're running on
print ("*** Resin Machine Info:")
print ("*** Type: "+os.environ.get('RESIN_MACHINE_NAME'))
print ("*** Arch: "+os.environ.get('RESIN_ARCH'))
print ("*** Type: "+str(os.environ.get('RESIN_MACHINE_NAME')))
print ("*** Arch: "+str(os.environ.get('RESIN_ARCH')))
if os.environ.get("RESIN_HOST_CONFIG_core_freq")!=None:
print ("*** Core freq: "+os.environ.get('RESIN_HOST_CONFIG_core_freq'))
print ("*** Core freq: "+str(os.environ.get('RESIN_HOST_CONFIG_core_freq')))
if os.environ.get("RESIN_HOST_CONFIG_dtoverlay")!=None:
print ("*** UART mode: "+os.environ.get('RESIN_HOST_CONFIG_dtoverlay'))
print ("*** UART mode: "+str(os.environ.get('RESIN_HOST_CONFIG_dtoverlay')))
# Check if the correct environment variables are set
@ -102,8 +102,8 @@ if(os.getenv('SERVER_TTN', True)):
frequency_plan = ttn_config.get('frequency_plan')#, "EU_863_870")
frequency_plan_url = ttn_config.get('frequency_plan_url')#, "https://account.thethingsnetwork.org/api/v2/frequency-plans/EU_863_870")
router = ttn_config.get('router')#, "router.dev.thethings.network:1883")
router = router[:router.index(':')] #strip port from url, as the ttn library also adds this
router = ttn_config.get('router').get('mqtt_address')#, "router.dev.thethings.network:1883")
router = router[:router.index(':')] #strip port from url, as this is added by mp_pkt_fwd
if "attributes" in ttn_config:
description = ttn_config['attributes'].get('description', "")