Peripheral: Nicla sense ME
Central: RP2040
Both use the ArduinoBLE library.
I wrote code for the Nicla Sense ME which creates one service and exactly one characteristic. This characteristic is added to the service. I then write a value to the characteristics. The RP2040 is then able to receive and print this value.
When I add another characteristic to the Nicla sense me, the RP2040 hangs and the LED flickers RED when it comes to "Discovering attributes".
I attached part of the code where I add characteristics on the Peripheral and do a "discoverAttributes" on the Central.
CODE:
Peripheral:
1/2
BLEService aService("0x01FF");
BLEUnsignedIntCharacteristic temperatureValChar("00000000-0000-0000-0000-00000000FF01", BLERead | BLENotify);
BLEUnsignedIntCharacteristic humidityValChar("00000000-0000-0000-0000-00000000FF02", BLERead | BLENotify);
2/2
Note: here when I remove the aService.addCharacteristic(humidityValChar); the central won't hang during discoverAttributes and everything works fine.
BLE.setAdvertisedService(aService);
aService.addCharacteristic(temperatureValChar);
aService.addCharacteristic(humidityValChar);
Central:
1/2
Serial.println("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;
}
2/2
BLECharacteristic TempCharacteristic = peripheral.characteristic("00000000-0000-0000-0000-00000000FF01");
BLECharacteristic HumidCharacteristic = peripheral.characteristic("00000000-0000-0000-0000-00000000FF02");
OUTPUT:
Peripheral:

Central:
