Skip to content

Commit 34da08f

Browse files
committed
Simplify led_control example by using BLE.scanForUuid(...)
1 parent 5314060 commit 34da08f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

libraries/CurieBLE/examples/central/led_control/led_control.ino

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void setup() {
3737
Serial.println("BLE Central - LED control");
3838

3939
// start scanning for peripherals
40-
BLE.scan();
40+
BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
4141
}
4242

4343
void loop() {
@@ -54,16 +54,13 @@ void loop() {
5454
Serial.print(peripheral.advertisedServiceUuid());
5555
Serial.println();
5656

57-
// see if peripheral is advertising the LED service
58-
if (peripheral.advertisedServiceUuid() == "19b10000-e8f2-537e-4f6c-d104768a1214") {
59-
// stop scanning
60-
BLE.stopScan();
57+
// stop scanning
58+
BLE.stopScan();
6159

62-
controlLed(peripheral);
60+
controlLed(peripheral);
6361

64-
// peripheral disconnected, start scanning again
65-
BLE.scan();
66-
}
62+
// peripheral disconnected, start scanning again
63+
BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
6764
}
6865
}
6966

@@ -124,4 +121,6 @@ void controlLed(BLEDevice peripheral) {
124121
}
125122
}
126123
}
124+
125+
Serial.println("Peripheral disconnected");
127126
}

0 commit comments

Comments
 (0)