I'm using an MKW31Z. Might be related to MKW30Z BLE connection flood protection but different processor so unsure.
I'm experiencing an issue where on occasion the call to Gap_Disconnect fails to produce a gConnEvtDisconnected_c callback event. If I call Gap_Disconnect again, I get an internal error of gHciUnknownConnectionIdentifier_c, which indicates that the disconnect occurred but no gConnEvtDisconnected_c callback.
If I ignore the fact that I didn't get the callback and go ahead and call Gap_SetAdvertisingParameters, I then receive no advertising callbacks.
The usual flow is:
gAdvertisingDataSetupComplete_c
gAdvertisingParametersSetupComplete_c
gAdvertisingStateChanged_c
gConnEvtConnected_c
gConnEvtParameterUpdateComplete_c
gConnEvtParameterUpdateComplete_c
gConnEvtDisconnected_c
And this will repeat until I don't get the gConnEvtDisconnected_c event. At that point, I can only achieve the gAdvertisingDataSetupComplete_c event, but not the other advertising events.
I have not found any pattern of number of connects/disconnects or advertising calls that trigger this. My code is based off the heart rate sensor example, but I don't currently have a working test sample. Using version 1.0.2 of the connectivity software.
Hello,
This issue has been fixed in the KW41Z SDK Maintenance Release which is out now. You can download it from the MCUXpresso SDK Builder.
Regards,
Gerardo
Tracked down the issue to a memory leak in L2ca_HciEventCallback, specifically when a Command Complete packet is returned for LE Remote Connection Parameter Request Reply.
Here's that packet: 0e 06 01 20 20 00 60 00
A buffer is allocated but then it fails the check comparing the first byte against 0x3e and the function returns. I've added some code to drop this packet before it hits Ble_HciRecv, and that appears to work for me. Please update the stack to properly fix this issue.
Hello Michael,
I have reported this issue to the SW team. I will update this thread when a resolution is available.
Regards,