From cf970efb98c5af97955bfffbcebb3b065b16edc4 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 28 Aug 2020 14:15:16 -0400 Subject: feat(bluetooth): Proper bond management, identity support for non-splits * Add `bt` behavior that can be used to perform certain actions, such as next/prev identity, reset identity, etc. NOTE: Multiple identities is only supported for non-split shields, due to missing Zephyr identity functionality for dual central/peripheral devices. * Proper bond reset tied to action, that honors peripheral bonds, so folks can reset and pair to other hosts, without breaking bonds between splt halves. --- app/include/dt-bindings/zmk/bt.h | 17 +++++++++++++++++ app/include/zmk/ble.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 app/include/dt-bindings/zmk/bt.h (limited to 'app/include') diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h new file mode 100644 index 0000000..6b05ff0 --- /dev/null +++ b/app/include/dt-bindings/zmk/bt.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#define BT_RST_CMD 0 +#define BT_IDENT_NEXT_CMD 1 +#define BT_IDENT_PREV_CMD 2 +#define BT_IDENT_SEL_CMD 3 +#define BT_IDENT_CLR_CMD 4 + +#define BT_RST BT_RST_CMD 0 +#define BT_IDENT_NEXT BT_IDENT_NEXT_CMD 0 +#define BT_IDENT_PREV BT_IDENT_PREV_CMD 0 +#define BT_IDENT_SEL BT_IDENT_SEL_CMD +#define BT_IDENT_CLR BT_IDENT_CLR_CMD 0 \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index d0aaa96..b3762cd 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -6,7 +6,20 @@ #pragma once +#include #include +int zmk_ble_adv_pause(); +int zmk_ble_adv_resume(); + +int zmk_ble_identity_clear(); +int zmk_ble_identity_next(); +int zmk_ble_identity_prev(); +int zmk_ble_identity_select(u8_t index); + int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) +void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr); +#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ \ No newline at end of file -- cgit v1.2.3 From fc0812bd2eb08d66819f38bafd1f5d00b933c87b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 1 Sep 2020 23:22:30 -0400 Subject: 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. --- app/include/dt-bindings/zmk/bt.h | 17 +++++++---------- app/include/zmk/ble.h | 7 +------ 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'app/include') diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 6b05ff0..24d27ae 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,14 +4,11 @@ * SPDX-License-Identifier: MIT */ -#define BT_RST_CMD 0 -#define BT_IDENT_NEXT_CMD 1 -#define BT_IDENT_PREV_CMD 2 -#define BT_IDENT_SEL_CMD 3 -#define BT_IDENT_CLR_CMD 4 +#define BT_CLEAR_BONDS_CMD 0 -#define BT_RST BT_RST_CMD 0 -#define BT_IDENT_NEXT BT_IDENT_NEXT_CMD 0 -#define BT_IDENT_PREV BT_IDENT_PREV_CMD 0 -#define BT_IDENT_SEL BT_IDENT_SEL_CMD -#define BT_IDENT_CLR BT_IDENT_CLR_CMD 0 \ No newline at end of file +/* +Note: Some future commands will include additional parameters, so we +defines these aliases up front. +*/ + +#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index b3762cd..62d476e 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -9,13 +9,8 @@ #include #include -int zmk_ble_adv_pause(); -int zmk_ble_adv_resume(); -int zmk_ble_identity_clear(); -int zmk_ble_identity_next(); -int zmk_ble_identity_prev(); -int zmk_ble_identity_select(u8_t index); +int zmk_ble_clear_bonds(); int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); -- cgit v1.2.3 From 39f980a06dac1769e4f09abaf19d3ccbb4b34e67 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 8 Sep 2020 23:26:00 -0400 Subject: feat(bluetooth): Add back profiles, split fixes. * Add back in profiles, not using Zephyr BT identity infrastructure. * Restore additional `&bt` commands for profile operations. * Fix for split pairing and subscriptions, since Zephyr persists subscriptions across connects. * Remove keymap from peripheral builds, reduces firmware size, and avoids unneeded attempts to send HID data. --- app/include/dt-bindings/zmk/bt.h | 11 +++++++++-- app/include/zmk/ble.h | 9 +++++++-- app/include/zmk/ble/profile.h | 16 ++++++++++++++++ .../zmk/events/ble-active-profile-changed.h | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 app/include/zmk/ble/profile.h create mode 100644 app/include/zmk/events/ble-active-profile-changed.h (limited to 'app/include') diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 24d27ae..b2899ab 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,11 +4,18 @@ * SPDX-License-Identifier: MIT */ -#define BT_CLEAR_BONDS_CMD 0 +#define BT_CLEAR_BONDS_CMD 0 +#define BT_PROF_NEXT_CMD 1 +#define BT_PROF_PREV_CMD 2 +#define BT_PROF_SEL_CMD 3 +// #define BT_FULL_RESET_CMD 4 /* Note: Some future commands will include additional parameters, so we defines these aliases up front. */ -#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 \ No newline at end of file +#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 +#define BT_PROF_NEXT BT_PROF_NEXT_CMD 0 +#define BT_PROF_PREV BT_PROF_PREV_CMD 0 +#define BT_PROF_SEL BT_PROF_SEL_CMD \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index 62d476e..1cf71a7 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -6,11 +6,16 @@ #pragma once -#include #include - +#include int zmk_ble_clear_bonds(); +int zmk_ble_prof_next(); +int zmk_ble_prof_prev(); +int zmk_ble_prof_select(u8_t index); + +bt_addr_le_t *zmk_ble_active_profile_addr(); +char *zmk_ble_active_profile_name(); int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); diff --git a/app/include/zmk/ble/profile.h b/app/include/zmk/ble/profile.h new file mode 100644 index 0000000..9a79c6d --- /dev/null +++ b/app/include/zmk/ble/profile.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include + +#define ZMK_BLE_PROFILE_NAME_MAX 15 + +struct zmk_ble_profile { + char name[ZMK_BLE_PROFILE_NAME_MAX]; + bt_addr_le_t peer; +}; diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble-active-profile-changed.h new file mode 100644 index 0000000..c464236 --- /dev/null +++ b/app/include/zmk/events/ble-active-profile-changed.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include +#include + +#include + + +struct ble_active_profile_changed { + struct zmk_event_header header; + u8_t index; + struct zmk_ble_profile *profile; +}; + +ZMK_EVENT_DECLARE(ble_active_profile_changed); -- cgit v1.2.3 From 6c8b0b53f0dbec695ab967ee947916875ed49352 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 13 Sep 2020 22:20:25 -0400 Subject: refactor(bluetooth): More concise names. --- app/include/dt-bindings/zmk/bt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app/include') diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index b2899ab..bf8b4f5 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,10 +4,10 @@ * SPDX-License-Identifier: MIT */ -#define BT_CLEAR_BONDS_CMD 0 -#define BT_PROF_NEXT_CMD 1 -#define BT_PROF_PREV_CMD 2 -#define BT_PROF_SEL_CMD 3 +#define BT_CLR_CMD 0 +#define BT_NXT_CMD 1 +#define BT_PRV_CMD 2 +#define BT_SEL_CMD 3 // #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. */ -#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 -#define BT_PROF_NEXT BT_PROF_NEXT_CMD 0 -#define BT_PROF_PREV BT_PROF_PREV_CMD 0 -#define BT_PROF_SEL BT_PROF_SEL_CMD \ No newline at end of file +#define BT_CLR BT_CLR_CMD 0 +#define BT_NXT BT_NXT_CMD 0 +#define BT_PRV BT_PRV_CMD 0 +#define BT_SEL BT_SEL_CMD \ No newline at end of file -- cgit v1.2.3