Browse Source

refactor(bluetooth): More concise names.

xmkb
Pete Johanson 4 years ago
parent
commit
6c8b0b53f0
  1. 16
      app/include/dt-bindings/zmk/bt.h
  2. 8
      app/src/behaviors/behavior_bt.c
  3. 32
      docs/docs/behavior/bluetooth.md

16
app/include/dt-bindings/zmk/bt.h

@ -4,10 +4,10 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#define BT_CLEAR_BONDS_CMD 0 #define BT_CLR_CMD 0
#define BT_PROF_NEXT_CMD 1 #define BT_NXT_CMD 1
#define BT_PROF_PREV_CMD 2 #define BT_PRV_CMD 2
#define BT_PROF_SEL_CMD 3 #define BT_SEL_CMD 3
// #define BT_FULL_RESET_CMD 4 // #define BT_FULL_RESET_CMD 4
/* /*
@ -15,7 +15,7 @@ Note: Some future commands will include additional parameters, so we
defines these aliases up front. defines these aliases up front.
*/ */
#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 #define BT_CLR BT_CLR_CMD 0
#define BT_PROF_NEXT BT_PROF_NEXT_CMD 0 #define BT_NXT BT_NXT_CMD 0
#define BT_PROF_PREV BT_PROF_PREV_CMD 0 #define BT_PRV BT_PRV_CMD 0
#define BT_PROF_SEL BT_PROF_SEL_CMD #define BT_SEL BT_SEL_CMD

8
app/src/behaviors/behavior_bt.c

@ -22,13 +22,13 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c
{ {
switch (command) switch (command)
{ {
case BT_CLEAR_BONDS_CMD: case BT_CLR_CMD:
return zmk_ble_clear_bonds(); return zmk_ble_clear_bonds();
case BT_PROF_NEXT_CMD: case BT_NXT_CMD:
return zmk_ble_prof_next(); return zmk_ble_prof_next();
case BT_PROF_PREV_CMD: case BT_PRV_CMD:
return zmk_ble_prof_prev(); return zmk_ble_prof_prev();
case BT_PROF_SEL_CMD: case BT_SEL_CMD:
return zmk_ble_prof_select(arg); return zmk_ble_prof_select(arg);
default: default:
LOG_ERR("Unknown BT command: %d", command); LOG_ERR("Unknown BT command: %d", command);

32
docs/docs/behavior/bluetooth.md

@ -18,26 +18,26 @@ which is added at the top of the keymap file:
#include <dt-bindings/zmk/bt.h> #include <dt-bindings/zmk/bt.h>
``` ```
This will allow you to reference the actions defined in this header such as `BT_CLEAR_BONDS_CMD`. This will allow you to reference the actions defined in this header such as `BT_CLR_CMD`.
Here is a table describing the command for each define: Here is a table describing the command for each define:
| Define | Action | | Define | Action |
| -------------------- | ---------------------------------------------------------------------------------------------- | | ------------ | ---------------------------------------------------------------------------------------------- |
| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] | | `BT_CLR_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] |
| `BT_PROF_NEXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. | | `BT_NXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. |
| `BT_PROF_PREV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. | | `BT_PRV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. |
| `BT_PROF_SEL_CMD` | Select the 0-indexed profile by number. | | `BT_SEL_CMD` | Select the 0-indexed profile by number. |
Because at least one bluetooth commands takes an additional parameter, it is recommended to use Because at least one bluetooth commands takes an additional parameter, it is recommended to use
the following aliases in your keymap to avoid having to specify an ignored second parameter: the following aliases in your keymap to avoid having to specify an ignored second parameter:
| Define | Action | | Define | Action |
| ---------------- | ---------------------------------------------------------------------------------------- | | -------- | -------------------------------------------------------------------------------- |
| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the current profile's bond to the current host | | `BT_CLR` | Alias for `BT_CLR_CMD 0` to clear the current profile's bond to the current host |
| `BT_PROF_NEXT` | Alias for `BT_PROF_NEXT_CMD 0` to select the next profile | | `BT_NXT` | Alias for `BT_NXT_CMD 0` to select the next profile |
| `BT_PROF_PREV` | Alias for `BT_PROF_PREV_CMD 0` to select the previous profile | | `BT_PRV` | Alias for `BT_PRV_CMD 0` to select the previous profile |
| `BT_PROF_SEL` | Alias for `BT_PROF_SEL_CMD` to select the given profile, e.g. `&bt BT_PROF_SEL 1` | | `BT_SEL` | Alias for `BT_SEL_CMD` to select the given profile, e.g. `&bt BT_SEL 1` |
## Bluetooth Behavior ## Bluetooth Behavior
@ -46,7 +46,7 @@ The bluetooth behavior completes an bluetooth action given on press.
### Behavior Binding ### Behavior Binding
- Reference: `&bt` - Reference: `&bt`
- Parameter #1: The bluetooth command define, e.g. `BT_CLEAR_BONDS_CMD` - Parameter #1: The bluetooth command define, e.g. `BT_CLR_CMD`
- Parameter #2: (Reserved for future bluetooth command types) - Parameter #2: (Reserved for future bluetooth command types)
### Examples ### Examples
@ -54,23 +54,23 @@ The bluetooth behavior completes an bluetooth action given on press.
1. Behavior binding to clear the paired host for the selected profile: 1. Behavior binding to clear the paired host for the selected profile:
``` ```
&bt BT_CLEAR_BONDS &bt BT_CLR
``` ```
1. Behavior binding to select the next profile: 1. Behavior binding to select the next profile:
``` ```
&bt BT_PROF_NEXT &bt BT_NXT
``` ```
1. Behavior binding to select the previous profile: 1. Behavior binding to select the previous profile:
``` ```
&bt BT_PROF_NEXT &bt BT_NXT
``` ```
1. Behavior binding to select the 2nd profile (passed parameters are [zero based](https://en.wikipedia.org/wiki/Zero-based_numbering)): 1. Behavior binding to select the 2nd profile (passed parameters are [zero based](https://en.wikipedia.org/wiki/Zero-based_numbering)):
``` ```
&bt BT_PROF_SEL 1 &bt BT_SEL 1
``` ```

Loading…
Cancel
Save