Tool/software:
Think this might be one for the TI engineers, not sure the relevant code is open source.... [based on SimpleLink Lowpower F3 8.10.1.2]
Scenario : CC2340R5 acting as a UART <> BLE bridge, MTU negotiated to allow a maximum GATT Notify payload of 244 bytes, with around 100 frames per second. The code is based upon the data_stream_UART_over_BLE example. There are no issues so long as nothing is connected to the device - it will run indefinitely, nicely toggling an LED for each frame that arrives at the UART (but then obviously doesn't have anywhere to go). When connected it continues to work fine - until the signal strength is reduced to the point it can't communicate any more. At this point the stack crashes.
The backtrace shows :
BLEAppUtil_Task()
SendUARTOverBLE()
DSP_sendData()
DSS_setParameter()
DSS_sendNotification()
icall_directAPI() [GATT_Notification() is #defined to icall_directAPI() with index 258]
ICall_abort() as a result of ICall_waitMatch() returning ICALL_ERRNO_TIMEOUT.
Of course ICall_abort() doesn't return so that effectively ends the BLE task. Increasing the signal strength again and manually allowing ICall_abort to return within the debugger does not resolve the issue, the device is still "dead" (ie no further LED activity and no advertisements, albeit FreeRTOS is still task switching).
My gut feeling is that the stack can't cope with the new data since there aren't any connection events which could drain the enqueued Notifies, but it doesn't seem to be failing gracefully. It's also not clear how to gracefully recover from this condition (returning from ICall_abort() doesn't work). For my part, it would be OK for the stack to gracefully say "nope, can't do that", ditch the Notify, tear down the connection and go back to just advertising, waiting for a new connection. Theoretically, if GATT_Notification() did return something other than SUCCESS, DSS_sendNotification() would free() the malloc()ed memory so there wouldn't be any memory leak as a result - but of course it never returns.
Any and all help very much appreciated.
Many thanks,
Patrick Herborn.