From cdd65095e3ac398b5ecc0675a3b0c411189b8672 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 2 Nov 2016 06:48:17 -0400 Subject: [PATCH] component bt:Change the wx_airsync_prf to the new API function --- components/bt/bluedroid/bta/dm/bta_dm_act.c | 6 +- components/bt/bluedroid/bta/dm/bta_dm_api.c | 2 +- .../profiles/esp/include/wx_airsync_prf.h | 1 + .../esp/wechat_AirSync/wx_airsync_prf.c | 68 +++++++++---------- .../profiles/std/include/hid_le_prf.h | 1 + .../bluedroid/profiles/std/include/prf_defs.h | 6 +- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index a48f51225..76dd5ff9b 100755 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -4295,10 +4295,10 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data) { UINT8 i ; - APPL_TRACE_DEBUG("bta_dm_set_encryption"); //todo + APPL_TRACE_DEBUG("bta_dm_set_encryption\n"); //todo if (!p_data->set_encryption.p_callback) { - APPL_TRACE_ERROR("bta_dm_set_encryption callback is not provided"); + APPL_TRACE_ERROR("bta_dm_set_encryption callback is not provided\n"); return; } for (i=0; iset_encryption.p_callback)(p_data->set_encryption.bd_addr, p_data->set_encryption.transport, BTA_BUSY); diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index e557dd5e4..bfae1011d 100755 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -2071,7 +2071,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length) ** p_callback - Pointer to callback function to indicat the ** link encryption status ** sec_act - This is the security action to indicate -** what knid of BLE security level is required for +** what kind of BLE security level is required for ** the BLE link if the BLE is supported ** Note: This parameter is ignored for the BR/EDR link ** or the BLE is not supported diff --git a/components/bt/bluedroid/profiles/esp/include/wx_airsync_prf.h b/components/bt/bluedroid/profiles/esp/include/wx_airsync_prf.h index 8323ae8b8..50fe37f18 100644 --- a/components/bt/bluedroid/profiles/esp/include/wx_airsync_prf.h +++ b/components/bt/bluedroid/profiles/esp/include/wx_airsync_prf.h @@ -19,6 +19,7 @@ #include "bt_target.h" #include "gatt_api.h" #include "gattdefs.h" +#include "bt_app_api.h" /// Maximum Transmission Unit diff --git a/components/bt/bluedroid/profiles/esp/wechat_AirSync/wx_airsync_prf.c b/components/bt/bluedroid/profiles/esp/wechat_AirSync/wx_airsync_prf.c index dc1e557b9..302290fad 100644 --- a/components/bt/bluedroid/profiles/esp/wechat_AirSync/wx_airsync_prf.c +++ b/components/bt/bluedroid/profiles/esp/wechat_AirSync/wx_airsync_prf.c @@ -37,7 +37,7 @@ tAIRSYNC_CB_ENV airsync_cb_env; /***************************************************************************** ** Constants *****************************************************************************/ -static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); +static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data); /******************************************************************************* @@ -49,17 +49,17 @@ static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); ** Returns NULL ** *******************************************************************************/ -static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) +static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) { - tBTA_GATTS_RSP rsp; - tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; + esp_gatts_rsp_t rsp; + esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst; LOG_ERROR("airsync profile cb event = %x\n",event); switch(event) { - case BTA_GATTS_REG_EVT: + case ESP_GATTS_REG_EVT: if(p_data->reg_oper.status != BTA_GATT_OK) { @@ -73,41 +73,41 @@ static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) AirSync_CreateService(); } break; - case BTA_GATTS_READ_EVT: + case ESP_GATTS_READ_EVT: if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){ //tBTA_GATTS_RSP rsp; memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP)); rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle; rsp.attr_value.len = 2; - BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, + esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id, p_data->req_data.status,&rsp); } break; - case BTA_GATTS_WRITE_EVT: + case ESP_GATTS_WRITE_EVT: if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){ - BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, + esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id, p_data->req_data.status,NULL); } break; - case BTA_GATTS_CONF_EVT: + case ESP_GATTS_CFM_EVT: break; - case BTA_GATTS_CREATE_EVT: + case ESP_GATTS_CREATE_EVT: uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_WIT; airsync_cb_env.clcb.cur_srvc_id= p_data->create.service_id; airsync_cb_env.is_primery = p_data->create.is_primary; //start the airsync service after created - BTA_GATTS_StartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE); + esp_ble_gatts_start_srvc(p_data->create.service_id); //add the frist airsync characteristic --> write characteristic - BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, + esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid, (GATT_PERM_WRITE|GATT_PERM_READ), (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE)); break; - case BTA_GATTS_ADD_CHAR_EVT: + case ESP_GATTS_ADD_CHAR_EVT: if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_WIT) { uuid.uu.uuid16 = ATT_CHAR_AIRSYBC_NTF; @@ -116,19 +116,19 @@ static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) //save the att handle to the env airsync_cb_env.airsync_inst.airsync_wirt_hdl = p_data->add_result.attr_id; //add the second airsync characteristic --> Notify characteristic - BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, + esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid, GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_INDICATE)); }else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYBC_NTF){ //tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE); uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG; airsync_cb_env.airsync_inst.airsync_ntf_hdl = p_data->add_result.attr_id; - BTA_GATTS_AddCharDescriptor (airsync_cb_env.clcb.cur_srvc_id, + esp_ble_gatts_add_char_descr (airsync_cb_env.clcb.cur_srvc_id, (GATT_PERM_WRITE|GATT_PERM_WRITE), &uuid); uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_READ; //add the third airsync characteristic --> Read characteristic - BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, + esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid, GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ); }else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_READ){ @@ -136,32 +136,30 @@ static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) } break; - case BTA_GATTS_ADD_CHAR_DESCR_EVT: + case ESP_GATTS_ADD_CHAR_DESCR_EVT: if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) { airsync_cb_env.airsync_inst.airsync_cfg_hdl = p_data->add_result.attr_id; } break; - case BTA_GATTS_CONNECT_EVT: + case ESP_GATTS_CONNECT_EVT: //set the connection flag to true airsync_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda); break; - case BTA_GATTS_DISCONNECT_EVT: + case ESP_GATTS_DISCONNECT_EVT: //set the connection flag to true airsync_cb_env.clcb.connected = false; break; - case BTA_GATTS_OPEN_EVT: + case ESP_GATTS_OPEN_EVT: break; - case BTA_GATTS_CLOSE_EVT: + case ESP_GATTS_CLOSE_EVT: if(airsync_cb_env.clcb.connected && (airsync_cb_env.clcb.conn_id == p_data->conn.conn_id)) { //set the connection channal congested flag to true airsync_cb_env.clcb.congest = p_data->congest.congested; } break; - case BTA_GATTS_LISTEN_EVT: - break; - case BTA_GATTS_CONGEST_EVT: + case ESP_GATTS_CONGEST_EVT: //set the congest flag airsync_cb_env.clcb.congest = p_data->congest.congested; break; @@ -182,14 +180,14 @@ static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) *******************************************************************************/ void AirSync_CreateService(void) { - tBTA_GATTS_IF server_if ; - tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; + esp_gatts_if_t server_if ; + esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; UINT16 num_handle = WX_IDX_NB; UINT8 inst = 0x00; server_if = airsync_cb_env.gatt_if; airsync_cb_env.inst_id = inst; - BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true); + esp_ble_gatts_create_srvc(server_if,&uuid,inst,num_handle,true); } @@ -254,13 +252,13 @@ UINT16 airsync_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda) *******************************************************************************/ tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back) { - tBT_UUID app_uuid = {LEN_UUID_16,{ATT_SVC_AIRSYNC}}; + esp_bt_uuid_t app_uuid = {LEN_UUID_16,{ATT_SVC_AIRSYNC}}; if(airsync_cb_env.enabled) { LOG_ERROR("airsync svc already initaliezd\n"); - return GATT_ERROR; + return ESP_GATT_ERROR; } else { @@ -269,17 +267,17 @@ tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back) if(call_back != NULL) - { - airsync_cb_env.airsync_inst.p_cback = call_back; - } + { + airsync_cb_env.airsync_inst.p_cback = call_back; + } /* register the airsync profile to the BTA_GATTS module*/ - BTA_GATTS_AppRegister(&app_uuid,airsync_profile_cb); + esp_ble_gatts_app_register(&app_uuid,airsync_profile_cb); airsync_cb_env.enabled = TRUE; - return GATT_SUCCESS; + return ESP_GATT_OK; } #endif ///WX_AIRSYNC_CFG diff --git a/components/bt/bluedroid/profiles/std/include/hid_le_prf.h b/components/bt/bluedroid/profiles/std/include/hid_le_prf.h index 753a2f66e..3c17edbbf 100644 --- a/components/bt/bluedroid/profiles/std/include/hid_le_prf.h +++ b/components/bt/bluedroid/profiles/std/include/hid_le_prf.h @@ -19,6 +19,7 @@ #include "bt_types.h" #include "bta_api.h" #include "gatt_api.h" +#include "bt_app_api.h" /// Maximal number of HIDS that can be added in the DB #ifndef USE_ONE_HIDS_INSTANCE diff --git a/components/bt/bluedroid/profiles/std/include/prf_defs.h b/components/bt/bluedroid/profiles/std/include/prf_defs.h index 6fb53d73b..b84eae2ab 100644 --- a/components/bt/bluedroid/profiles/std/include/prf_defs.h +++ b/components/bt/bluedroid/profiles/std/include/prf_defs.h @@ -27,9 +27,9 @@ #define ATT_UUID_128_LEN 0x0010 #define ATT_UUID_32_LEN 0x0004 -#define WX_AIRSYNC_CFG 0 -#define BUT_PROFILE_CFG 1 -#define HIDD_LE_PROFILE_CFG 0 +#define WX_AIRSYNC_CFG TRUE +#define BUT_PROFILE_CFG TRUE +#define HIDD_LE_PROFILE_CFG TRUE /* * Type Definition