markqvist / RNode_Firmware

RNode is an open, free and flexible digital radio interface with many uses
https://unsigned.io/rnode
GNU General Public License v3.0
145 stars 52 forks source link

Battery percentage/state accessible over serial connection #39

Closed faragher closed 9 months ago

faragher commented 1 year ago

As a feature request, I would like to be able to query the battery state over serial, similar to the way you can request the firmware version. Ideally this would take the form of adding a CMD_BATTERY_PERCENT and CMD_BATTERY_STATE which would return a percentage and BATTERY_STATE_CHARGING/DISCHARGING/CHARGED respectively.

I consider this fairly low priority, as a USB tethered node is dependent on the controller's battery state, but it does have a use state for multiple wireless nodes attached to a single hub or when a microcontroller RNS implementation is ready.

markqvist commented 9 months ago

This is now implemented in 6d26997fa4d6cefa591ba9f9273e3a096ad966cd. If battery management is available, the battery state (BATTERY_STATE_DISCHARGING=0x01, BATTERY_STATE_CHARGING=0x02 and BATTERY_STATE_CHARGED=0x03), along with the current battery percentage will be send as command CMD_STAT_BAT=0x27 approximately every 5 seconds.