mirror of https://github.com/meshcore-dev/MeshCore
9 changed files with 64 additions and 12 deletions
@ -0,0 +1,17 @@ |
|||
#pragma once |
|||
|
|||
#include <RadioLib.h> |
|||
|
|||
#define LR1121_IRQ_HAS_PREAMBLE 0b0000000100 // 4 4 valid LoRa header received
|
|||
#define LR1121_IRQ_HEADER_VALID 0b0000010000 // 4 4 valid LoRa header received
|
|||
|
|||
class CustomLR1121 : public LR1121 { |
|||
public: |
|||
CustomLR1121(Module *mod) : LR1121(mod) { } |
|||
|
|||
bool isReceiving() { |
|||
uint16_t irq = getIrqStatus(); |
|||
bool hasPreamble = ((irq & LR1121_IRQ_HEADER_VALID) && (irq & LR1121_IRQ_HAS_PREAMBLE)); |
|||
return hasPreamble; |
|||
} |
|||
}; |
|||
@ -0,0 +1,30 @@ |
|||
#pragma once |
|||
|
|||
#include "CustomLR1121.h" |
|||
#include "RadioLibWrappers.h" |
|||
|
|||
class CustomLR1121Wrapper : public RadioLibWrapper { |
|||
public: |
|||
CustomLR1121Wrapper(CustomLR1121& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { } |
|||
bool isReceiving() override { |
|||
if (((CustomLR1121 *)_radio)->isReceiving()) return true; |
|||
|
|||
idle(); // put lr1121 into standby
|
|||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|||
bool activity = (((CustomLR1121 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED); |
|||
if (activity) { |
|||
startRecv(); |
|||
} else { |
|||
idle(); |
|||
} |
|||
return activity; |
|||
} |
|||
|
|||
void onSendFinished() override { |
|||
RadioLibWrapper::onSendFinished(); |
|||
_radio->setPreambleLength(8); // overcomes weird issues with small and big pkts
|
|||
} |
|||
|
|||
float getLastRSSI() const override { return ((CustomLR1121 *)_radio)->getRSSI(); } |
|||
float getLastSNR() const override { return ((CustomLR1121 *)_radio)->getSNR(); } |
|||
}; |
|||
Loading…
Reference in new issue