I recently created a Raspberry Bluetooth music player with MQTT control, and discovered that, Raspberry allows multiple users to connect at the same time, and plays up to 3 people's music (which is awful).

Here is the code I'm using: https://github.com/sajtiii/rpi-mqtt-a2dp

The board I'm using is a model 3 B+

My question regarding to the problem, is there any way to limit how many devices can connect up to my PI at the same time?


I would not limit the number of Bluetooth connections but limit the number of tracks actually being played at once.

You could change the onMessage routine to put new requests in a queue and change the play routines to play from the queue (first come first served) or to just ignore requests while playing.

The other way would be to monitor connections in a script and as soon as one device is connected issue the discoverable off command to bluetoothctl to stop other devices connecting.

  • I'm already using the bluetoothctl discoverable off command after a successfull connection, but it doesn't help with already paired devices. It let's them connect anyway. Jun 21 '20 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.