@@ -174,6 +174,8 @@ def start_advertising(
174
174
:param float interval: advertising interval, in seconds
175
175
:param int timeout: advertising timeout in seconds.
176
176
If None, no timeout.
177
+
178
+ ``timeout`` is not available in CircuitPython 5.x and must be `None`.
177
179
"""
178
180
advertisement_bytes = bytes (advertisement )
179
181
scan_response_bytes = b""
@@ -183,13 +185,28 @@ def start_advertising(
183
185
scan_response .tx_power = self .tx_power
184
186
if scan_response :
185
187
scan_response_bytes = bytes (scan_response )
186
- self ._adapter .start_advertising (
187
- advertisement_bytes ,
188
- scan_response = scan_response_bytes ,
189
- connectable = advertisement .connectable ,
190
- interval = interval ,
191
- timeout = 0 if timeout is None else timeout ,
192
- )
188
+
189
+ # Remove after 5.x is no longer supported.
190
+ if (
191
+ sys .implementation .name == "circuitpython"
192
+ and sys .implementation .version [0 ] <= 5
193
+ ):
194
+ if timeout is not None :
195
+ raise NotImplementedError ("timeout not available for CircuitPython 5.x" )
196
+ self ._adapter .start_advertising (
197
+ advertisement_bytes ,
198
+ scan_response = scan_response_bytes ,
199
+ connectable = advertisement .connectable ,
200
+ interval = interval ,
201
+ )
202
+ else :
203
+ self ._adapter .start_advertising (
204
+ advertisement_bytes ,
205
+ scan_response = scan_response_bytes ,
206
+ connectable = advertisement .connectable ,
207
+ interval = interval ,
208
+ timeout = 0 if timeout is None else timeout ,
209
+ )
193
210
194
211
def stop_advertising (self ):
195
212
"""Stops advertising."""
0 commit comments