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;