Skip to content

Add optional charging flag to companion battery response#1710

Open
Specter242 wants to merge 2 commits intomeshcore-dev:mainfrom
Specter242:feature/companion-battery-charging-flag
Open

Add optional charging flag to companion battery response#1710
Specter242 wants to merge 2 commits intomeshcore-dev:mainfrom
Specter242:feature/companion-battery-charging-flag

Conversation

@Specter242
Copy link

@Specter242 Specter242 commented Feb 16, 2026

Summary

  • append an optional is_charging byte to RESP_CODE_BATT_AND_STORAGE (0x0C) in companion firmware payloads
  • source the value from board external power state (MainBoard::isExternalPowered()), so no command code changes are required
  • add a T1000-E override for isExternalPowered() that reads EXT_PWR_DETECT and EXT_CHRG_DETECT for accurate charging/power detection on this hardware
  • update companion protocol docs (PACKET_BATTERY) to document the new optional field and backward-compatible parsing

Compatibility

  • existing clients remain compatible because the new byte is appended at the end of the response frame
  • legacy parsers that read only existing bytes continue to work unchanged
  • updated parsers can read is_charging only when frame length is >= 12

Test Plan

  • Build companion firmware target for Seeed T1000-E: pio run -e t1000e_companion_radio_ble
  • Verify on-device with external power connected: is_charging == 1 (app charging icon visible)
  • Verify on-device on battery only: is_charging == 0
  • Confirm legacy app/client parsing remains stable with optional trailing byte

Made with Cursor

Specter242 and others added 2 commits February 15, 2026 19:37
Append an optional is_charging byte to RESP_CODE_BATT_AND_STORAGE using board external power state so clients can render a charging indicator without breaking older parsers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use T1000-E specific EXT_PWR_DETECT and EXT_CHRG_DETECT lines in isExternalPowered() so the companion battery charging byte reflects actual hardware charging/power state on this board.

Co-authored-by: Cursor <cursoragent@cursor.com>

bool T1000eBoard::isExternalPowered() {
// T1000-E exposes dedicated detect lines for external power and charge state.
// Use these first, then fall back to NRF52 USB VBUS detection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does NRF52 fallback provide us with anything? Wouldn't it always be false currently? :)

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