PowerSaving for repeaters

This commit is contained in:
Kevin Le committed 2026-10-18 21:05:46 +07:00
1 parent 7213cb8166
commit 60e9e41028
2 files changed
+49 -3

No files matched your search

+30 -2
View File
@@ -933,13 +933,33 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.rx_boosted_gain = 1; // enabled by default;
#endif
#endif
_prefs.radio_fem_rxgain = 1;
// PowerSaving variant
#ifdef RADIO_FEM_RXGAIN
_prefs.radio_fem_rxgain = RADIO_FEM_RXGAIN;
#else
_prefs.radio_fem_rxgain = 0;
#endif
#ifdef RADIO_FEM_TXGAIN
_prefs.radio_fem_txgain = RADIO_FEM_TXGAIN; // board-specific default for PA
#else
_prefs.radio_fem_txgain = 0;
#endif
pending_discover_tag = 0;
pending_discover_until = 0;
memset(default_scope.key, 0, sizeof(default_scope.key));
// PowerSaving variant
// PowerSaving defaults
_prefs.powersaving_enabled = 1;
// RXPS defaults - Balanced profile
_prefs.rxps.enabled = 1;
_prefs.rxps.level = 6;
_prefs.rxps.preamble = 16;
}
void MyMesh::begin(FILESYSTEM *fs) {
@@ -978,6 +998,8 @@ void MyMesh::begin(FILESYSTEM *fs) {
#endif
radio_driver.setParams(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
// PowerSaving variant
_prefs.getRadioPrefs()->applyRxPowerSaving(_prefs.sf, _prefs.bw);
radio_driver.setTxPower(_prefs.tx_power_dbm);
radio_driver.setRxBoostedGainMode(_prefs.rx_boosted_gain);
@@ -1310,12 +1332,16 @@ void MyMesh::loop() {
if (set_radio_at && millisHasNowPassed(set_radio_at)) { // apply pending (temporary) radio params
set_radio_at = 0; // clear timer
radio_driver.setParams(pending_freq, pending_bw, pending_sf, pending_cr);
// PowerSaving variant
_prefs.getRadioPrefs()->applyRxPowerSaving(pending_sf, pending_bw);
MESH_DEBUG_PRINTLN("Temp radio params");
}
if (revert_radio_at && millisHasNowPassed(revert_radio_at)) { // revert radio params to orig
revert_radio_at = 0; // clear timer
radio_driver.setParams(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
// PowerSaving variant
_prefs.getRadioPrefs()->applyRxPowerSaving(_prefs.sf, _prefs.bw);
MESH_DEBUG_PRINTLN("Radio params restored");
}
@@ -1336,5 +1362,7 @@ bool MyMesh::hasPendingWork() const {
#if defined(WITH_BRIDGE)
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
#endif
return _mgr->getOutboundTotal() > 0;
// PowerSaving variant
return _mgr->getOutboundTotal() > 0 || _mgr->getInboundTotal() > 0 || // rxdelay packets wait in the inbound queue
isTransmitting() || _prefs.getRadioPrefs()->isRxPowerSavingCalibrationActive();
}
+19 -1
View File
@@ -102,12 +102,24 @@ void setup() {
ethernet_command[0] = 0;
#endif
// PowerSaving variant
#if ENV_INCLUDE_GPS == 1
// Apply PowerSaving profile for GPS
if (sensors.getLocationProvider() != NULL) {
// GPS on and off duration in seconds
sensors.getLocationProvider()->setPowerSavingProfile(the_mesh.getNodePrefs()->powersaving_enabled, 600,
86400); // Max 10 minutes, 1 day
}
#endif
sensors.begin();
the_mesh.begin(fs);
#ifdef DISPLAY_CLASS
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION);
// PowerSaving variant
// Added board for battery display
ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, &board);
#endif
#ifdef ETHERNET_ENABLED
@@ -214,4 +226,10 @@ void loop() {
}
#endif
}
// PowerSaving variant
if (the_mesh.getNodePrefs()->reboot_interval > 0 &&
the_mesh.millisHasNowPassed(the_mesh.getNodePrefs()->reboot_interval * 3600000)) {
board.reboot();
}
}