diff --git a/libraries/BLE/src/BLEServer.cpp b/libraries/BLE/src/BLEServer.cpp index 0b39c9ca..fcb67da9 100644 --- a/libraries/BLE/src/BLEServer.cpp +++ b/libraries/BLE/src/BLEServer.cpp @@ -157,6 +157,7 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t case ESP_GATTS_MTU_EVT: updatePeerMTU(param->mtu.conn_id, param->mtu.mtu); + m_pServerCallbacks->onMtuChanged(this, param); break; // ESP_GATTS_CONNECT_EVT @@ -371,6 +372,12 @@ void BLEServerCallbacks::onDisconnect(BLEServer* pServer) { log_d("BLEServerCallbacks", "<< onDisconnect()"); } // onDisconnect +void BLEServerCallbacks::onMtuChanged(BLEServer* pServer, esp_ble_gatts_cb_param_t* param) { + log_d("BLEServerCallbacks", ">> onMtuChanged(): Default"); + log_d("BLEServerCallbacks", "Device: %s MTU: %d", BLEDevice::toString().c_str(), param->mtu.mtu); + log_d("BLEServerCallbacks", "<< onMtuChanged()"); +} // onMtuChanged + /* multi connect support */ /* TODO do some more tweaks */ void BLEServer::updatePeerMTU(uint16_t conn_id, uint16_t mtu) { diff --git a/libraries/BLE/src/BLEServer.h b/libraries/BLE/src/BLEServer.h index 2ae23edb..f3ca5be6 100644 --- a/libraries/BLE/src/BLEServer.h +++ b/libraries/BLE/src/BLEServer.h @@ -134,6 +134,16 @@ public: * @param [in] pServer A reference to the %BLE server that received the existing client disconnection. */ virtual void onDisconnect(BLEServer* pServer); + + /** + * @brief Handle a new client connection. + * + * When the MTU changes this method is invoked. + * + * @param [in] pServer A reference to the %BLE server that received the client connection. + * @param [in] param A reference to esp_ble_gatts_cb_param_t. + */ + virtual void onMtuChanged(BLEServer* pServer, esp_ble_gatts_cb_param_t* param); }; // BLEServerCallbacks