Skip to content

Commit c91c02c

Browse files
authored
Merge pull request #374 from fabik111/fix-shutdown-ble-portenta
Fix for BLE restart after a BLE end on portenta based devices
2 parents 9712cb1 + bbc2baa commit c91c02c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/utility/HCICordioTransport.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "CordioHCICustomDriver.h"
5656

5757
extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver();
58+
extern "C" void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len);
5859

5960
namespace BLE_NAMESPACE {
6061
struct CordioHCIHook {
@@ -236,6 +237,13 @@ void HCICordioTransportClass::end()
236237
delete bleLoopThread;
237238
bleLoopThread = NULL;
238239
}
240+
// Reset the callback with the mbed-os default handler to properly handle the following CYW43xxx chip initializations and begins
241+
CordioHCIHook::setDataReceivedHandler(hciTrSerialRxIncoming);
242+
243+
#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)
244+
BLE &ble = BLE::Instance();
245+
ble.shutdown();
246+
#endif
239247

240248
#if !defined(TARGET_STM32H7)
241249
CordioHCIHook::getDriver().terminate();

0 commit comments

Comments
 (0)