* basic CAD before TX, for sx126x wrappers

This commit is contained in:
Scott Powell
2025-01-21 13:37:32 +11:00
parent e838f405a7
commit de27dfacb6
5 changed files with 24 additions and 3 deletions

View File

@@ -121,7 +121,7 @@ void Dispatcher::checkRecv() {
void Dispatcher::checkSend() {
if (_mgr->getOutboundCount() == 0) return; // nothing waiting to send
if (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting)
if (_radio->isReceiving()) return; // check if radio is currently mid-receive
if (_radio->isReceiving()) return; // LBT - check if radio is currently mid-receive, or if channel activity
outbound = _mgr->getNextOutbound(_ms->getMillis());
if (outbound) {

View File

@@ -6,7 +6,14 @@
class CustomSX1262Wrapper : public RadioLibWrapper {
public:
CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
bool isReceiving() override { return ((CustomSX1262 *)_radio)->isReceiving(); }
bool isReceiving() override {
if (((CustomSX1262 *)_radio)->isReceiving()) return true;
idle(); // put sx126x into standby
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
if (((CustomSX1262 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED) return true;
return false;
}
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
};

View File

@@ -6,7 +6,14 @@
class CustomSX1268Wrapper : public RadioLibWrapper {
public:
CustomSX1268Wrapper(CustomSX1268& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
bool isReceiving() override { return ((CustomSX1268 *)_radio)->isReceiving(); }
bool isReceiving() override {
if (((CustomSX1268 *)_radio)->isReceiving()) return true;
idle(); // put sx126x into standby
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
if (((CustomSX1268 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED) return true;
return false;
}
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
float getLastSNR() const override { return ((CustomSX1268 *)_radio)->getSNR(); }
};

View File

@@ -30,6 +30,11 @@ void RadioLibWrapper::begin() {
}
}
void RadioLibWrapper::idle() {
_radio->standby();
state = STATE_IDLE; // need another startReceive()
}
int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
if (state & STATE_INT_READY) {
int len = _radio->getPacketLength();

View File

@@ -9,6 +9,8 @@ protected:
mesh::MainBoard* _board;
uint32_t n_recv, n_sent;
void idle();
public:
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }