Komut
connect()
Açıklama
Bir BLE cihazına bağlayın.
Sözdizimi
bleDevice.connect ()
Parametreler
Yok
İadeler
true , bağlantı başarılı olursa, aksi takdirde false .
Misal
…
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
Serial.println("BLE Central scan");
// start scanning for peripheral
BLE.scan();
// …
BLEDevice peripheral = BLE.available();
if (peripheral) {
// ...
Serial.println("Connecting ...");
if (peripheral.connect()) {
Serial.println("Connected");
} else {
Serial.println("Failed to connect!");
return;
}
// ...
}
…
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
Serial.println("BLE Central scan");
// start scanning for peripheral
BLE.scan();
// …
BLEDevice peripheral = BLE.available();
if (peripheral) {
// ...
Serial.println("Connecting ...");
if (peripheral.connect()) {
Serial.println("Connected");
} else {
Serial.println("Failed to connect!");
return;
}
// ...
}
…
See Also
- hasLocalName()
- hasAdvertisedServiceUuid()
- advertisedServiceUuidCount()
- localName()
- advertisedServiceUuid()