diff --git a/app/.idea/.gitignore b/app/.idea/.gitignore
new file mode 100644
index 00000000000..13566b81b01
--- /dev/null
+++ b/app/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/app/.idea/misc.xml b/app/.idea/misc.xml
new file mode 100644
index 00000000000..53624c9e1f9
--- /dev/null
+++ b/app/.idea/misc.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.idea/vcs.xml b/app/.idea/vcs.xml
new file mode 100644
index 00000000000..6c0b8635858
--- /dev/null
+++ b/app/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Kconfig b/app/Kconfig
index 30d8e8cd082..5f1b9e3a8a5 100644
--- a/app/Kconfig
+++ b/app/Kconfig
@@ -415,6 +415,15 @@ config ZMK_IDLE_SLEEP_TIMEOUT
int "Milliseconds of inactivity before entering deep sleep"
default 900000
+config ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED
+ bool "Enable keep awake for active profile"
+ depends on ZMK_BLE
+ default n
+
+config ZMK_USB_ALLOW_SLEEP_WHILE_POWERED
+ bool "Allow the device to sleep while USB power is present"
+ default n
+
endif # ZMK_SLEEP
config ZMK_EXT_POWER
diff --git a/app/src/.idea/.gitignore b/app/src/.idea/.gitignore
new file mode 100644
index 00000000000..13566b81b01
--- /dev/null
+++ b/app/src/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/app/src/.idea/modules.xml b/app/src/.idea/modules.xml
new file mode 100644
index 00000000000..f669a0e5940
--- /dev/null
+++ b/app/src/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/.idea/src.iml b/app/src/.idea/src.iml
new file mode 100644
index 00000000000..bc2cd874090
--- /dev/null
+++ b/app/src/.idea/src.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/.idea/vcs.xml b/app/src/.idea/vcs.xml
new file mode 100644
index 00000000000..b2bdec2d71b
--- /dev/null
+++ b/app/src/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/activity.c b/app/src/activity.c
index f4dc3562437..62d0ebc0c89 100644
--- a/app/src/activity.c
+++ b/app/src/activity.c
@@ -26,6 +26,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include
#endif
+#if IS_ENABLED(CONFIG_ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED)
+#include
+#endif
+
#if IS_ENABLED(CONFIG_ZMK_POINTING)
#include
#endif
@@ -75,7 +79,16 @@ void activity_work_handler(struct k_work *work) {
int32_t current = k_uptime_get();
int32_t inactive_time = current - activity_last_uptime;
#if IS_ENABLED(CONFIG_ZMK_SLEEP)
- if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()) {
+ bool prevent_sleep = !IS_ENABLED(CONFIG_ZMK_USB_ALLOW_SLEEP_WHILE_POWERED) && is_usb_power_present();
+ #if IS_ENABLED(CONFIG_ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED)
+ 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
+ #endif
+ if (inactive_time > MAX_SLEEP_MS && !prevent_sleep) {
// Put devices in suspend power mode before sleeping
set_state(ZMK_ACTIVITY_SLEEP);