refactor: remove legacy battery reporting toggle path

Bu işleme şunda yer alıyor:
Jared Dohrman
2026-04-22 09:57:51 +10:00
ebeveyn 274cb8b8c2
işleme bbab7c95d4
10 değiştirilmiş dosya ile 34 ekleme ve 43 silme
-2
Dosyayı Görüntüle
@@ -86,8 +86,6 @@ Legacy dotted aliases are also accepted:
### Board Battery Reporting ### Board Battery Reporting
- `get battery.reporting`: shows whether board battery reporting is enabled. Support is board-dependent.
- `set battery.reporting on|off`: enables or disables battery voltage reporting on supported boards. This is currently useful for Heltec V3 boards where USB-only power can produce misleading battery readings. If your board needs this too, open an issue and support can be added board-by-board.
- On repeater MQTT builds, background battery sampling used for MQTT/status history is rate-limited to about once per minute. Explicit status and telemetry requests still refresh the reading immediately. - On repeater MQTT builds, background battery sampling used for MQTT/status history is rate-limited to about once per minute. Explicit status and telemetry requests still refresh the reading immediately.
### T-Beam 1W Fan Control ### T-Beam 1W Fan Control
+24
Dosyayı Görüntüle
@@ -165,6 +165,30 @@ Notes:
- the refresh buttons load the current value from the repeater - the refresh buttons load the current value from the repeater
- the save buttons send the matching CLI command immediately - the save buttons send the matching CLI command immediately
## Ghost Node Mode
Ghost Node Mode is a convenience control on `/app` for a repeater that should stay on Wi-Fi and MQTT, but should not actively behave like another nearby repeater.
Typical use case:
- an indoor or colocated MQTT observer where another repeater nearby is already doing the RF relay work
- a node you want feeding MQTT, web status, and troubleshooting data without also adding extra repeat traffic or adverts
When enabled, Ghost Node Mode:
- turns `repeat` off
- sets `advert.interval` to `0`
- sets `flood.advert.interval` to `0`
- leaves the local web panel and MQTT features running
When disabled, the panel restores the prior repeat and advert settings if it still knows them from the current browser session. If not, it falls back to:
- `repeat on`
- `advert.interval 60`
- `flood.advert.interval 12`
This mode is useful when you want the device to observe and publish, not to act as an additional RF repeater. It does not create a separate firmware role; it is just a grouped web-panel shortcut for those existing settings.
## MQTT Settings ## MQTT Settings
This section includes: This section includes:
+1 -9
Dosyayı Görüntüle
@@ -1240,7 +1240,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.advert_loc_policy = ADVERT_LOC_PREFS; _prefs.advert_loc_policy = ADVERT_LOC_PREFS;
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier _prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
_prefs.battery_reporting_enabled = 1; _prefs.reserved_290 = 0;
_prefs.fan_mode = 0; // auto _prefs.fan_mode = 0; // auto
_prefs.fan_timeout_secs = 30; _prefs.fan_timeout_secs = 30;
@@ -1347,7 +1347,6 @@ void MyMesh::begin(FILESYSTEM *fs, ArchiveStorage* archive) {
updateFloodAdvertTimer(); updateFloodAdvertTimer();
board.setAdcMultiplier(_prefs.adc_multiplier); board.setAdcMultiplier(_prefs.adc_multiplier);
board.setBatteryReporting(_prefs.battery_reporting_enabled);
#if defined(TBEAM_1W) #if defined(TBEAM_1W)
auto& tbeam1w_board = static_cast<TBeam1WBoard&>(board); auto& tbeam1w_board = static_cast<TBeam1WBoard&>(board);
tbeam1w_board.setFanPostTxHoldMs(static_cast<uint32_t>(_prefs.fan_timeout_secs) * 1000UL); tbeam1w_board.setFanPostTxHoldMs(static_cast<uint32_t>(_prefs.fan_timeout_secs) * 1000UL);
@@ -1375,13 +1374,6 @@ void MyMesh::sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint3
uint16_t MyMesh::getBatteryMilliVolts(bool force_refresh) { uint16_t MyMesh::getBatteryMilliVolts(bool force_refresh) {
constexpr unsigned long kBatterySampleIntervalMs = 60000UL; constexpr unsigned long kBatterySampleIntervalMs = 60000UL;
if (board.supportsBatteryReporting() && !board.isBatteryReportingEnabled()) {
_battery_sample_valid = true;
_battery_mv_cache = 0;
next_battery_sample_ms = 0;
return 0;
}
if (force_refresh || !_battery_sample_valid || next_battery_sample_ms == 0 || millisHasNowPassed(next_battery_sample_ms)) { if (force_refresh || !_battery_sample_valid || next_battery_sample_ms == 0 || millisHasNowPassed(next_battery_sample_ms)) {
_battery_mv_cache = board.getBattMilliVolts(); _battery_mv_cache = board.getBattMilliVolts();
_battery_sample_valid = true; _battery_sample_valid = true;
+1 -3
Dosyayı Görüntüle
@@ -652,8 +652,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.gps_enabled = 0; _prefs.gps_enabled = 0;
_prefs.gps_interval = 0; _prefs.gps_interval = 0;
_prefs.advert_loc_policy = ADVERT_LOC_PREFS; _prefs.advert_loc_policy = ADVERT_LOC_PREFS;
_prefs.battery_reporting_enabled = 1; _prefs.reserved_290 = 0;
next_post_idx = 0; next_post_idx = 0;
next_client_idx = 0; next_client_idx = 0;
next_push = 0; next_push = 0;
@@ -699,7 +698,6 @@ void MyMesh::begin(FILESYSTEM *fs) {
updateFloodAdvertTimer(); updateFloodAdvertTimer();
board.setAdcMultiplier(_prefs.adc_multiplier); board.setAdcMultiplier(_prefs.adc_multiplier);
board.setBatteryReporting(_prefs.battery_reporting_enabled);
#if ENV_INCLUDE_GPS == 1 #if ENV_INCLUDE_GPS == 1
applyGpsPrefs(); applyGpsPrefs();
+1 -2
Dosyayı Görüntüle
@@ -731,7 +731,7 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
_prefs.gps_enabled = 0; _prefs.gps_enabled = 0;
_prefs.gps_interval = 0; _prefs.gps_interval = 0;
_prefs.advert_loc_policy = ADVERT_LOC_PREFS; _prefs.advert_loc_policy = ADVERT_LOC_PREFS;
_prefs.battery_reporting_enabled = 1; _prefs.reserved_290 = 0;
memset(default_scope.key, 0, sizeof(default_scope.key)); memset(default_scope.key, 0, sizeof(default_scope.key));
} }
@@ -771,7 +771,6 @@ void SensorMesh::begin(FILESYSTEM* fs) {
updateFloodAdvertTimer(); updateFloodAdvertTimer();
board.setAdcMultiplier(_prefs.adc_multiplier); board.setAdcMultiplier(_prefs.adc_multiplier);
board.setBatteryReporting(_prefs.battery_reporting_enabled);
#if ENV_INCLUDE_GPS == 1 #if ENV_INCLUDE_GPS == 1
applyGpsPrefs(); applyGpsPrefs();
+3
Dosyayı Görüntüle
@@ -418,6 +418,9 @@ releases:
- type: fixed - type: fixed
area: board-support area: board-support
text: "Reduced Heltec V3 battery-sense activity while MQTT and web features are active, while still keeping explicit status and telemetry requests on a fresh reading path." text: "Reduced Heltec V3 battery-sense activity while MQTT and web features are active, while still keeping explicit status and telemetry requests on a fresh reading path."
- type: changed
area: board-support
text: "Removed the obsolete battery reporting toggle path and its stale CLI documentation now that repeater battery sampling is handled correctly without a board-level reporting disable switch."
- type: docs - type: docs
area: docs area: docs
text: "Updated the custom CLI docs to note that repeater MQTT background battery sampling is now rate-limited while explicit status and telemetry requests still refresh immediately." text: "Updated the custom CLI docs to note that repeater MQTT background battery sampling is now rate-limited while explicit status and telemetry requests still refresh immediately."
-3
Dosyayı Görüntüle
@@ -44,9 +44,6 @@ namespace mesh {
class MainBoard { class MainBoard {
public: public:
virtual uint16_t getBattMilliVolts() = 0; virtual uint16_t getBattMilliVolts() = 0;
virtual bool supportsBatteryReporting() const { return false; }
virtual bool setBatteryReporting(bool enabled) { (void)enabled; return false; }
virtual bool isBatteryReportingEnabled() const { return true; }
virtual int getBatteryPercent() { return -1; } virtual int getBatteryPercent() { return -1; }
virtual bool isCharging() { return false; } virtual bool isCharging() { return false; }
virtual bool isVbusPresent() { return false; } virtual bool isVbusPresent() { return false; }
+3 -4
Dosyayı Görüntüle
@@ -87,8 +87,8 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
file.read((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162 file.read((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
file.read((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166 file.read((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
file.read((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170 file.read((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170
if (file.available() >= (int)sizeof(_prefs->battery_reporting_enabled)) { if (file.available() >= (int)sizeof(_prefs->reserved_290)) {
file.read((uint8_t *)&_prefs->battery_reporting_enabled, sizeof(_prefs->battery_reporting_enabled)); // 290 file.read((uint8_t *)&_prefs->reserved_290, sizeof(_prefs->reserved_290)); // 290 reserved
} }
if (file.available() >= (int)sizeof(_prefs->rx_boosted_gain)) { if (file.available() >= (int)sizeof(_prefs->rx_boosted_gain)) {
file.read((uint8_t *)&_prefs->rx_boosted_gain, sizeof(_prefs->rx_boosted_gain)); // 291 file.read((uint8_t *)&_prefs->rx_boosted_gain, sizeof(_prefs->rx_boosted_gain)); // 291
@@ -123,7 +123,6 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
_prefs->bridge_channel = constrain(_prefs->bridge_channel, 0, 14); _prefs->bridge_channel = constrain(_prefs->bridge_channel, 0, 14);
_prefs->powersaving_enabled = constrain(_prefs->powersaving_enabled, 0, 1); _prefs->powersaving_enabled = constrain(_prefs->powersaving_enabled, 0, 1);
_prefs->battery_reporting_enabled = constrain(_prefs->battery_reporting_enabled, 0, 1);
_prefs->gps_enabled = constrain(_prefs->gps_enabled, 0, 1); _prefs->gps_enabled = constrain(_prefs->gps_enabled, 0, 1);
_prefs->advert_loc_policy = constrain(_prefs->advert_loc_policy, 0, 2); _prefs->advert_loc_policy = constrain(_prefs->advert_loc_policy, 0, 2);
@@ -192,7 +191,7 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
file.write((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162 file.write((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
file.write((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166 file.write((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
file.write((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170 file.write((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170
file.write((uint8_t *)&_prefs->battery_reporting_enabled, sizeof(_prefs->battery_reporting_enabled)); // 290 file.write((uint8_t *)&_prefs->reserved_290, sizeof(_prefs->reserved_290)); // 290 reserved
file.write((uint8_t *)&_prefs->rx_boosted_gain, sizeof(_prefs->rx_boosted_gain)); // 291 file.write((uint8_t *)&_prefs->rx_boosted_gain, sizeof(_prefs->rx_boosted_gain)); // 291
file.write((uint8_t *)&_prefs->fan_mode, sizeof(_prefs->fan_mode)); // 292 file.write((uint8_t *)&_prefs->fan_mode, sizeof(_prefs->fan_mode)); // 292
file.write((uint8_t *)&_prefs->fan_timeout_secs, sizeof(_prefs->fan_timeout_secs)); // 293 file.write((uint8_t *)&_prefs->fan_timeout_secs, sizeof(_prefs->fan_timeout_secs)); // 293
+1 -1
Dosyayı Görüntüle
@@ -58,7 +58,7 @@ struct NodePrefs { // persisted to file
uint32_t discovery_mod_timestamp; uint32_t discovery_mod_timestamp;
float adc_multiplier; float adc_multiplier;
char owner_info[120]; char owner_info[120];
uint8_t battery_reporting_enabled; // boolean uint8_t reserved_290; // reserved to preserve on-disk prefs layout
uint8_t rx_boosted_gain; // power settings uint8_t rx_boosted_gain; // power settings
uint8_t path_hash_mode; // which path mode to use when sending uint8_t path_hash_mode; // which path mode to use when sending
uint8_t loop_detect; uint8_t loop_detect;
-19
Dosyayı Görüntüle
@@ -22,13 +22,11 @@
class HeltecV3Board : public ESP32Board { class HeltecV3Board : public ESP32Board {
private: private:
bool adc_active_state; bool adc_active_state;
bool battery_reporting_enabled;
public: public:
RefCountedDigitalPin periph_power; RefCountedDigitalPin periph_power;
HeltecV3Board() : adc_active_state(false), HeltecV3Board() : adc_active_state(false),
battery_reporting_enabled(true),
periph_power(PIN_VEXT_EN) { } periph_power(PIN_VEXT_EN) { }
void begin() { void begin() {
@@ -83,10 +81,6 @@ public:
} }
uint16_t getBattMilliVolts() override { uint16_t getBattMilliVolts() override {
if (!battery_reporting_enabled) {
return 0;
}
analogReadResolution(10); analogReadResolution(10);
digitalWrite(PIN_ADC_CTRL, adc_active_state); digitalWrite(PIN_ADC_CTRL, adc_active_state);
@@ -109,19 +103,6 @@ public:
return mv; return mv;
} }
bool supportsBatteryReporting() const override {
return true;
}
bool setBatteryReporting(bool enabled) override {
battery_reporting_enabled = enabled;
return true;
}
bool isBatteryReportingEnabled() const override {
return battery_reporting_enabled;
}
const char* getManufacturerName() const override { const char* getManufacturerName() const override {
return "Heltec V3"; return "Heltec V3";
} }