【发布时间】:2023-03-31 05:20:02
【问题描述】:
这是在 Gentoo Linux 上。
我正在尝试让 BlueZ 5 告诉我我的蓝牙耳机是否已连接。
我已经阅读并重新阅读了 freedesktop.org 上的 D-Bus «文档»,但它似乎已经过时(或不完整,或两者兼而有之)。我也尝试了解 bluez.org 上的微薄信息,但运气不佳。
我尝试了以下方法:
Python 2.7.6 (default, Apr 26 2014, 11:38:54)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> bus = dbus.SystemBus()
>>> obj = bus.get_object( "org.bluez", '/org/bluez/hci0/dev_00_18_91_D0_7A_24' )
>>> iface = dbus.Interface( obj, "org.bluez.Device1" )
>>> print iface.Connected
<dbus.proxies._DeferredMethod instance at 0x236e2d8>
我认为 Connected 是设备的属性,但它是 _DeferredMethod?那我怎样才能得到这个属性的值呢?
【问题讨论】:
-
看来你需要调用它:
print iface.Connected().