feat(bluetooth): bootloader after settings reset

This commit is contained in:
ReFil 2022-10-11 11:35:40 +01:00 committed by ReFil
parent bdc706f88d
commit c49da513b4
4 changed files with 19 additions and 0 deletions

View file

@ -143,6 +143,11 @@ config ZMK_BLE_CLEAR_BONDS_ON_START
bool "Configuration that clears all bond information from the keyboard on startup." bool "Configuration that clears all bond information from the keyboard on startup."
default n default n
config ZMK_BOOTLOADER_BLE_CLEAR_BONDS
bool "Configuration that resets to bootloader after clearing all bond information"
depends on ZMK_BLE_CLEAR_BONDS_ON_START
default n
# HID GATT notifications sent this way are *not* picked up by Linux, and possibly others. # HID GATT notifications sent this way are *not* picked up by Linux, and possibly others.
config BT_GATT_NOTIFY_MULTIPLE config BT_GATT_NOTIFY_MULTIPLE
default n default n

View file

@ -1 +1,2 @@
CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y
CONFIG_ZMK_BOOTLOADER_BLE_CLEAR_BONDS=y

View file

@ -47,6 +47,10 @@ static uint8_t passkey_digit = 0;
#endif /* IS_ENABLED(CONFIG_ZMK_BLE_PASSKEY_ENTRY) */ #endif /* IS_ENABLED(CONFIG_ZMK_BLE_PASSKEY_ENTRY) */
#if IS_ENABLED(CONFIG_ZMK_BOOTLOADER_BLE_CLEAR_BONDS)
#include <sys/reboot.h>
#endif
#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) #if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
#define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1) #define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1)
#else #else
@ -585,6 +589,11 @@ static int zmk_ble_init(const struct device *_arg) {
LOG_ERR("Failed to delete setting: %d", err); LOG_ERR("Failed to delete setting: %d", err);
} }
} }
#if IS_ENABLED(CONFIG_ZMK_BOOTLOADER_BLE_CLEAR_BONDS)
LOG_WRN("Clearing completed, rebooting to bootloader");
sys_reboot(0x57);
#endif
#endif #endif
bt_conn_cb_register(&conn_callbacks); bt_conn_cb_register(&conn_callbacks);

View file

@ -116,6 +116,10 @@ static int zmk_peripheral_ble_init(const struct device *_arg) {
LOG_WRN("Clearing all existing BLE bond information from the keyboard"); LOG_WRN("Clearing all existing BLE bond information from the keyboard");
bt_unpair(BT_ID_DEFAULT, NULL); bt_unpair(BT_ID_DEFAULT, NULL);
#if IS_ENABLED(CONFIG_ZMK_BOOTLOADER_BLE_CLEAR_BONDS)
LOG_WRN("Clearing completed, rebooting to bootloader");
sys_reboot(0x57);
#endif
#endif #endif
bt_conn_cb_register(&conn_callbacks); bt_conn_cb_register(&conn_callbacks);