CustomLR1110.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <RadioLib.h>
  3. #include "MeshCore.h"
  4. class CustomLR1110 : public LR1110 {
  5. bool _rx_boosted = false;
  6. public:
  7. CustomLR1110(Module *mod) : LR1110(mod) { }
  8. size_t getPacketLength(bool update) override {
  9. size_t len = LR1110::getPacketLength(update);
  10. if (len == 0 && getIrqStatus() & RADIOLIB_LR11X0_IRQ_HEADER_ERR) {
  11. // we've just received a corrupted packet
  12. // this may have triggered a bug causing subsequent packets to be shifted
  13. // call standby() to return radio to known-good state
  14. // recvRaw will call startReceive() to restart rx
  15. MESH_DEBUG_PRINTLN("LR1110: got header err, calling standby()");
  16. standby();
  17. }
  18. return len;
  19. }
  20. float getFreqMHz() const { return freqMHz; }
  21. int16_t setRxBoostedGainMode(bool en) {
  22. _rx_boosted = en;
  23. return LR1110::setRxBoostedGainMode(en);
  24. }
  25. bool getRxBoostedGainMode() const { return _rx_boosted; }
  26. bool isReceiving() {
  27. uint16_t irq = getIrqStatus();
  28. bool detected = ((irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID) || (irq & RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED));
  29. return detected;
  30. }
  31. uint8_t getSpreadingFactor() const { return spreadingFactor; }
  32. };