This is an automated email from the ASF dual-hosted git repository. janc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push: new 262546918 host/services/bas: some minor fixes 262546918 is described below commit 26254691863b90aeec0947c5ff238ae4fb6b2aa9 Author: Gerard Marull-Paretas <ger...@teslabs.com> AuthorDate: Thu Aug 7 14:04:32 2025 +0200 host/services/bas: some minor fixes - Internal battery level can be `static` - s/tabs/spaces - Initialize battery level to 0 when initializing the service Signed-off-by: Gerard Marull-Paretas <ger...@teslabs.com> --- nimble/host/services/bas/src/ble_svc_bas.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nimble/host/services/bas/src/ble_svc_bas.c b/nimble/host/services/bas/src/ble_svc_bas.c index 631519cf9..b49eb862e 100644 --- a/nimble/host/services/bas/src/ble_svc_bas.c +++ b/nimble/host/services/bas/src/ble_svc_bas.c @@ -32,7 +32,7 @@ static uint16_t ble_svc_bas_battery_handle; #endif /* Battery level */ -uint8_t ble_svc_bas_battery_level; +static uint8_t ble_svc_bas_battery_level; /* Access function */ static int @@ -98,9 +98,9 @@ ble_svc_bas_access(uint16_t conn_handle, uint16_t attr_handle, int ble_svc_bas_battery_level_set(uint8_t level) { if (level > 100) - level = 100; + level = 100; if (ble_svc_bas_battery_level != level) { - ble_svc_bas_battery_level = level; + ble_svc_bas_battery_level = level; #if MYNEWT_VAL(BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE) > 0 ble_gatts_chr_updated(ble_svc_bas_battery_handle); #endif @@ -119,6 +119,8 @@ ble_svc_bas_init(void) /* Ensure this function only gets called by sysinit. */ SYSINIT_ASSERT_ACTIVE(); + ble_svc_bas_battery_level = 0; + rc = ble_gatts_count_cfg(ble_svc_bas_defs); SYSINIT_PANIC_ASSERT(rc == 0);