From 44a2d5e8eb19cfc0de58a5dfe155c9dcee0277b5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jan 2018 12:10:07 +1000 Subject: [PATCH] ble: if we connect twice, log the error as debug We likely get multiple 'udpated' notifications as the RSSI property changes, all causing a Connect() on the device and an ugly error message (that we used to catch and print). Make that error message prettier. --- tuhi/ble.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tuhi/ble.py b/tuhi/ble.py index d578861..d430ed5 100755 --- a/tuhi/ble.py +++ b/tuhi/ble.py @@ -209,7 +209,13 @@ class BlueZDevice(GObject.Object): i.Connect(result_handler=self._on_connect_result) def _on_connect_result(self, obj, result, user_data): - if isinstance(result, Exception): + if (isinstance(result, GLib.Error) and + result.domain == 'g-io-error-quark' and + result.code == Gio.IOErrorEnum.DBUS_ERROR and + Gio.dbus_error_get_remote_error(result) == 'org.bluez.Error.Failed' and + 'Operation already in progress' in result.message): + logger.debug('{}: Already connecting'.format(self.address)) + elif isinstance(result, Exception): logger.error('Connection failed: {}'.format(result)) def disconnect_device(self):