Skip to content

Commit 26d91cf

Browse files
authored
Update ble_magic_light_simpletest.py
1 parent 61c24a3 commit 26d91cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/ble_magic_light_simpletest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
66
from adafruit_ble_magic_light import MagicLightService
77

8+
# CircuitPython <6 uses it's own ConnectionError type. So, is it if available. Otherwise,
9+
# the built in ConnectionError is used.
10+
connection_error = ConnectionError
11+
if hasattr(_bleio, "ConnectionError"):
12+
connection_error = _bleio.ConnectionError
813

914
def find_connection():
1015
for connection in radio.connections:
@@ -43,7 +48,7 @@ def wheel(pos):
4348
active_connection = radio.connect(scan)
4449
try:
4550
pixels = active_connection[MagicLightService]
46-
except _bleio.ConnectionError: # pylint: disable=no-member
51+
except connection_error:
4752
print("disconnected")
4853
continue
4954
break

0 commit comments

Comments
 (0)