@@ -1210,7 +1210,16 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
12101210 break ;
12111211 }
12121212
1213- if (event->passkey .params .action == BLE_SM_IOACT_NUMCMP ) {
1213+ if (event->passkey .params .action == BLE_SM_IOACT_DISP ) {
1214+ struct ble_sm_io pkey = {0 , 0 };
1215+ pkey.action = event->passkey .params .action ;
1216+ pkey.passkey = NimBLEDevice::getSecurityPasskey ();
1217+ if (pkey.passkey == 123456 ) {
1218+ pkey.passkey = pClient->m_pClientCallbacks ->onPassKeyDisplay (peerInfo);
1219+ }
1220+ rc = ble_sm_inject_io (event->passkey .conn_handle , &pkey);
1221+ NIMBLE_LOGD (LOG_TAG , " BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d" , rc);
1222+ } else if (event->passkey .params .action == BLE_SM_IOACT_NUMCMP ) {
12141223 NIMBLE_LOGD (LOG_TAG , " Passkey on device's display: %" PRIu32, event->passkey .params .numcmp );
12151224 pClient->m_pClientCallbacks ->onConfirmPasskey (peerInfo, event->passkey .params .numcmp );
12161225 } else if (event->passkey .params .action == BLE_SM_IOACT_OOB ) {
@@ -1314,6 +1323,11 @@ void NimBLEClientCallbacks::onPassKeyEntry(NimBLEConnInfo& connInfo) {
13141323 NimBLEDevice::injectPassKey (connInfo, 123456 );
13151324} // onPassKeyEntry
13161325
1326+ uint32_t NimBLEClientCallbacks::onPassKeyDisplay (NimBLEConnInfo& connInfo) {
1327+ NIMBLE_LOGD (CB_TAG , " onPassKeyDisplay: default" );
1328+ return NimBLEDevice::getSecurityPasskey ();
1329+ } // onPassKeyDisplay
1330+
13171331void NimBLEClientCallbacks::onAuthenticationComplete (NimBLEConnInfo& connInfo) {
13181332 NIMBLE_LOGD (CB_TAG , " onAuthenticationComplete: default" );
13191333} // onAuthenticationComplete
0 commit comments