* new Dispatcher::getCADFailRetryDelay()
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
/* ------------------------------ Config -------------------------------- */
|
/* ------------------------------ Config -------------------------------- */
|
||||||
|
|
||||||
#define FIRMWARE_VER_TEXT "v5 (build: 25 Feb 2025)"
|
#define FIRMWARE_VER_TEXT "v6 (build: 27 Feb 2025)"
|
||||||
|
|
||||||
#ifndef LORA_FREQ
|
#ifndef LORA_FREQ
|
||||||
#define LORA_FREQ 915.0
|
#define LORA_FREQ 915.0
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
/* ------------------------------ Config -------------------------------- */
|
/* ------------------------------ Config -------------------------------- */
|
||||||
|
|
||||||
#define FIRMWARE_VER_TEXT "v5 (build: 25 Feb 2025)"
|
#define FIRMWARE_VER_TEXT "v6 (build: 27 Feb 2025)"
|
||||||
|
|
||||||
#ifndef LORA_FREQ
|
#ifndef LORA_FREQ
|
||||||
#define LORA_FREQ 915.0
|
#define LORA_FREQ 915.0
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ int Dispatcher::calcRxDelay(float score, uint32_t air_time) const {
|
|||||||
return (int) ((pow(10, 0.85f - score) - 1.0) * air_time);
|
return (int) ((pow(10, 0.85f - score) - 1.0) * air_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Dispatcher::getCADFailRetryDelay() const {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
void Dispatcher::loop() {
|
void Dispatcher::loop() {
|
||||||
if (outbound) { // waiting for outbound send to be completed
|
if (outbound) { // waiting for outbound send to be completed
|
||||||
if (_radio->isSendComplete()) {
|
if (_radio->isSendComplete()) {
|
||||||
@@ -165,7 +169,10 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
|
|||||||
void Dispatcher::checkSend() {
|
void Dispatcher::checkSend() {
|
||||||
if (_mgr->getOutboundCount() == 0) return; // nothing waiting to send
|
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 (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting)
|
||||||
if (_radio->isReceiving()) return; // LBT - check if radio is currently mid-receive, or if channel activity
|
if (_radio->isReceiving()) { // LBT - check if radio is currently mid-receive, or if channel activity
|
||||||
|
next_tx_time = futureMillis(getCADFailRetryDelay());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
outbound = _mgr->getNextOutbound(_ms->getMillis());
|
outbound = _mgr->getNextOutbound(_ms->getMillis());
|
||||||
if (outbound) {
|
if (outbound) {
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ protected:
|
|||||||
|
|
||||||
virtual float getAirtimeBudgetFactor() const;
|
virtual float getAirtimeBudgetFactor() const;
|
||||||
virtual int calcRxDelay(float score, uint32_t air_time) const;
|
virtual int calcRxDelay(float score, uint32_t air_time) const;
|
||||||
|
virtual uint32_t getCADFailRetryDelay() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void begin();
|
void begin();
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ uint32_t Mesh::getDirectRetransmitDelay(const Packet* packet) {
|
|||||||
return 0; // by default, no delay
|
return 0; // by default, no delay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Mesh::getCADFailRetryDelay() const {
|
||||||
|
return _rng->nextInt(1, 4)*120;
|
||||||
|
}
|
||||||
|
|
||||||
int Mesh::searchPeersByHash(const uint8_t* hash) {
|
int Mesh::searchPeersByHash(const uint8_t* hash) {
|
||||||
return 0; // not found
|
return 0; // not found
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class Mesh : public Dispatcher {
|
|||||||
protected:
|
protected:
|
||||||
DispatcherAction onRecvPacket(Packet* pkt) override;
|
DispatcherAction onRecvPacket(Packet* pkt) override;
|
||||||
|
|
||||||
|
virtual uint32_t getCADFailRetryDelay() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Decide what to do with received packet, ie. discard, forward, or hold
|
* \brief Decide what to do with received packet, ie. discard, forward, or hold
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ public:
|
|||||||
idle(); // put sx126x into standby
|
idle(); // put sx126x into standby
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
bool activity = (((CustomLLCC68 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
bool activity = (((CustomLLCC68 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
||||||
idle();
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ public:
|
|||||||
idle(); // put sx126x into standby
|
idle(); // put sx126x into standby
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
bool activity = (((CustomLR1110 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
bool activity = (((CustomLR1110 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
||||||
idle();
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ public:
|
|||||||
idle(); // put sx126x into standby
|
idle(); // put sx126x into standby
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
bool activity = (((CustomSX1262 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
bool activity = (((CustomSX1262 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
||||||
idle();
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ public:
|
|||||||
idle(); // put sx126x into standby
|
idle(); // put sx126x into standby
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
bool activity = (((CustomSX1268 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
bool activity = (((CustomSX1268 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
||||||
idle();
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ public:
|
|||||||
idle(); // put into standby
|
idle(); // put into standby
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
bool activity = (((CustomSX1276 *)_radio)->tryScanChannel() == RADIOLIB_PREAMBLE_DETECTED);
|
bool activity = (((CustomSX1276 *)_radio)->tryScanChannel() == RADIOLIB_PREAMBLE_DETECTED);
|
||||||
idle();
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1276 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1276 *)_radio)->getRSSI(); }
|
||||||
|
|||||||
@@ -35,6 +35,15 @@ void RadioLibWrapper::idle() {
|
|||||||
state = STATE_IDLE; // need another startReceive()
|
state = STATE_IDLE; // need another startReceive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RadioLibWrapper::startRecv() {
|
||||||
|
int err = _radio->startReceive();
|
||||||
|
if (err == RADIOLIB_ERR_NONE) {
|
||||||
|
state = STATE_RX;
|
||||||
|
} else {
|
||||||
|
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive(%d)", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||||
if (state & STATE_INT_READY) {
|
if (state & STATE_INT_READY) {
|
||||||
int len = _radio->getPacketLength();
|
int len = _radio->getPacketLength();
|
||||||
@@ -54,10 +63,11 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
|||||||
|
|
||||||
if (state != STATE_RX) {
|
if (state != STATE_RX) {
|
||||||
int err = _radio->startReceive();
|
int err = _radio->startReceive();
|
||||||
if (err != RADIOLIB_ERR_NONE) {
|
if (err == RADIOLIB_ERR_NONE) {
|
||||||
|
state = STATE_RX;
|
||||||
|
} else {
|
||||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive(%d)", err);
|
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive(%d)", err);
|
||||||
}
|
}
|
||||||
state = STATE_RX;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ protected:
|
|||||||
uint32_t n_recv, n_sent;
|
uint32_t n_recv, n_sent;
|
||||||
|
|
||||||
void idle();
|
void idle();
|
||||||
|
void startRecv();
|
||||||
float packetScoreInt(float snr, int sf, int packet_len);
|
float packetScoreInt(float snr, int sf, int packet_len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user