Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(split): sync central & peripherals last activity timing #2459

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on Sep 8, 2024

  1. feat(split): sync central & peripherals last activity timing

    Sync central last activity timings to all devices, by having the
    central emit how long it's inactive for, and the peripheral(s) using it
    to adjust the local last activity time.
    
    Prior to this commit, key presses on a peripheral keeps the central
    awake, but not vice versa. With this commit, key presses on the central
    (or hypothetical peripheral B) can keep peripheral A awake.
    
    This is done by:
    1. Adding a new `SYNC_ACTIVITY` GATT characteristic for central to sync
    it's inactive timer to the other peripheral(s).
    2. Central's `activity.c` broadcasting the inactive time at a regular
    `ZMK_SPLIT_SYNC_SLEEP_TIMERS_INTERVAL_MS` interval
    3. Peripheral's `service.c` receiving the data and sending it to its
    `activity.c`
    4. Peripheral's `activity.c` determining the new `activity_last_uptime`
    value using the inactive duration as a relative difference.
    
    Additionally:
    - `central.c` is updated to sync the timers upon a new BLE connection,
    so that new devices don't need to wait the full interval to get sync-ed.
    - If a peripheral is in IDLE mode when the central comes online, it'll
    get sync-ed to ACTIVE as well.
    
    Cons:
    - This solution doesn't handle cases where the peripheral(s) is already
    in deep sleep, since BLE is turned off. However, the sync-ing can
    prevent peripheral(s) from going into deep sleep if the central is used.
    - This is a time based sync, so it won't be as accurate as event based
    where each key press is sync-ed to the peripheral(s), but that would
    take up more of the channel bandwidth.
    - If `ZMK_SPLIT_SYNC_SLEEP_TIMERS_INTERVAL_MS` > `ZMK_IDLE_TIMEOUT`,
    there can be situations where the peripheral(s) goes into IDLE before
    receiving the next sync from central. The original default interval was
    5 minutes, primarily to prevent unnecessary deep sleeps, but it would
    run into the above case.
    angweekiat committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    4be177a View commit details
    Browse the repository at this point in the history
  2. add 2nd sync timer

    angweekiat committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    63b989c View commit details
    Browse the repository at this point in the history
  3. cleanup variables

    angweekiat committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    273ad05 View commit details
    Browse the repository at this point in the history
  4. split into 2 sync options

    angweekiat committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    aa2d3aa View commit details
    Browse the repository at this point in the history