implement connection parameters update callback (#210)

This commit is contained in:
Jeff 2024-10-24 20:21:43 -07:00 committed by GitHub
parent 3820f57076
commit 8ca58f5a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -624,7 +624,12 @@ int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg) {
// BLE_GAP_EVENT_ADV_COMPLETE | BLE_GAP_EVENT_SCAN_REQ_RCVD // BLE_GAP_EVENT_ADV_COMPLETE | BLE_GAP_EVENT_SCAN_REQ_RCVD
case BLE_GAP_EVENT_CONN_UPDATE: { case BLE_GAP_EVENT_CONN_UPDATE: {
NIMBLE_LOGD(LOG_TAG, "Connection parameters updated."); rc = ble_gap_conn_find(event->connect.conn_handle, &peerInfo.m_desc);
if (rc != 0) {
return 0;
}
pServer->m_pServerCallbacks->onConnParamsUpdate(peerInfo);
return 0; return 0;
} // BLE_GAP_EVENT_CONN_UPDATE } // BLE_GAP_EVENT_CONN_UPDATE
@ -1088,4 +1093,8 @@ void NimBLEServerCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo, c
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default"); NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
} // onAuthenticationComplete } // onAuthenticationComplete
void NimBLEServerCallbacks::onConnParamsUpdate(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEServerCallbacks", "onConnParamsUpdate: default");
} // onConnParamsUpdate
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */ #endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

View file

@ -205,6 +205,14 @@ public:
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information * @param [in] connInfo A reference to a NimBLEConnInfo instance with information
*/ */
virtual void onIdentity(NimBLEConnInfo& connInfo); virtual void onIdentity(NimBLEConnInfo& connInfo);
/**
* @brief Called when connection parameters are updated following a request to
* update via NimBLEServer::updateConnParams
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the
* updated connection parameters.
*/
virtual void onConnParamsUpdate(NimBLEConnInfo& connInfo);
}; // NimBLEServerCallbacks }; // NimBLEServerCallbacks
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */ #endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */