From 2852fe315ca804d68a99396cf1ceb5dd20e552cb Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:31:42 +0100 Subject: [PATCH] Address review comments --- app/Kconfig | 2 +- app/include/zmk/ble.h | 2 +- app/src/ble.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 7857ba7b..6a285a15 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -147,7 +147,7 @@ menuconfig ZMK_BLE select BT_SMP_APP_PAIRING_ACCEPT select BT_PERIPHERAL select BT_DIS - select BT_DEVICE_NAME_DYNAMIC + imply BT_DEVICE_NAME_DYNAMIC imply BT_SETTINGS if !ARCH_POSIX imply SETTINGS if !ARCH_POSIX imply ZMK_BATTERY_REPORTING if !ARCH_POSIX diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index f03f09ca..17cb38ed 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -36,7 +36,7 @@ char *zmk_ble_active_profile_name(void); int zmk_ble_unpair_all(void); -void zmk_ble_set_device_name(char *name); +int zmk_ble_set_device_name(char *name); #if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr); diff --git a/app/src/ble.c b/app/src/ble.c index 34590532..b3cf6c79 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -319,19 +319,24 @@ bt_addr_le_t *zmk_ble_active_profile_addr(void) { return &profiles[active_profil char *zmk_ble_active_profile_name(void) { return profiles[active_profile].name; } -void zmk_ble_set_device_name(char *name) { +int zmk_ble_set_device_name(char *name) { // Copy new name to advertising parameters - bt_set_name(name); + int err = bt_set_name(name); LOG_DBG("New device name: %s", name); + if (err) { + LOG_ERR("Failed to set new device name (err %d)", err); + return err; + } if (advertising_status == ZMK_ADV_CONN) { // Stop current advertising so it can restart with new name - int err = bt_le_adv_stop(); + err = bt_le_adv_stop(); advertising_status = ZMK_ADV_NONE; if (err) { LOG_ERR("Failed to stop advertising (err %d)", err); + return err; } } - update_advertising(); + return update_advertising(); } #if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)