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

pull/622/merge
Yulong 2017-06-09 04:32:01 -04:00
rodzic e7db29b2a8
commit 4734ba40b0
2 zmienionych plików z 18 dodań i 7 usunięć

Wyświetl plik

@ -24,6 +24,7 @@
#include "btc_ble_storage.h"
#include "esp_gap_ble_api.h"
#include "bta_api.h"
#include "bta_gatt_api.h"
/******************************************************************************
@ -117,13 +118,16 @@ static void btc_disable_bluetooth_evt(void)
static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
{
/* Save link key, if not temporary */
bt_bdaddr_t bd_addr;
bt_status_t status = BT_STATUS_FAIL;
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 +342,19 @@ 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:
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,7 @@ 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:
break;
default:
LOG_WARN( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
break;

Wyświetl plik

@ -258,7 +258,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
(bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
(bd_addr[4] << 8) + bd_addr[5]);
ESP_LOGI(GATTS_TABLE_TAG, "address type = %d", param->ble_security.auth_cmpl.addr_type);
ESP_LOGI(GATTS_TABLE_TAG, "pair status = %s",param->ble_security.auth_cmpl.success ? "fail" : "success");
ESP_LOGI(GATTS_TABLE_TAG, "pair status = %s",param->ble_security.auth_cmpl.success ? "success" : "fail");
break;
}
default:
@ -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;