Update keymind retry controls
This commit is contained in:
1 parent
ca0679e999
commit
7d237f8730
8 files changed
+114
-44
No files matched your search
+3
-2
@@ -6,6 +6,7 @@ namespace mesh {
|
||||
static const uint8_t DIRECT_RETRY_MAX_ATTEMPTS_DEFAULT = 15;
|
||||
static const uint8_t DIRECT_RETRY_MAX_ATTEMPTS_HARD_MAX = 15;
|
||||
static const uint8_t FLOOD_RETRY_MAX_ATTEMPTS_DEFAULT = 3;
|
||||
static const uint8_t FLOOD_RETRY_MAX_ATTEMPTS_HARD_MAX = 15;
|
||||
|
||||
static uint8_t decodeTraceHashSize(uint8_t flags, uint8_t route_bytes) {
|
||||
uint8_t code = flags & 0x03;
|
||||
@@ -966,8 +967,8 @@ void Mesh::armFloodRetryOnSendComplete(const Packet* packet) {
|
||||
uint8_t max_attempts = getFloodRetryMaxAttempts(packet);
|
||||
if (max_attempts < 1) {
|
||||
max_attempts = 1;
|
||||
} else if (max_attempts > FLOOD_RETRY_MAX_ATTEMPTS_DEFAULT) {
|
||||
max_attempts = FLOOD_RETRY_MAX_ATTEMPTS_DEFAULT;
|
||||
} else if (max_attempts > FLOOD_RETRY_MAX_ATTEMPTS_HARD_MAX) {
|
||||
max_attempts = FLOOD_RETRY_MAX_ATTEMPTS_HARD_MAX;
|
||||
}
|
||||
if (_flood_retries[i].retry_attempts_sent >= max_attempts) {
|
||||
Packet* final_wait = obtainNewPacket();
|
||||
|
||||
@@ -17,6 +17,10 @@ bool ArduinoSerialInterface::isConnected() const {
|
||||
return true; // no way of knowing, so assume yes
|
||||
}
|
||||
|
||||
bool ArduinoSerialInterface::isReadBusy() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ArduinoSerialInterface::isWriteBusy() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public:
|
||||
|
||||
bool isConnected() const override;
|
||||
|
||||
bool isReadBusy() const override;
|
||||
bool isWriteBusy() const override;
|
||||
size_t writeFrame(const uint8_t src[], size_t len) override;
|
||||
size_t checkRecvFrame(uint8_t dest[]) override;
|
||||
};
|
||||
};
|
||||
+60
-26
@@ -33,7 +33,7 @@
|
||||
#define FLOOD_RETRY_PREFS_MAGIC_0 0xF4
|
||||
#define FLOOD_RETRY_PREFS_MAGIC_1 0x52
|
||||
#define FLOOD_RETRY_COUNT_MIN 0
|
||||
#define FLOOD_RETRY_COUNT_MAX 3
|
||||
#define FLOOD_RETRY_COUNT_MAX 15
|
||||
#define FLOOD_RETRY_ADVERT_DEFAULT 0
|
||||
|
||||
// Believe it or not, this std C function is busted on some platforms!
|
||||
@@ -121,29 +121,53 @@ static float directRetryCrX4ToDb(int8_t snr_x4) {
|
||||
static void setDirectRetryCrDefaults(NodePrefs* prefs) {
|
||||
prefs->direct_retry_cr4_snr_x4 = DIRECT_RETRY_CR4_MIN_SNR_X4_DEFAULT;
|
||||
prefs->direct_retry_cr5_snr_x4 = DIRECT_RETRY_CR5_MIN_SNR_X4_DEFAULT;
|
||||
prefs->direct_retry_cr7_snr_x4 = DIRECT_RETRY_CR7_MIN_SNR_X4_DEFAULT;
|
||||
prefs->direct_retry_cr8_snr_x4 = DIRECT_RETRY_CR8_MAX_SNR_X4_DEFAULT;
|
||||
}
|
||||
|
||||
static bool directRetryCrThresholdsAreValid(int8_t cr4_snr_x4, int8_t cr5_snr_x4, int8_t cr8_snr_x4) {
|
||||
return (cr4_snr_x4 != 0 || cr5_snr_x4 != 0 || cr8_snr_x4 != 0)
|
||||
&& cr4_snr_x4 >= cr5_snr_x4
|
||||
&& cr5_snr_x4 >= cr8_snr_x4;
|
||||
static void setDirectRetryCrOff(NodePrefs* prefs) {
|
||||
prefs->direct_retry_cr4_snr_x4 = 0;
|
||||
prefs->direct_retry_cr5_snr_x4 = 0;
|
||||
prefs->direct_retry_cr7_snr_x4 = 0;
|
||||
prefs->direct_retry_cr8_snr_x4 = 0;
|
||||
}
|
||||
|
||||
static bool directRetryCrThresholdsAreOff(int8_t cr4_snr_x4, int8_t cr5_snr_x4, int8_t cr7_snr_x4, int8_t cr8_snr_x4) {
|
||||
return cr4_snr_x4 == 0 && cr5_snr_x4 == 0 && cr7_snr_x4 == 0 && cr8_snr_x4 == 0;
|
||||
}
|
||||
|
||||
static bool directRetryCrThresholdsAreValid(int8_t cr4_snr_x4, int8_t cr5_snr_x4, int8_t cr7_snr_x4, int8_t cr8_snr_x4) {
|
||||
return directRetryCrThresholdsAreOff(cr4_snr_x4, cr5_snr_x4, cr7_snr_x4, cr8_snr_x4)
|
||||
|| ((cr4_snr_x4 != 0 || cr5_snr_x4 != 0 || cr7_snr_x4 != 0 || cr8_snr_x4 != 0)
|
||||
&& cr4_snr_x4 >= cr5_snr_x4
|
||||
&& cr5_snr_x4 >= cr7_snr_x4
|
||||
&& cr7_snr_x4 >= cr8_snr_x4);
|
||||
}
|
||||
|
||||
static void sanitizeDirectRetryCrThresholds(NodePrefs* prefs) {
|
||||
if (!directRetryCrThresholdsAreValid(prefs->direct_retry_cr4_snr_x4,
|
||||
prefs->direct_retry_cr5_snr_x4,
|
||||
prefs->direct_retry_cr7_snr_x4,
|
||||
prefs->direct_retry_cr8_snr_x4)) {
|
||||
setDirectRetryCrDefaults(prefs);
|
||||
}
|
||||
}
|
||||
|
||||
static void formatDirectRetryCrThresholds(const NodePrefs* prefs, char* reply) {
|
||||
char cr4[12], cr5[12], cr8[12];
|
||||
if (directRetryCrThresholdsAreOff(prefs->direct_retry_cr4_snr_x4,
|
||||
prefs->direct_retry_cr5_snr_x4,
|
||||
prefs->direct_retry_cr7_snr_x4,
|
||||
prefs->direct_retry_cr8_snr_x4)) {
|
||||
strcpy(reply, "> off");
|
||||
return;
|
||||
}
|
||||
|
||||
char cr4[12], cr5[12], cr7[12], cr8[12];
|
||||
strcpy(cr4, StrHelper::ftoa(directRetryCrX4ToDb(prefs->direct_retry_cr4_snr_x4)));
|
||||
strcpy(cr5, StrHelper::ftoa(directRetryCrX4ToDb(prefs->direct_retry_cr5_snr_x4)));
|
||||
strcpy(cr7, StrHelper::ftoa(directRetryCrX4ToDb(prefs->direct_retry_cr7_snr_x4)));
|
||||
strcpy(cr8, StrHelper::ftoa(directRetryCrX4ToDb(prefs->direct_retry_cr8_snr_x4)));
|
||||
sprintf(reply, "> %s,%s,%s,%s", cr4, cr5, cr8, cr8);
|
||||
sprintf(reply, "> %s,%s,%s,%s", cr4, cr5, cr7, cr8);
|
||||
}
|
||||
|
||||
static uint16_t retryPresetStepDefault(uint8_t preset) {
|
||||
@@ -388,35 +412,36 @@ static bool parseDirectRetryCrThresholds(char* value, NodePrefs* prefs) {
|
||||
if (value == NULL || prefs == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (strcmp(value, "off") == 0) {
|
||||
setDirectRetryCrOff(prefs);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* parts[4];
|
||||
int num = mesh::Utils::parseTextParts(value, parts, 4);
|
||||
if (num != 3 && num != 4) {
|
||||
const char* parts[5];
|
||||
int num = mesh::Utils::parseTextParts(value, parts, 5);
|
||||
if (num != 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int8_t cr4_snr_x4;
|
||||
int8_t cr5_snr_x4;
|
||||
int8_t cr7_snr_x4;
|
||||
int8_t cr8_snr_x4;
|
||||
if (!parseDirectRetryCrDb(parts[0], cr4_snr_x4)
|
||||
|| !parseDirectRetryCrDb(parts[1], cr5_snr_x4)
|
||||
|| !parseDirectRetryCrDb(parts[num == 4 ? 3 : 2], cr8_snr_x4)) {
|
||||
|| !parseDirectRetryCrDb(parts[2], cr7_snr_x4)
|
||||
|| !parseDirectRetryCrDb(parts[3], cr8_snr_x4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (num == 4) {
|
||||
int8_t repeated_low_snr_x4;
|
||||
if (!parseDirectRetryCrDb(parts[2], repeated_low_snr_x4) || repeated_low_snr_x4 != cr8_snr_x4) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!directRetryCrThresholdsAreValid(cr4_snr_x4, cr5_snr_x4, cr8_snr_x4)) {
|
||||
if (directRetryCrThresholdsAreOff(cr4_snr_x4, cr5_snr_x4, cr7_snr_x4, cr8_snr_x4)
|
||||
|| !directRetryCrThresholdsAreValid(cr4_snr_x4, cr5_snr_x4, cr7_snr_x4, cr8_snr_x4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
prefs->direct_retry_cr4_snr_x4 = cr4_snr_x4;
|
||||
prefs->direct_retry_cr5_snr_x4 = cr5_snr_x4;
|
||||
prefs->direct_retry_cr7_snr_x4 = cr7_snr_x4;
|
||||
prefs->direct_retry_cr8_snr_x4 = cr8_snr_x4;
|
||||
return true;
|
||||
}
|
||||
@@ -527,8 +552,10 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
||||
sizeof(_prefs->direct_retry_cr4_snr_x4)); // 660
|
||||
retry_cr_read += file.read((uint8_t *)&_prefs->direct_retry_cr5_snr_x4,
|
||||
sizeof(_prefs->direct_retry_cr5_snr_x4)); // 661
|
||||
retry_cr_read += file.read((uint8_t *)&_prefs->direct_retry_cr7_snr_x4,
|
||||
sizeof(_prefs->direct_retry_cr7_snr_x4)); // 662
|
||||
retry_cr_read += file.read((uint8_t *)&_prefs->direct_retry_cr8_snr_x4,
|
||||
sizeof(_prefs->direct_retry_cr8_snr_x4)); // 662
|
||||
sizeof(_prefs->direct_retry_cr8_snr_x4)); // 663
|
||||
// PowerSaving-only prefs stored radio_fem_rxgain at 291, before direct retry timing existed.
|
||||
if (radio_fem_rxgain_read != sizeof(_prefs->radio_fem_rxgain)
|
||||
&& legacy_retry_attempts_read == sizeof(legacy_retry_attempts_or_radio_fem_rxgain)
|
||||
@@ -536,7 +563,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
||||
|| _prefs->direct_retry_timing_magic[1] != DIRECT_RETRY_TIMING_MAGIC_1)) {
|
||||
_prefs->radio_fem_rxgain = constrain(legacy_retry_attempts_or_radio_fem_rxgain, 0, 1);
|
||||
}
|
||||
// next: 663
|
||||
// next: 664
|
||||
|
||||
// sanitise bad pref values
|
||||
_prefs->rx_delay_base = constrain(_prefs->rx_delay_base, 0, 20.0f);
|
||||
@@ -614,8 +641,14 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
||||
_prefs->flood_retry_advert_enabled = constrain(_prefs->flood_retry_advert_enabled, 0, 1);
|
||||
}
|
||||
}
|
||||
if (retry_cr_read != sizeof(_prefs->direct_retry_cr4_snr_x4)
|
||||
if (retry_cr_read == sizeof(_prefs->direct_retry_cr4_snr_x4)
|
||||
+ sizeof(_prefs->direct_retry_cr5_snr_x4)
|
||||
+ sizeof(_prefs->direct_retry_cr7_snr_x4)) {
|
||||
_prefs->direct_retry_cr8_snr_x4 = _prefs->direct_retry_cr7_snr_x4;
|
||||
sanitizeDirectRetryCrThresholds(_prefs);
|
||||
} else if (retry_cr_read != sizeof(_prefs->direct_retry_cr4_snr_x4)
|
||||
+ sizeof(_prefs->direct_retry_cr5_snr_x4)
|
||||
+ sizeof(_prefs->direct_retry_cr7_snr_x4)
|
||||
+ sizeof(_prefs->direct_retry_cr8_snr_x4)) {
|
||||
setDirectRetryCrDefaults(_prefs);
|
||||
} else {
|
||||
@@ -704,8 +737,9 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
|
||||
file.write((uint8_t *)&_prefs->flood_retry_advert_enabled, sizeof(_prefs->flood_retry_advert_enabled)); // 659
|
||||
file.write((uint8_t *)&_prefs->direct_retry_cr4_snr_x4, sizeof(_prefs->direct_retry_cr4_snr_x4)); // 660
|
||||
file.write((uint8_t *)&_prefs->direct_retry_cr5_snr_x4, sizeof(_prefs->direct_retry_cr5_snr_x4)); // 661
|
||||
file.write((uint8_t *)&_prefs->direct_retry_cr8_snr_x4, sizeof(_prefs->direct_retry_cr8_snr_x4)); // 662
|
||||
// next: 663
|
||||
file.write((uint8_t *)&_prefs->direct_retry_cr7_snr_x4, sizeof(_prefs->direct_retry_cr7_snr_x4)); // 662
|
||||
file.write((uint8_t *)&_prefs->direct_retry_cr8_snr_x4, sizeof(_prefs->direct_retry_cr8_snr_x4)); // 663
|
||||
// next: 664
|
||||
|
||||
file.close();
|
||||
}
|
||||
@@ -1285,7 +1319,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
savePrefs();
|
||||
formatDirectRetryCrThresholds(_prefs, reply);
|
||||
} else {
|
||||
strcpy(reply, "Error, expected cr4,cr5,cr8 or cr4,cr5,low,low");
|
||||
strcpy(reply, "Error, expected off or cr4,cr5,cr7,cr8");
|
||||
}
|
||||
} else if (memcmp(config, "owner.info ", 11) == 0) {
|
||||
config += 11;
|
||||
@@ -1919,7 +1953,7 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
savePrefs();
|
||||
formatDirectRetryCrThresholds(_prefs, reply);
|
||||
} else {
|
||||
strcpy(reply, "Error, expected cr4,cr5,cr8 or cr4,cr5,low,low");
|
||||
strcpy(reply, "Error, expected off or cr4,cr5,cr7,cr8");
|
||||
}
|
||||
} else if (memcmp(config, "owner.info ", 11) == 0) {
|
||||
config += 11;
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
|
||||
#define DIRECT_RETRY_CR4_MIN_SNR_X4_DEFAULT 40 // 10.0 dB and up => CR4
|
||||
#define DIRECT_RETRY_CR5_MIN_SNR_X4_DEFAULT 30 // 7.5 dB and up => CR5
|
||||
#define DIRECT_RETRY_CR7_MIN_SNR_X4_DEFAULT 10 // 2.5 dB and up => CR7
|
||||
#define DIRECT_RETRY_CR8_MAX_SNR_X4_DEFAULT 10 // 2.5 dB and down => CR8
|
||||
#define DIRECT_RETRY_CR_SNR_X4_MIN -128
|
||||
#define DIRECT_RETRY_CR_SNR_X4_MAX 127
|
||||
@@ -129,6 +130,7 @@ struct NodePrefs { // persisted to file
|
||||
uint8_t flood_retry_advert_enabled;
|
||||
int8_t direct_retry_cr4_snr_x4;
|
||||
int8_t direct_retry_cr5_snr_x4;
|
||||
int8_t direct_retry_cr7_snr_x4;
|
||||
int8_t direct_retry_cr8_snr_x4;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user