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

aioble: Pass additional connection arguments to gap_connect. #906

Merged
merged 1 commit into from
Oct 18, 2024
Merged
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
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble-central/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(version="0.2.2")
metadata(version="0.3.0")

require("aioble-core")

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble-core/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(version="0.3.0")
metadata(version="0.4.0")

package(
"aioble",
Expand Down
12 changes: 10 additions & 2 deletions micropython/bluetooth/aioble/aioble/central.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ async def _cancel_pending():

# Start connecting to a peripheral.
# Call device.connect() rather than using method directly.
async def _connect(connection, timeout_ms):
async def _connect(
connection, timeout_ms, scan_duration_ms, min_conn_interval_us, max_conn_interval_us
):
device = connection.device
if device in _connecting:
return
Expand All @@ -122,7 +124,13 @@ async def _connect(connection, timeout_ms):

try:
with DeviceTimeout(None, timeout_ms):
ble.gap_connect(device.addr_type, device.addr)
ble.gap_connect(
device.addr_type,
device.addr,
scan_duration_ms,
min_conn_interval_us,
max_conn_interval_us,
)

# Wait for the connected IRQ.
await connection._event.wait()
Expand Down
16 changes: 14 additions & 2 deletions micropython/bluetooth/aioble/aioble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,26 @@ def __str__(self):
def addr_hex(self):
return binascii.hexlify(self.addr, ":").decode()

async def connect(self, timeout_ms=10000):
async def connect(
self,
timeout_ms=10000,
scan_duration_ms=None,
min_conn_interval_us=None,
max_conn_interval_us=None,
):
if self._connection:
return self._connection

# Forward to implementation in central.py.
from .central import _connect

await _connect(DeviceConnection(self), timeout_ms)
await _connect(
DeviceConnection(self),
timeout_ms,
scan_duration_ms,
min_conn_interval_us,
max_conn_interval_us,
)

# Start the device task that will clean up after disconnection.
self._connection._run_task()
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# code. This allows (for development purposes) all the files to live in the
# one directory.

metadata(version="0.5.2")
metadata(version="0.6.0")

# Default installation gives you everything. Install the individual
# components (or a combination of them) if you want a more minimal install.
Expand Down
Loading