fix(bluetooth): Remove identity, minimal bt.

* Simplify the `bt` behavior to one current command
  `BT_CLEAR_BONDS_CMD`.
* Simplify BLE code for split and non-split keyboards.
* Remove keymap processing from split peripheral side.
This commit is contained in:
Pete Johanson
2020-09-01 23:22:30 -04:00
parent a4d06f69ac
commit fc0812bd2e
8 changed files with 52 additions and 232 deletions

View File

@@ -6,7 +6,8 @@ sidebar_label: Bluetooth
## Summary
The bluetooth behavior allows management of various settings and states related to the bluetooth connection(s)
between the keyboard and the host.
between the keyboard and the host. As of right now, there is only one such action support, but in the future
more will be added.
## Bluetooth Command Defines
@@ -17,31 +18,20 @@ which is added at the top of the keymap file:
#include <dt-bindings/zmk/bt.h>
```
This will allow you to reference the actions defined in this header such as `BT_IDENT_CLR_CMD`.
This will allow you to reference the actions defined in this header such as `BT_CLEAR_BONDS_CMD`.
Here is a table describing the command for each define:
| Define | Action |
| ------------------- | ----------------------------------------------------- |
| `BT_IDENT_CLR_CMD` | Clear paired keyboards (for the current identity)[^1] |
| `BT_IDENT_NEXT_CMD` | Switch to the next identity[^1] |
| `BT_IDENT_PREV_CMD` | Switch to the previous identity |
| `BT_IDENT_SEL_CMD` | Switch to a specific numbered identity |
| `BT_RST_CMD` | Hard reset of all bluetooth bonds |
| Define | Action |
| -------------------- | --------------------------------------------------------- |
| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host [^1] |
Because the `BT_IDENT_SEL_CMD` command takes an additional parameter, the numeric index of the identity to select, _all_ the commands for the bluetooth behavior must take that additional parameter, and ignore the value. To make this easier,
there are alias defines that add those default parameters for you:
Because future bluetooth commands will take an additional parameter, it is recommended to use
the following alias in your keymap to avoid having to change it later.
| Define | Action |
| --------------- | --------------------------------------------------------------------------------------- |
| `BT_IDENT_CLR` | Alias for `BT_IDENT_CLR_CMD 0` to clear paired keyboards (for the current identity)[^1] |
| `BT_IDENT_NEXT` | Alias for `BT_IDENT_NEXT_CMD 0` to switch to the next identity[^1] |
| `BT_IDENT_PREV` | Alias for `BT_IDENT_PREV_CMD 0` to switch to the previous identity |
| `BT_IDENT_SEL` | Alias for `BT_IDENT_SEL_CMD` to switch to a specific numbered identity |
| `BT_RST` | Alias for `BT_RST_CMD 0` to reset all bonds[^2] |
[^1]: Multiple keyboard identities/profiles is only support on non-split keyboards as of this time.
[^2]: This may interrupt pairing between both halves of a split keyboard. For split keyboards, it is preferred to use the [/docs/bond-reset] combo to clear bonds on both devices
| Define | Action |
| ---------------- | ---------------------------------------------------------------------- |
| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the bond to the current host |
## Bluetooth Behavior
@@ -50,33 +40,13 @@ The bluetooth behavior completes an bluetooth action given on press.
### Behavior Binding
- Reference: `&bt`
- Parameter #1: The bluetooth command define, e.g. `BT_IDENT_CLR_CMD` or `BT_RST_CMD`
- Parameter #2: The parameter for the command, when used to identify an identity/profile to select, e.g. `0`
- Parameter #1: The bluetooth command define, e.g. `BT_CLEAR_BONDS_CMD`
- Parameter #2: (Reserved for future bluetooth command types)
### Examples
1. Behavior to clear the paired host:
```
&bt BT_IDENT_CLR
```
1. Behavior to hard reset all bonded devices[^2]:
```
&bt BT_IDENT_CLR
```
Examples for non-split keyboards with multiple identities:
1. Behavior to switch to the next identity:
```
&bt BT_IDENT_NEXT
```
1. Behavior to switch to the specific numbered identity:
```
&bt BT_IDENT_SEL 1
&bt BT_CLEAR_BONDS
```