BLE: connection behaviour ESP-WROOM-32 vs ESP-WROOM-32E

Dewalddp
Posts: 1
Joined: Mon Jan 30, 2023 1:43 pm

BLE: connection behaviour ESP-WROOM-32 vs ESP-WROOM-32E

Postby Dewalddp » Mon Jan 30, 2023 2:17 pm

Hi everyone,

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
Arduino BLE code snippits:

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();
}
...
I browsed through the update notes, but could not find anything wrt BLE that was a bug on the older ESP-WROOM-32. I did see notes everywhere that ESP-WROOM-32 is deprecated, but there are still a number of these sold, majority in dev modules, so I think the question is still relevant.

Kind regards,
Dewald

Who is online

Users browsing this forum: No registered users and 46 guests