ArduinoBLE - bleDevice.advertisedServiceUuid()

Query an advertised service UUID discovered Bluetooth® Low Energy device is advertising.

Syntax

bleDevice.advertisedServiceUuid()
bleDevice.advertisedServiceUuid(index)

Parameters

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

Returns

  • Advertised service UUID (as a String).

Example


  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting Bluetooth® Low Energy module 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();
    }

    // ...
  }