feat(ble): Support perhipheral battery levels.

* Add ability to fetch and report peripheral battery levels
  on split centrals.
* Add additional support for adding a new Battery Level
  service to split centrals that exposes fetched peripheral
  battery levels to connected hosts.

Co-authored-by: Peter Johanson <peter@peterjohanson.com>
This commit is contained in:
Gabor Hornyak
2022-03-29 21:20:52 +00:00
committed by Pete Johanson
parent d35311af97
commit 0e2f94b73b
9 changed files with 299 additions and 21 deletions

View File

@@ -63,8 +63,9 @@ void battery_status_update_cb(struct battery_status_state state) {
}
static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
const struct zmk_battery_state_changed *ev = as_zmk_battery_state_changed(eh);
return (struct battery_status_state) {
.level = bt_bas_get_battery_level(),
.level = ev->state_of_charge,
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */