Browse Source

Merge pull request #357 from petejohanson/ble/remove-unpair-combo

fix(ble): Remove unpair combo code.
xmkb
Pete Johanson 4 years ago committed by GitHub
parent
commit
0031f9bd4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/CMakeLists.txt
  2. 4
      app/boards/shields/corne/corne.dtsi
  3. 4
      app/boards/shields/corne/corne_left.overlay
  4. 4
      app/boards/shields/corne/corne_right.overlay
  5. 4
      app/boards/shields/iris/iris.dtsi
  6. 4
      app/boards/shields/iris/iris_left.overlay
  7. 4
      app/boards/shields/iris/iris_right.overlay
  8. 4
      app/boards/shields/kyria/kyria.dtsi
  9. 4
      app/boards/shields/kyria/kyria_left.overlay
  10. 4
      app/boards/shields/kyria/kyria_right.overlay
  11. 4
      app/boards/shields/lily58/lily58.dtsi
  12. 4
      app/boards/shields/lily58/lily58_left.overlay
  13. 4
      app/boards/shields/lily58/lily58_right.overlay
  14. 6
      app/boards/shields/m60/m60.overlay
  15. 6
      app/boards/shields/romac/romac.overlay
  16. 4
      app/boards/shields/sofle/sofle.dtsi
  17. 4
      app/boards/shields/sofle/sofle_left.overlay
  18. 4
      app/boards/shields/sofle/sofle_right.overlay
  19. 12
      app/dts/bindings/zmk,bt-unpair-combo.yaml
  20. 76
      app/src/ble_unpair_combo.c
  21. BIN
      docs/docs/assets/bond-clearing/corne.jpg
  22. 0
      docs/docs/assets/bond-clearing/debug.log
  23. BIN
      docs/docs/assets/bond-clearing/kyria.jpg
  24. BIN
      docs/docs/assets/bond-clearing/lily58.jpg
  25. 30
      docs/docs/bond-reset.md
  26. 2
      docs/docs/user-setup.md

1
app/CMakeLists.txt

@ -30,7 +30,6 @@ target_sources(app PRIVATE src/hid.c)
target_sources(app PRIVATE src/sensors.c) target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c)
target_sources(app PRIVATE src/event_manager.c) target_sources(app PRIVATE src/event_manager.c)
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c)
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c) target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c)
target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c)

4
app/boards/shields/corne/corne.dtsi

@ -58,10 +58,6 @@ RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
// TODO: per-key RGB node(s)? // TODO: per-key RGB node(s)?
}; };

4
app/boards/shields/corne/corne_left.overlay

@ -16,7 +16,3 @@
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH> , <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
; ;
}; };
&bt_unpair_combo {
key-positions = <0 38>;
};

4
app/boards/shields/corne/corne_right.overlay

@ -20,7 +20,3 @@
, <&pro_micro_a 3 GPIO_ACTIVE_HIGH> , <&pro_micro_a 3 GPIO_ACTIVE_HIGH>
; ;
}; };
&bt_unpair_combo {
key-positions = <11 39>;
};

4
app/boards/shields/iris/iris.dtsi

@ -44,8 +44,4 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7)
; ;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
}; };

4
app/boards/shields/iris/iris_left.overlay

@ -16,7 +16,3 @@
, <&pro_micro_d 10 GPIO_ACTIVE_HIGH> , <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
; ;
}; };
&bt_unpair_combo {
key-positions = <0 42>;
};

4
app/boards/shields/iris/iris_right.overlay

@ -20,7 +20,3 @@
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH> , <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
; ;
}; };
&bt_unpair_combo {
key-positions = <11 43>;
};

4
app/boards/shields/kyria/kyria.dtsi

@ -81,10 +81,6 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9)
sensors = <&left_encoder &right_encoder>; sensors = <&left_encoder &right_encoder>;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
// TODO: RGB node(s) // TODO: RGB node(s)
}; };

4
app/boards/shields/kyria/kyria_left.overlay

@ -22,7 +22,3 @@
&left_encoder { &left_encoder {
status = "okay"; status = "okay";
}; };
&bt_unpair_combo {
key-positions = <0 44>;
};

4
app/boards/shields/kyria/kyria_right.overlay

@ -27,7 +27,3 @@
&right_encoder { &right_encoder {
status = "okay"; status = "okay";
}; };
&bt_unpair_combo {
key-positions = <11 45>;
};

4
app/boards/shields/lily58/lily58.dtsi

@ -57,10 +57,6 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
compatible = "zmk,keymap-sensors"; compatible = "zmk,keymap-sensors";
sensors = <&left_encoder>; sensors = <&left_encoder>;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
}; };
&pro_micro_i2c { &pro_micro_i2c {

4
app/boards/shields/lily58/lily58_left.overlay

@ -20,7 +20,3 @@
&left_encoder { &left_encoder {
status = "okay"; status = "okay";
}; };
&bt_unpair_combo {
key-positions = <0 53>;
};

4
app/boards/shields/lily58/lily58_right.overlay

@ -20,7 +20,3 @@
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH> , <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
; ;
}; };
&bt_unpair_combo {
key-positions = <11 54>;
};

