GIGA R1 Android BLE unable to discover attributes

Hi,

following the example from ArduinoBLE library called "PeripheralExplorer"
I should be able to call discoverAttibutes after successful connecting:


...
if (peripheral.connect()) {
    Serial.println("Connected");
  } else {
    Serial.println("Failed to connect!");
    return;
  }

  // discover peripheral attributes
  Serial.println("Discovering attributes ...");
  if (peripheral.discoverAttributes()) {
    Serial.println("Attributes discovered");
  } else {
    Serial.println("Attribute discovery failed!");
    peripheral.disconnect();
    return;
  }
...

But when I flash this code to the board it does actually connect and the scan process and so on works as expected.
However, as soon as I call discoverAttributes, the library seems to hang there leading to a crash ob the mbed os after a few seconds.

Another strange thing:

I can discover a service with BLEDevice.discoverService (it returns true).
But if I check BLEDevice.serviceCount() it actually returns 0.

Really strange behavior of the library.

Do I miss anything apart from the normal BLE.begin() stuff as done in the examples?

To me it seems like the connection setup might miss some security process? Can this be the case? Is there any alternative library for that?

Thanks
Alex

It does work... Did you remember to change the "localName" to suit your application. In the example it searches for any device with the name "LED". In my animation below, I changed my local name to "Pico" as my peripheral was a Raspberry Pi Pico board running its own custom BLE example.

void loop() {
  // check if a peripheral has been discovered
  BLEDevice peripheral = BLE.available();

  if (peripheral) {
    // discovered a peripheral, print out address, local name, and advertised service
    Serial.print("Found ");
    Serial.print(peripheral.address());
    Serial.print(" '");
    Serial.print(peripheral.localName());
    Serial.print("' ");
    Serial.print(peripheral.advertisedServiceUuid());
    Serial.println();

    // see if peripheral is a LED
    if (peripheral.localName() == "LED") {
      // stop scanning
      BLE.stopScan();

      explorerPeripheral(peripheral);

      // peripheral disconnected, we are done
      while (1) {
        // do nothing
      }
    }
  }
}

Giga_PeripheralExplorer