Make antenna_gain override value in global_conf
This commit is contained in:
parent
11911bebdb
commit
0d922b243b
@ -42,8 +42,8 @@ All server variables are optional, but when a server is enabled, it is recommend
|
|||||||
* SERVER_1_ADDRESS
|
* SERVER_1_ADDRESS
|
||||||
* SERVER_1_PORTUP - only when using type semtech
|
* SERVER_1_PORTUP - only when using type semtech
|
||||||
* SERVER_1_PORTDOWN - only when using type semtech
|
* SERVER_1_PORTDOWN - only when using type semtech
|
||||||
* SERVER_1_GWID
|
* SERVER_1_GWID - only when using type ttn
|
||||||
* SERVER_1_GWKEY
|
* SERVER_1_GWKEY - only when using type ttn
|
||||||
* SERVER_1_DOWNLINK - default false
|
* SERVER_1_DOWNLINK - default false
|
||||||
|
|
||||||
* SERVER_2_ENABLED optional - default false
|
* SERVER_2_ENABLED optional - default false
|
||||||
|
18
run.py
18
run.py
@ -146,17 +146,18 @@ if(os.getenv('SERVER_TTN', True)):
|
|||||||
|
|
||||||
|
|
||||||
# Retrieve global_conf
|
# Retrieve global_conf
|
||||||
global_conf = ""
|
sx1301_conf = {}
|
||||||
try:
|
try:
|
||||||
response = urllib2.urlopen(frequency_plan_url, timeout=30)
|
response = urllib2.urlopen(frequency_plan_url, timeout=30)
|
||||||
global_conf = response.read()
|
global_conf = response.read()
|
||||||
|
global_conf_object = json.loads(global_conf)
|
||||||
|
if('SX1301_conf' in global_conf_object):
|
||||||
|
sx1301_conf = global_conf_object['SX1301_conf']
|
||||||
except urllib2.URLError as err:
|
except urllib2.URLError as err:
|
||||||
print ("Unable to fetch global conf from Github")
|
print ("Unable to fetch global conf from Github")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Write global_coonf
|
sx1301_conf['antenna_gain'] = float(os.getenv('GW_ANTENNA_GAIN', 0))
|
||||||
with open('global_conf.json', 'w') as the_file:
|
|
||||||
the_file.write(global_conf)
|
|
||||||
|
|
||||||
|
|
||||||
# Build local_conf
|
# Build local_conf
|
||||||
@ -164,7 +165,6 @@ gateway_conf = {}
|
|||||||
gateway_conf['gateway_ID'] = my_eui
|
gateway_conf['gateway_ID'] = my_eui
|
||||||
gateway_conf['contact_email'] = os.getenv('GW_CONTACT_EMAIL', "")
|
gateway_conf['contact_email'] = os.getenv('GW_CONTACT_EMAIL', "")
|
||||||
gateway_conf['description'] = description
|
gateway_conf['description'] = description
|
||||||
gateway_conf['antenna_gain'] = float(os.getenv('GW_ANTENNA_GAIN', 0))
|
|
||||||
|
|
||||||
if(os.getenv('GW_FWD_CRC_ERR', False)=="true"):
|
if(os.getenv('GW_FWD_CRC_ERR', False)=="true"):
|
||||||
#default is False
|
#default is False
|
||||||
@ -266,10 +266,10 @@ if(os.getenv('SERVER_3_ENABLED', False)):
|
|||||||
gateway_conf['servers'].append(server)
|
gateway_conf['servers'].append(server)
|
||||||
|
|
||||||
|
|
||||||
# Now write the local_conf out to a file
|
# We merge the json objects from the global_conf and local_conf and save it to the global_conf.
|
||||||
# Write global_coonf
|
# Therefore there will not be a local_conf.json file.
|
||||||
local_conf = {'gateway_conf': gateway_conf}
|
local_conf = {'SX1301_conf': sx1301_conf, 'gateway_conf': gateway_conf}
|
||||||
with open('local_conf.json', 'w') as the_file:
|
with open('global_conf.json', 'w') as the_file:
|
||||||
the_file.write(json.dumps(local_conf, indent=4))
|
the_file.write(json.dumps(local_conf, indent=4))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user