Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Add region to config in order for nano gateway to start up #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/lorawan-nano-gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/lorawan-nano-gateway/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 10 additions & 5 deletions examples/lorawan-nano-gateway/nanogateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down