Skip to content

Fix repeater battery % inconsistency and add configurable repeater battery chemistry#199

Merged
wel97459 merged 4 commits into
zjs81:mainfrom
just-stuff-tm:issue-174-battery-status-vs-telemetry
Feb 21, 2026
Merged

Fix repeater battery % inconsistency and add configurable repeater battery chemistry#199
wel97459 merged 4 commits into
zjs81:mainfrom
just-stuff-tm:issue-174-battery-status-vs-telemetry

Conversation

@just-stuff-tm

@just-stuff-tm just-stuff-tm commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses two related repeater battery issues:

What Changed

  • Added shared battery utility:
    • lib/utils/battery_utils.dart
    • Centralizes voltage-range mapping and percent estimation by chemistry
  • Updated companion/device battery % path to use shared utility:
    • lib/connector/meshcore_connector.dart
  • Added repeater battery chemistry persistence:
    • lib/models/app_settings.dart
    • lib/services/app_settings_service.dart
    • New map: batteryChemistryByRepeaterId
    • New APIs: batteryChemistryForRepeater, setBatteryChemistryForRepeater
  • Added repeater chemistry selector in Repeater Hub:
    • lib/screens/repeater_hub_screen.dart
  • Unified repeater battery % calculation in both screens:
    • lib/screens/repeater_status_screen.dart
    • lib/screens/telemetry_screen.dart
    • Both now use the same shared math + selected repeater chemistry

Why

Previously, status and telemetry used different hardcoded voltage ranges, so battery % differed for the same battery voltage. This PR removes duplicated logic and ensures both screens compute the same value using a user-selected chemistry.

Tests / Validation

  • Added tests:
    • test/utils/battery_utils_test.dart
  • Verified:
    • flutter analyze passes for changed files
    • flutter test test/utils/battery_utils_test.dart passes

Notes

  • No BLE protocol/frame format changes.
  • Translation method remains consistent with existing project usage (context.l10n), and no new localization keys were introduced.

Closes

…ry setting

- Add shared battery percent utility used by connector, repeater status, and telemetry

- Add repeater-specific battery chemistry persistence and service accessors

- Add repeater chemistry selector in Repeater Hub

- Ensure telemetry and status compute percentages consistently from same chemistry

- Add focused battery utility tests

Refs #116

Refs #174
@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

@446564 @wel97459 @zjs81 or anyone who wants to take the time, can you review?

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

Screenshot_20260219-183330.png

Screenshot_20260219-183312.png

Screenshot_20260219-183325.png

@just-stuff-tm just-stuff-tm marked this pull request as ready for review February 19, 2026 23:38
@446564

446564 commented Feb 19, 2026

Copy link
Copy Markdown
Collaborator

@446564 @wel97459 @zjs81 or anyone who wants to take the time, can you review?

I'll be able to test tomorrow morning.

@just-stuff-tm

just-stuff-tm commented Feb 21, 2026

Copy link
Copy Markdown
Contributor Author

This fix for #174 fully unifies repeater battery display between Repeater Status and Telemetry by introducing a shared battery snapshot source in MeshCoreConnector. Both screens now publish and consume the same millivolt value, so percentage and voltage formatting are derived from the same canonical data path. Any residual variation (±3%) is due to request timing, not different calculations.

It also includes a new feature which allows users to change battery chemistry on repeaters.... #116

@wel97459 wel97459 merged commit 061b715 into zjs81:main Feb 21, 2026
6 checks passed
@just-stuff-tm just-stuff-tm deleted the issue-174-battery-status-vs-telemetry branch February 21, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants