@@ -9,6 +9,59 @@ class CustomLR1110 : public LR1110 {
99 public:
1010 CustomLR1110 (Module *mod) : LR1110(mod) { }
1111
12+ RadioLibTime_t getTimeOnAir (size_t len) override {
13+ // calculate number of symbols
14+ float N_symbol = 0 ;
15+ if (this ->codingRate <= RADIOLIB_LR11X0_LORA_CR_4_8_SHORT) {
16+ // legacy coding rate - nice and simple
17+ // get SF coefficients
18+ float coeff1 = 0 ;
19+ int16_t coeff2 = 0 ;
20+ int16_t coeff3 = 0 ;
21+ if (this ->spreadingFactor < 7 ) {
22+ // SF5, SF6
23+ coeff1 = 6.25 ;
24+ coeff2 = 4 *this ->spreadingFactor ;
25+ coeff3 = 4 *this ->spreadingFactor ;
26+ } else if (this ->spreadingFactor < 11 ) {
27+ // SF7. SF8, SF9, SF10
28+ coeff1 = 4.25 ;
29+ coeff2 = 4 *this ->spreadingFactor + 8 ;
30+ coeff3 = 4 *this ->spreadingFactor ;
31+ } else {
32+ // SF11, SF12
33+ coeff1 = 4.25 ;
34+ coeff2 = 4 *this ->spreadingFactor + 8 ;
35+ coeff3 = 4 *(this ->spreadingFactor - 2 );
36+ }
37+
38+ // get CRC length
39+ int16_t N_bitCRC = 16 ;
40+ if (this ->crcTypeLoRa == RADIOLIB_LR11X0_LORA_CRC_DISABLED) {
41+ N_bitCRC = 0 ;
42+ }
43+
44+ // get header length
45+ int16_t N_symbolHeader = 20 ;
46+ if (this ->headerType == RADIOLIB_LR11X0_LORA_HEADER_IMPLICIT) {
47+ N_symbolHeader = 0 ;
48+ }
49+
50+ // calculate number of LoRa preamble symbols - NO! Lora preamble is already in symbols
51+ // uint32_t N_symbolPreamble = (this->preambleLengthLoRa & 0x0F) * (uint32_t(1) << ((this->preambleLengthLoRa & 0xF0) >> 4));
52+
53+ // calculate the number of symbols - nope
54+ // N_symbol = (float)N_symbolPreamble + coeff1 + 8.0f + ceilf((float)RADIOLIB_MAX((int16_t)(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t)0) / (float)coeff3) * (float)(this->codingRate + 4);
55+ // calculate the number of symbols - using only preamblelora because it's already in symbols
56+ N_symbol = (float )preambleLengthLoRa + coeff1 + 8 .0f + ceilf ((float )RADIOLIB_MAX ((int16_t )(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t )0 ) / (float )coeff3) * (float )(this ->codingRate + 4 );
57+ } else {
58+ // long interleaving - not needed for this modem
59+ }
60+
61+ // get time-on-air in us
62+ return (((uint32_t (1 ) << this ->spreadingFactor ) / this ->bandwidthKhz ) * N_symbol * 1000 .0f );
63+ }
64+
1265 bool isReceiving () {
1366 uint16_t irq = getIrqStatus ();
1467 bool detected = ((irq & LR1110_IRQ_HEADER_VALID) || (irq & LR1110_IRQ_HAS_PREAMBLE));
0 commit comments