mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 21:54:33 +02:00
fix(ble/bluedroid): set sec_conn only on successful pairing in ble_hid_device_demo
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +148,6 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
|
|||||||
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
|
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
|
||||||
break;
|
break;
|
||||||
case ESP_GAP_BLE_AUTH_CMPL_EVT:
|
case ESP_GAP_BLE_AUTH_CMPL_EVT:
|
||||||
sec_conn = true;
|
|
||||||
esp_bd_addr_t bd_addr;
|
esp_bd_addr_t bd_addr;
|
||||||
memcpy(bd_addr, param->ble_security.auth_cmpl.bd_addr, sizeof(esp_bd_addr_t));
|
memcpy(bd_addr, param->ble_security.auth_cmpl.bd_addr, sizeof(esp_bd_addr_t));
|
||||||
ESP_LOGI(HID_DEMO_TAG, "remote BD_ADDR: %08x%04x",\
|
ESP_LOGI(HID_DEMO_TAG, "remote BD_ADDR: %08x%04x",\
|
||||||
@@ -156,8 +155,12 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
|
|||||||
(bd_addr[4] << 8) + bd_addr[5]);
|
(bd_addr[4] << 8) + bd_addr[5]);
|
||||||
ESP_LOGI(HID_DEMO_TAG, "address type = %d", param->ble_security.auth_cmpl.addr_type);
|
ESP_LOGI(HID_DEMO_TAG, "address type = %d", param->ble_security.auth_cmpl.addr_type);
|
||||||
ESP_LOGI(HID_DEMO_TAG, "pair status = %s",param->ble_security.auth_cmpl.success ? "success" : "fail");
|
ESP_LOGI(HID_DEMO_TAG, "pair status = %s",param->ble_security.auth_cmpl.success ? "success" : "fail");
|
||||||
if(!param->ble_security.auth_cmpl.success) {
|
if (param->ble_security.auth_cmpl.success) {
|
||||||
ESP_LOGE(HID_DEMO_TAG, "fail reason = 0x%x",param->ble_security.auth_cmpl.fail_reason);
|
sec_conn = true;
|
||||||
|
ESP_LOGI(HID_DEMO_TAG, "secure connection established.");
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(HID_DEMO_TAG, "pairing failed, reason = 0x%x",
|
||||||
|
param->ble_security.auth_cmpl.fail_reason);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user