@@ -162,14 +162,18 @@ def __init__(self, adapter=None):
162
162
self ._current_advertisement = None
163
163
self ._connection_cache = {}
164
164
165
- def start_advertising (self , advertisement , scan_response = None , interval = 0.1 ):
165
+ def start_advertising (
166
+ self , advertisement , scan_response = None , interval = 0.1 , timeout = None
167
+ ):
166
168
"""
167
169
Starts advertising the given advertisement.
168
170
169
171
:param buf scan_response: scan response data packet bytes.
170
172
If ``None``, a default scan response will be generated that includes
171
173
`BLERadio.name` and `BLERadio.tx_power`.
172
174
:param float interval: advertising interval, in seconds
175
+ :param int timeout: advertising timeout in seconds.
176
+ If None, no timeout.
173
177
"""
174
178
advertisement_bytes = bytes (advertisement )
175
179
scan_response_bytes = b""
@@ -184,6 +188,7 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
184
188
scan_response = scan_response_bytes ,
185
189
connectable = advertisement .connectable ,
186
190
interval = interval ,
191
+ timeout = 0 if timeout is None else timeout ,
187
192
)
188
193
189
194
def stop_advertising (self ):
@@ -321,3 +326,8 @@ def tx_power(self, value):
321
326
def address_bytes (self ):
322
327
"""The device address, as a ``bytes()`` object of length 6."""
323
328
return self ._adapter .address .address_bytes
329
+
330
+ @property
331
+ def advertising (self ):
332
+ """The advertising state"""
333
+ return self ._adapter .advertising
0 commit comments