From e40d71b4a83df09ee06b1b3a5bf66996518878b7 Mon Sep 17 00:00:00 2001 From: jpmeijers Date: Sun, 12 Nov 2017 22:52:13 +0200 Subject: [PATCH] Add the ability to manually configure server 0, which is normally used by TTN --- CONFIGURATION.md | 10 ++++++++++ run.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index b0db5f8..bc87c9a 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -68,6 +68,16 @@ All server variables are optional, but when a server is enabled, it is recommend * SERVER_3_GWKEY * SERVER_3_DOWNLINK - default false +As long as `SERVER_TTN` is set to false, you can also: +* SERVER_0_ENABLED optional - default false +* SERVER_0_TYPE - default "semtech" +* SERVER_0_ADDRESS +* SERVER_0_PORTUP - only when using type semtech +* SERVER_0_PORTDOWN - only when using type semtech +* SERVER_0_GWID +* SERVER_0_GWKEY +* SERVER_0_DOWNLINK - default false + ## Example for using only legacy forwarder | Variable | Value | diff --git a/run.py b/run.py index 148bdd4..18515e6 100755 --- a/run.py +++ b/run.py @@ -221,6 +221,22 @@ if(os.getenv('SERVER_TTN', "true")=="true"): server['serv_gw_key'] = os.environ.get("GW_KEY") server['serv_enabled'] = True gateway_conf['servers'].append(server) +else: + if(os.getenv('SERVER_0_ENABLED', "false")=="true"): + server = {} + if(os.getenv('SERVER_0_TYPE', "semtech")=="ttn"): + server['serv_type'] = "ttn" + server['serv_gw_id'] = os.environ.get("SERVER_0_GWID") + server['serv_gw_key'] = os.environ.get("SERVER_0_GWKEY") + server['server_address'] = os.environ.get("SERVER_0_ADDRESS") + server['serv_port_up'] = int(os.getenv("SERVER_0_PORTUP", 1700)) + server['serv_port_down'] = int(os.getenv("SERVER_0_PORTDOWN", 1700)) + server['serv_enabled'] = True + if(os.getenv('SERVER_0_DOWNLINK', "false")=="true"): + server['serv_down_enabled'] = True + else: + server['serv_down_enabled'] = False + gateway_conf['servers'].append(server) # Add up to 3 additional servers if(os.getenv('SERVER_1_ENABLED', "false")=="true"):