Skip to content

add onMtuChanged to BLEServerCallbacks #5222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libraries/BLE/src/BLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions libraries/BLE/src/BLEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ class BLEServerCallbacks {
* @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


Expand Down