PyBluez 连接问题
我对蓝牙技术完全是个新手。现在我正在尝试写一个脚本,想要连接我的手机并从中获取数据。理想情况下,我希望能捕捉到传输到我设备上的声音,就像蓝牙耳机那样。
不过,现在我的脚本在尝试创建一个连接时一直卡住,怎么回事呢?
import bluetooth
devices = bluetooth.discover_devices(lookup_names=True)
for addr, name in devices:
if 'Yealink' in name:
print(f"Найдено устройство: {name} с адресом {addr}")
address = addr
break
print("Connecting..")
port = 3
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.settimeout(10)
sock.connect((address, port))
print("Connected. Type something...")
while True:
data = input()
if not data:
break
sock.send(data)
sock.close()
我的电脑上的蓝牙工作得很好。
pythonProject uname -a
Linux 5.16.0-051600-generic #202201092355 SMP PREEMPT Mon Jan 10 00:21:11 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
我的蓝牙适配器是UB500。
PyBluez version:
Name: PyBluez
Version: 0.23
Summary: Bluetooth Python extension module
Home-page: http://pybluez.github.io/
Author: Albert Huang
Author-email: ashuang@alum.mit.edu
License: GPL
Location: /home/vladislav/.local/lib/python3.8/site-packages
Requires:
Required-by:
0 个回答
暂无回答