Added variable description to TODO.

Added more server configurability.
This commit is contained in:
jpmeijers 2017-02-26 20:28:09 +01:00
parent 9834e8bc46
commit dbe212df83
2 changed files with 85 additions and 10 deletions

56
TODO.md
View File

@ -47,3 +47,59 @@
} }
} }
``` ```
##Environment Variables
###Required global variables
* GW_TYPE required
* GW_ID required
* GW_KEY required
* GW_CONTACT_EMAIL required - default an empty string
The gateway owner's contact information.
###Optional global variables
* GW_GPS optional - default False
* If True, use the hardware GPS.
* If False,
use either fake gps if a location was configured in the TTN console,
otherwise try using fake gps with the reference location as set via environment variables,
otherwise don't send coordinates.
* GW_GPS_PORT optional - default /dev/ttyAMA0
The UART to which the hardware GPS is connected to.
* GW_REF_LATITUDE optional - default 0
The latitude to use for fake gps if the coordinates are not set in the TTN console.
* GW_REF_LONGITUDE optional - default 0
The longitude to use for fake gps if the coordinates are not set in the TTN console.
* GW_REF_ALTITUDE optional - default 0
The altitude to use for fake gps if the coordinates are not set in the TTN console.
###Server variables
All server variables are optional, but when a server is enabled, it is recommended to set all variables to configure it completely.
* SERVER_TTN optional - default True
Should the gateway connect to the TTN backend
* SERVER_1_ENABLED optional - default false
* SERVER_1_TYPE - default "semtech"
* SERVER_1_ADDRESS
* SERVER_1_PORTUP - only when using type semtech
* SERVER_1_PORTDOWN - only when using type semtech
* SERVER_1_GWID
* SERVER_1_GWKEY
* SERVER_1_DOWNLINK - default false
* SERVER_2_ENABLED optional - default false
* SERVER_2_TYPE - default "semtech"
* SERVER_2_ADDRESS
* SERVER_2_PORTUP - only when using type semtech
* SERVER_2_PORTDOWN - only when using type semtech
* SERVER_2_GWID
* SERVER_2_GWKEY
* SERVER_2_DOWNLINK - default false
* SERVER_3_ENABLED optional - default false
* SERVER_3_TYPE - default "semtech"
* SERVER_3_ADDRESS
* SERVER_3_PORTUP - only when using type semtech
* SERVER_3_PORTDOWN - only when using type semtech
* SERVER_3_GWID
* SERVER_3_GWKEY
* SERVER_3_DOWNLINK - default false

39
run.py
View File

@ -188,38 +188,57 @@ if(os.getenv('SERVER_1_ENABLED', False)):
if(os.getenv('SERVER_1_TYPE', "semtech")=="ttn"): if(os.getenv('SERVER_1_TYPE', "semtech")=="ttn"):
server['serv_type'] = "ttn" server['serv_type'] = "ttn"
server['server_address'] = os.environ.get("SERVER_1_ADDRESS") server['server_address'] = os.environ.get("SERVER_1_ADDRESS")
server['serv_port_up'] = os.environ.get("SERVER_1_PORTUP")
server['serv_port_down'] = os.environ.get("SERVER_1_PORTDOWN")
server['serv_gw_id'] = os.environ.get("SERVER_1_GWID") server['serv_gw_id'] = os.environ.get("SERVER_1_GWID")
server['serv_gw_key'] = os.environ.get("SERVER_1_GWKEY") server['serv_gw_key'] = os.environ.get("SERVER_1_GWKEY")
if(os.getenv('SERVER_1_ENABLED', "false")=="true"): if(os.getenv('SERVER_1_ENABLED', "false")=="true"):
server['serv_enabled'] = True server['serv_enabled'] = True
else: else:
server['serv_enabled'] = False server['serv_enabled'] = False
if(os.getenv('SERVER_1_DOWNLINK', "false")=="true"):
server['serv_down_enabled'] = True
else:
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)):
server = {} server = {}
if(os.getenv('SERVER_1_TYPE', "semtech")=="ttn"): if(os.getenv('SERVER_2_TYPE', "semtech")=="ttn"):
server['serv_type'] = "ttn" server['serv_type'] = "ttn"
server['server_address'] = os.environ.get("SERVER_1_ADDRESS") server['server_address'] = os.environ.get("SERVER_2_ADDRESS")
server['serv_gw_id'] = os.environ.get("SERVER_1_GWID") server['serv_port_up'] = os.environ.get("SERVER_2_PORTUP")
server['serv_gw_key'] = os.environ.get("SERVER_1_GWKEY") server['serv_port_down'] = os.environ.get("SERVER_2_PORTDOWN")
if(os.getenv('SERVER_1_ENABLED', "false")=="true"): server['serv_gw_id'] = os.environ.get("SERVER_2_GWID")
server['serv_gw_key'] = os.environ.get("SERVER_2_GWKEY")
if(os.getenv('SERVER_2_ENABLED', "false")=="true"):
server['serv_enabled'] = True server['serv_enabled'] = True
else: else:
server['serv_enabled'] = False server['serv_enabled'] = False
if(os.getenv('SERVER_2_DOWNLINK', "false")=="true"):
server['serv_down_enabled'] = True
else:
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)):
server = {} server = {}
if(os.getenv('SERVER_1_TYPE', "semtech")=="ttn"): if(os.getenv('SERVER_3_TYPE', "semtech")=="ttn"):
server['serv_type'] = "ttn" server['serv_type'] = "ttn"
server['server_address'] = os.environ.get("SERVER_1_ADDRESS") server['server_address'] = os.environ.get("SERVER_3_ADDRESS")
server['serv_gw_id'] = os.environ.get("SERVER_1_GWID") server['serv_port_up'] = os.environ.get("SERVER_3_PORTUP")
server['serv_gw_key'] = os.environ.get("SERVER_1_GWKEY") server['serv_port_down'] = os.environ.get("SERVER_3_PORTDOWN")
if(os.getenv('SERVER_1_ENABLED', "false")=="true"): server['serv_gw_id'] = os.environ.get("SERVER_3_GWID")
server['serv_gw_key'] = os.environ.get("SERVER_3_GWKEY")
if(os.getenv('SERVER_3_ENABLED', "false")=="true"):
server['serv_enabled'] = True server['serv_enabled'] = True
else: else:
server['serv_enabled'] = False server['serv_enabled'] = False
if(os.getenv('SERVER_3_DOWNLINK', "false")=="true"):
server['serv_down_enabled'] = True
else:
server['serv_down_enabled'] = False
gateway_conf['servers'].append(server) gateway_conf['servers'].append(server)