ArduinoBLE - bleDevice.localName()

Query the local name a discovered Bluetooth® Low Energy device is advertising with.

Syntax

bleDevice.localName()

Parameters

Nothing

Returns

  • Advertised local name (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 local name, if present
    if (peripheral.hasLocalName()) {
      Serial.print("Local Name: ");
      Serial.println(peripheral.localName());
    }

    // ...
  }