6
app/boards/shields/m60/m60.overlay

@ -56,11 +56,5 @@ RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) RC(5,7) RC(5,6) RC(5,5) RC(5,4) RC
RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4) RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4)
>; >;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
key-positions = <0 53>;
};
}; };

6
app/boards/shields/romac/romac.overlay

@ -30,11 +30,5 @@
; ;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
key-positions = <0 11>;
};
}; };

4
app/boards/shields/sofle/sofle.dtsi

@ -66,10 +66,6 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
compatible = "zmk,keymap-sensors"; compatible = "zmk,keymap-sensors";
sensors = <&left_encoder &right_encoder>; sensors = <&left_encoder &right_encoder>;
}; };
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
}; };
&pro_micro_i2c { &pro_micro_i2c {

4
app/boards/shields/sofle/sofle_left.overlay

@ -20,7 +20,3 @@
&left_encoder { &left_encoder {
status = "okay"; status = "okay";
}; };
&bt_unpair_combo {
key-positions = <0 54>;
};

4
app/boards/shields/sofle/sofle_right.overlay

@ -24,7 +24,3 @@
&right_encoder { &right_encoder {
status = "okay"; status = "okay";
}; };
&bt_unpair_combo {
key-positions = <11 55>;
};

12
app/dts/bindings/zmk,bt-unpair-combo.yaml

@ -1,12 +0,0 @@
# Copyright (c) 2020, Pete Johanson
# SPDX-License-Identifier: MIT
description: |
Defines a set of key positions that will unpair all BT devices if held on startup.
compatible: "zmk,bt-unpair-combo"
properties:
key-positions:
type: array
required: true

76
app/src/ble_unpair_combo.c

@ -1,76 +0,0 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <device.h>
#include <init.h>
#define DT_DRV_COMPAT zmk_bt_unpair_combo
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
#include <logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/ble.h>
#include <zmk/event-manager.h>
#include <zmk/events/position-state-changed.h>
static u8_t combo_state;
const u32_t key_positions[] = DT_INST_PROP(0, key_positions);
#define KP_LEN DT_INST_PROP_LEN(0, key_positions)
int index_for_key_position(u32_t kp) {
for (int i = 0; i < KP_LEN; i++) {
if (key_positions[i] == kp) {
return i;
}
}
return -1;
}
int unpair_combo_listener(const struct zmk_event_header *eh) {
if (is_position_state_changed(eh)) {
const struct position_state_changed *psc = cast_position_state_changed(eh);
int kp_index = index_for_key_position(psc->position);
if (kp_index < 0) {
return 0;
}
WRITE_BIT(combo_state, kp_index, psc->state);
}
return 0;
};
void unpair_combo_work_handler(struct k_work *work) {
for (int i = 0; i < KP_LEN; i++) {
if (!(combo_state & BIT(i))) {
LOG_DBG("Key position %d not held, skipping unpair combo", key_positions[i]);
return;
}
}
zmk_ble_unpair_all();
};
struct k_delayed_work unpair_combo_work;
int zmk_ble_unpair_combo_init(struct device *_unused) {
k_delayed_work_init(&unpair_combo_work, unpair_combo_work_handler);
k_delayed_work_submit(&unpair_combo_work, K_SECONDS(2));
return 0;
};
ZMK_LISTENER(zmk_ble_unpair_combo, unpair_combo_listener);
ZMK_SUBSCRIPTION(zmk_ble_unpair_combo, position_state_changed);
SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

BIN
docs/docs/assets/bond-clearing/corne.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

0
docs/docs/assets/bond-clearing/debug.log

BIN
docs/docs/assets/bond-clearing/kyria.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

BIN
docs/docs/assets/bond-clearing/lily58.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

30
docs/docs/bond-reset.md

@ -1,30 +0,0 @@
---
id: bond-reset
title: Reset BLE Connections (DEPRECATED)
sidebar_label: BLE Reset (DEPRECATED)
---
Known as a 'bond reset', each keyboard has a special key combination independent of the user defined key map which will
clear all wireless connection configurations. The keys must be held for 3 to 5 seconds after the device is
reset.
:::warning
Currently, ZMK only supports a single BLE host. If you remove the keyboard from the host's bluetooth devices
list, you will need to clear the bonds.
:::
## Split Keyboards
Split keyboards will need to be cleared on both halves. For best results try to reset them at the same time.
### Kyria
![Kyria bond-reset combo](assets/bond-clearing/kyria.jpg)
### Corne
![Corne bond-reset combo](assets/bond-clearing/corne.jpg)
### Lily58
![Lily58 bond-reset combo](assets/bond-clearing/lily58.jpg)

2
docs/docs/user-setup.md

@ -194,7 +194,7 @@ storage device. Once the flash is complete, the controller should automatically
## Wirelessly Connecting Your Keyboard ## Wirelessly Connecting Your Keyboard
Connecting your keyboard wirelessly is the same as adding other Bluetooth devides: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. Connecting your keyboard wirelessly is the same as adding other Bluetooth devides: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently.
### Connecting Split Keyboard Halves ### Connecting Split Keyboard Halves

Loading…
Cancel
Save