Skip to content

Comments

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

Open
just-stuff-tm wants to merge 1 commit intozjs81:mainfrom
just-stuff-tm:issue-174-battery-status-vs-telemetry
Open

Fix repeater battery % inconsistency and add configurable repeater battery chemistry#199
just-stuff-tm wants to merge 1 commit intozjs81:mainfrom
just-stuff-tm:issue-174-battery-status-vs-telemetry

Conversation

@just-stuff-tm
Copy link
Contributor

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

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 zjs81#116

Refs zjs81#174
@just-stuff-tm
Copy link
Contributor Author

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

@just-stuff-tm
Copy link
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
Copy link
Collaborator

446564 commented Feb 19, 2026

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

I'll be able to test tomorrow morning.

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.

2 participants