The 2 MCU's behave differently wrt BLE connections. Both MCU's advertisements are easily detected, but when I try to connect to ESP-WROOM-32, it takes around 20 attempts before success. ESP-WROOM-32E connects every time without any failures. Connection is attempted with "nRF Connect" app on an Android phone. Is there something specific I need to do to make connections to ESP-WROOM-32 easier?
nRF Connect output for failed connection attempt to ESP-WROOM-32:
Code: Select all
nRF Connect, 2023-01-30
ESP32-WROOM-32 (24:D7:EB:15:2B:32)
V 15:55:19.520 Connecting to 24:D7:EB:15:2B:32...
D 15:55:19.520 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
D 15:55:19.888 [Callback] Connection state changed with status: 133 and new state: DISCONNECTED (0)
E 15:55:19.888 Error 133 (0x85): GATT ERROR
I 15:55:19.888 Disconnected
Code: Select all
...
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer *pServer) {
Serial.println("onConnect");
deviceConnected = true;
pServer->startAdvertising();
}
void onDisconnect(BLEServer *pServer) {
Serial.println("onDisconnect");
deviceConnected = false;
pServer->startAdvertising();
}
};
class MyCallbacks : public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string blevalue = pCharacteristic->getValue();
if (blevalue.length() > 0) {
Serial.println("Got BLE value");
delay(1000);
Serial.println(blevalue.c_str());
pCharacteristic->notify();
}
}
};
void setupBLE() {
BLEDevice::init("ESP32-WROOM-32"); //Create BLE device
pServer = BLEDevice::createServer(); //Create BLE server
pServer->setCallbacks(new MyServerCallbacks()); //Set the callback function of the server
pService = pServer->createService(SERVICE_UUID); //Create BLE service
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC1_UUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_WRITE);
pCharacteristic->setCallbacks(new MyCallbacks());
pCharacteristic->addDescriptor(new BLE2902());
pService->start();
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->start();
}
...
Kind regards,
Dewald