add onMtuChanged to BLEServerCallbacks (#5222)

* add onMtuChanged to BLEServerCallbacks

Add method onMtuChanged to the BLEServerCallbacks so the application can be notified if the MTU size changes.

* Correct missing semicolon and misspelled method.

Correct missing semicolon and misspelled method.
This commit is contained in:
David Lehrian 2021-06-09 02:37:46 -07:00 committed by GitHub
parent 39155e70a6
commit 67de199bac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -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) {

View File

@ -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