Commit Graph

41 Commits

Author SHA1 Message Date
Peter Johanson 3d2bd01747 fix(split): Raise release events on disconnect.
* When a peripheral disconnects from a centraly, raise position events
  to release any active positions from that
  peripheral.
2022-06-12 22:53:02 -04:00
Peter Johanson 4f503246a3 refactor(split): cmake split clean up.
* Cleaner cmake setup for split build.
2022-05-29 19:18:09 -04: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 16ab6df18d feat(display): Add new peripheral status/display
* Add new API/status to track state of the
  peripheral connection to the central.
* Add new peripheral status widget for displaying
  the current status of the connection to
  the central.
2022-05-17 13:09:21 -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
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 2c5d5fde51 refactor: `k_work_queue` API updates. 2022-04-03 00:10:29 -04:00
Peter Johanson 7430750428 refactor(splits): Minor cleanups to periph invocation
* Add strlcpy from public domain version.
* Leverage strlcpy to detect truncation of behavior dev strs, and log.
* Use `offsetof` for cleaner detection on peripheral side.
2022-01-31 23:03:34 -05:00
Peter Johanson b8700eaaa1 fix(split): Fix an off-by-one error in split svc.
* Properly check end of behavior device string for null terminator.
2022-01-31 23:03:34 -05:00
Peter Johanson dbefe92ea0 fix(split): Slightly improved logging on peripherals. 2022-01-31 23:03:34 -05: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 ce3471d4fe fix(split): Add queue for running remote behaviors 2022-01-31 23:03:34 -05:00
Pete Johanson 0febaa142a refactor(split): Clean up split GATT discovery.
* Use Zephyr auto CCC discovery instead of doing it ourselves.
* Split service versus characteristic discovery into dedicated
  steps in the flow.
* Fix for not searching properly when connecting to a peripheral
  a second time.
2022-01-31 23:03:34 -05:00
Pete Johanson 47f873b038 feature(split): behavior locality support.
* GATT characteristic allowing passng data + behavior
  label to invoke the behavior on the peripheral side.
* Behaviors have a locality setting to specify where they run.
* Build reset/power/RGB on peripheral.
2022-01-31 23:03:34 -05:00
Peter Johanson 0b0b49d626 fix(split): Properly rediscover peripherals.
* Handle disconnects of peripherals, and properly clean up
  and resume discovering for when the peripheral re-appears.
2021-11-04 22:31:56 -04: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 003db892ad refactor(core): Extra position state change data struct.
* Separate header and data struct for the event.
* Remove duplicate struct in split code.
2021-01-20 07:06:11 -05:00
Pete Johanson 65e476df3e fix(splits): Send pos notify from dedicated thread
* Avoid deadlocks by using a deadicated workqueue for sending
  position state notifications from peripherals.
2021-01-15 13:50:36 -05:00
Pete Johanson a5c39dfa76 fix(ble): Perform GATT notifies from dedicated queue.
* Zephyr BT stack frees TX buffers from system workqueue,
  and to avoid blocking waiting to allocate, perform notify
  from a dedicated queue.
2021-01-15 13:50:36 -05:00
Pete Johanson 4aa78a6f8d fix(split): Use queue/work for peripheral events.
* Avoid corruption by using work to process
  peripheral key position events on the main
  work thread, like local kscan events are.
* Fixes #221
2021-01-15 13:50:36 -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
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
Xudong Zheng 51ca4fbc18 Fix connection to incorrect peripheral 2020-11-11 13:16:31 -05:00
Okke Formsma d38740cebf
Add timestamps to position and behavior events (#147)
* Add timestamps to position events and behaviors.

- Take original event timestamps into consideration so nested tap-holds have proper timing.
- Add position and timestamp to keycode state changed event so the one-shot behavior can properly identify other keypresses and timings.
- Add timestamp to position events received from peripheral

* reduce number of arguments to behaviors
2020-10-10 17:32:53 -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 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 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
Nick f23ca9d7ee Add two solutions to param updates 2020-08-02 15:51:38 -05:00
Nick f26bd495ea Fix interval update, add PHY update 2020-08-02 14:51:42 -05:00
Pete Johanson c4d3c03eb0 Improved function naming for central functions. 2020-07-20 23:02:27 -04:00
Pete Johanson 542a9de48a Replace magic 16 with sane constant. 2020-07-20 22:52:37 -04:00
Pete Johanson 2a6b9ec86e Fixed min/max. 2020-07-19 22:33:15 -04:00
Pete Johanson 879fd5b8e7 Connection params tweaks. 2020-07-19 22:20:42 -04:00
Pete Johanson d4afd989f3 More split implementation.
* Propogate key position state changes on central.
* Various BLE tweaks.
2020-07-17 22:43:40 -04:00
Pete Johanson d1a5c7ee5a Swtich to SYS_INIT. 2020-07-17 22:43:40 -04:00
Pete Johanson be537d0656 Lots of work on split peripheral/central logic. 2020-07-17 22:43:40 -04:00
Pete Johanson a165db6358 Initial work on split central support. 2020-07-17 22:43:40 -04:00
Pete Johanson 3796f76c56 Initial exploration of split BLE service.
* Service for split peripheral to report
  position state to split central.
* Updated advertising info.
* Behavior for split BT until we have a proper
  event system.
2020-07-17 22:43:40 -04:00