我正在使用BlueZ随附的样本gatt服务器,并添加了一个信号处理程序来检测连接和断开,如下所示:
bus.add_signal_receiver(PropertiesChangedHandler,
dbus_interface = "org.freedesktop.DBus.Properties",
signal_name = "PropertiesChanged",
arg0 = "org.bluez.Device1",
path_keyword = "path")
我的信号处理程序只是打印出一些信息:
def PropertiesChangedHandler(interface, changed, invalidated, path):
if 'Connected' in changed:
print("---- Connected Property Changed ----")
print('Interface: ', interface)
print('Changed: ', changed['Connected'])
print('Path: ', path)
if 'ServicesResolved' in changed:
print("---- ServicesResolved Property Changed ----")
print('Interface: ', interface)
print('Changed: ', changed['ServicesResolved'])
print('Path: ', path)
但是,在运行服务器时,我只能检测到断开连接。我从未收到任何连接信号。我在正在处理的信号中添加了“ ServicesResolved”,它似乎按预期工作。连接和断开连接时,我的日志如下所示:
---- ServicesResolved属性已更改----
接口:org.bluez.Device1
已更改:1
路径:/ org / bluez / hci0 / dev_42_36_D9_11_CA_4B
----关联财产已更改----
接口:org.bluez.Device1
已更改:0
路径:/ org / bluez / hci0 / dev_42_36_D9_11_CA_4B
---- ServicesResolved属性已更改----
接口:org.bluez.Device1
已更改:0
路径:/ org / bluez / hci0 / dev_42_36_D9_11_CA_4B
这种奇怪的行为可能有什么原因?如果那很重要,我正在使用BlueZ 5.46。