arduino-libraries / ArduinoBLE

ArduinoBLE library for Arduino
GNU Lesser General Public License v2.1
314 stars 205 forks source link

[mbed boards] Packet drops cause failures #130

Open polldo opened 4 years ago

polldo commented 4 years ago

Background Mbed boards (nano33ble, portentaH7) running ArduinoBLE have two relevant concurrent threads in execution: one executes the main arduino sketch, the other one handles the transport of HCI packets and stores the received ones in an internal buffer. The thread executing the sketch should regularly call the BLE.poll() function to retrieve and analyze the packets stored by the other thread.

Problem: If too much time passes between calls to the BLE.poll() function, then the buffer of received packets may become full. If it becomes full then the new packets received will be dropped. (see code) This behaviour may result in a buffer overflow and consequently in a system crash.

Possible solutions

Related issues https://github.com/arduino-libraries/ArduinoBLE/issues/126 https://github.com/arduino-libraries/ArduinoBLE/issues/73 https://github.com/arduino-libraries/ArduinoBLE/issues/102

andbe-gh commented 4 years ago

Hi @Polldo, the changes in HCICordioTransport.cpp (#96) seem to fix my problem (#126) with hanging arduino when many BLE devices are nearby. I've succesfully tested it with 32 devices.

andbe-gh commented 3 years ago

Is the problem fixed in the new release? I can't find anything in the changelog from 1.1.3 to 1.2.