Merge remote-tracking branch 'upstream/dev' into feat/kiss-agc-fem-control
This commit is contained in:
commit
c0ccb9c7ff
123 files changed
+2095
-396
No files matched your search
@@ -20,6 +20,11 @@ public:
|
||||
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomLLCC68 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLLCC68 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ public:
|
||||
((CustomLR1110 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomLR1110 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLR1110 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class CustomLR1121 : public LR1121 {
|
||||
uint32_t _activityAt = 0;
|
||||
bool _headerSeen = false;
|
||||
bool _rx_boosted = false;
|
||||
int8_t _txPower = 0;
|
||||
bool _txPowerSet = false;
|
||||
|
||||
public:
|
||||
CustomLR1121(Module *mod) : LR1121(mod) { }
|
||||
@@ -36,6 +38,33 @@ class CustomLR1121 : public LR1121 {
|
||||
return len;
|
||||
}
|
||||
|
||||
using LR1121::setOutputPower;
|
||||
using LR1121::setFrequency;
|
||||
|
||||
int16_t setOutputPower(int8_t power) override {
|
||||
#ifdef LR1121_FORCE_HP_PA
|
||||
const bool force_hp = true; // boards with only RFO_HP_LF wired: never select the LP PA
|
||||
#else
|
||||
const bool force_hp = false;
|
||||
#endif
|
||||
// clip to the active PA's range (HF PA tops out at 13 dBm) rather than fail and keep the other band's PA
|
||||
int8_t clipped = power;
|
||||
checkOutputPower(power, &clipped, force_hp);
|
||||
int16_t state = LR1121::setOutputPower(clipped, force_hp);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
_txPower = power;
|
||||
_txPowerSet = true;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
int16_t setFrequency(float freq) override {
|
||||
int16_t state = LR1121::setFrequency(freq);
|
||||
// PA selection depends on the band, and set radio / tempradio don't call setTxPower
|
||||
if (state == RADIOLIB_ERR_NONE && _txPowerSet) state = setOutputPower(_txPower);
|
||||
return state;
|
||||
}
|
||||
|
||||
float getFreqMHz() const { return freqMHz; }
|
||||
|
||||
int16_t setRxBoostedGainMode(bool en) {
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
}
|
||||
|
||||
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1121 *)_radio)->getFreqMHz(), getRxBoostedGainMode()); }
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomLR1121 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLR1121 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -16,15 +16,23 @@ public:
|
||||
CustomLR2021Wrapper(CustomLR2021& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
|
||||
void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
|
||||
((CustomLR2021 *)_radio)->setFrequency(freq);
|
||||
((CustomLR2021 *)_radio)->setSpreadingFactor(sf);
|
||||
((CustomLR2021 *)_radio)->setBandwidth(bw);
|
||||
((CustomLR2021 *)_radio)->setCodingRate(cr);
|
||||
auto r = (CustomLR2021 *)_radio;
|
||||
// LR2021 only accepts RF/modulation config commands while in STANDBY mode.
|
||||
// Re-configuring while in continuous RX gets silently rejected (-706),
|
||||
// which broke hot frequency changes over BLE.
|
||||
int16_t status = r->standby();
|
||||
if (status != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: standby() -> %d", status); }
|
||||
if ((status = r->setFrequency(freq)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setFrequency() -> %d", status); }
|
||||
if ((status = r->setSpreadingFactor(sf)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setSpreadingFactor() -> %d", status); }
|
||||
if ((status = r->setBandwidth(bw)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setBandwidth() -> %d", status); }
|
||||
if ((status = r->setCodingRate(cr)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setCodingRate() -> %d", status); }
|
||||
updatePreamble(sf);
|
||||
applySideDetectorConfig();
|
||||
// internal idle() sets STATE_IDLE, which triggers a startReceive() on the next loop
|
||||
status = applySideDetectorConfig();
|
||||
if (status != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: applySideDetectorConfig() -> %d", status); }
|
||||
PacketMillis pm = calcMaxPacketMillis(sf, bw, cr, preambleLengthForSF(sf));
|
||||
((CustomLR2021 *)_radio)->setPreambleMillis(pm.preambleMillis);
|
||||
((CustomLR2021 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
||||
r->setPreambleMillis(pm.preambleMillis); // pure in-memory setters, no standby needed
|
||||
r->setMaxPayloadMillis(pm.payloadMillis);
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +81,11 @@ public:
|
||||
return tSym;
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomLR2021 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLR2021 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
((CustomSTM32WLx *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomSTM32WLx *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSTM32WLx *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ public:
|
||||
((CustomSX1262 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomSX1262 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSX1262 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ public:
|
||||
((CustomSX1268 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
||||
}
|
||||
|
||||
bool lastRxHadCRC() override {
|
||||
bool crc = true;
|
||||
((CustomSX1268 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc);
|
||||
return crc;
|
||||
}
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSX1268 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -132,6 +132,9 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||
if (len > 0) {
|
||||
if (len > sz) { len = sz; }
|
||||
int err = _radio->readData(bytes, len);
|
||||
if (err == RADIOLIB_ERR_NONE && !lastRxHadCRC()) {
|
||||
err = RADIOLIB_ERR_LORA_HEADER_DAMAGED; // header says no CRC, so the payload was never checked
|
||||
}
|
||||
if (err != RADIOLIB_ERR_NONE) {
|
||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err);
|
||||
len = 0;
|
||||
|
||||
@@ -26,10 +26,14 @@ protected:
|
||||
void startRecv();
|
||||
float packetScoreInt(float snr, int sf, int packet_len);
|
||||
virtual bool isReceivingPacket() =0;
|
||||
virtual bool lastRxHadCRC() { return true; }
|
||||
virtual void doResetAGC();
|
||||
|
||||
public:
|
||||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board), _preamble_sf(0) { n_recv = n_sent = 0; }
|
||||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board)
|
||||
: _radio(&radio), _board(&board), _preamble_sf(0) {
|
||||
n_recv = n_sent = n_recv_errors = 0;
|
||||
}
|
||||
|
||||
void begin() override;
|
||||
virtual void powerOff() { _radio->sleep(); }
|
||||
|
||||
Reference in new issue
Block a user