@@ -32,7 +32,7 @@ class BLEConnection:
32
32
Represents a connection to a peer BLE device.
33
33
It acts as a map from a `Service` type to a `Service` instance for the connection.
34
34
35
- :param bleio_connection _bleio.Connection: the native `_bleio.Connection` object to wrap
35
+ :param _bleio.Connection bleio_connection : the native `_bleio.Connection` object to wrap
36
36
37
37
"""
38
38
@@ -227,15 +227,15 @@ def start_scan(
227
227
:param float timeout: the scan timeout in seconds.
228
228
If None, will scan until `stop_scan` is called.
229
229
:param float interval: the interval (in seconds) between the start
230
- of two consecutive scan windows
231
- Must be in the range 0.0025 - 40.959375 seconds.
230
+ of two consecutive scan windows
231
+ Must be in the range 0.0025 - 40.959375 seconds.
232
232
:param float window: the duration (in seconds) to scan a single BLE channel.
233
- window must be <= interval.
233
+ window must be <= interval.
234
234
:param int minimum_rssi: the minimum rssi of entries to return.
235
235
:param bool active: request and retrieve scan responses for scannable advertisements.
236
236
:return: If any ``advertisement_types`` are given,
237
- only Advertisements of those types are produced by the returned iterator.
238
- If none are given then `Advertisement` objects will be returned.
237
+ only Advertisements of those types are produced by the returned iterator.
238
+ If none are given then `Advertisement` objects will be returned.
239
239
:rtype: iterable
240
240
"""
241
241
if not advertisement_types :
@@ -276,16 +276,18 @@ def stop_scan(self):
276
276
once empty."""
277
277
self ._adapter .stop_scan ()
278
278
279
- def connect (self , advertisement , * , timeout = 4.0 ):
279
+ def connect (self , peer , * , timeout = 4.0 ):
280
280
"""
281
281
Initiates a `BLEConnection` to the peer that advertised the given advertisement.
282
282
283
- :param advertisement Advertisement : An `Advertisement` or a subclass of `Advertisement`
284
- :param timeout float: how long to wait for a connection
283
+ :param peer : An `Advertisement`, a subclass of `Advertisement` or `_bleio.Address `
284
+ :param float timeout : how long to wait for a connection
285
285
:return: the connection to the peer
286
286
:rtype: BLEConnection
287
287
"""
288
- connection = self ._adapter .connect (advertisement .address , timeout = timeout )
288
+ if not isinstance (peer , _bleio .Address ):
289
+ peer = peer .address
290
+ connection = self ._adapter .connect (peer , timeout = timeout )
289
291
self ._connection_cache [connection ] = BLEConnection (connection )
290
292
return self ._connection_cache [connection ]
291
293
0 commit comments