Merge branch 'bugfix/btdm_smp_auth_complete_error' into 'master'

component/bt: Change the btc layer data copy method.

See merge request !844
This commit is contained in:
Jiang Jiang Jian 2017-06-14 15:16:38 +08:00
commit ae7269d39d
2 changed files with 18 additions and 6 deletions

View File

@ -24,6 +24,7 @@
#include "btc_ble_storage.h"
#include "esp_gap_ble_api.h"
#include "bta_api.h"
#include "bta_gatt_api.h"
/******************************************************************************
@ -121,9 +122,11 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
if (p_auth_cmpl->success) {
status = BT_STATUS_SUCCESS;
int addr_type;
bt_bdaddr_t bdaddr;
bdcpy(bdaddr.address, p_auth_cmpl->bd_addr);
bdcpy(pairing_cb.bd_addr, p_auth_cmpl->bd_addr);
if (btc_storage_get_remote_addr_type((bt_bdaddr_t *)pairing_cb.bd_addr, &addr_type) != BT_STATUS_SUCCESS) {
btc_storage_set_remote_addr_type((bt_bdaddr_t *)pairing_cb.bd_addr, p_auth_cmpl->addr_type);
if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) {
btc_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type);
}
btc_save_ble_bonding_keys();
@ -338,12 +341,20 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
case BTA_DM_LINK_UP_EVT:
case BTA_DM_LINK_DOWN_EVT:
case BTA_DM_HW_ERROR_EVT:
LOG_WARN( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
break;
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
case BTA_DM_BLE_AUTH_CMPL_EVT: {
rsp_app = true;
ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT;
memcpy(&param.ble_security.auth_cmpl, &p_data->auth_cmpl, sizeof(esp_ble_auth_cmpl_t));
param.ble_security.auth_cmpl.addr_type = p_data->auth_cmpl.addr_type;
param.ble_security.auth_cmpl.dev_type = p_data->auth_cmpl.dev_type;
param.ble_security.auth_cmpl.key_type = p_data->auth_cmpl.key_type;
param.ble_security.auth_cmpl.fail_reason = p_data->auth_cmpl.fail_reason;
param.ble_security.auth_cmpl.success = p_data->auth_cmpl.success ? true : false;
param.ble_security.auth_cmpl.key_present = p_data->auth_cmpl.key_present;
memcpy(param.ble_security.auth_cmpl.bd_addr, p_data->auth_cmpl.bd_addr, sizeof(BD_ADDR));
memcpy(param.ble_security.auth_cmpl.key, p_data->auth_cmpl.key, sizeof(LINK_KEY));
btc_dm_ble_auth_cmpl_evt(&p_data->auth_cmpl);
break;
}
@ -484,7 +495,8 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
case BTA_DM_SP_RMT_OOB_EVT:
case BTA_DM_SP_KEYPRESS_EVT:
case BTA_DM_ROLE_CHG_EVT:
LOG_WARN( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
break;
default:
LOG_WARN( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
break;

View File

@ -396,7 +396,7 @@ void app_main()
/* set the security iocap & auth_req & key size & init key response key parameters to the stack*/
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_BOND; //bonding with peer device after authentication
esp_ble_io_cap_t iocap = ESP_IO_CAP_IO; //set the IO capability to Output only
esp_ble_io_cap_t iocap = ESP_IO_CAP_OUT; //set the IO capability to Output only
uint8_t key_size = 16; //the key size should be 7~16 bytes
uint8_t init_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;
uint8_t rsp_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;