Skip to content

Commit 58c3e31

Browse files
committed
lora: Fix SNR value in SX126x received packets.
Wasn't being treated as a signed value. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 5b496e9 commit 58c3e31

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

micropython/lora/lora-sx126x/lora/sx126x.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,9 @@ def _read_packet(self, rx_packet, flags):
596596
pkt_status = self._cmd("B", _CMD_GET_PACKET_STATUS, n_read=4)
597597

598598
rx_packet.ticks_ms = ticks_ms
599-
rx_packet.snr = pkt_status[2] # SNR, units: dB *4
600-
rx_packet.rssi = 0 - pkt_status[1] // 2 # RSSI, units: dBm
599+
# SNR units are dB * 4 (signed)
600+
rx_packet.rssi, rx_packet.snr = struct.unpack("xBbx", pkt_status)
601+
rx_packet.rssi //= -2 # RSSI, units: dBm
601602
rx_packet.crc_error = (flags & _IRQ_CRC_ERR) != 0
602603

603604
return rx_packet

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy