add the GATTC_INCLUDED marco to close the bta_gattc module when not used the GATTC

This commit is contained in:
Yulong 2017-04-19 05:16:24 -04:00
parent 0ddadc98a3
commit 2723504473
15 changed files with 43 additions and 33 deletions

View file

@ -20,6 +20,7 @@
#include "btc_gattc.h"
#include "btc_gatt_util.h"
#if (GATTC_INCLUDED == TRUE)
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
{
if (esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
@ -450,3 +451,5 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif ///GATTC_INCLUDED == TRUE

View file

@ -95,7 +95,7 @@ static void bta_dm_disable_search_and_disc(void);
static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
#endif
static void bta_dm_ble_id_key_cback (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
static void bta_dm_gattc_register(void);
static void btm_dm_start_gatt_discovery(BD_ADDR bd_addr);
static void bta_dm_cancel_gatt_discovery(BD_ADDR bd_addr);
@ -343,7 +343,7 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ID) {
BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ID, (tBTM_BLE_LOCAL_KEYS *)&id_key);
}
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
bta_dm_search_cb.conn_id = BTA_GATT_INVALID_CONN_ID;
#endif
#endif
@ -373,7 +373,7 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
bta_dm_gattc_register();
#endif
@ -592,14 +592,14 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
*******************************************************************************/
void bta_dm_process_remove_device(BD_ADDR bd_addr)
{
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection before unpair */
BTA_GATTC_CancelOpen(0, bd_addr, FALSE);
#endif
BTM_SecDeleteDevice(bd_addr);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* remove all cached GATT information */
BTA_GATTC_Refresh(bd_addr);
#endif
@ -782,7 +782,7 @@ void bta_dm_close_acl(tBTA_DM_MSG *p_data)
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr)) {
APPL_TRACE_ERROR("delete device from security database failed.");
}
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection if any */
BTA_GATTC_CancelOpen(0, p_remove_acl->bd_addr, FALSE);
/* remove all cached GATT information */
@ -1085,7 +1085,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
{
tBTM_INQUIRY_CMPL result;
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->search.num_uuid);
bta_dm_gattc_register();
#endif
@ -1103,7 +1103,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
bta_dm_search_cb.p_search_cback = p_data->search.p_cback;
bta_dm_search_cb.services = p_data->search.services;
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
@ -1178,7 +1178,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
}
}
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
if (bta_dm_search_cb.gatt_disc_active) {
bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
}
@ -1198,7 +1198,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
void bta_dm_discover (tBTA_DM_MSG *p_data)
{
#if (SDP_INCLUDED == TRUE)
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->discover.num_uuid);
#endif
APPL_TRACE_EVENT("%s services_to_search=0x%04X, sdp_search=%d", __func__,
@ -1741,7 +1741,7 @@ void bta_dm_search_cmpl (tBTA_DM_MSG *p_data)
{
APPL_TRACE_EVENT("%s", __func__);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
#endif
@ -1980,7 +1980,7 @@ void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data)
if (!bta_dm_search_cb.name_discover_done) {
BTM_CancelRemoteDeviceName();
}
#if (BLE_INCLUDED == TRUE) && (BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE) && (BTA_GATT_INCLUDED == TRUE) && (SDP_INCLUDED == TRUE)
if (bta_dm_search_cb.gatt_disc_active) {
bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
}
@ -2216,7 +2216,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
bta_dm_search_cb.service_index = 0;
bta_dm_search_cb.services_found = 0;
bta_dm_search_cb.services_to_search = bta_dm_search_cb.services;
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
bta_dm_search_cb.uuid_to_search = bta_dm_search_cb.num_uuid;
#endif
if ((bta_dm_search_cb.p_btm_inq_info != NULL) &&
@ -2239,7 +2239,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
bta_dm_search_cb.wait_disc = TRUE;
}
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
if ( bta_dm_search_cb.p_btm_inq_info ) {
APPL_TRACE_DEBUG("%s p_btm_inq_info %p results.device_type 0x%x services_to_search 0x%x",
__func__,
@ -3222,7 +3222,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
}
if (conn.link_down.is_removed) {
BTM_SecDeleteDevice(p_bda);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
/* remove all cached GATT information */
@ -3392,7 +3392,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
}
} else {
BTM_SecDeleteDevice (remote_bd_addr);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
/* remove all cached GATT information */
@ -5207,11 +5207,11 @@ static void bta_ble_energy_info_cmpl(tBTM_BLE_TX_TIME_MS tx_time,
{
tBTA_STATUS st = (status == BTM_SUCCESS) ? BTA_SUCCESS : BTA_FAILURE;
tBTA_DM_CONTRL_STATE ctrl_state = 0;
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
if (BTA_SUCCESS == st) {
ctrl_state = bta_dm_pm_obtain_controller_state();
}
#endif
if (bta_dm_cb.p_energy_info_cback) {
bta_dm_cb.p_energy_info_cback(tx_time, rx_time, idle_time, energy_used, ctrl_state, st);
}
@ -5237,7 +5237,7 @@ void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data)
}
}
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
#ifndef BTA_DM_GATT_CLOSE_DELAY_TOUT
#define BTA_DM_GATT_CLOSE_DELAY_TOUT 1000
#endif

View file

@ -943,7 +943,7 @@ typedef struct {
tBTA_TRANSPORT transport;
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
tBTA_DM_SEARCH_CBACK *p_scan_cback;
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
tBTA_GATTC_IF client_if;
UINT8 num_uuid;
tBT_UUID *p_srvc_uuid;

View file

@ -188,7 +188,7 @@ const tBTA_DM_ACTION bta_dm_search_action[] = {
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
#if BLE_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE
, bta_dm_close_gatt_conn
#endif
};

View file

@ -43,7 +43,7 @@
// #include "osi/include/log.h"
#if BTA_GATT_INCLUDED && BLE_INCLUDED == TRUE
#if GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
/*****************************************************************************
** Constants
@ -2199,4 +2199,4 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
}
}
#endif
#endif
#endif ///GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE

View file

@ -24,7 +24,7 @@
#include "bt_target.h"
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
#include <string.h>
#include "gki.h"

View file

@ -25,7 +25,7 @@
#include "bt_target.h"
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
#include <string.h>
#include "utl.h"
@ -1510,5 +1510,5 @@ BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
return FALSE;
}
}
#endif /* BTA_GATT_INCLUDED */
#endif /* GATTC_INCLUDED */

View file

@ -24,7 +24,7 @@
#include "bt_target.h"
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
#include <string.h>
@ -133,4 +133,4 @@ void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
bta_sys_sendmsg(p_evt);
}
}
#endif /* BTA_GATT_INCLUDED */
#endif /* GATTC_INCLUDED */

