2025-02-14 09:54:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CustomLR1110.h"
|
|
|
|
|
#include "RadioLibWrappers.h"
|
2026-02-21 15:33:38 +01:00
|
|
|
#include "LR11x0Reset.h"
|
2025-02-14 09:54:06 +01:00
|
|
|
|
|
|
|
|
class CustomLR1110Wrapper : public RadioLibWrapper {
|
|
|
|
|
public:
|
|
|
|
|
CustomLR1110Wrapper(CustomLR1110& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
2026-05-01 14:47:07 +10:00
|
|
|
|
|
|
|
|
void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
|
|
|
|
|
((CustomLR1110 *)_radio)->setFrequency(freq);
|
|
|
|
|
((CustomLR1110 *)_radio)->setSpreadingFactor(sf);
|
|
|
|
|
((CustomLR1110 *)_radio)->setBandwidth(bw);
|
|
|
|
|
((CustomLR1110 *)_radio)->setCodingRate(cr);
|
|
|
|
|
updatePreamble(sf);
|
2026-07-20 19:42:22 +10:00
|
|
|
PacketMillis pm = calcMaxPacketMillis(sf, bw, cr, preambleLengthForSF(sf));
|
|
|
|
|
((CustomLR1110 *)_radio)->setPreambleMillis(pm.preambleMillis);
|
|
|
|
|
((CustomLR1110 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
|
2026-05-01 14:47:07 +10:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 17:34:28 +01:00
|
|
|
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1110 *)_radio)->getFreqMHz()); }
|
2026-02-21 15:33:38 +01:00
|
|
|
bool isReceivingPacket() override {
|
2025-05-24 20:42:00 +10:00
|
|
|
return ((CustomLR1110 *)_radio)->isReceiving();
|
2025-02-14 09:54:06 +01:00
|
|
|
}
|
2025-05-24 21:24:44 +10:00
|
|
|
float getCurrentRSSI() override {
|
|
|
|
|
float rssi = -110;
|
|
|
|
|
((CustomLR1110 *)_radio)->getRssiInst(&rssi);
|
|
|
|
|
return rssi;
|
|
|
|
|
}
|
2025-02-14 09:54:06 +01:00
|
|
|
|
2026-06-27 21:06:01 +10:00
|
|
|
uint32_t getEstAirtimeFor(int len_bytes) override {
|
|
|
|
|
auto airtime = RadioLibWrapper::getEstAirtimeFor(len_bytes);
|
|
|
|
|
return airtime < 200 ? 200 : airtime; // at least 200 millis
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-14 09:54:06 +01:00
|
|
|
void onSendFinished() override {
|
|
|
|
|
RadioLibWrapper::onSendFinished();
|
2026-03-08 05:37:49 +11:00
|
|
|
_radio->setPreambleLength(preambleLengthForSF(getSpreadingFactor())); // overcomes weird issues with small and big pkts
|
2025-02-14 09:54:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float getLastRSSI() const override { return ((CustomLR1110 *)_radio)->getRSSI(); }
|
|
|
|
|
float getLastSNR() const override { return ((CustomLR1110 *)_radio)->getSNR(); }
|
2026-03-05 18:31:00 +00:00
|
|
|
|
2026-03-05 22:14:22 +11:00
|
|
|
uint8_t getSpreadingFactor() const override { return ((CustomLR1110 *)_radio)->getSpreadingFactor(); }
|
2026-04-16 20:43:46 +10:00
|
|
|
|
2026-06-26 07:44:01 +10:00
|
|
|
bool setRxBoostedGainMode(bool en) override {
|
|
|
|
|
return ((CustomLR1110 *)_radio)->setRxBoostedGainMode(en) == RADIOLIB_ERR_NONE;
|
2026-03-05 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
bool getRxBoostedGainMode() const override {
|
|
|
|
|
return ((CustomLR1110 *)_radio)->getRxBoostedGainMode();
|
|
|
|
|
}
|
2025-02-14 09:54:06 +01:00
|
|
|
};
|