So, I've been wanting to make my own raspberry-pi bluetooth speaker that I can connect my android phone to and play music. To do this, I stumbled across the PyBluez library in python, and found that I could use it to create and advertise a bluetooth service. So for testing out to see if I could advertise a service and connect my phone to it, I wrote the following code to try it out:
from bluetooth import * server = BluetoothSocket(RFCOMM) server.bind(("", PORT_ANY)) server.listen(1) uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee" advertise_service(sock=server, name="Bluetooth Speaker", service_id=uuid, service_classes=[SERIAL_PORT_CLASS], profiles=[SERIAL_PORT_PROFILE]) while True: client,addr = server.accept() print "Connection from " + addr client.close()
However, while the service does show up my phone just doesn't want to connect to it. After some googling, I've already done all of the following steps towards solving this problem, but to no avail:
- "DisablePlugins = pnat" in /etc/bluetooth/main.conf
- Service bluetooth restart
- hciconfig hci0 up
- hciconfig hci0 sspmode 0
- hciconfig hci0 piscan
- sdptool add SP
Is there something else that I need to do in order to get my phone to connect properly to my raspberry pi? Or is there a step that I'm missing?
Thank you!