kopia lustrzana https://github.com/micropython/micropython-lib
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>pull/906/head v1.24.0
rodzic
a7cd740b64
commit
68e3e07bc7
|
@ -1,4 +1,4 @@
|
|||
metadata(version="0.2.2")
|
||||
metadata(version="0.3.0")
|
||||
|
||||
require("aioble-core")
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
metadata(version="0.3.0")
|
||||
metadata(version="0.4.0")
|
||||
|
||||
package(
|
||||
"aioble",
|
||||
|
|
|
@ -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
|
||||
|
@ -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()
|
||||
|
|
|
@ -132,14 +132,26 @@ class Device:
|
|||
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()
|
||||
|
|
|
@ -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.
|
||||
|
|
Ładowanie…
Reference in New Issue