Description
Hello,
I came across an occasional crash while using BLE/HCI.poll(). The crash occurs when _recvIndex goes above the size of _recvBuffer. The crash in my tests occurs when _recvIndex = 533.
I explained how I came across it in this Arduino forum post: https://forum.arduino.cc/index.php?topic=680797.0 but the long and the short of it is that it seems to happen after receiving an HCI_ACLDATA_PKT (possibly without being connected to anything) which leads to _recvIndex++ over and over without being caught and reset by the if statements and reset (not sure why). The basic fix I currently have running in HCI.cpp within the while (HCITransport.available()) loop is:
if (_recvIndex > 257) { _recvIndex = 0; if (_debug) { _debug->println(); _debug->println("***Overflow Catch***"); _debug->println(); } }
Not groundbreaking but seems to be stopping the crash.
The "overflow catch" is still occurring in my tests, however it may be something else. Please let me know if more information would help or if I am missing something obvious.
Thanks,
Matt