Skip to content

Commit 3563ce4

Browse files
committed
Fix arduino#445 Deprecated BLEConnected and BLEDisconnected events not triggered
1. Root casue: The callback regiter before the begin and the begin reset the callback. 2. Solution: Remove it from the init method and init it when create.
1 parent 11108f7 commit 3563ce4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libraries/CurieBLE/src/BLEPeripheral.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "BLEPeripheral.h"
2323

24-
static BLEPeripheralEventHandler m_eventHandlers[BLEDeviceLastEvent];
24+
static BLEPeripheralEventHandler m_eventHandlers[BLEDeviceLastEvent] = {NULL, NULL, NULL, NULL};
2525

2626
void bleBackCompatiblePeripheralConnectHandler(BLEDevice central)
2727
{
@@ -154,7 +154,6 @@ void BLEPeripheral::init()
154154
if (!_initCalled)
155155
{
156156
BLE.begin();
157-
memset(m_eventHandlers, 0, sizeof(m_eventHandlers));
158157
_initCalled = true;
159158
}
160159
}

0 commit comments

Comments
 (0)