ArduinoBLE - bleDevice.advertisedServiceUuidCount()

Query the number of advertised services a discovered Bluetooth® Low Energy device is advertising.

Syntax

bleDevice.advertisedServiceUuidCount()

Parameters

None

Returns

  • The number of advertised services a discovered Bluetooth® Low Energy device is advertising.

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();
    }

    // ...
  }