]> git.tnoah.ca Git - lora-radio.git/commitdiff
Updated SNR indication method
authorMark Qvist <mark@adepta.io>
Thu, 21 May 2020 10:41:39 +0000 (12:41 +0200)
committerMark Qvist <mark@adepta.io>
Thu, 21 May 2020 10:41:39 +0000 (12:41 +0200)
Config.h
LoRa.cpp
LoRa.h
RNode_Firmware.ino
Utilities.h

index 13b0b91198df4c900e56a9710874b745c96bd3ea..3d76536c50cf655bf7dc4fc728aeb187e0a3e2b1 100644 (file)
--- a/Config.h
+++ b/Config.h
@@ -4,7 +4,7 @@
        #define CONFIG_H
 
        #define MAJ_VERS  0x01
-       #define MIN_VERS  0x0C
+       #define MIN_VERS  0x0D
 
        #define MCU_328P  0x90
        #define MCU_1284P 0x91
@@ -88,7 +88,7 @@
        
        int             last_rssi               = -292;
        uint8_t last_rssi_raw   = 0x00;
-       int8_t  last_snr                = 0;
+       uint8_t last_snr_raw    = 0x00;
        size_t  read_len                = 0;
        uint8_t seq                             = 0xFF;
        uint8_t pbuf[MTU];
index 37d63f819f5123e590c8e5a09b2727ab950408a5..8243ecb502db1d4055cdd5891cc4fc87eb866b8b 100644 (file)
--- a/LoRa.cpp
+++ b/LoRa.cpp
@@ -235,8 +235,11 @@ int LoRaClass::packetRssi() {
   return pkt_rssi;
 }
 
-float LoRaClass::packetSnr()
-{
+uint8_t LoRaClass::packetSnrRaw() {
+  return readRegister(REG_PKT_SNR_VALUE);
+}
+
+float LoRaClass::packetSnr() {
   return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25;
 }
 
diff --git a/LoRa.h b/LoRa.h
index 4027bdfe62b59123e2610538d16f8b619425530f..09bdc54672616c3844228b44377db9d0b6ec1af4 100644 (file)
--- a/LoRa.h
+++ b/LoRa.h
@@ -1,5 +1,8 @@
 // Copyright (c) Sandeep Mistry. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+// Licensed under the MIT license.
+
+// Modifications and additions copyright 2018 by Mark Qvist
+// Obviously still under the MIT license.
 
 #ifndef LORA_H
 #define LORA_H
@@ -29,6 +32,7 @@ public:
   int parsePacket(int size = 0);
   int packetRssi();
   uint8_t packetRssiRaw();
+  uint8_t packetSnrRaw();
   float packetSnr();
   long packetFrequencyError();
 
index f1d52802d41a97485ac9c5025a3a6ea0dac831a4..b961f11bf4a20357ac0874d3c19ae2fd2d636c49 100644 (file)
@@ -104,14 +104,14 @@ void receiveCallback(int packet_size) {
       read_len = 0;
       seq = sequence;
       last_rssi = LoRa.packetRssi();
-      last_snr = LoRa.packetSnr();
+      last_snr_raw = LoRa.packetSnrRaw();
       getPacketData(packet_size);
     } else if (isSplitPacket(header) && seq == sequence) {
       // This is the second part of a split
       // packet, so we add it to the buffer
       // and set the ready flag.
       last_rssi = (last_rssi+LoRa.packetRssi())/2;
-      last_snr = (last_snr+LoRa.packetSnr())/2;
+      last_snr_raw = (last_snr_raw+LoRa.packetSnrRaw())/2;
       getPacketData(packet_size);
       seq = SEQ_UNSET;
       ready = true;
@@ -123,7 +123,7 @@ void receiveCallback(int packet_size) {
       read_len = 0;
       seq = sequence;
       last_rssi = LoRa.packetRssi();
-      last_snr = LoRa.packetSnr();
+      last_snr_raw = LoRa.packetSnrRaw();
       getPacketData(packet_size);
     } else if (!isSplitPacket(header)) {
       // This is not a split packet, so we
@@ -138,7 +138,7 @@ void receiveCallback(int packet_size) {
       }
 
       last_rssi = LoRa.packetRssi();
-      last_snr = LoRa.packetSnr();
+      last_snr_raw = LoRa.packetSnrRaw();
       getPacketData(packet_size);
       ready = true;
     }
@@ -166,6 +166,7 @@ void receiveCallback(int packet_size) {
     // output directly over to the host
     read_len = 0;
     last_rssi = LoRa.packetRssi();
+    last_snr_raw = LoRa.packetSnrRaw();
     getPacketData(packet_size);
 
     // We first signal the RSSI of the
index 26c22556325990e0340f02165ee63ce8b7a0683f..2753fad804944bd20f8e2c7a02ca89a71c410815 100644 (file)
@@ -138,10 +138,9 @@ void kiss_indicate_stat_rssi() {
 }
 
 void kiss_indicate_stat_snr() {
-       uint8_t packet_snr_val = (uint8_t)(last_snr+snr_offset);
        Serial.write(FEND);
        Serial.write(CMD_STAT_SNR);
-       escapedSerialWrite(packet_snr_val);
+       escapedSerialWrite(last_snr_raw);
        Serial.write(FEND);
 }