Commit Graph

59 Commits

Author SHA1 Message Date
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
Pete Johanson 4db5b169bf refactor(splits): Ability to override split role.
* Move central/peripheral setting to Kconfig.defconfig
  files to allow left/right .conf files to override
  central/peripheral role for splits.
2020-12-28 10:16:24 -05:00
innovaker 842aa5a842 refactor: replace filename hyphens with underscores
Aligns *.h and *.c to underscore naming convention.

These were kept (with warnings) for backwards compatibility with external boards/shields:
- kscan-mock.h
- matrix-transform.h
They should be removed in the future.

PR: #523
2020-12-28 01:15:35 -05:00
Nick 2204a5dce4 refactor(settings): Debounce BLE/endpoint settings saves 2020-12-14 22:46:49 -05:00
Nick Winans 69d48c5715 refactor(settings): Only load used subtrees 2020-12-14 22:46:49 -05:00
innovaker 00ca0d2f1c refactor(app): replace `struct device *` with `const struct device *`
Replaced with RegExp: /(?<!const )(struct device \*)/g

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker bac1f17cf6 refactor(app): replace Zephyr integer types with C99 integer types
u8_t → uint8_t
u16_t → uint16_t
u32_t → uint32_t
u64_t → uint64_t
s8_t → int8_t
s16_t → int16_t
s32_t → int32_t
s64_t → int64_t

Prerequisite for #223
See: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v2.4.0
PR: #467
2020-12-14 12:41:25 -05:00
Pete Johanson 0d80220e14 fix(ble): Raise profile events from work thread.
* Make sure we don't raise events from BLE
  host thread.
2020-12-06 22:47:21 -05:00
Pete Johanson b3f3362b50 feat(display): Initial widget/status screen work.
* Battery and output status widgets
* Built in status screen combining them.
* Ability to define a custom status screen factory
  function.
2020-12-02 16:04:56 -05:00
innovaker 7b3a55cf50 refactor(ble): silence warning `auth_passkey_display` not used
Silences the following build warning ...

../src/ble.c:407:13: warning: 'auth_passkey_display' defined but not used [-Wunused-function]
  407 | static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) {
2020-12-01 07:21:45 -05:00
innovaker d748d8a749 refactor: Replace superseded key names
Replace deprecated key names (LCTL, NUM_0, NUM_1).

Replace abbreviated names with fully qualified names (LCTL, RGUI, NUM_0, NUM_1).

Follow-up to #21.
2020-11-03 23:50:54 -05:00
Joel Spadin 821f054071 feat(endpoints): remove redundant connection check 2020-10-28 18:15:05 -05:00
Joel Spadin b538e60532 feat(endpoints): update on BLE profile change
Added zmk_ble_active_profile_is_connected() to allow code outside ble.c to check
the status of the active profile, and changed the ble_active_profile_changed
event to also notify when the active profile connects or disconnects.

Changed endpoint selection to to also update when the active profile changes,
connects, or disconnects.
2020-10-28 18:15:05 -05:00
Pete Johanson 9d512eaef0 fix(bluetooth): Add adv data in non-peripherals. 2020-10-16 09:49:28 -04:00
Pete Johanson b07475b7d4 fix(bluetooth): Stop adv on connected profile. 2020-10-16 00:56:05 -04:00
Pete Johanson 818f0a1f91 fix(bluetooth): Advertise name + appearance.
* Properly put device name and GAP appearance
  in advertising packets, for proper display in
  macOS, Android, etc.
* Closes #124
2020-10-16 00:48:53 -04:00
Pete Johanson 204d1300ba fix(ble): Only advertise when needed.* Once we have a peer connected to for the active profile, don't continue advertising. 2020-10-15 00:51:21 -04:00
Pete Johanson 191a2d755a chore: clang-format the codebase.
* Use the LLVM style
* Override indent width (8) and column limit (100)
* Fixes #142.
2020-09-14 00:10:34 -04:00
Pete Johanson 4658999e31 fix(bluetooth): Reject pairing to taken profiles. 2020-09-13 22:33:31 -04:00
Pete Johanson 39f980a06d 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.
2020-09-13 22:33:29 -04:00
Pete Johanson e88d0833c5 fix(bluetooth): Log when clearing on start. 2020-09-13 22:33:05 -04:00
Pete Johanson b103eb4b05 fix(bluetooth): Delete any previously stored name. 2020-09-13 22:33:05 -04:00
Pete Johanson 13842a8a1e fix(bluetooth): Kconfig to clear bonds on start 2020-09-13 22:33:05 -04:00
Pete Johanson fc0812bd2e 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.
2020-09-13 22:33:05 -04:00
Pete Johanson cf970efb98 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.
2020-09-13 22:33:05 -04:00
Pete Johanson 68e72f9275 fix: Switch to single AUTHORS file.* Closes #164 2020-09-10 10:24:23 -04:00
Pete Johanson 0d3cfa8596
Merge pull request #99 from petejohanson/core/bluetooth-unpair-magic-combo
Add magic combo for unpairing BT devices on start.
2020-08-18 19:21:43 -04:00
Pete Johanson 05235ca96d fix(bluetooth): Stop peripheral half advertising once connected. 2020-08-18 16:18:16 -04:00
Pete Johanson 4402e4fbc7 feeature(bt): Add "unpair combo" on startup.
* Especially for splits, we need the ability to
  unpair all paired devices as  sledgehammer
  if we need to "reset things", and doing so via
  keymaps isn't suitable.
* Allows shields to define a collection of key
  positions that if all held 2 seconds after
  startup, will unpair all existing pairs for the
  device.
2020-08-18 13:17:10 -04:00
Pete Johanson d7dee20e8d Add missing license header. 2020-08-18 09:56:25 -04:00
Nick 087574f607 Create proper fix for split default conn bug 2020-08-16 15:36:43 -05:00
Pete Johanson 7e8a07e693 Remove use of printk. 2020-08-14 16:45:05 -04:00
Nick 370cfcc59f Add if block and param req callback comment 2020-08-05 22:38:40 -05:00
Nick cfea5cceb1 Remove updated callback 2020-08-03 17:22:11 -05:00
Nick f23ca9d7ee Add two solutions to param updates 2020-08-02 15:51:38 -05:00
Nick 880c6e0601 Fix variable name in peripheral PHY update 2020-08-02 15:01:32 -05:00
Nick f26bd495ea Fix interval update, add PHY update 2020-08-02 14:51:42 -05:00