Enable retry CR radio overrides
This commit is contained in:
1 parent
9c510ab7a6
commit
8d46ed4f21
11 files changed
+78
-13
No files matched your search
@@ -1155,12 +1155,12 @@ set direct.retry.cr 20.0,12.0,6.0,2.0
|
||||
**Usage:**
|
||||
- `get recent.repeater`
|
||||
- `get recent.repeater <page>`
|
||||
- `set recent.repeater <prefix> <snr_db>`
|
||||
- `set recent.repeater <prefix> [snr_db]`
|
||||
- `clear recent.repeater`
|
||||
|
||||
**Parameters:**
|
||||
- `prefix`: Repeater path-hash prefix as hex.
|
||||
- `snr_db`: SNR in dB.
|
||||
- `snr_db`: Optional SNR in dB. If omitted or invalid, defaults to `3.0`.
|
||||
- `page`: 1-based result page.
|
||||
|
||||
**SNR details:**
|
||||
@@ -1170,7 +1170,8 @@ set direct.retry.cr 20.0,12.0,6.0,2.0
|
||||
- Direct retry failure is not weighted: each final echo-timeout failure lowers that repeater's SNR by `0.25 dB`.
|
||||
- Unknown repeaters start at `+3.00 dB` for adaptive CR selection.
|
||||
- If an unknown repeater fails, it is seeded into the table at `+2.75 dB`.
|
||||
- `set recent.repeater <prefix> <snr_db>` seeds a missing prefix or adds another weighted sample for an existing prefix.
|
||||
- `set recent.repeater <prefix> [snr_db]` seeds a missing prefix or adds another weighted sample for an existing prefix.
|
||||
- Successful `set recent.repeater` replies include the stored prefix and SNR, for example `OK - set A1B2C3 at 3.0 SNR`.
|
||||
|
||||
**Examples:**
|
||||
```
|
||||
@@ -1178,6 +1179,7 @@ get recent.repeater
|
||||
get recent.repeater 2
|
||||
set recent.repeater A1B2C3 8.5
|
||||
set recent.repeater 71CE82 -3.25
|
||||
set recent.repeater A1B2C3
|
||||
clear recent.repeater
|
||||
```
|
||||
|
||||
|
||||
+19
-4
@@ -52,11 +52,15 @@ void Dispatcher::updateTxBudget() {
|
||||
}
|
||||
}
|
||||
|
||||
void Dispatcher::restoreOutboundCodingRate() {
|
||||
void Dispatcher::restoreOutboundTxOverrides() {
|
||||
if (outbound_restore_cr != 0) {
|
||||
_radio->setCodingRate(outbound_restore_cr);
|
||||
outbound_restore_cr = 0;
|
||||
}
|
||||
if (outbound_restore_preamble_len != 0) {
|
||||
_radio->setPreambleLength(outbound_restore_preamble_len);
|
||||
outbound_restore_preamble_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Dispatcher::calcRxDelay(float score, uint32_t air_time) const {
|
||||
@@ -113,7 +117,7 @@ void Dispatcher::loop() {
|
||||
}
|
||||
|
||||
_radio->onSendFinished();
|
||||
restoreOutboundCodingRate();
|
||||
restoreOutboundTxOverrides();
|
||||
logTx(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||
onSendComplete(outbound);
|
||||
if (outbound->isRouteFlood()) {
|
||||
@@ -127,7 +131,7 @@ void Dispatcher::loop() {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::loop(): WARNING: outbound packed send timed out!", getLogDateTime());
|
||||
|
||||
_radio->onSendFinished();
|
||||
restoreOutboundCodingRate();
|
||||
restoreOutboundTxOverrides();
|
||||
logTxFail(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||
onSendFail(outbound);
|
||||
|
||||
@@ -342,6 +346,7 @@ void Dispatcher::checkSend() {
|
||||
|
||||
uint32_t max_airtime = _radio->getEstAirtimeFor(len)*3/2;
|
||||
outbound_restore_cr = 0;
|
||||
outbound_restore_preamble_len = 0;
|
||||
uint8_t default_cr = getDefaultTxCodingRate();
|
||||
if (outbound->tx_cr >= 4 && outbound->tx_cr <= 8 && default_cr >= 4 && default_cr <= 8
|
||||
&& outbound->tx_cr != default_cr) {
|
||||
@@ -352,12 +357,22 @@ void Dispatcher::checkSend() {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::checkSend(): WARN: failed to set packet CR%d", getLogDateTime(), (uint32_t)outbound->tx_cr);
|
||||
}
|
||||
}
|
||||
bool has_direct_path = outbound->getPathHashCount() > 0
|
||||
|| (outbound->getPayloadType() == PAYLOAD_TYPE_TRACE && outbound->payload_len > 9);
|
||||
if (outbound->isRouteDirect() && has_direct_path
|
||||
&& (outbound->tx_cr == 4 || outbound->tx_cr == 5)) {
|
||||
uint16_t default_preamble_len = _radio->getDefaultPreambleLength();
|
||||
if (default_preamble_len > 16 && _radio->setPreambleLength(16)) {
|
||||
outbound_restore_preamble_len = default_preamble_len;
|
||||
max_airtime = _radio->getEstAirtimeFor(len)*3/2;
|
||||
}
|
||||
}
|
||||
outbound_start = _ms->getMillis();
|
||||
bool success = _radio->startSendRaw(raw, len);
|
||||
if (!success) {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::loop(): ERROR: send start failed!", getLogDateTime());
|
||||
|
||||
restoreOutboundCodingRate();
|
||||
restoreOutboundTxOverrides();
|
||||
logTxFail(outbound, outbound->getRawLength());
|
||||
onSendFail(outbound);
|
||||
|
||||
|
||||
+5
-1
@@ -51,6 +51,8 @@ public:
|
||||
* \returns true if the radio accepted the coding rate.
|
||||
*/
|
||||
virtual bool setCodingRate(uint8_t cr) { return false; }
|
||||
virtual uint16_t getDefaultPreambleLength() const { return 0; }
|
||||
virtual bool setPreambleLength(uint16_t len) { return false; }
|
||||
|
||||
/**
|
||||
* \returns true if the previous 'startSendRaw()' completed successfully.
|
||||
@@ -124,6 +126,7 @@ typedef uint32_t DispatcherAction;
|
||||
class Dispatcher {
|
||||
Packet* outbound; // current outbound packet
|
||||
unsigned long outbound_expiry, outbound_start, total_air_time, rx_air_time;
|
||||
uint16_t outbound_restore_preamble_len;
|
||||
uint8_t outbound_restore_cr;
|
||||
unsigned long next_tx_time;
|
||||
unsigned long cad_busy_start;
|
||||
@@ -137,7 +140,7 @@ class Dispatcher {
|
||||
unsigned long duty_cycle_window_ms;
|
||||
|
||||
void processRecvPacket(Packet* pkt);
|
||||
void restoreOutboundCodingRate();
|
||||
void restoreOutboundTxOverrides();
|
||||
void updateTxBudget();
|
||||
|
||||
protected:
|
||||
@@ -150,6 +153,7 @@ protected:
|
||||
: _radio(&radio), _ms(&ms), _mgr(&mgr)
|
||||
{
|
||||
outbound = NULL;
|
||||
outbound_restore_preamble_len = 0;
|
||||
outbound_restore_cr = 0;
|
||||
total_air_time = rx_air_time = 0;
|
||||
next_tx_time = ms.getMillis();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define BRIDGE_MAX_BAUD 115200
|
||||
#endif
|
||||
|
||||
#define RECENT_REPEATER_PREFIX_MAX_BYTES 3
|
||||
|
||||
// Believe it or not, this std C function is busted on some platforms!
|
||||
static uint32_t _atoi(const char* sp) {
|
||||
uint32_t n = 0;
|
||||
@@ -128,13 +130,21 @@ static bool parseRetryPreset(const char* s, uint8_t& preset) {
|
||||
|
||||
static bool parseHashPrefix(const char* text, uint8_t* prefix, uint8_t& prefix_len) {
|
||||
size_t hex_len = strlen(text);
|
||||
if (hex_len == 0 || (hex_len & 1) || hex_len > MAX_HASH_SIZE * 2) {
|
||||
if (hex_len == 0 || (hex_len & 1) || hex_len > RECENT_REPEATER_PREFIX_MAX_BYTES * 2) {
|
||||
return false;
|
||||
}
|
||||
prefix_len = hex_len / 2;
|
||||
return mesh::Utils::fromHex(prefix, prefix_len, text);
|
||||
}
|
||||
|
||||
static void formatSnrDbX4Short(char* dest, size_t dest_len, int16_t snr_x4) {
|
||||
formatSnrDbX4(dest, dest_len, snr_x4);
|
||||
size_t len = strlen(dest);
|
||||
if (len > 3 && dest[len - 1] == '0') {
|
||||
dest[len - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CommonCLI::loadPrefs(FILESYSTEM* fs) {
|
||||
if (fs->exists("/com_prefs")) {
|
||||
loadPrefsInt(fs, "/com_prefs"); // new filename
|
||||
@@ -928,13 +938,21 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
int num = mesh::Utils::parseTextParts(tmp, parts, 2, ' ');
|
||||
uint8_t prefix[MAX_HASH_SIZE];
|
||||
uint8_t prefix_len = 0;
|
||||
int16_t snr_x4 = num > 1 && looksNumeric(parts[1]) ? parseSnrDbX4(parts[1]) : 0;
|
||||
if (num != 2 || !parseHashPrefix(parts[0], prefix, prefix_len)) {
|
||||
strcpy(reply, "Error, use: set recent.repeater <hex> <snr_db>");
|
||||
int16_t snr_x4 = 12; // default to +3.0 dB when omitted or invalid
|
||||
if (num > 1 && looksNumeric(parts[1])) {
|
||||
snr_x4 = parseSnrDbX4(parts[1]);
|
||||
}
|
||||
if (num < 1 || !parseHashPrefix(parts[0], prefix, prefix_len)) {
|
||||
strcpy(reply, "Error, use: set recent.repeater <hex> [snr_db]");
|
||||
} else if (snr_x4 < -128 || snr_x4 > 127) {
|
||||
strcpy(reply, "Error, SNR must fit -32.00..31.75 dB");
|
||||
} else if (_callbacks->setRecentRepeater(prefix, prefix_len, (int8_t)snr_x4)) {
|
||||
strcpy(reply, "OK");
|
||||
char prefix_hex[RECENT_REPEATER_PREFIX_MAX_BYTES * 2 + 1];
|
||||
char snr[12];
|
||||
mesh::Utils::toHex(prefix_hex, prefix, prefix_len);
|
||||
prefix_hex[prefix_len * 2] = 0;
|
||||
formatSnrDbX4Short(snr, sizeof(snr), snr_x4);
|
||||
sprintf(reply, "OK - set %s at %s SNR", prefix_hex, snr);
|
||||
} else {
|
||||
strcpy(reply, "Error, table rejected prefix");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomLLCC68 *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLLCC68 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomLR1110 *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1110 *)_radio)->getFreqMHz()); }
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLR1110 *)_radio)->isReceiving();
|
||||
|
||||
@@ -17,6 +17,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomSTM32WLx *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSTM32WLx *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomSX1262 *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSX1262 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomSX1268 *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSX1268 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ public:
|
||||
updatePreamble(sf);
|
||||
}
|
||||
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
return ((CustomSX1276 *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomSX1276 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void setParams(float freq, float bw, uint8_t sf, uint8_t cr) = 0;
|
||||
uint16_t getDefaultPreambleLength() const override { return preambleLengthForSF(_preamble_sf); }
|
||||
bool setPreambleLength(uint16_t len) override { return _radio->setPreambleLength(len) == RADIOLIB_ERR_NONE; }
|
||||
uint32_t getRngSeed();
|
||||
void setTxPower(int8_t dbm);
|
||||
|
||||
|
||||
Reference in new issue
Block a user