From eab56317032f9c878503f61090ad3b043ff17001 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 29 Oct 2024 15:15:29 +0100 Subject: [PATCH] fix ble end on mbed portenta boards for successfully ble restart --- src/utility/HCICordioTransport.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utility/HCICordioTransport.cpp b/src/utility/HCICordioTransport.cpp index 7848712f..e28414e3 100644 --- a/src/utility/HCICordioTransport.cpp +++ b/src/utility/HCICordioTransport.cpp @@ -55,6 +55,7 @@ #include "CordioHCICustomDriver.h" extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver(); +extern "C" void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len); namespace BLE_NAMESPACE { struct CordioHCIHook { @@ -236,6 +237,12 @@ void HCICordioTransportClass::end() delete bleLoopThread; bleLoopThread = NULL; } + CordioHCIHook::setDataReceivedHandler(hciTrSerialRxIncoming); + +#if (defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)) && !defined(CUSTOM_HCI_DRIVER) + BLE &ble = BLE::Instance(); + ble.shutdown(); +#endif #if !defined(TARGET_STM32H7) CordioHCIHook::getDriver().terminate(); @@ -290,7 +297,7 @@ size_t HCICordioTransportClass::write(const uint8_t* data, size_t length) } void HCICordioTransportClass::handleRxData(uint8_t* data, uint8_t len) -{ +{ if (_rxBuf.availableForStore() < len) { // drop! return;