Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Nov 13, 2024
1 parent 75ea53a commit 201f571
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/include/dt-bindings/zmk/bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ defines these aliases up front.
#define BT_SEL BT_SEL_CMD
#define BT_CLR_ALL BT_CLR_ALL_CMD 0
#define BT_DISC BT_DISC_CMD
#define ADV_OFF BT_ADV_OFF_CMD 0
#define ADV_ON BT_ADV_ON_CMD 0
#define ADV_TOG BT_ADV_TOG_CMD 0
#define BT_ADV_OFF BT_ADV_OFF_CMD 0
#define BT_ADV_ON BT_ADV_ON_CMD 0
#define BT_ADV_TOG BT_ADV_TOG_CMD 0
4 changes: 2 additions & 2 deletions app/include/zmk/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ int zmk_ble_unpair_all(void);

int zmk_ble_set_device_name(char *name);

void zmk_ble_adv_mode_set(bool mode);
bool zmk_ble_adv_mode_get(void);
void zmk_bt_adv_enabled_set(bool adv_enabled);
bool zmk_bt_adv_enabled_get(void);

#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr);
Expand Down
6 changes: 3 additions & 3 deletions app/src/behaviors/behavior_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
case BT_DISC_CMD:
return zmk_ble_prof_disconnect(binding->param2);
case BT_ADV_ON_CMD:
zmk_ble_adv_mode_set(true);
zmk_bt_adv_enabled_set(true);
return 0;
case BT_ADV_OFF_CMD:
zmk_ble_adv_mode_set(false);
zmk_bt_adv_enabled_set(false);
return 0;
case BT_ADV_TOG_CMD:
zmk_ble_adv_mode_set(zmk_ble_adv_mode_get() ? false : true);
zmk_bt_adv_enabled_set(zmk_bt_adv_enabled_get() ? false : true);
return 0;
default:
LOG_ERR("Unknown BT command: %d", binding->param1);
Expand Down
4 changes: 2 additions & 2 deletions app/src/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void update_advertising_callback(struct k_work *work) { update_advertisin

K_WORK_DEFINE(update_advertising_work, update_advertising_callback);

void zmk_ble_adv_mode_set(bool mode) {
void zmk_bt_adv_enabled_set(bool adv_enabled) {
if (mode) {
if (advertising_status != ZMK_ADV_CONN) {
permit_adv = true;
Expand All @@ -228,7 +228,7 @@ void zmk_ble_adv_mode_set(bool mode) {
}
}

bool zmk_ble_adv_mode_get(void) { return permit_adv; }
bool zmk_bt_adv_enabled_get(void) { return permit_adv; }

static void clear_profile_bond(uint8_t profile) {
if (bt_addr_le_cmp(&profiles[profile].peer, BT_ADDR_LE_ANY)) {
Expand Down
10 changes: 7 additions & 3 deletions docs/docs/keymaps/behaviors/bluetooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ Here is a table describing the command for each define:
| `BT_PRV` | Switch to the previous profile, cycling through to the last one when the beginning is reached. |
| `BT_SEL` | Select the 0-indexed profile by number; must include a number as an argument in the keymap to work correctly, e.g. `BT_SEL 0`. |
| `BT_DISC` | Disconnect from the 0-indexed profile by number, if it's currently connected and inactive; must include a number as an argument in the keymap to work correctly, e.g. `BT_DISC 0`. |
| `ADV_OFF` | Disable advertising and disconnect from all profiles |
| `ADV_ON` | Enable advertising and attempt to reconnect to profiles |
| `ADV_TOG` | Toggle advertising on and off |
| `BT_ADV_OFF` | Disable advertising and disconnect from all profiles |
| `BT_ADV_ON` | Enable advertising and attempt to reconnect to profiles |
| `BT_ADV_TOG` | Toggle advertising on and off |

:::note[Selected profile persistence]
The profile that is selected by the `BT_SEL`/`BT_PRV`/`BT_NXT` actions will be saved to flash storage and hence persist across restarts and firmware flashes.
However it will only be saved after [`CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE`](../../config/system.md#general) milliseconds in order to reduce potential wear on the flash memory.
:::

:::note[Advertising]
By default bluetooth advertising is enabled in all situations and doesn't have to be explicitly commanded
:::

## Bluetooth Behavior

The bluetooth behavior completes an bluetooth action given on press.
Expand Down

0 comments on commit 201f571

Please sign in to comment.