Add a 'batt' CLI command to report battery voltage locally - #3297
Open
andyhoobing wants to merge 1 commit into
Open
Add a 'batt' CLI command to report battery voltage locally#3297andyhoobing wants to merge 1 commit into
andyhoobing wants to merge 1 commit into
Conversation
Battery voltage was only reachable over the mesh, via REQ_TYPE_GET_STATUS in the repeater/room-server stats reply. That means a headless node on the bench cannot be checked at all without a second radio to query it -- which is exactly the situation when bringing up a new repeater. 'batt' returns the same value the node already reports in its stats, from MainBoard::getBattMilliVolts(), which every board implements. No new board API, no per-variant work, and nothing gated on NRF52_POWER_MANAGEMENT (that path is unavailable on variants like ThinkNode M6, where the existing pwrmgt.* keys return "unsupported"). Documented in docs/cli_commands.md alongside 'board', including the caveat that the reading reflects charging voltage while on USB. Verified: ThinkNode_M6_repeater, ThinkNode_M6_room_server and RAK_4631_repeater all build, and the command returns a plausible reading on real ThinkNode M6 hardware. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H7b3E6KcBEGZ2zr2jZMrBL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Battery voltage is currently only reachable over the mesh, via
REQ_TYPE_GET_STATUSin the repeater / room-server stats reply. There is no wayto read it from the serial console.
That makes it unavailable in exactly the situation where you most want it:
bringing up a new headless node. A repeater has no screen, no button and (in the
repeater build) no BLE, so checking its battery requires a second radio to query
it over the air. On a solar node that is the first number you want to look at.
The existing
pwrmgt.*get-keys do not fill this gap — they are gated behindNRF52_POWER_MANAGEMENT, which many variants (ThinkNode M6 among them) do notenable, and they report boot voltage rather than a live reading:
Change
Adds a
battcommand that returns the live reading:It calls
MainBoard::getBattMilliVolts(), which is pure-virtual and alreadyimplemented by every board, and returns the same value the node already reports
in its stats. No new board API, no per-variant work, nothing gated on
NRF52_POWER_MANAGEMENT.Documented in
docs/cli_commands.mdalongsideboard, including the caveatthat the value reflects charging voltage while the node is on USB.
Testing
ThinkNode_M6_repeater,ThinkNode_M6_room_serverandRAK_4631_repeaterall build against
dev(the change is in shared CLI code, so a non-M6 boardwas built deliberately).
batt -> 4174 mV, consistent with anear-full 18650 pack on USB charge.
.clang-formatclean.Note on process
CONTRIBUTING.mdasks for an issue first on new features, and this istechnically a new command rather than a bug fix. I've opened it directly since
it is 5 lines against an existing interface with no new API surface — but very
happy to close this and file an issue instead if you would rather discuss the
idea first, or if you would prefer this exposed as
get battfor consistencywith the other read-only values rather than as a top-level command.
Authored with assistance from Claude (see
Co-Authored-Bytrailer).