您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

必须重置适配器后,蓝牙的Python代码会引发错误

必须重置适配器后,蓝牙的Python代码会引发错误

确保运行sdptool browse local会出现以下错误

Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory

事实证明,罪魁祸首是bluetoothd蓝牙守护程序。与SDP一起bluetoothd使用时,出于某些愚蠢的原因,要求使用不推荐使用的功能,因此要解决此问题,必须在兼容模式下使用bluetoothd -C(或bluetooth --compat)启动该守护程序。

查找位置bluetooth.service

systemctl status bluetooth.service

然后编辑bluetooth.service并寻找

ExecStart=/usr/libexec/bluetooth/bluetoothd

追加--compat到此行的末尾,保存,然后运行

service bluetooth start

如果一切顺利,您应该能够成功运行

sudo sdptool browse local

最后,重置适配器:

sudo hciconfig -a hci0 reset

现在一切正常

只是让人们知道,我相信最新BlueZ版本在我的系统中被破坏了。我下载,编译并安装了5.35版本,但没有任何效果。我拨到5.34,还是一样。我还注意到,蓝牙适配器在启用后会自动关闭3-4分钟,

sudo hciconfig hci0 up # hci0 is the bt adapter

我使用一个USB蓝牙加密狗进行测试。它没有像内置适配器那样自动关闭,但是问题仍然存在。然后我曾经apt-get重新安装bluez

apt-get install --reinstall bluez

突然之间一切恢复正常。

python 2022/1/1 18:28:31 有475人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