Commit Graph

95 Commits

Author SHA1 Message Date
snoyer fe91cc6625
refactor(ble): add functions to check if profile is open/connected by address (#2993)
Helper functions for BLE profile statuses.
2025-07-19 07:51:53 -06:00
snoyer 9e905d6593
feat(ble): Add function to get profile address by index (#2992) 2025-07-09 20:25:11 -06:00
Pete Johanson 147c340c6e
Feature: Full-Duplex Wired Split (#2766)
refactor(split): Refactor split code for extension

Extract central/peripheral code to allow for plugging in alternate
transports, instead of tying all split logic to BT.

feat(split): Add full-duplex wired split support

* Depends on full-duplex hardware UART for communication.
* Supports all existing central commands/peripheral events, including
  sensors/inputs from peripherals.
* Only one wired split peripheral supported (for now)
* Relies on chosen `zmk,split-uart` referencing the UART device.

docs: Add wired split config docs.

Migrate split to its own dedicated config file, and add details
on wired split config.

Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>

fix: Properly override stack size on RP2040

Move the system work queue stack size override on RP2040 ouf of
a `ZMK_BLE` conditional so it is properly applied generally for that
SoC.

---------

Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
2025-03-18 02:48:32 -04:00
Xudong Zheng ea267b0f35
fix(ble): enforce maximum length for dynamic device name (#2784) 2025-02-26 13:29:30 -05:00
Pete Johanson 85aba16eec
testing: Add split BLE tests (#2737)
* Enhance the BLE test runner to build additional peripheral builds
  when detecting peripheral*.overlay files in the test.
* Add basic and multiple-peripheral tests to exercise the testing
  support
* Add test for triggering local behaviors on split peripherals.

fix(ble): Fix building split code w/o settings

* Properly exclude storing peripheral addresses to settings when
  settings support isn't turned on.
2025-01-01 18:13:47 -05:00
ReFil 17f0a4d307
feat(ble): Set device name at runtime
This allows for the device name to be set at runtime, possible uses for this include a custom display screen that lets you type it in using the keycode state event, future configuration in zmk studio, or altering it per profile as per #1169
2024-09-25 15:35:42 -04:00
Abe Nonym 92745903c9
fix(ble): Properly compile with clear bonds on start 2024-09-16 12:06:34 -04:00
Peter Johanson 6b4d591c37 fix(bt): Fix compilation failure for clearing bonds.
* Refactor broke the build when clearing bonds on start.
2024-09-09 11:26:53 -06:00
Peter Johanson 80173f8ea3 fix: Improve startup time with proper settings loading.
* Avoid doing duplicate calls to setings_load_subtree, which iterates
  NVS fully each time under the hood, and instead use on settings_load
  later in the lifecycle.
2024-07-03 16:24:17 -06:00
Peter Johanson f7c34c70ba refactor(ble): Extract API to get active profile connection.
* Add `struct bt_conn *zmk_ble_active_profile_conn(void)` function for
  fetching a connection for the current profile.
2024-06-28 14:43:17 -06:00
Peter Johanson b6d9f3c911 fix(ble): Ensure large enough string for setting name.
* Fix warning related to potentially large number of profiles
  causing overflow of allocated string for the setting name.
2024-02-09 14:32:46 -08:00
Peter Johanson 0b5afbf9c0 refacter(bluetooth): Proper HCI header include. 2024-02-09 14:32:46 -08:00
Peter Johanson bf4008da02 refactor: All SYS_INIT functions are void args. 2024-02-09 14:32:46 -08:00
Peter Johanson 33209dee1d refactor(core): Move to stack allocated events.
* Move to local/stack allocated event API that doesn't require
  dynamic allocation/freeing.
* Disable heap, we no longer use alloc/free unless using LVGL.
* Tons of refactors all over to account for the new event approach.
2024-01-14 11:13:57 -08:00
Peter Johanson bc7b4b56bd fix(ble): Disable Auto Sec Req again.
* Auto security request actually makes macOS worse, so disable it,
  and remove our early request in favor of using GATT enforcement
 to ensure connections are secured.
2024-01-05 12:17:59 -08:00
Chris Andreae 194a9790eb fixup! use wider type for loop iterator 2024-01-05 12:16:38 -08:00
Chris Andreae b813f34e34 fixup! bt: add BT_CLR_ALL behaviour 2024-01-05 12:16:38 -08:00
Chris Andreae f4fe7fa40f Extract common behaviour of clearing a bond 2024-01-05 12:16:38 -08:00
Chris Andreae 604c95118e Remove error reporting from ble utility functions that never error 2024-01-05 12:16:38 -08:00
Chris Andreae 7a5155f36e lint: add (void) parameter to pass -Wstrict-prototypes
Note there was one place where a non-strict prototype was actually being used
with an argument, in `zmk_hog_init`. In this case, the actual argument type was
added instead.
2024-01-05 12:16:38 -08:00
moergo-sc 5257cde1f5 bt: add BT_CLR_ALL behaviour
Defines behaviour to clear all paired Bluetooth profiles
2024-01-05 12:16:38 -08:00
Peter Johanson da15564d0e feat(bluetooth): Build on ARCH_POSIX. 2023-12-02 17:11:45 -08:00
Peter Johanson 3fad4dba07 fix(bt): Passkey entry pairing fixes.
* Don't propogate any key press events while in the
  middle of passkey entry, avoid funky state on hosts.
* Handle passkey on release, not press, to ensure key *releases*
  are not accidentally sent, especially the Enter release
  at the very end of passkey entry, which can trigger
  cancel in the dialog if the keyboard is connected
  via USB to the same host.
2023-12-01 16:48:46 -08:00
Peter Johanson 329d6474ee feat(ble): Make it possible to use BT_GATT_AUTO_SEC_REQ
* Only upgrade security of new connections if BT_GATT_AUTO_SEC_REQ
  is not enabled.
2023-12-01 16:47:49 -08:00
Peter Johanson 744f70c80c feat(bt): Add support for unauth overwrite
* Properly handle the user enabling the
  `CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE`
  Zephyr flag and handle re-pairing to an existing taken
  profile from the same address.
2023-12-01 23:39:31 +00:00
Alessandro Bortolin 4e55c5f6e9 feat: handle LED indicators report 2023-11-27 16:03:18 -08:00
Chris Andreae 0a4b1a6533
feat(ble): add behavior to disconnect from BLE profile
Adds new functionality and a behavior to disconnect an active BLE connection.
The motivation for this is that for some devices like phones, the presence of an
active BLE connection results in the onscreen keyboard being selected.
2023-11-20 15:00:10 -05:00
Peter Johanson 54c2e8e155 feat: Add more logging to peripheral settings. 2023-07-21 10:41:23 -07:00
Peter Johanson ed400c4feb fix(bluetooth): Corrected use of `bt_addr_le_cmp`
* Properly compare to zero when comparing LE addresses.
2023-07-21 10:41:23 -07:00
Peter Johanson 73e1b526d5 fix(bluetooth): Properly clear peripheral slots
* When the clear bonds Kconfig is set, also clear peripheral
  address slots addresses from settings as well.
2023-07-21 10:41:23 -07:00
Xudong Zheng 5d9ae8fffa feat(split): allow central to connect to multiple peripherals 2023-06-05 16:22:41 -06:00
Peter Johanson 19d883cdfe fix(bluetooth): Passkey pairing improvements.
* Capture the last 6 entered digits, and then require pressing
   Enter/Return to submit the entered digits. This matches the
   messaging shown on hosts regarding how to complete pairing.
* Fix the wording on the Kconfig menu item to accurately describe
  the feature.
2023-06-05 00:01:44 -06:00
Peter Johanson 5aac2743b1 fix(bluetooth): Improved checking for conn status.
* Check the actual connection status before considering
  a discovered connection as connected.
2023-05-22 23:09:40 -06:00
Peter Johanson 062f94d014 refactor: Remove v1 logging vestiges. 2023-04-05 22:55:38 -07:00
Peter Johanson 3a958c667f refactor: Move to `zephyr/` include paths.
* Zephyr moved to properly namespaced headers, so major "rip
  the bandaid" commit to move us to those everywhere.
2023-04-05 22:55:38 -07:00
Peter Johanson 4f2f9db1d4 refactor(ble): New callback API for pairing complete. 2023-04-05 22:55:38 -07:00
Peter Johanson 6539b3ae25 refactor(split): Clean up Kconfig organization.
* Seperated configs for split role (central/peripheral)
  and transport (BLE only for now).
* Split the configs to align on structure.
2022-05-29 19:18:09 -04:00
Peter Johanson 0a40f922b5 refactor(split): Seperate peripheral BLE handling.
* Move foundational BLE code for split
  peripherals to a dedicated file to avoid
  tons of conditionals and awkward code.
2022-05-17 13:09:21 -04:00
Nick Winans 2c7e5b9232 refactor(ble): Use auto phy/conn for split 2022-04-24 18:29:18 -04:00
Nick Winans d08463e483 fix(ble): Restore manual connection params 2022-04-15 12:25:15 -04:00
Peter Johanson 5015a88545 fix(split): Proper role checking in BT callbacks.
* Properly react to events only for connections
  with the correct role.
2022-04-03 00:10:29 -04:00
Peter Johanson 53dae35710 refactor: Move to `k_work_delayable` API.
* Move to new `k_work_delayable` APIs introduced in Zephyr 2.6.

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.6.html#api-changes
2022-04-03 00:10:29 -04:00
Peter Johanson 9297c5f2b4 refactor(splits): Use index for event source.
* Track peripherals by indexes slot, with all appropiate peripheral
  state stored in the slot.
* Event sources tracked by peripheral slot index.
2022-01-31 23:03:34 -05:00
Peter Johanson ed48d1ae89 fix(ble): Restore BLE SC passkey entry for pairing.
* Handle capturing numeric inputs while pairing and sending
  final passkey once six digits entered.
2022-01-30 22:41:41 -05:00
Joel Spadin 0a9efbf85d fix(ble): Ignore out of range profiles
Don't allow selecting a BLE profile that is out of range to avoid
reading/writing past the end of the profiles array.
2021-06-08 20:33:43 -04:00
Nick Winans 82173f354e fix(core): Assert BLE device name is correct length 2021-02-02 00:59:17 -05:00
Jeff Rizzo 4f040fecdf Add a missing log_strdup() 2021-01-30 00:31:07 -05:00
Pete Johanson 3fe2acc2d1 refactor(core): Extra event payloads to own types, refactor API.
* Make it easier to use *just* event payloads by defining the data,
  and then having event manager macros generate "wrapper structs"
* Improve is_*/cast_* APIs to hide details of full event struct.
* Create `zmk_event_t` typedef to pass to event handlers.
* Bring event names inline w/ consistent `zmk_` prefix.
2021-01-20 07:06:11 -05:00
Pete Johanson a0c32bb47e fix(bluetooth): improve LE param update logging 2021-01-15 13:50:36 -05:00
innovaker 87179698b4 refactor(app): replace zmk_key with zmk_key_t
Aligns with typedef _t convention.

PR: #531
2020-12-28 10:20:12 -05:00