Add CMD_PM5_BWM_GET_BATTERY: compact structured battery telemetry

hw status's battery/BWM section (bwm_print_battery_status()) only ever
formats its numbers into free-text Dbprintf lines, unusable by any
embedded/non-terminal client. Add a new command that returns the same
SoC/voltage/current/capacity/temp/health/fault numbers as one small
packed struct via reply_ng().

Refactor the shared reads into bwm_read_battery_info() so hw status
and the new command read the same values and can't drift apart -
hw status keeps all its existing charger-detail lines (MainCtl, input
limit, VIN_DPM, charge voltage/enable) unchanged, sourced from its own
reads as before; only the fuel-gauge numbers and the two small
charger-status reads the new struct needs are now shared.

Motivated by wanting a Flipper Zero FAP battery-status test screen
(separate app repo), but this command is generic and usable by any
client, not CEP-specific.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom HarknessandClaude Sonnet 5 authored and Philippe Teuwen committed 2026-10-04 14:38:33 +02:00
1 parent ba4016d7e2
commit 5661f21d60
5 files changed
+105 -29

No files matched your search

+4
View File
@@ -987,6 +987,10 @@ typedef struct {
uint8_t bonded_count;
uint8_t bonded[BWM_BLE_BONDED_MAX][7]; // addr[6] + type, first bonded_count valid
} PACKED bwm_ble_status_t;
// PM5, read compact BWM battery telemetry (bwm_battery_info_t). Used by `hw status`'s
// underlying data source and by clients (e.g. the Flipper Zero FAP) that want the raw
// numbers instead of hw status's free-text Dbprintf lines.
#define CMD_PM5_BWM_GET_BATTERY 0x0184
#define BWM_OTA_ACTION_BEGIN 0x00
#define BWM_OTA_ACTION_WRITE 0x01
#define BWM_OTA_ACTION_END 0x02