Skip to content

Commit a2f5432

Browse files
authored
Merge pull request #1018 from Woodie-07/dev
LR1110 IRQ fixes
2 parents 6d6db10 + 0e259a6 commit a2f5432

File tree

1 file changed

+2
-58
lines changed

1 file changed

+2
-58
lines changed

src/helpers/radiolib/CustomLR1110.h

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#include <RadioLib.h>
44
#include "MeshCore.h"
55

6-
#define LR1110_IRQ_HAS_PREAMBLE 0b0000000100 // 4 4 valid LoRa header received
7-
#define LR1110_IRQ_HEADER_VALID 0b0000010000 // 4 4 valid LoRa header received
8-
96
class CustomLR1110 : public LR1110 {
107
public:
118
CustomLR1110(Module *mod) : LR1110(mod) { }
@@ -22,63 +19,10 @@ class CustomLR1110 : public LR1110 {
2219
}
2320
return len;
2421
}
25-
26-
RadioLibTime_t getTimeOnAir(size_t len) override {
27-
// calculate number of symbols
28-
float N_symbol = 0;
29-
if(this->codingRate <= RADIOLIB_LR11X0_LORA_CR_4_8_SHORT) {
30-
// legacy coding rate - nice and simple
31-
// get SF coefficients
32-
float coeff1 = 0;
33-
int16_t coeff2 = 0;
34-
int16_t coeff3 = 0;
35-
if(this->spreadingFactor < 7) {
36-
// SF5, SF6
37-
coeff1 = 6.25;
38-
coeff2 = 4*this->spreadingFactor;
39-
coeff3 = 4*this->spreadingFactor;
40-
} else if(this->spreadingFactor < 11) {
41-
// SF7. SF8, SF9, SF10
42-
coeff1 = 4.25;
43-
coeff2 = 4*this->spreadingFactor + 8;
44-
coeff3 = 4*this->spreadingFactor;
45-
} else {
46-
// SF11, SF12
47-
coeff1 = 4.25;
48-
coeff2 = 4*this->spreadingFactor + 8;
49-
coeff3 = 4*(this->spreadingFactor - 2);
50-
}
51-
52-
// get CRC length
53-
int16_t N_bitCRC = 16;
54-
if(this->crcTypeLoRa == RADIOLIB_LR11X0_LORA_CRC_DISABLED) {
55-
N_bitCRC = 0;
56-
}
57-
58-
// get header length
59-
int16_t N_symbolHeader = 20;
60-
if(this->headerType == RADIOLIB_LR11X0_LORA_HEADER_IMPLICIT) {
61-
N_symbolHeader = 0;
62-
}
63-
64-
// calculate number of LoRa preamble symbols - NO! Lora preamble is already in symbols
65-
// uint32_t N_symbolPreamble = (this->preambleLengthLoRa & 0x0F) * (uint32_t(1) << ((this->preambleLengthLoRa & 0xF0) >> 4));
66-
67-
// calculate the number of symbols - nope
68-
// 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);
69-
// calculate the number of symbols - using only preamblelora because it's already in symbols
70-
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);
71-
} else {
72-
// long interleaving - not needed for this modem
73-
}
74-
75-
// get time-on-air in us
76-
return(((uint32_t(1) << this->spreadingFactor) / this->bandwidthKhz) * N_symbol * 1000.0f);
77-
}
78-
22+
7923
bool isReceiving() {
8024
uint16_t irq = getIrqStatus();
81-
bool detected = ((irq & LR1110_IRQ_HEADER_VALID) || (irq & LR1110_IRQ_HAS_PREAMBLE));
25+
bool detected = ((irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID) || (irq & RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED));
8226
return detected;
8327
}
8428
};

0 commit comments

Comments
 (0)