CustomLR1110Wrapper.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "CustomLR1110.h"
  3. #include "RadioLibWrappers.h"
  4. #include "LR11x0Reset.h"
  5. class CustomLR1110Wrapper : public RadioLibWrapper {
  6. public:
  7. CustomLR1110Wrapper(CustomLR1110& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
  8. void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
  9. ((CustomLR1110 *)_radio)->setFrequency(freq);
  10. ((CustomLR1110 *)_radio)->setSpreadingFactor(sf);
  11. ((CustomLR1110 *)_radio)->setBandwidth(bw);
  12. ((CustomLR1110 *)_radio)->setCodingRate(cr);
  13. updatePreamble(sf);
  14. }
  15. void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1110 *)_radio)->getFreqMHz()); }
  16. bool isReceivingPacket() override {
  17. return ((CustomLR1110 *)_radio)->isReceiving();
  18. }
  19. float getCurrentRSSI() override {
  20. float rssi = -110;
  21. ((CustomLR1110 *)_radio)->getRssiInst(&rssi);
  22. return rssi;
  23. }
  24. void onSendFinished() override {
  25. RadioLibWrapper::onSendFinished();
  26. _radio->setPreambleLength(preambleLengthForSF(getSpreadingFactor())); // overcomes weird issues with small and big pkts
  27. }
  28. float getLastRSSI() const override { return ((CustomLR1110 *)_radio)->getRSSI(); }
  29. float getLastSNR() const override { return ((CustomLR1110 *)_radio)->getSNR(); }
  30. uint8_t getSpreadingFactor() const override { return ((CustomLR1110 *)_radio)->getSpreadingFactor(); }
  31. void setRxBoostedGainMode(bool en) override {
  32. ((CustomLR1110 *)_radio)->setRxBoostedGainMode(en);
  33. }
  34. bool getRxBoostedGainMode() const override {
  35. return ((CustomLR1110 *)_radio)->getRxBoostedGainMode();
  36. }
  37. };