From 48734bca632350cd8a55af68a7eae49f8d982e5a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Thu, 13 Sep 2018 21:50:45 +0200 Subject: [PATCH] lmic/radio.c: Fix RSSI and SNR calculation --- lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c b/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c index 780226c2..0fffaa4f 100644 --- a/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c +++ b/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c @@ -790,8 +790,12 @@ void radio_irq_handler (u1_t dio) { // now read the FIFO readBuf(RegFifo, LMIC.frame, LMIC.dataLen); // read rx quality parameters - LMIC.snr = readReg(LORARegPktSnrValue); // SNR [dB] * 4 - LMIC.rssi = readReg(LORARegPktRssiValue) - 125 + 64; // RSSI [dBm] (-196...+63) + //LMIC.snr = readReg(LORARegPktSnrValue); // SNR [dB] * 4 + LMIC.snr = readReg(LORARegPktSnrValue) / 4; + //LMIC.rssi = readReg(LORARegPktRssiValue) - 125 + 64; // RSSI [dBm] (-196...+63) + LMIC.rssi = readReg(LORARegPktRssiValue) - 157; // RFI_HF for 868 and 915MHZ band + if (LMIC.snr < 0) + LMIC.rssi += LMIC.snr; } else if( flags & IRQ_LORA_RXTOUT_MASK ) { // indicate timeout LMIC.dataLen = 0;