I have not looked at the central, but there is an issue with the peripheral and the use of a long local name.
BLE.setLocalName("Arduino Nano 33 BLE (Peripheral)");
I'm not clear if there is an advertising packet size issue or a library limitation but if you test for the status of .setLocalName()
bool BLEAdvertisingData::setLocalName(const char *localName)
{
int previousLength = (_localName && strlen(_localName) > 0) ? (strlen(_localName) + AD_FIELD_OVERHEAD) : 0;
bool success = updateRemainingLength(previousLength, (strlen(localName) + AD_FIELD_OVERHEAD));
if (success) {
_localName = localName;
}
return success;
}
Add the test to the setup of your code and you can see this for a long and a short local name.
Status with Long Name: 0
Status with Short Name: 1
Nano 33 BLE (Peripheral Device)
void setup() {
Serial.begin(9600);
while (!Serial);
pinMode(LEDR, OUTPUT);
pinMode(LEDG, OUTPUT);
pinMode(LEDB, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LEDR, HIGH);
digitalWrite(LEDG, HIGH);
digitalWrite(LEDB, HIGH);
digitalWrite(LED_BUILTIN, LOW);
if (!BLE.begin()) {
Serial.println("- Starting Bluetooth® Low Energy module failed!");
while (1);
}
byte status = BLE.setLocalName("Arduino Nano 33 BLE (Peripheral)");
Serial.print("Status with Long Name: ");
Serial.println(status);
status = BLE.setLocalName("BLE (Peripheral)");
Serial.print("Status with Short Name: ");
Serial.println(status);
BLE.setAdvertisedService(gestureService);
gestureService.addCharacteristic(gestureCharacteristic);
BLE.addService(gestureService);
gestureCharacteristic.writeValue(-1);
BLE.advertise();
Serial.println("Nano 33 BLE (Peripheral Device)");
Serial.println(" ");
}
nrfConnect can find and connect when using the short name.