From 5a423bafc443115679e0613ba1248d4ad557938d Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Tue, 14 Jan 2025 13:40:29 +0100 Subject: [PATCH] fix gap central connection flow to be compatible between wb5x, wba5x and wba6x --- .../middlewares/ble_middleware/GapCentralSt.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp index e69846e9..f7505f96 100644 --- a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp @@ -165,11 +165,11 @@ namespace hal auto gattCompleteEvent = *reinterpret_cast(vendorEvent->data); - if (onMtuExchangeDone && gattCompleteEvent.Error_Code == BLE_STATUS_SUCCESS) - { + if (gattCompleteEvent.Error_Code == BLE_STATUS_SUCCESS) really_assert(gattCompleteEvent.Connection_Handle == connectionContext.connectionHandle); + + if (onMtuExchangeDone) onMtuExchangeDone(); - } } void GapCentralSt::HandleL2capConnectionUpdateRequestEvent(evt_blecore_aci* vendorEvent) @@ -187,10 +187,13 @@ namespace hal assert(status == BLE_STATUS_SUCCESS); }); - infra::EventDispatcherWithWeakPtr::Instance().Schedule([this]() - { - MtuExchange(); - }); + if (onMtuExchangeDone) + infra::EventDispatcherWithWeakPtr::Instance().Schedule([this]() + { + MtuExchange(); + }); + else + SetDataLength(); } void GapCentralSt::HandleHciLeDataLengthChangeEvent(evt_le_meta_event* metaEvent)