Harden fast RXPS timing and board behavior
This commit is contained in:
1 parent
dc92ee61ef
commit
ba70c5b3c6
21 files changed
+607
-30
No files matched your search
@@ -1790,6 +1790,7 @@ bool MyMesh::scheduleTempRadio(float freq, float bw, uint8_t sf, uint8_t cr,
|
||||
_temp_radio_failures = 0;
|
||||
snprintf(reply, reply_size, "OK - temp params for %lu mins",
|
||||
(unsigned long)timeout_mins);
|
||||
appendRxPowerSavingAdjustmentNote(reply, reply_size, sf, bw);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4108,6 +4109,46 @@ bool MyMesh::applyAndSaveRxPowerSaving(const char* value, char* reply) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyMesh::appendRxPowerSavingAdjustmentNote(char* reply, size_t reply_size,
|
||||
uint8_t sf, float bw) const {
|
||||
if (!reply || reply_size == 0 || !_prefs.rx_powersaving_enabled
|
||||
|| _prefs.rx_ps_level < 1 || _prefs.rx_ps_level > 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
if (!recalcRxPowerSavingFromLevel(
|
||||
_prefs.rx_ps_level, sf, bw, _prefs.rx_ps_preamble,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t used = strlen(reply);
|
||||
if (used >= reply_size - 1) return;
|
||||
|
||||
if (rxPowerSavingUsesContinuousFallback(rx_us, sleep_us)) {
|
||||
snprintf(reply + used, reply_size - used,
|
||||
"; RXPS continuous-fast (no safe level %u-10)",
|
||||
(unsigned)_prefs.rx_ps_level);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t requested_preamble = _prefs.rx_ps_preamble == 0
|
||||
? rxPowerSavingPreambleForSF(sf) : _prefs.rx_ps_preamble;
|
||||
if (effective_level == _prefs.rx_ps_level
|
||||
&& effective_preamble == requested_preamble) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(reply + used, reply_size - used,
|
||||
"; RXPS effective level %u, preamble %u (saved minimum %u)",
|
||||
(unsigned)effective_level, (unsigned)effective_preamble,
|
||||
(unsigned)_prefs.rx_ps_level);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_USB_INTERFACE
|
||||
Stream& MyMesh::terminalOutput() {
|
||||
return _terminal_output != NULL ? *_terminal_output : Serial;
|
||||
@@ -4953,12 +4994,49 @@ void MyMesh::handleTerminalCommand(char* command) {
|
||||
if (!radio_driver.supportsRxPowerSaving()) {
|
||||
terminalOutput().print(" ERROR: RX power saving is unsupported on this radio\r\n");
|
||||
} else {
|
||||
terminalOutput().printf(" radio.rxps %s,level=%u,preamble=%u,rx=%lu,sleep=%lu\r\n",
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
uint32_t effective_rx_us = _prefs.rx_ps_rx_us;
|
||||
uint32_t effective_sleep_us = _prefs.rx_ps_sleep_us;
|
||||
uint8_t active_sf = _prefs.sf;
|
||||
float active_bw = _prefs.bw;
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
if (isTempRadioActive()) {
|
||||
active_sf = _temp_radio_sf;
|
||||
active_bw = _temp_radio_bw;
|
||||
}
|
||||
#endif
|
||||
if (_prefs.rx_ps_level != 0) {
|
||||
recalcRxPowerSavingFromLevel(
|
||||
_prefs.rx_ps_level, active_sf, active_bw,
|
||||
_prefs.rx_ps_preamble, &effective_rx_us, &effective_sleep_us,
|
||||
&effective_level, &effective_preamble);
|
||||
}
|
||||
char effective_suffix[48] = {};
|
||||
const bool adjusted_level = effective_level != 0
|
||||
&& effective_level != _prefs.rx_ps_level;
|
||||
const bool adjusted_preamble = effective_preamble != 0
|
||||
&& effective_preamble != _prefs.rx_ps_preamble;
|
||||
if (adjusted_level && adjusted_preamble) {
|
||||
snprintf(effective_suffix, sizeof(effective_suffix),
|
||||
",effective-level=%u,effective-preamble=%u",
|
||||
(unsigned)effective_level, (unsigned)effective_preamble);
|
||||
} else if (adjusted_level) {
|
||||
snprintf(effective_suffix, sizeof(effective_suffix),
|
||||
",effective-level=%u", (unsigned)effective_level);
|
||||
} else if (adjusted_preamble) {
|
||||
snprintf(effective_suffix, sizeof(effective_suffix),
|
||||
",effective-preamble=%u", (unsigned)effective_preamble);
|
||||
}
|
||||
terminalOutput().printf(" radio.rxps %s,level=%u,preamble=%u,rx=%lu,sleep=%lu%s%s\r\n",
|
||||
_prefs.rx_powersaving_enabled ? "on" : "off",
|
||||
(unsigned)_prefs.rx_ps_level,
|
||||
(unsigned)_prefs.rx_ps_preamble,
|
||||
(unsigned long)_prefs.rx_ps_rx_us,
|
||||
(unsigned long)_prefs.rx_ps_sleep_us);
|
||||
(unsigned long)effective_rx_us,
|
||||
(unsigned long)effective_sleep_us,
|
||||
radio_driver.isRxPowerSavingContinuousFallback()
|
||||
? ",mode=continuous-fast" : "",
|
||||
effective_suffix);
|
||||
}
|
||||
#if defined(ESP32) && defined(WIFI_SSID)
|
||||
} else if (strcmp(command, "get wifi.powersave") == 0) {
|
||||
|
||||
@@ -302,6 +302,8 @@ private:
|
||||
bool applyAndSaveRxBoostedGain(bool enabled);
|
||||
bool applyAndSavePowerSaving(const char* value, char* reply);
|
||||
bool applyAndSaveRxPowerSaving(const char* value, char* reply);
|
||||
void appendRxPowerSavingAdjustmentNote(char* reply, size_t reply_size,
|
||||
uint8_t sf, float bw) const;
|
||||
#if defined(ESP32) && defined(WIFI_SSID)
|
||||
bool applyAndSaveWiFiPowerSaving(const char* value, char* reply,
|
||||
size_t reply_size);
|
||||
|
||||
@@ -109,7 +109,9 @@ class HomeScreen : public UIScreen {
|
||||
#if UI_SENSORS_PAGE == 1
|
||||
SENSORS,
|
||||
#endif
|
||||
#ifndef UI_NO_HIBERNATE
|
||||
SHUTDOWN,
|
||||
#endif
|
||||
Count // keep as last
|
||||
};
|
||||
|
||||
@@ -165,9 +167,18 @@ class HomeScreen : public UIScreen {
|
||||
}
|
||||
|
||||
display.setTextSize(1);
|
||||
bool charging = board.isExternalPowered();
|
||||
#ifdef PIN_BUZZER
|
||||
bool muted = _task->isBuzzerQuiet();
|
||||
#endif
|
||||
|
||||
int uptimeWidth = display.getTextWidth(uptime);
|
||||
int spaceWidth = display.getTextWidth(" ");
|
||||
display.setCursor(iconX - uptimeWidth - spaceWidth, iconY);
|
||||
int statusWidth = charging ? 9 : 0;
|
||||
#ifdef PIN_BUZZER
|
||||
if (muted) statusWidth += 9;
|
||||
#endif
|
||||
display.setCursor(iconX - statusWidth - uptimeWidth - spaceWidth, iconY);
|
||||
display.print(uptime);
|
||||
|
||||
// battery outline
|
||||
@@ -180,11 +191,21 @@ class HomeScreen : public UIScreen {
|
||||
int fillWidth = (batteryPercentage * (iconWidth - 4)) / 100;
|
||||
display.fillRect(iconX + 2, iconY + 2, fillWidth, iconHeight - 4);
|
||||
|
||||
// show muted icon if buzzer is muted
|
||||
// Show external power beside the battery. Most boards have no
|
||||
// charge-complete signal, so use a high percentage band for the plug.
|
||||
if (charging) {
|
||||
static constexpr int BATT_FULL_PCT = 95;
|
||||
const uint8_t* symbol =
|
||||
batteryPercentage >= BATT_FULL_PCT ? plug_icon : charging_icon;
|
||||
display.setColor(UIColor::title_txt);
|
||||
display.drawXbm(iconX - 9, iconY + 1, symbol, 8, 8);
|
||||
}
|
||||
|
||||
// Keep the mute icon left of the charging icon when both are present.
|
||||
#ifdef PIN_BUZZER
|
||||
if (_task->isBuzzerQuiet()) {
|
||||
if (muted) {
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.drawXbm(iconX - 9, iconY + 1, muted_icon, 8, 8);
|
||||
display.drawXbm(iconX - (charging ? 18 : 9), iconY + 1, muted_icon, 8, 8);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -487,6 +508,7 @@ public:
|
||||
if (sensors_scroll) sensors_scroll_offset = (sensors_scroll_offset+1)%sensors_nb;
|
||||
else sensors_scroll_offset = 0;
|
||||
#endif
|
||||
#ifndef UI_NO_HIBERNATE
|
||||
} else if (_page == HomePage::SHUTDOWN) {
|
||||
display.setColor(UIColor::corp_blue);
|
||||
display.setTextSize(1);
|
||||
@@ -498,6 +520,7 @@ public:
|
||||
display.drawXbm((display.width() - 32) / 2, 18, power_icon, 32, 32);
|
||||
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 5000; // next render after 5000 ms
|
||||
}
|
||||
@@ -544,10 +567,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifndef UI_NO_HIBERNATE
|
||||
if (c == KEY_ENTER && _page == HomePage::SHUTDOWN) {
|
||||
_shutdown_init = true; // need to wait for button to be released
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,4 +119,14 @@ static const uint8_t advert_icon[] = {
|
||||
|
||||
static const uint8_t muted_icon[] = {
|
||||
0x20, 0x6a, 0xea, 0xe4, 0xe4, 0xea, 0x6a, 0x20
|
||||
};
|
||||
};
|
||||
|
||||
// Small lightning bolt, 8x8px, shown while externally powered and charging.
|
||||
static const uint8_t charging_icon[] = {
|
||||
0x18, 0x30, 0x60, 0xFC, 0x18, 0x30, 0x60, 0xC0
|
||||
};
|
||||
|
||||
// Small power plug, 8x8px, shown once the battery reaches the full band.
|
||||
static const uint8_t plug_icon[] = {
|
||||
0x24, 0x24, 0x7E, 0x7E, 0x7E, 0x3C, 0x18, 0x18
|
||||
};
|
||||
@@ -125,10 +125,6 @@ struct RepeaterStats {
|
||||
uint32_t n_recv_errors;
|
||||
};
|
||||
|
||||
#ifndef MAX_CLIENTS
|
||||
#define MAX_CLIENTS 32
|
||||
#endif
|
||||
|
||||
struct NeighbourInfo {
|
||||
mesh::Identity id;
|
||||
uint32_t advert_timestamp;
|
||||
|
||||
Reference in new issue
Block a user