Feat: BLE prevent sleep while active connected and Feat: allow sleep while USB powered#3286
Conversation
Temporarily disable USB power check for sleep prevention in order to test BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED flag
snoyer
left a comment
There was a problem hiding this comment.
I'm not a maintainer and I don't speak with any authority but here's a few comments for your consideration.
Also you have pushed some of your IDE's files which should not be in the PR. And eventually you'll want to have run the pre-commit checks for formatting and whatnot
| prevent_sleep = prevent_sleep || | ||
| #if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) | ||
| zmk_ble_active_profile_is_connected(); | ||
| #else | ||
| zmk_split_bt_peripheral_is_connected(); | ||
| #endif |
There was a problem hiding this comment.
| prevent_sleep = prevent_sleep || | |
| #if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) | |
| zmk_ble_active_profile_is_connected(); | |
| #else | |
| zmk_split_bt_peripheral_is_connected(); | |
| #endif | |
| #if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) | |
| prevent_sleep |= zmk_ble_active_profile_is_connected(); | |
| #else | |
| prevent_sleep |= zmk_split_bt_peripheral_is_connected(); | |
| #endif |
maybe clearer to not split statements across preproc directives?
There was a problem hiding this comment.
Definitely more readable, I like it.
| default 900000 | ||
|
|
||
| config ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED | ||
| bool "Enable keep awake for active profile" |
There was a problem hiding this comment.
phrase in terms of preventing/allowing sleep instead of keeping awake?
There was a problem hiding this comment.
Also a great catch, I think I spotted this one and forgot it unfortunately.
|
I'm closing this pr in favor of another with cleaned up commit history and fixes applied, it's here: PR 3288 |
|
You shouldn't keep opening new PRs for minor changes, it makes the review process harder and spams the PR list. You can rewrite the commit history in the same PR if you need to. |
|
Noted, thanks for the info! Won't happen again 😎 |
A solution for issue 2198, wherein I changed the activity.c loop that checks for sleep to watch for the status of the active BT connection. When the flag is enabled and the active BT profile is connected, the check does not let the device sleep. If the flag is not enabled, the device acts the same as it would before this PR.
While I was working on testing the flag, I decided to add a flag to allow the device to sleep while USB power is present. This was primarily so i could test over USB debugging, but for users who are willing to allow their device to sleep while USB is powered (like split or dongle users) this should have non-negligible effects on battery life (from the zmk power profiler) for the peripherals, which may not be plugged in.
First time contributor so any and all advice is welcome and encouraged!
PR check-list