Skip to content

Commit c633848

Browse files
authored
Update README.rst
1 parent 87b99b8 commit c633848

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ Usage Example
6565
6666
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
6767
from adafruit_ble_magic_light import MagicLightService
68+
69+
# CircuitPython <5 uses it's 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
6874
6975
def find_connection():
7076
for connection in radio.connections:
@@ -100,7 +106,7 @@ Usage Example
100106
active_connection = radio.connect(scan)
101107
try:
102108
pixels = active_connection[MagicLightService]
103-
except _bleio.ConnectionError:
109+
except connection_error:
104110
print("disconnected")
105111
continue
106112
break

0 commit comments

Comments
 (0)