@@ -32,7 +32,7 @@ class BLEConnection:
3232 Represents a connection to a peer BLE device.
3333 It acts as a map from a `Service` type to a `Service` instance for the connection.
3434
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
3636
3737 """
3838
@@ -227,15 +227,15 @@ def start_scan(
227227 :param float timeout: the scan timeout in seconds.
228228 If None, will scan until `stop_scan` is called.
229229 :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.
232232 :param float window: the duration (in seconds) to scan a single BLE channel.
233- window must be <= interval.
233+ window must be <= interval.
234234 :param int minimum_rssi: the minimum rssi of entries to return.
235235 :param bool active: request and retrieve scan responses for scannable advertisements.
236236 :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.
239239 :rtype: iterable
240240 """
241241 if not advertisement_types :
@@ -276,16 +276,18 @@ def stop_scan(self):
276276 once empty."""
277277 self ._adapter .stop_scan ()
278278
279- def connect (self , advertisement , * , timeout = 4.0 ):
279+ def connect (self , peer , * , timeout = 4.0 ):
280280 """
281281 Initiates a `BLEConnection` to the peer that advertised the given advertisement.
282282
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
285285 :return: the connection to the peer
286286 :rtype: BLEConnection
287287 """
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 )
289291 self ._connection_cache [connection ] = BLEConnection (connection )
290292 return self ._connection_cache [connection ]
291293
0 commit comments