zmk icon indicating copy to clipboard operation
zmk copied to clipboard

feat: stay awake while BLE connected

Open elpekenin opened this issue 11 months ago • 7 comments

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

elpekenin avatar Mar 15 '24 21:03 elpekenin

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.

caksoylar avatar Mar 16 '24 01:03 caksoylar

[...] 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

elpekenin avatar Mar 16 '24 10:03 elpekenin

[...] 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.

huber-th avatar Mar 16 '24 18:03 huber-th

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

aroum avatar Mar 17 '24 09:03 aroum

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.

Nick-Munnich avatar Aug 03 '24 06:08 Nick-Munnich

Current behavior is still an option (the default one, actually) if you dont enable the ZMK_NO_SLEEP_WHILE_BLE_CONNECTED flag (?)

elpekenin avatar Aug 03 '24 09:08 elpekenin

Sorry, poorly phrased on my part: Instead of choosing one behaviour or the other, you could have both behaviours simultaneously.

Nick-Munnich avatar Aug 03 '24 09:08 Nick-Munnich