Skip to content

Commit e2a45e6

Browse files
Rescan if first scan fails in HIDMaster examples (#3089)
Sometimes the BT or BLE announcement doesn't show up during an initial scan window. Loop in the KeyboardPiano examples so that scans will be repeated until something actually links up. Fixes #3074
1 parent 775f46a commit e2a45e6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libraries/BluetoothHIDMaster/examples/KeyboardPiano/KeyboardPiano.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ void setup() {
206206

207207
hid.begin();
208208

209-
hid.connectAny();
210-
// or hid.connectMouse();
209+
do {
210+
hid.connectAny();
211+
// or hid.connectMouse();
212+
} while (!hid.connected());
211213
}
212214

213215
void loop() {

libraries/BluetoothHIDMaster/examples/KeyboardPianoBLE/KeyboardPianoBLE.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ void setup() {
206206

207207
hid.begin(true);
208208

209-
hid.connectBLE();
209+
do {
210+
hid.connectBLE();
211+
} while (!hid.connected());
210212
}
211213

212214
void loop() {

0 commit comments

Comments
 (0)