user1688175
user1688175

Reputation:

How keep connected to a Bluetooth device with Raspbian

I have just connected my Raspberry Pi (running Raspbian) with bluetooth speakers (Creative D80) and they working "quite" fine.

The only issue I have is whenever I play a sound using mpg321 through a Python command, it takes a while to actually start playing something (time the Raspbian takes to establish a connection to the device).

Here you can see my code:

from os import system

def play(file):

    statement = 'sudo -u pi mpg321 -g 5 -q -a bluetooth sound/' + file
    system(statement)

Is there a way to force Raspbian to keep the connection alive all the time?

Upvotes: 1

Views: 2112

Answers (1)

user1688175
user1688175

Reputation:

  1. Install the bluez-tools package - sudo apt-get install bluez-tools
  2. Open the rc.local file - sudo nano /etc/rc.local
  3. Insert this command before the "exit 0" statement - bt-audio -c MAC ID
  4. Restart your Raspberry Pi - sudo reboot

Upvotes: 1

Related Questions