Skip to content

Commit 68e3e07

Browse files
Joris-van-der-Weldpgeorge
authored andcommitted
aioble: Pass additional connection arguments to gap_connect.
This allows the following arguments to be passed to `device.connect()`: * scan_duration_ms * min_conn_interval_us * max_conn_interval_us These are passed as-is to `gap_connect()`. The default value for all of these is `None`, which causes gap_connect to use its own defaults. Signed-off-by: Joris van der Wel <joris@jorisvanderwel.com>
1 parent a7cd740 commit 68e3e07

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

micropython/bluetooth/aioble-central/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.2.2")
1+
metadata(version="0.3.0")
22

33
require("aioble-core")
44

micropython/bluetooth/aioble-core/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.3.0")
1+
metadata(version="0.4.0")
22

33
package(
44
"aioble",

micropython/bluetooth/aioble/aioble/central.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ async def _cancel_pending():
104104

105105
# Start connecting to a peripheral.
106106
# Call device.connect() rather than using method directly.
107-
async def _connect(connection, timeout_ms):
107+
async def _connect(
108+
connection, timeout_ms, scan_duration_ms, min_conn_interval_us, max_conn_interval_us
109+
):
108110
device = connection.device
109111
if device in _connecting:
110112
return
@@ -122,7 +124,13 @@ async def _connect(connection, timeout_ms):
122124

123125
try:
124126
with DeviceTimeout(None, timeout_ms):
125-
ble.gap_connect(device.addr_type, device.addr)
127+
ble.gap_connect(
128+
device.addr_type,
129+
device.addr,
130+
scan_duration_ms,
131+
min_conn_interval_us,
132+
max_conn_interval_us,
133+
)
126134

127135
# Wait for the connected IRQ.
128136
await connection._event.wait()

micropython/bluetooth/aioble/aioble/device.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,26 @@ def __str__(self):
132132
def addr_hex(self):
133133
return binascii.hexlify(self.addr, ":").decode()
134134

135-
async def connect(self, timeout_ms=10000):
135+
async def connect(
136+
self,
137+
timeout_ms=10000,
138+
scan_duration_ms=None,
139+
min_conn_interval_us=None,
140+
max_conn_interval_us=None,
141+
):
136142
if self._connection:
137143
return self._connection
138144

139145
# Forward to implementation in central.py.
140146
from .central import _connect
141147

142-
await _connect(DeviceConnection(self), timeout_ms)
148+
await _connect(
149+
DeviceConnection(self),
150+
timeout_ms,
151+
scan_duration_ms,
152+
min_conn_interval_us,
153+
max_conn_interval_us,
154+
)
143155

144156
# Start the device task that will clean up after disconnection.
145157
self._connection._run_task()

micropython/bluetooth/aioble/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# code. This allows (for development purposes) all the files to live in the
44
# one directory.
55

6-
metadata(version="0.5.2")
6+
metadata(version="0.6.0")
77

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy