IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.59k stars 491 forks source link

Error 13 - "Too many links" bluepy infinite loop? #361

Open johnfwhitmore opened 5 years ago

johnfwhitmore commented 5 years ago

I hit this problem whilst connecting BLE devices to an Ubuntu 16.04 install. I'm not sure what the Bluetooth chipset in the platform is, but it has a limit on the number of BLE connections which can be maintained.

I had to make changes to bluepy_helper.c to log the error so I'll make a pull request for that and try to fix the resulting issue. The issue being that bluepy doesn't back off but constantly bombards bluez with packets for the device it's trying to connect to. The only way I have to getting bluepy out of that state is to cut power to the device being connected, at which point bluepy stops transmitting to the device.

I'm not sure this project is still being maintained but there should be some way of informing the python application of this error, but unfortunately it's asynchronous so have to look into the proper mechanism for reporting back to application layer. Another problem is that the number has been changing, dropping from 7 connected devices down to 5. A reboot restores the limit to 7 so there may be some leakage of resources or something.