Сбой соединения Bluetooth с неизвестной ошибкой при использовании Python и PyBleuz - PullRequest
0 голосов
/ 16 февраля 2020

Кто-нибудь может мне помочь? Я использую Python 3.7, и я скачал PyBluez (версия 0.22) с pip install pybluez. Сейчас я пытаюсь подключить устройство Bluetooth к своему P C. Это следующий код:

import bluetooth

print("performing inquiry...")
found_it = 0
while(found_it==0):
    nearby_devices =bluetooth.discover_devices(lookup_names = True)
    print("found %d devices" % len(nearby_devices))

    for addr,name in nearby_devices:
        print(" %s - %s" % (addr, name))
        if (addr == "98:D3:31:FD:79:32" and name == "CraneController_1"):
            found_it=1
            client_socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
            client_socket.connect((addr,19))
print("Sending Data!")
for i in range(1,5):
    client_socket.send("Hello World %s"%(i))

print("Finished!")
client_socket.close()

Мой P C найти одно устройство Bluetooth, но, к сожалению, я получаю ошибку в client_socket.connect((addr,19))

Traceback (most recent call last):
File "C:/Ablage/Python_Script/Bluetooth/Connection.py", line 16, in <module>
    client_socket.connect((addr,19))

File "C:\Ablage\Anaconda3\envs\intel\lib\site-packages\bluetooth\msbt.py", line 84, in connect
    bt.connect (self._sockfd, addr, port)

OSError

Порт правильный, в соответствии с Windows: enter image description here

Я много искал, но не нашел решения. Большое спасибо за вашу поддержку.

...