component/bt: modify the BLE example to make it run with "numeric comparison" mode

This commit is contained in:
island 2018-10-17 16:55:11 +08:00
parent 95e4bdf030
commit 024f27f3d5
3 changed files with 7 additions and 3 deletions

View File

@ -1067,7 +1067,7 @@ esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t pas
/** /**
* @brief Reply the confirm value to the peer device in the legacy connection stage. * @brief Reply the confirm value to the peer device in the secure connection stage.
* *
* @param[in] bd_addr : BD address of the peer device * @param[in] bd_addr : BD address of the peer device
* @param[in] accept : numbers to compare are the same or different. * @param[in] accept : numbers to compare are the same or different.

View File

@ -381,6 +381,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
ESP_LOGI(GATTC_TAG, "Scan start success"); ESP_LOGI(GATTC_TAG, "Scan start success");
break; break;
case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */ case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */
/* Call the following function to input the passkey which is displayed on the remote device */
//esp_ble_passkey_reply(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, true, 0x00); //esp_ble_passkey_reply(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, true, 0x00);
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_PASSKEY_REQ_EVT"); ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_PASSKEY_REQ_EVT");
break; break;
@ -400,7 +401,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
break; break;
case ESP_GAP_BLE_NC_REQ_EVT: case ESP_GAP_BLE_NC_REQ_EVT:
/* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
show the passkey number to the user to confirm it with the number displayed by peer deivce. */ show the passkey number to the user to confirm it with the number displayed by peer device. */
esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true);
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey);
break; break;
case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.

View File

@ -316,6 +316,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
break; break;
case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */ case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_PASSKEY_REQ_EVT"); ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_PASSKEY_REQ_EVT");
/* Call the following function to input the passkey which is displayed on the remote device */
//esp_ble_passkey_reply(heart_rate_profile_tab[HEART_PROFILE_APP_IDX].remote_bda, true, 0x00); //esp_ble_passkey_reply(heart_rate_profile_tab[HEART_PROFILE_APP_IDX].remote_bda, true, 0x00);
break; break;
case ESP_GAP_BLE_OOB_REQ_EVT: /* OOB request event */ case ESP_GAP_BLE_OOB_REQ_EVT: /* OOB request event */
@ -329,7 +330,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
break; break;
case ESP_GAP_BLE_NC_REQ_EVT: case ESP_GAP_BLE_NC_REQ_EVT:
/* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
show the passkey number to the user to confirm it with the number displayed by peer deivce. */ show the passkey number to the user to confirm it with the number displayed by peer device. */
esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true);
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey);
break; break;
case ESP_GAP_BLE_SEC_REQ_EVT: case ESP_GAP_BLE_SEC_REQ_EVT: