ArduinoBLE - hasLocalName()

Query if a discovered BLE device is advertising a local name.

Syntax

bleDevice.hasLocalName()

Parameters

Nothing

Returns

true, if the device is advertising a local name, 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 local name, if present
    if (peripheral.hasLocalName()) {
      Serial.print("Local Name: ");
      Serial.println(peripheral.localName());
    }

    // ...
  }