bluetooth OnloadCb,RefreshDevices will block n secs if there is no bluez daemon

This commit is contained in:
cuu 2018-12-02 18:00:07 +08:00
parent 793e0cae3a
commit eeb0a616c3

View File

@ -544,12 +544,16 @@ class BluetoothPage(Page):
def RefreshDevices(self):
global devices
devices = {}
proxy_obj = bus.get_object("org.bluez", "/")
manager = dbus.Interface(proxy_obj,"org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path, interfaces in objects.iteritems():
if "org.bluez.Device1" in interfaces:
devices[path] = interfaces["org.bluez.Device1"] ## like /org/bluez/hci0/dev_xx_xx_xx_yy_yy_yy
try:
proxy_obj = bus.get_object("org.bluez", "/")
manager = dbus.Interface(proxy_obj,"org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path, interfaces in objects.iteritems():
if "org.bluez.Device1" in interfaces:
devices[path] = interfaces["org.bluez.Device1"] ## like /org/bluez/hci0/dev_xx_xx_xx_yy_yy_yy
except Exception,e:
print(str(e))
devices={}
self._Devices = devices