You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

系统更新后调用org.bluez.Adapter1的StopDiscovery方法报错求助

问题描述

在RPi Zero 2 W上使用LM1010蓝牙USB适配器(已禁用板载WiFi和蓝牙),运行solar-monitor脚本连接两个蓝牙适配器并通过MQTT传输数据,该脚本已稳定运行2年。执行sudo apt-get update && sudo apt-get upgrade系统更新后,脚本在BLE扫描阶段崩溃,报错如下:

INFO: Adapter status - Powered: True
INFO: Starting discovery...
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/gatt/gatt_linux.py", line 156, in stop_discovery
    self._adapter.StopDiscovery()
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: Method "StopDiscovery" with signature "" on interface "org.bluez.Adapter1" doesn't exist


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/solar-monitor/solar-monitor.py", line 84, in <module>
    device_manager.stop_discovery()
  File "/home/pi/.local/lib/python3.9/site-packages/gatt/gatt_linux.py", line 161, in stop_discovery
    raise _error_from_dbus_error(e)
gatt.errors.Failed: Method "StopDiscovery" with signature "" on interface "org.bluez.Adapter1" doesn't exist
排查与解决建议
  • 检查BlueZ版本变更
    系统升级大概率更新了BlueZ(Linux蓝牙栈),新版本可能移除或修改了StopDiscovery方法。执行bluetoothctl --version查看当前版本,对比升级前的版本(可通过/var/log/apt/history.log查找升级记录)。BlueZ 5.60+之后部分DBus接口有调整,StopDiscovery可能被替换为其他逻辑,或者需要通过不同方式调用。

  • 验证蓝牙适配器DBus接口
    使用dbus-send工具直接查询适配器的可用方法,确认StopDiscovery是否存在:

    dbus-send --system --print-reply --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
    

    替换/org/bluez/hci0为你的适配器路径(可通过bluetoothctl list获取)。如果输出中没有StopDiscovery方法,说明BlueZ版本确实调整了接口。

  • 适配脚本或更新依赖库

    1. 脚本依赖的gatt Python库可能未适配新版本BlueZ,尝试更新该库:
      pip3 install --upgrade gatt
      
      如果更新后问题依旧,需要修改脚本中调用stop_discovery()的逻辑:比如先检查适配器是否处于扫描状态,或者改用BlueZ新的扫描控制方式(如通过SetDiscoveryFilter或其他DBus调用终止扫描)。
    2. 查看solar-monitor脚本的最新修改,是否有针对BlueZ新版本的修复,手动同步相关代码调整。
  • 临时降级BlueZ恢复服务
    如果需要快速恢复运行,可尝试降级BlueZ到升级前的版本:

    1. 从/var/log/apt/history.log中查找升级前的BlueZ版本号,例如bluez=5.55-3+rpt2。
    2. 执行降级命令:
      sudo apt-get install bluez=旧版本号
      
      之后标记BlueZ为禁止升级,避免再次触发问题:
      sudo apt-mark hold bluez
      
  • 检查蓝牙适配器状态与兼容性
    新版本BlueZ可能对LM1010适配器的支持有变化,先确认适配器状态正常:

    hciconfig hci0
    

    尝试重启蓝牙服务:

    sudo systemctl restart bluetooth
    

    重新加载蓝牙USB模块:

    sudo rmmod btusb && sudo modprobe btusb
    

内容的提问来源于stack exchange,提问作者Positron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 14:50:21