Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add auto_connect for android #1644

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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