]> git.tnoah.ca Git - lora-radio.git/commitdiff
Fix RSSI miscalculation and TX power not being set correctly
authorjacob.eva <x00010@disroot.org>
Mon, 29 Jan 2024 20:36:14 +0000 (20:36 +0000)
committerjacob.eva <x00010@disroot.org>
Mon, 29 Jan 2024 20:36:14 +0000 (20:36 +0000)
LoRa.cpp
RNode_Firmware.ino
Utilities.h

index efe7bc4d4fbe552abfc2e8b0057463b239339d43..7501187af2efcf110278362047a3f91b5169ed41 100644 (file)
--- a/LoRa.cpp
+++ b/LoRa.cpp
@@ -775,7 +775,7 @@ int ISR_VECT LoRaClass::packetRssi() {
     // may need more calculations here
     uint8_t buf[3] = {0};
     executeOpcodeRead(OP_PACKET_STATUS, buf, 3);
-    int pkt_rssi = -(int(buf[2])) / 2;
+    int pkt_rssi = -buf[0] / 2;
     return pkt_rssi;
   #endif
 }
@@ -796,7 +796,7 @@ float ISR_VECT LoRaClass::packetSnr() {
   #elif MODEM == SX1262
     uint8_t buf[3] = {0};
     executeOpcodeRead(OP_PACKET_STATUS, buf, 3);
-    return float(buf[1]) / 4.0;
+    return float(buf[1]) * 0.25;
   #endif
 }
 
index 05acd1ac7ffb4a3f37edf947ec21e567bc69c5f6..54e06e2d7c4480f787be25b3abb0968e97972e54 100644 (file)
@@ -620,7 +620,7 @@ void serialCallback(uint8_t sbyte) {
         kiss_indicate_txpower();
       } else {
         int txp = sbyte;
-        if (txp > 17) txp = 17;
+        if (txp > 22) txp = 22;
 
         lora_txp = txp;
         if (op_mode == MODE_HOST) setTXPower();
index fe61b7c9c5118d86f5c449bac7b6e976712c3cf0..c162443d5b2119e7af518b53f71191ccd42d742c 100644 (file)
@@ -658,7 +658,7 @@ void kiss_indicate_stat_rssi() {
     #if MODEM == SX1276 || MODEM == SX1278
         uint8_t packet_rssi_val = (uint8_t)(last_rssi+rssi_offset);
     #elif MODEM == SX1262
-        uint8_t packet_rssi_val = (uint8_t)(last_rssi);
+        int8_t packet_rssi_val = (int8_t)(last_rssi+rssi_offset);
     #endif
        serial_write(FEND);
        serial_write(CMD_STAT_RSSI);