p4a: raise exception on disconnect failure
returning a bool from the disconnect() method is for backwards compatilbity only and should always be True. If disconnecting failed, an exception should be raised.
@@ -131,6 +131,7 @@ class BleakClientP4Android(BaseBleakClient):
# No connection exists. Either one hasn't been created or
# we have already called disconnect and closed the gatt
# connection.
+ logger.debug("already disconnected")
return True
# Try to disconnect the actual device/peripheral
@@ -147,9 +148,6 @@ class BleakClientP4Android(BaseBleakClient):
except Exception as e:
logger.error("Attempt to disconnect device failed: {0}".format(e))
- is_disconnected = not await self.is_connected()
-
- if is_disconnected:
self.__gatt = None
self.__callbacks = None
@@ -157,7 +155,7 @@ class BleakClientP4Android(BaseBleakClient):
self.services = BleakGATTServiceCollection()
self._services_resolved = False
- return is_disconnected
+ return True
async def pair(self, *args, **kwargs) -> bool:
"""Pair with the peripheral.
