1

Revision:
9:97a6de3dbc86
Parent:
8:0518c6e68b79
Child:
12:fcfafd17ae1b
Child:
14:94993ae5b164
--- a/radio_sx128x.cpp	Thu Dec 06 17:57:21 2018 -0800
+++ b/radio_sx128x.cpp	Fri Dec 07 17:13:39 2018 -0800
@@ -57,6 +57,10 @@
 const RadioEvents_t* RadioEvents;
 volatile us_timestamp_t Radio::irqAt;
 
+unsigned Radio::symbolPeriodUs;
+unsigned Radio::nSymbs;
+unsigned Radio::rxTimeoutMs;
+
 void Radio::readChip()
 {
     uint8_t reg8;
@@ -312,6 +316,7 @@
     fe_enable = true;
 
     radio.periodBase = 2;   // 1ms resolution
+    nSymbs = 8;
 }
 
 float Radio::GetRssiInst()
@@ -532,7 +537,8 @@
 
 void Radio::SetLoRaSymbolTimeout(uint8_t symbs)
 {
-    //symbolTimeout = symbs;
+    nSymbs = symbs;
+    rxTimeoutMs = nSymbs * (symbolPeriodUs / 1000.0);
 }
 
 void Radio::LoRaModemConfig(unsigned bwKHz, uint8_t sf, uint8_t cr)
@@ -555,6 +561,9 @@
     mpLORA.lora.spreadingFactor = sf << 4;
 
     radio.xfer(OPCODE_SET_MODULATION_PARAMS, 3, 0, mpLORA.buf);
+
+    symbolPeriodUs = (1 << sf) / (bwKHz / 1000.0);   // bw in MHz gives microseconds
+    rxTimeoutMs = nSymbs * (symbolPeriodUs / 1000.0);
 }
 
 void Radio::LoRaPacketConfig(unsigned preambleLen, bool fixLen, bool crcOn, bool invIQ)
@@ -603,7 +612,11 @@
 #ifdef RX_INDICATION
     RX_INDICATION = 1;
 #endif
-    radio.start_rx(timeout / 1000);
+    if (timeout == 0)
+        radio.start_rx(0);  // continuous rx
+    else {
+        radio.start_rx(rxTimeoutMs);
+    }
 }
 
 void Radio::Standby()