View file

@ -24,7 +24,7 @@
#include "bt_target.h"
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
#include <string.h>
@ -522,4 +522,4 @@ static char *gattc_state_code(tBTA_GATTC_STATE state_code)
}
#endif /* Debug Functions */
#endif /* BTA_GATT_INCLUDED */
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */

View file

@ -24,7 +24,7 @@
#include "bt_target.h"
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
#include <string.h>

View file

@ -42,7 +42,9 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
#if (GATTC_INCLUDED == TRUE)
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
#endif ///GATTC_INCLUDED == TRUE
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
[BTC_PID_BLE_HID] = {NULL, NULL},
[BTC_PID_SPPLIKE] = {NULL, NULL},

View file

@ -38,7 +38,9 @@ typedef enum {
BTC_PID_MAIN_INIT = 0,
BTC_PID_DEV,
BTC_PID_GATTS,
#if (GATTC_INCLUDED == TRUE)
BTC_PID_GATTC,
#endif ///GATTC_INCLUDED == TRUE
BTC_PID_GAP_BLE,
BTC_PID_BLE_HID,
BTC_PID_SPPLIKE,

View file

@ -22,6 +22,7 @@
#include "bt_trace.h"
#include "esp_gattc_api.h"
#if (GATTC_INCLUDED == TRUE)
static inline void btc_gattc_cb_to_app(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param)
{
esp_gattc_cb_t btc_gattc_cb = (esp_gattc_cb_t )btc_profile_cb_get(BTC_PID_GATTC);
@ -699,3 +700,5 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
// free the deep-copied data
btc_gattc_free_req_data(msg);
}
#endif ///GATTC_INCLUDED == TRUE

View file

@ -27,7 +27,7 @@
#include "btm_int.h"
#if( defined BLE_INCLUDED ) && (BLE_INCLUDED == TRUE)
#if( defined BTA_GATT_INCLUDED ) && (BTA_GATT_INCLUDED == TRUE)
#if( defined BTA_GATT_INCLUDED ) && (GATTC_INCLUDED == TRUE)
#define GATT_CACHE_PREFIX "/data/misc/bluedroid/gatt_cache_"

View file

@ -984,7 +984,7 @@
******************************************************************************/
#ifndef GATTC_INCLUDED
#if BLE_INCLUDED == TRUE
#define GATTC_INCLUDED TRUE
#define GATTC_INCLUDED FALSE
#else
#define GATTC_INCLUDED FALSE
#endif