Update run.py

Add ability to override the EUI.
Fix a bug where server 2 and server 3 are never used.
This commit is contained in:
JP Meijers 2017-11-09 10:12:03 +02:00 committed by GitHub
parent 16a374665d
commit d68c4b2904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

7
run.py
View File

@ -59,10 +59,13 @@ if os.environ.get("GW_KEY")==None:
print ("See https://www.thethingsnetwork.org/docs/gateways/registration.html#via-gateway-connector") print ("See https://www.thethingsnetwork.org/docs/gateways/registration.html#via-gateway-connector")
sys.exit(0) sys.exit(0)
if os.environ.get("GW_EUI")==None:
# The FFFE should be inserted in the middle (so xxxxxxFFFExxxxxx) # The FFFE should be inserted in the middle (so xxxxxxFFFExxxxxx)
my_eui = format(uuid.getnode(), '012x') my_eui = format(uuid.getnode(), '012x')
my_eui = my_eui[:6]+GWID_PREFIX+my_eui[6:] my_eui = my_eui[:6]+GWID_PREFIX+my_eui[6:]
my_eui = my_eui.upper() my_eui = my_eui.upper()
else:
my_eui = os.environ.get("GW_EUI")
print ("Gateway ID:\t"+os.environ.get("GW_ID")) print ("Gateway ID:\t"+os.environ.get("GW_ID"))
print ("Gateway EUI:\t"+my_eui) print ("Gateway EUI:\t"+my_eui)
@ -233,7 +236,7 @@ if(os.getenv('SERVER_1_ENABLED', "false")=="true"):
server['serv_down_enabled'] = False server['serv_down_enabled'] = False
gateway_conf['servers'].append(server) gateway_conf['servers'].append(server)
if(os.getenv('SERVER_2_ENABLED', False)): if(os.getenv('SERVER_2_ENABLED', "false")=="true"):
server = {} server = {}
if(os.getenv('SERVER_2_TYPE', "semtech")=="ttn"): if(os.getenv('SERVER_2_TYPE', "semtech")=="ttn"):
server['serv_type'] = "ttn" server['serv_type'] = "ttn"
@ -249,7 +252,7 @@ if(os.getenv('SERVER_2_ENABLED', False)):
server['serv_down_enabled'] = False server['serv_down_enabled'] = False
gateway_conf['servers'].append(server) gateway_conf['servers'].append(server)
if(os.getenv('SERVER_3_ENABLED', False)): if(os.getenv('SERVER_3_ENABLED', "false")=="true"):
server = {} server = {}
if(os.getenv('SERVER_3_TYPE', "semtech")=="ttn"): if(os.getenv('SERVER_3_TYPE', "semtech")=="ttn"):
server['serv_type'] = "ttn" server['serv_type'] = "ttn"