Ilya Krylov / SX127x1

Files at this revision

API Documentation at this revision

Comitter:
dudmuck
Date:
Tue Oct 20 21:59:06 2015 +0000
Parent:
22:7e165c16c13c
Child:
24:cad6e7ce6928
Commit message:
added lora function to read background signal strength

Changed in this revision

sx127x_lora.cpp Show annotated file Show diff for this revision Revisions of this file
sx127x_lora.h Show annotated file Show diff for this revision Revisions of this file
--- a/sx127x_lora.cpp	Thu Oct 15 00:20:08 2015 +0000
+++ b/sx127x_lora.cpp	Tue Oct 20 21:59:06 2015 +0000
@@ -447,15 +447,29 @@
     m_xcvr.write_reg(REG_LR_FIFOADDRPTR, m_xcvr.read_reg(REG_LR_FIFORXBASEADDR));
 }
 
-float SX127x_lora::get_pkt_rssi()
+int SX127x_lora::get_pkt_rssi()
 {
-    /* TODO: calculating with pktSNR to give meaningful result below noise floor */
-    if (m_xcvr.type == SX1276)
-        return RegPktRssiValue - 137;
-    else
+    if (m_xcvr.type == SX1276) {
+        if (m_xcvr.HF)
+            return RegPktRssiValue - 157;
+        else
+            return RegPktRssiValue - 164;
+    } else
         return RegPktRssiValue - 125;
 }
 
+int SX127x_lora::get_current_rssi()
+{
+    uint8_t v = m_xcvr.read_reg(REG_LR_RSSIVALUE);
+    if (m_xcvr.type == SX1276) {
+        if (m_xcvr.HF)
+            return v - 157;
+        else
+            return v - 164;
+    } else
+        return v - 125;    
+}
+
 service_action_e SX127x_lora::service()
 {
     if (m_xcvr.RegOpMode.bits.Mode == RF_OPMODE_RECEIVER) {
--- a/sx127x_lora.h	Thu Oct 15 00:20:08 2015 +0000
+++ b/sx127x_lora.h	Tue Oct 20 21:59:06 2015 +0000
@@ -246,7 +246,8 @@
         bool getAgcAutoOn(void);
         void setAgcAutoOn(bool);
         
-        float get_pkt_rssi(void);
+        int get_pkt_rssi(void);
+        int get_current_rssi(void);
         
         /** retrieve symbol duration from bandwidth and spreading factor
          * @returns symbol duration in milliseconds