mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 05:00:55 +01:00
Add server and client onIdentity
callback.
Adds a callback that is called when the identity address of the peer is resolved, this is useful for adding it to a whitelist.
This commit is contained in:
parent
44daa3c687
commit
aeb4334e98
4 changed files with 43 additions and 0 deletions
|
@ -1189,6 +1189,19 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event *event, void *arg) {
|
|||
break;
|
||||
} //BLE_GAP_EVENT_ENC_CHANGE
|
||||
|
||||
case BLE_GAP_EVENT_IDENTITY_RESOLVED: {
|
||||
NimBLEConnInfo peerInfo;
|
||||
rc = ble_gap_conn_find(event->identity_resolved.conn_handle, &peerInfo.m_desc);
|
||||
if (rc != 0) {
|
||||
NIMBLE_LOGE(LOG_TAG, "Connection info not found");
|
||||
rc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
pClient->m_pClientCallbacks->onIdentity(peerInfo);
|
||||
break;
|
||||
} // BLE_GAP_EVENT_IDENTITY_RESOLVED
|
||||
|
||||
case BLE_GAP_EVENT_MTU: {
|
||||
if(pClient->m_conn_id != event->mtu.conn_handle){
|
||||
return 0;
|
||||
|
@ -1326,6 +1339,10 @@ void NimBLEClientCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connI
|
|||
NIMBLE_LOGD("NimBLEClientCallbacks", "onAuthenticationComplete: default");
|
||||
}
|
||||
|
||||
void NimBLEClientCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
|
||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onIdentity: default");
|
||||
} // onIdentity
|
||||
|
||||
void NimBLEClientCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin){
|
||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onConfirmPIN: default: true");
|
||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||
|
|
|
@ -164,6 +164,12 @@ public:
|
|||
* @param [in] pin The pin to compare with the server.
|
||||
*/
|
||||
virtual void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin);
|
||||
|
||||
/**
|
||||
* @brief Called when the peer identity address is resolved.
|
||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
||||
*/
|
||||
virtual void onIdentity(const NimBLEConnInfo& connInfo);
|
||||
};
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
|
||||
|
|
|
@ -528,6 +528,16 @@ int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg) {
|
|||
return 0;
|
||||
} // BLE_GAP_EVENT_ENC_CHANGE
|
||||
|
||||
case BLE_GAP_EVENT_IDENTITY_RESOLVED: {
|
||||
rc = ble_gap_conn_find(event->identity_resolved.conn_handle, &peerInfo.m_desc);
|
||||
if(rc != 0) {
|
||||
return BLE_ATT_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
pServer->m_pServerCallbacks->onIdentity(peerInfo);
|
||||
return 0;
|
||||
} // BLE_GAP_EVENT_IDENTITY_RESOLVED
|
||||
|
||||
case BLE_GAP_EVENT_PASSKEY_ACTION: {
|
||||
struct ble_sm_io pkey = {0,0};
|
||||
|
||||
|
@ -864,6 +874,10 @@ void NimBLEServerCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_
|
|||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||
} // onConfirmPIN
|
||||
|
||||
void NimBLEServerCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
|
||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onIdentity: default");
|
||||
} // onIdentity
|
||||
|
||||
void NimBLEServerCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
|
||||
} // onAuthenticationComplete
|
||||
|
|
|
@ -173,6 +173,12 @@ public:
|
|||
* about the peer connection parameters.
|
||||
*/
|
||||
virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo);
|
||||
|
||||
/**
|
||||
* @brief Called when the peer identity address is resolved.
|
||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
||||
*/
|
||||
virtual void onIdentity(const NimBLEConnInfo& connInfo);
|
||||
}; // NimBLEServerCallbacks
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
|
||||
|
|
Loading…
Reference in a new issue