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

Commit 57a4665

Browse files
author
Daniel Campora
committed
examples/lorawan-nano-gateway: Improve downlink frequency accuracy.
1 parent 9808886 commit 57a4665

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

examples/lorawan-nano-gateway/abp_node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
s.setblocking(False)
3636

3737
for i in range (200):
38-
s.send(b'PKT #' + bytes([i]))
38+
pkt = b'PKT #' + bytes([i])
39+
print('Sending:', pkt)
40+
s.send(pkt)
3941
time.sleep(4)
4042
rx, port = s.recvfrom(256)
4143
if rx:

examples/lorawan-nano-gateway/abp_node_US915.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
s.setblocking(False)
3535

3636
for i in range (200):
37-
s.send(b'PKT #' + bytes([i]))
37+
pkt = b'PKT #' + bytes([i])
38+
print('Sending:', pkt)
39+
s.send(pkt)
3840
time.sleep(4)
3941
rx, port = s.recvfrom(256)
4042
if rx:

examples/lorawan-nano-gateway/nanogateway.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def start(self):
157157
_thread.start_new_thread(self._udp_thread, ())
158158

159159
# initialize the LoRa radio in LORA mode
160-
self._log('Setting up the LoRa radio at {:.1f} Mhz using {}', self._freq_to_float(self.frequency), self.datarate)
160+
self._log('Setting up the LoRa radio at {} Mhz using {}', self._freq_to_float(self.frequency), self.datarate)
161161
self.lora = LoRa(
162162
mode=LoRa.LORA,
163163
frequency=self.frequency,
@@ -344,7 +344,7 @@ def _send_down_link(self, data, tmst, datarate, frequency):
344344
pass
345345
self.lora_sock.send(data)
346346
self._log(
347-
'Sent downlink packet scheduled on {:.3f}, at {:.1f} Mhz using {}: {}',
347+
'Sent downlink packet scheduled on {:.3f}, at {:.3f} Mhz using {}: {}',
348348
tmst / 1000000,
349349
self._freq_to_float(frequency),
350350
datarate,
@@ -370,15 +370,15 @@ def _udp_thread(self):
370370
ack_error = TX_ERR_NONE
371371
tx_pk = ujson.loads(data[4:])
372372
tmst = tx_pk["txpk"]["tmst"]
373-
t_us = tmst - utime.ticks_us() - 12500
373+
t_us = tmst - utime.ticks_us() - 15000
374374
if t_us < 0:
375375
t_us += 0xFFFFFFFF
376376
if t_us < 20000000:
377377
self.uplink_alarm = Timer.Alarm(
378378
handler=lambda x: self._send_down_link(
379379
ubinascii.a2b_base64(tx_pk["txpk"]["data"]),
380380
tx_pk["txpk"]["tmst"] - 50, tx_pk["txpk"]["datr"],
381-
int(tx_pk["txpk"]["freq"] * 1000000)
381+
int(tx_pk["txpk"]["freq"] * 1000) * 1000
382382
),
383383
us=t_us
384384
)

examples/lorawan-nano-gateway/otaa_node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
time.sleep(5.0)
4545

4646
for i in range (200):
47-
s.send(b'PKT #' + bytes([i]))
47+
pkt = b'PKT #' + bytes([i])
48+
print('Sending:', pkt)
49+
s.send(pkt)
4850
time.sleep(4)
4951
rx, port = s.recvfrom(256)
5052
if rx:

examples/lorawan-nano-gateway/otaa_node_US915.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
time.sleep(5.0)
5252

5353
for i in range (200):
54-
s.send(b'PKT #' + bytes([i]))
54+
pkt = b'PKT #' + bytes([i])
55+
print('Sending:', pkt)
56+
s.send(pkt)
5557
time.sleep(4)
5658
rx, port = s.recvfrom(256)
5759
if rx:

0 commit comments

Comments
 (0)