Add connection desc param to disconnect callback.

This commit is contained in:
h2zero 2020-12-04 19:03:52 -07:00
parent 3e9a63a514
commit a85ac6ad5a
2 changed files with 14 additions and 0 deletions

View file

@ -296,6 +296,7 @@ size_t NimBLEServer::getConnectedCount() {
} }
server->m_pServerCallbacks->onDisconnect(server); server->m_pServerCallbacks->onDisconnect(server);
server->m_pServerCallbacks->onDisconnect(server, &event->disconnect.conn);
if(server->m_advertiseOnDisconnect) { if(server->m_advertiseOnDisconnect) {
server->startAdvertising(); server->startAdvertising();
@ -658,6 +659,10 @@ void NimBLEServerCallbacks::onDisconnect(NimBLEServer* pServer) {
NIMBLE_LOGD("NimBLEServerCallbacks", "onDisconnect(): Default"); NIMBLE_LOGD("NimBLEServerCallbacks", "onDisconnect(): Default");
} // onDisconnect } // onDisconnect
void NimBLEServerCallbacks::onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc* desc) {
NIMBLE_LOGD("NimBLEServerCallbacks", "onDisconnect(): Default");
} // onDisconnect
uint32_t NimBLEServerCallbacks::onPassKeyRequest(){ uint32_t NimBLEServerCallbacks::onPassKeyRequest(){
NIMBLE_LOGD("NimBLEServerCallbacks", "onPassKeyRequest: default: 123456"); NIMBLE_LOGD("NimBLEServerCallbacks", "onPassKeyRequest: default: 123456");
return 123456; return 123456;

View file

@ -114,6 +114,15 @@ public:
*/ */
virtual void onDisconnect(NimBLEServer* pServer); virtual void onDisconnect(NimBLEServer* pServer);
/**
* @brief Handle a client disconnection.
* This is called when a client discconnects.
* @param [in] pServer A pointer to the %BLE server that received the client disconnection.
* @param [in] desc A pointer to the connection description structure containig information
* about the connection.
*/
virtual void onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc* desc);
/** /**
* @brief Called when a client requests a passkey for pairing. * @brief Called when a client requests a passkey for pairing.
* @return The passkey to be sent to the client. * @return The passkey to be sent to the client.