Skip to content

Commit

Permalink
add auto_connect for android
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Duda committed Sep 28, 2024
1 parent 3393c46 commit 4f4ee33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bleak/backends/p4android/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
),
Expand Down
10 changes: 10 additions & 0 deletions docs/backends/android.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

Expand Down

0 comments on commit 4f4ee33

Please sign in to comment.