nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

BLE dualRole Server/Client OnConnect() method overlapp. - Arduino #1153

Open doh38 opened 1 year ago

doh38 commented 1 year ago

I successfully built a simple dualRole BLEuart simple sketch allowing me to connect as Client to a server and simultaneously be connected from a Client to my esp32-s3 as server as the one from Nordic on the nrf52 devices. There is but a little glitch. I use these callbacks for connection state:'

//BLE Peripheral Class class MyServerCallbacks : public BLEServerCallbacks { void onConnect(BLEServer* pServer) { Serial.println("Server connected to device!"); deviceConnected = true; };

//BLE Central Class class MyClientCallback : public BLEClientCallbacks { void onConnect(BLEClient* pclient) { }

void onDisconnect(BLEClient* pclient) { connected = false; Serial.println("onDisconnect"); } }; But the code don't take any difference between both. which means, if the Client connect/disconnect, the server is "seen" as connected/disconnected too and start/stop its tasks. in short onConnect() doesn't differentiate which server is targeted. Is it "normal"? I was in the expectation that they would be both differently handled. well.. If anyone has a workaround, I would be glad to hear from :)