ble: catch and ignore the InProgress error when we're already listening

pull/8/head
Peter Hutterer 2018-01-16 11:08:21 +10:00
parent d4405cc1ef
commit 5f9766cb71
1 changed files with 8 additions and 2 deletions

View File

@ -320,8 +320,14 @@ class BlueZDeviceManager(GObject.Object):
continue
objpath = obj.get_object_path()
i.StartDiscovery()
logger.debug('{}: Discovery started (timeout {})'.format(objpath, timeout))
try:
i.StartDiscovery()
logger.debug('{}: Discovery started (timeout {})'.format(objpath, timeout))
except GLib.Error as e:
if (e.domain == 'g-io-error-quark' and
e.code == Gio.IOErrorEnum.DBUS_ERROR and
Gio.dbus_error_get_remote_error(e) == 'org.bluez.Error.InProgress'):
logger.debug('{}: Already listening'.format(objpath))
if timeout > 0:
GObject.timeout_add_seconds(timeout, self._discovery_timeout_expired)