From 4051da809b335d295a7fb917da03f12cd08320e5 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:39:04 +0000 Subject: [PATCH] Fix connection lockups/issues --- app/src/split/bluetooth/central.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 61bad67741b..57b5a257fac 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -901,12 +901,15 @@ void split_central_split_led_callback(struct k_work *work) { while (k_msgq_get(&zmk_split_central_split_led_msgq, &payload, K_NO_WAIT) == 0) { if (peripherals[0].state != PERIPHERAL_SLOT_STATE_CONNECTED) { LOG_ERR("Source not connected"); - continue; + return; } if (!peripherals[0].update_led_handle) { LOG_ERR("handle not discovered"); - continue; + return; + } + if (bt_conn_get_security(peripherals[0].conn) < BT_SECURITY_L2) { + return; } int err = bt_gatt_write_without_response(peripherals[0].conn, @@ -967,14 +970,16 @@ void split_central_split_bl_callback(struct k_work *work) { while (k_msgq_get(&zmk_split_central_split_bl_msgq, &payload, K_NO_WAIT) == 0) { if (peripherals[0].state != PERIPHERAL_SLOT_STATE_CONNECTED) { LOG_ERR("Source not connected"); - continue; + return; } if (!peripherals[0].update_bl_handle) { LOG_ERR("handle not discovered"); - continue; + return; + } + if (bt_conn_get_security(peripherals[0].conn) < BT_SECURITY_L2) { + return; } - int err = bt_gatt_write_without_response(peripherals[0].conn, peripherals[0].update_bl_handle, &payload, sizeof(struct zmk_split_update_bl_data), true);