From 20144c87f86459f2177657ca21b9bbbfb5c90118 Mon Sep 17 00:00:00 2001 From: jpmeijers Date: Thu, 6 Apr 2017 18:47:50 +0200 Subject: [PATCH] TTN API changed to include protocol in url. Only pass hostname to mp_kt_fwd. --- run.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index fd12b2c..040831a 100755 --- a/run.py +++ b/run.py @@ -12,6 +12,10 @@ import time import uuid import json import subprocess +try: + import urlparse +except: + import urllib.parse as urlparse try: import RPi.GPIO as GPIO except RuntimeError: @@ -104,8 +108,9 @@ if(os.getenv('SERVER_TTN', True)): frequency_plan_url = ttn_config.get('frequency_plan_url', "https://account.thethingsnetwork.org/api/v2/frequency-plans/EU_863_870") if "router" in ttn_config: - router = ttn_config['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 + router = ttn_config['router'].get('mqtt_address', "mqtt://router.dev.thethings.network:1883") + router = urlparse.urlparse(router) + router = router.hostname # mp_pkt_fwd only wants the hostname, not the protocol and port else: router = "router.dev.thethings.network"