Skip to content

Commit f8c8875

Browse files
projectgusdpgeorge
authored andcommitted
lora: Fix SNR value in SX126x received packets.
Wasn't being treated as a signed value. Fixes issue #999. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 5b496e9 commit f8c8875

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
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
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.4")
1+
metadata(version="0.1.5")
22
require("lora")
33
package("lora")

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