From d5ce09332ece86c4e87f2f9c6abed6cc0206d357 Mon Sep 17 00:00:00 2001 From: Michael van Niekerk Date: Sat, 7 Aug 2021 17:19:46 +0200 Subject: [PATCH 1/3] Add region to config in order for nano gateway to start up --- examples/lorawan-nano-gateway/config.py | 2 ++ examples/lorawan-nano-gateway/main.py | 3 ++- examples/lorawan-nano-gateway/nanogateway.py | 14 +++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/lorawan-nano-gateway/config.py b/examples/lorawan-nano-gateway/config.py index 552df79..dc1f568 100644 --- a/examples/lorawan-nano-gateway/config.py +++ b/examples/lorawan-nano-gateway/config.py @@ -12,6 +12,7 @@ import machine import ubinascii +from network import LoRa WIFI_MAC = ubinascii.hexlify(machine.unique_id()).upper() # Set the Gateway ID to be the first 3 bytes of MAC address + 'FFFE' + last 3 bytes of MAC address @@ -27,6 +28,7 @@ WIFI_PASS = 'my-wifi-password' # for EU868 +LORA_REGION = LoRa.EU868 LORA_FREQUENCY = 868100000 LORA_GW_DR = "SF7BW125" # DR_5 LORA_NODE_DR = 5 diff --git a/examples/lorawan-nano-gateway/main.py b/examples/lorawan-nano-gateway/main.py index c17920e..8fb2baf 100644 --- a/examples/lorawan-nano-gateway/main.py +++ b/examples/lorawan-nano-gateway/main.py @@ -23,7 +23,8 @@ server=config.SERVER, port=config.PORT, ntp_server=config.NTP, - ntp_period=config.NTP_PERIOD_S + ntp_period=config.NTP_PERIOD_S, + regoin=config.LORA_REGION ) nanogw.start() diff --git a/examples/lorawan-nano-gateway/nanogateway.py b/examples/lorawan-nano-gateway/nanogateway.py index 1810cd5..08941ec 100644 --- a/examples/lorawan-nano-gateway/nanogateway.py +++ b/examples/lorawan-nano-gateway/nanogateway.py @@ -91,7 +91,7 @@ class NanoGateway: connecting to the Internet. """ - def __init__(self, id, frequency, datarate, ssid, password, server, port, ntp_server='pool.ntp.org', ntp_period=3600): + def __init__(self, id, frequency, datarate, ssid, password, server, port, ntp_server='pool.ntp.org', ntp_period=3600, region=LoRa.EU868): self.id = id self.server = server self.port = port @@ -175,7 +175,8 @@ def start(self): sf=self.sf, preamble=8, coding_rate=LoRa.CODING_4_5, - tx_iq=True + tx_iq=True, + region=self.region ) # create a raw LoRa socket @@ -268,7 +269,8 @@ def _lora_cb(self, lora): sf=self.sf, preamble=8, coding_rate=LoRa.CODING_4_5, - tx_iq=True + tx_iq=True, + region=self.region ) def _freq_to_float(self, frequency): @@ -359,7 +361,8 @@ def _send_down_link(self, data, tmst, datarate, frequency): sf=self._dr_to_sf(datarate), preamble=8, coding_rate=LoRa.CODING_4_5, - tx_iq=True + tx_iq=True, + region=self.region ) #while utime.ticks_cpu() < tmst: # pass @@ -381,7 +384,8 @@ def _send_down_link_class_c(self, data, datarate, frequency): preamble=8, coding_rate=LoRa.CODING_4_5, tx_iq=True, - device_class=LoRa.CLASS_C + device_class=LoRa.CLASS_C, + region=self.region ) self.lora_sock.send(data) From 16ec68d5ad861fed611bbc5892d2d0a4b3f41126 Mon Sep 17 00:00:00 2001 From: Michael van Niekerk Date: Sun, 8 Aug 2021 20:20:08 +0200 Subject: [PATCH 2/3] Update main.py --- examples/lorawan-nano-gateway/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lorawan-nano-gateway/main.py b/examples/lorawan-nano-gateway/main.py index 8fb2baf..e10236c 100644 --- a/examples/lorawan-nano-gateway/main.py +++ b/examples/lorawan-nano-gateway/main.py @@ -24,7 +24,7 @@ port=config.PORT, ntp_server=config.NTP, ntp_period=config.NTP_PERIOD_S, - regoin=config.LORA_REGION + region=config.LORA_REGION ) nanogw.start() From 45cb52ae857c2c52710b6bbe450f3151cb4d4175 Mon Sep 17 00:00:00 2001 From: Michael van Niekerk Date: Sun, 8 Aug 2021 20:21:48 +0200 Subject: [PATCH 3/3] Update nanogateway.py --- examples/lorawan-nano-gateway/nanogateway.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/lorawan-nano-gateway/nanogateway.py b/examples/lorawan-nano-gateway/nanogateway.py index 08941ec..f8b2247 100644 --- a/examples/lorawan-nano-gateway/nanogateway.py +++ b/examples/lorawan-nano-gateway/nanogateway.py @@ -129,6 +129,7 @@ def __init__(self, id, frequency, datarate, ssid, password, server, port, ntp_se self.lora_sock = None self.rtc = machine.RTC() + self.region = region def start(self): """