mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
LR1110 has codingRate as protected field in LR_common.h, so getCodingRate() is implemented in CustomLR1110 class directly, and exposed via CustomLR1110Wrapper override. This enables dynamic MAX_TEXT_LEN calculation for T1000-E under JP_STRICT mode.
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <RadioLib.h>
|
|
#include "MeshCore.h"
|
|
|
|
class CustomLR1110 : public LR1110 {
|
|
bool _rx_boosted = false;
|
|
|
|
public:
|
|
CustomLR1110(Module *mod) : LR1110(mod) { }
|
|
|
|
size_t getPacketLength(bool update) override {
|
|
size_t len = LR1110::getPacketLength(update);
|
|
if (len == 0 && getIrqStatus() & RADIOLIB_LR11X0_IRQ_HEADER_ERR) {
|
|
// we've just received a corrupted packet
|
|
// this may have triggered a bug causing subsequent packets to be shifted
|
|
// call standby() to return radio to known-good state
|
|
// recvRaw will call startReceive() to restart rx
|
|
MESH_DEBUG_PRINTLN("LR1110: got header err, calling standby()");
|
|
standby();
|
|
}
|
|
return len;
|
|
}
|
|
|
|
float getFreqMHz() const { return freqMHz; }
|
|
|
|
int16_t setRxBoostedGainMode(bool en) {
|
|
_rx_boosted = en;
|
|
return LR1110::setRxBoostedGainMode(en);
|
|
}
|
|
|
|
bool getRxBoostedGainMode() const { return _rx_boosted; }
|
|
|
|
bool isReceiving() {
|
|
uint16_t irq = getIrqStatus();
|
|
bool detected = ((irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID) || (irq & RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED));
|
|
return detected;
|
|
}
|
|
|
|
uint8_t getCodingRate() const {
|
|
return this->codingRate + 4; // RadioLib stores 1-4, return 5-8
|
|
}
|
|
};
|