The default definitions
class BLEServerCallbacks {
public:
virtual ~BLEServerCallbacks() {};
/**
* @brief Handle a new client connection.
*
* When a new client connects, we are invoked.
*
* @param [in] pServer A reference to the %BLE server that received the client connection.
*/
virtual void onConnect(BLEServer* pServer);
/**
* @brief Handle an existing client disconnection.
*
* When an existing client disconnects, we are invoked.
*
* @param [in] pServer A reference to the %BLE server that received the existing client disconnection.
*/
virtual void onDisconnect(BLEServer* pServer);
}; // BLEServerCallbacks
I hope the
class BLEServerCallbacks {
public:
virtual ~BLEServerCallbacks() {};
virtual void onConnect(BELAddress* address);
};
Please tell me how to do it, or is there any way to get the address of the connected device?
Thank you very much !
Yes, you can add virtual void onConnect(BELAddress* address);
then you can add here:
https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLEServer.cpp#L203
m_pServerCallbacks->onConnect(param->connect.remote_bda);
PS some time ago ive got idea to add customHandleGAPEvent() and customHandleGATTServerEvent() and let programmers to handle events.
@chegewara I can get the address, thank you very much
Refer to chegewara's answer and give small details for others.
BLEServer.h#include "BLEAddress.h"BLEServerCallbacksvirtual void onConnect(BLEAddress address);BLEServer.cppm_pServerCallbacks->onConnect(BLEAddress(param->connect.remote_bda));
Most helpful comment
Yes, you can add
virtual void onConnect(BELAddress* address);then you can add here:
https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLEServer.cpp#L203
m_pServerCallbacks->onConnect(param->connect.remote_bda);PS some time ago ive got idea to add customHandleGAPEvent() and customHandleGATTServerEvent() and let programmers to handle events.