T-vK / ESP32-BLE-Keyboard

Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible)
2.28k stars 379 forks source link

onConnect callback #206

Closed KnokTheBottle closed 1 year ago

KnokTheBottle commented 1 year ago

Hi, I am fairly new to C++ and have trouble understanding how to use the onConnect callback. The onConnect function takes BLEServer as a parameter. How do I use that?

I am used to just doing it like this:

void connectCallback(...){ ... } bleKeyboard.onConnect(connectCallback);

Can someone show me how to set up the onConnect callback function for me to use?

Best regards

mayaku2go commented 1 year ago

The onConnect() method is a protected member of BleKeyboard. If you want to use it you have to either make it public (bad idea) or to edit the source code. A public method is isConnected().

KnokTheBottle commented 1 year ago

Okay, I will check isConnected() every now and then instead of using a callback. Thank you for the info!