diff --git a/bleak/backends/p4android/client.py b/bleak/backends/p4android/client.py index f1bca4dd..e99cea19 100644 --- a/bleak/backends/p4android/client.py +++ b/bleak/backends/p4android/client.py @@ -49,6 +49,7 @@ def __init__( self.__adapter = kwargs.get("adapter", kwargs.get("device", None)) self.__gatt = None self.__mtu = 23 + self.__auto_connect = kwargs.get("auto_connect", False) def __del__(self): if self.__gatt is not None: @@ -84,7 +85,7 @@ async def connect(self, **kwargs) -> bool: dispatchApi=self.__device.connectGatt, dispatchParams=( defs.context, - False, + self.__auto_connect, self.__callbacks.java, defs.BluetoothDevice.TRANSPORT_LE, ), diff --git a/docs/backends/android.rst b/docs/backends/android.rst index 71f9d8c8..76ef227c 100644 --- a/docs/backends/android.rst +++ b/docs/backends/android.rst @@ -56,6 +56,16 @@ be added to the android application in the buildozer.spec file, and are also requested from the user at runtime. This means that enabling bluetooth may not succeed if the user does not accept permissions. +Specific features for the Android backend +----------------------------------------- + +Client +~~~~~~ + - The constructor keyword ``auto_connect`` which can be set to ``True`` or ``False``. +Whether to directly connect to the remote device ``False`` or to automatically +connect as soon as the remote device becomes available ``True``. +The default value is ``False``. + API ---