zmk
zmk copied to clipboard
feat: stay awake while BLE connected
Solves* #2198 by adding a new Kconfig option and its corresponding change on the "shall we sleep?" check.
* Should solve, but i cant test as i dont have a battery-powered device (:
Note: May run into issues with the refactoring of this file on #2085
I think there is a question here whether this should check only the current profile's connection status (this implementation) or any of the profiles. If the former is preferred that's fine, but the docs should be more specific.
[...] current profile [...] or any of the profiles [...]
Didnt even know that a profile could still be connected after changing to another. But even then, i agree that it makes more sense to (not) sleep based on the selected one, rather than having a "leftover" connection prevent power saving
[...] current profile [...] or any of the profiles [...]
[…] i agree that it makes more sense to (not) sleep based on the selected one, rather than having a "leftover" connection prevent power saving
Agreed. I don’t think this should prevent deep sleep if a device is in range which isn’t selected as the active profile.
Otherwise my phone would keep my keyboard up most of the time, being in range of the keyboard but not the selected profile.
peripheral side
Here is an example of checking the connection for the peripheral half
https://github.com/SplittedSpace/zmk-firmware/blob/913ecc0f21d5bebb9405ecd826cc61a375573385/app/boards/arm/harper/status_led.c#L287C1-L287C111
Rather than preventing sleep entirely while BLE is connected, I think it would make more sense to add a new flag which sets a separate sleep timer when neither the current BLE profile nor a USB connection is present. That would solve the original issue, while not removing the current behaviour as an option.
Current behavior is still an option (the default one, actually) if you dont enable the ZMK_NO_SLEEP_WHILE_BLE_CONNECTED
flag (?)
Sorry, poorly phrased on my part: Instead of choosing one behaviour or the other, you could have both behaviours simultaneously.