python bluetooth.BluetoothSocket connection No-route/Device or resource busy

Viewed 500

I'm trying to connect to my bluetooth devices using python, but I fail on very first step. Most tutorial I found have code similar to this to connect. I use MAC address from hciconfig - I guess this is mac of my only adapter.

import bluetooth

for port in range(1, 11):
    try:
        s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
        s.connect(('00:1A:7D:DA:71:11', port))
        print("Connected")
        s.close()
    except OSError as err:
        print(f"Error connecting to {port}", err)

If run this above it will fail with „Device or resource busy”

If I use s.connect('') it fails with „Device or resource busy”.

I can use this adapter through bluetoothctl and other managers.

I have multiple devices working on it. So it is detected correctly by OS.

What is wrong here. How can I connect to my adapter using Python?

0 Answers
Related