ESP32 BLE Reconnection Issue with REMOTEXY App

Hi, DevHeads
I'm using ESP32. I'm now trying out the BLE code to broadcast sine values to my Android 11 phone using REMOTEXY app. However, it doesn't get connected, a pop up message appears " couldn't connect" whenever I try to reconnect after disconnecting. I have to forget the device, scan for the device, and then connect to it. Are there any workarounds to this? Any advice for it to work correctly?
this is the code I'm working with
file0.jpg
Solution
move BLEDevice::startAdvertising(); inside the onDisconnect callback. Also, ensure pServer->getAdvertising()->start(); is called without BLEDevice::stopAdvertising();. This helps the ESP32 automatically reconnect without having to forget and rescan the device.
Was this page helpful?