Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Jun 18, 2024
1 parent f7dee82 commit 2852fe3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/include/zmk/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions app/src/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2852fe3

Please sign in to comment.