Skip to content

Commit 2856d2b

Browse files
committed
Disconnect when restarting HID example
1 parent 3d7bb01 commit 2856d2b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/ble_hid_periph.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,14 @@
124124
advertisement = ProvideServicesAdvertisement(hid)
125125
advertisement.appearance = 961
126126
scan_response = Advertisement()
127-
scan_response.complete_name = "CircuitPython HID"
128127

129128
ble = adafruit_ble.BLERadio()
130-
if not ble.connected:
131-
print("advertising")
132-
ble.start_advertising(advertisement, scan_response)
133-
else:
134-
print("already connected")
135-
print(ble.connections)
129+
if ble.connected:
130+
for c in ble.connections:
131+
c.disconnect()
132+
133+
print("advertising")
134+
ble.start_advertising(advertisement, scan_response)
136135

137136
k = Keyboard(hid.devices)
138137
kl = KeyboardLayoutUS(k)

0 commit comments

Comments
 (0)