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..e10236c 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, + region=config.LORA_REGION ) nanogw.start() diff --git a/examples/lorawan-nano-gateway/nanogateway.py b/examples/lorawan-nano-gateway/nanogateway.py index 1810cd5..f8b2247 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 @@ -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): """ @@ -175,7 +176,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 +270,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 +362,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 +385,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)