From 2cf64d8ce779aed9419aa2d51fa9bb20ff29776b Mon Sep 17 00:00:00 2001 From: Dimitris Zervas Date: Tue, 15 Sep 2020 01:52:33 +0300 Subject: [PATCH] [ble] Add support to clear all current bondings --- kmk/ble.py | 5 +++++ kmk/handlers/stock.py | 5 +++++ kmk/keys.py | 1 + user_keymaps/dzervas/lab68.py | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kmk/ble.py b/kmk/ble.py index 22bef19..ab6bef5 100644 --- a/kmk/ble.py +++ b/kmk/ble.py @@ -63,3 +63,8 @@ class BLEHID(AbstractHID): return self.devices[reporting_device_const].send_report( evt[1 : report_size + 1] ) + + def clear_bonds(self): + import _bleio + + _bleio.adapter.erase_bonding() diff --git a/kmk/handlers/stock.py b/kmk/handlers/stock.py index bf0f353..30c9383 100644 --- a/kmk/handlers/stock.py +++ b/kmk/handlers/stock.py @@ -254,3 +254,8 @@ def led_mode_breathe(key, state, *args, **kwargs): state.config.led.effect_init = True state.config.led.animation_mode = 'breathing' return state + + +def bt_clear_bonds(key, state, *args, **kwargs): + state.config._hid_helper_inst.clear_bonds() + return state diff --git a/kmk/keys.py b/kmk/keys.py index 658a54c..3ba4a97 100644 --- a/kmk/keys.py +++ b/kmk/keys.py @@ -641,6 +641,7 @@ make_key(names=('LED_ANI',), on_press=handlers.led_ani) make_key(names=('LED_AND',), on_press=handlers.led_and) make_key(names=('LED_MODE_PLAIN', 'LED_M_P'), on_press=handlers.led_mode_static) make_key(names=('LED_MODE_BREATHE', 'LED_M_B'), on_press=handlers.led_mode_breathe) +make_key(names=('BT_CLEAR_BONDS', 'BT_CLR'), on_press=handlers.bt_clear_bonds) make_key( diff --git a/user_keymaps/dzervas/lab68.py b/user_keymaps/dzervas/lab68.py index be505f1..56670b7 100644 --- a/user_keymaps/dzervas/lab68.py +++ b/user_keymaps/dzervas/lab68.py @@ -61,7 +61,7 @@ keyboard.keymap = [ # `------------------------------------------------------------------------------------------+------+------' # CLR: Clear bonds [ - XXXXXXX, KC.F1, KC.F2, KC.F3, KC.F4, KC.F5, KC.F6, KC.F7, KC.F8, KC.F9, KC.F10, KC.F11, KC.F12, XXXXXXX, _______, + XXXXXXX, KC.F1, KC.F2, KC.F3, KC.F4, KC.F5, KC.F6, KC.F7, KC.F8, KC.F9, KC.F10, KC.F11, KC.F12, XXXXXXX, KC.BT_CLR, KC.TAB, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.PSCR, XXXXXXX, KC.PAUSE, _______, XXXXXXX, _______, KC.ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC.LSFT, XXXXXXX, KC.MPLY, KC.MSTP, KC.MPRV, KC.MNXT, KC.VOLD, KC.VOLU, KC.MUTE, XXXXXXX, XXXXXXX, KC.RSFT, XXXXXXX, _______, XXXXXXX,