-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
0f972f1
commit 09ddf9b
Showing
9 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zmk/hid_indicators_types.h> | ||
#include <zmk/event_manager.h> | ||
|
||
struct zmk_sync_activity_event { | ||
int32_t central_inactive_duration; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_sync_activity_event); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zmk/events/sync_activity_event.h> | ||
|
||
ZMK_EVENT_IMPL(zmk_sync_activity_event); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters