From 928f82ab813f852c4fa9cf6802fb5fb08d1692b8 Mon Sep 17 00:00:00 2001
From: Xudong Zheng <7pkvm5aw@slicealias.com>
Date: Wed, 6 Mar 2024 23:25:00 -0500
Subject: [PATCH] feat(ble): allow dongle without Bluetooth profiles

Allow setting CONFIG_BT_MAX_CONN to CONFIG_ZMK_SPLIT_BLE_CENTRAL_PERIPHERALS for
dongle mode without Bluetooth profiles (USB output only).
---
 app/src/ble.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/src/ble.c b/app/src/ble.c
index 776730fe..a92e5508 100644
--- a/app/src/ble.c
+++ b/app/src/ble.c
@@ -162,6 +162,13 @@ bool zmk_ble_active_profile_is_connected(void) {
     advertising_status = ZMK_ADV_CONN;
 
 int update_advertising(void) {
+#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
+    if (CONFIG_ZMK_SPLIT_BLE_CENTRAL_PERIPHERALS == CONFIG_BT_MAX_CONN) {
+        LOG_INF("skipped advertising, no connections allocated for profiles");
+        return 0;
+    }
+#endif
+
     int err = 0;
     bt_addr_le_t *addr;
     struct bt_conn *conn;