@@ -162,14 +162,18 @@ def __init__(self, adapter=None):
162162 self ._current_advertisement = None
163163 self ._connection_cache = {}
164164
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+ ):
166168 """
167169 Starts advertising the given advertisement.
168170
169171 :param buf scan_response: scan response data packet bytes.
170172 If ``None``, a default scan response will be generated that includes
171173 `BLERadio.name` and `BLERadio.tx_power`.
172174 :param float interval: advertising interval, in seconds
175+ :param int timeout: advertising timeout in seconds.
176+ If None, no timeout.
173177 """
174178 advertisement_bytes = bytes (advertisement )
175179 scan_response_bytes = b""
@@ -184,6 +188,7 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
184188 scan_response = scan_response_bytes ,
185189 connectable = advertisement .connectable ,
186190 interval = interval ,
191+ timeout = 0 if timeout is None else timeout ,
187192 )
188193
189194 def stop_advertising (self ):
@@ -321,3 +326,8 @@ def tx_power(self, value):
321326 def address_bytes (self ):
322327 """The device address, as a ``bytes()`` object of length 6."""
323328 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