Reference   Language | Libraries | Comparison | Changes

ArduinoBLE : BLEDevice class

hasAdvertisedServiceUuid()

Description

Query if a discovered BLE device is advertising a service UUID.

Syntax

bleDevice.hasAdvertisedServiceUuid()
bleDevice.hasAdvertisedServiceUuid(index)

Parameters

index - optional, defaults to 0, the index of the service UUID, if the device is advertising more than one.

Returns

true, if the device is advertising a service UUID, false otherwise.

Example


  // 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) {
    // ...

    // print the advertised service UUIDs, if present
    if (peripheral.hasAdvertisedServiceUuid()) {
      Serial.print("Service UUIDs: ");
      for (int i = 0; i < peripheral.advertisedServiceUuidCount(); i++) {
        Serial.print(peripheral.advertisedServiceUuid(i));
        Serial.print(" ");
      }
      Serial.println();
    }

    // ...
  }

See Also




Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.