File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ Usage Example
65
65
66
66
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
67
67
from adafruit_ble_magic_light import MagicLightService
68
+
69
+ # CircuitPython <6 uses its own ConnectionError type. So, is it if available. Otherwise,
70
+ # the built in ConnectionError is used.
71
+ connection_error = ConnectionError
72
+ if hasattr (_bleio, " ConnectionError" ):
73
+ connection_error = _bleio.ConnectionError
68
74
69
75
def find_connection ():
70
76
for connection in radio.connections:
@@ -100,7 +106,7 @@ Usage Example
100
106
active_connection = radio.connect(scan)
101
107
try :
102
108
pixels = active_connection[MagicLightService]
103
- except _bleio.ConnectionError :
109
+ except connection_error :
104
110
print (" disconnected" )
105
111
continue
106
112
break
Original file line number Diff line number Diff line change 5
5
from adafruit_ble .advertising .standard import ProvideServicesAdvertisement
6
6
from adafruit_ble_magic_light import MagicLightService
7
7
8
+ # CircuitPython <6 uses its 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
13
+
8
14
9
15
def find_connection ():
10
16
for connection in radio .connections :
@@ -43,7 +49,7 @@ def wheel(pos):
43
49
active_connection = radio .connect (scan )
44
50
try :
45
51
pixels = active_connection [MagicLightService ]
46
- except _bleio . ConnectionError : # pylint: disable=no-member
52
+ except connection_error :
47
53
print ("disconnected" )
48
54
continue
49
55
break
You can’t perform that action at this time.
0 commit comments