Files
MeshCore-Solo/src/helpers/radiolib/CustomLR1110Wrapper.h
T

54 lines
2.0 KiB
C++
Raw Normal View History

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) { }
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);
PacketMillis pm = calcMaxPacketMillis(sf, bw, cr, preambleLengthForSF(sf));
((CustomLR1110 *)_radio)->setPreambleMillis(pm.preambleMillis);
((CustomLR1110 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
}
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1110 *)_radio)->getFreqMHz()); }
2026-02-21 15:33:38 +01:00
bool isReceivingPacket() override {
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
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(); }
uint8_t getSpreadingFactor() const override { return ((CustomLR1110 *)_radio)->getSpreadingFactor(); }
2026-06-26 07:44:01 +10:00
bool setRxBoostedGainMode(bool en) override {
return ((CustomLR1110 *)_radio)->setRxBoostedGainMode(en) == RADIOLIB_ERR_NONE;
}
bool getRxBoostedGainMode() const override {
return ((CustomLR1110 *)_radio)->getRxBoostedGainMode();
}
2025-02-14 09:54:06 +01:00
};