mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 21:25:46 +00:00
* basic CAD before TX, for sx126x wrappers
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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(); }
|
||||
};
|
||||
|
||||
@@ -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(); }
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user