]> granicus.if.org Git - esp-idf/commitdiff
add the GATTC_INCLUDED marco to close the bta_gattc module when not used the GATTC
authorYulong <huangyulong@espressif.com>
Wed, 19 Apr 2017 09:16:24 +0000 (05:16 -0400)
committerYulong <huangyulong@espressif.com>
Wed, 19 Apr 2017 09:16:24 +0000 (05:16 -0400)
15 files changed:
components/bt/bluedroid/api/esp_gattc_api.c
components/bt/bluedroid/bta/dm/bta_dm_act.c
components/bt/bluedroid/bta/dm/bta_dm_int.h
components/bt/bluedroid/bta/dm/bta_dm_main.c
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
components/bt/bluedroid/bta/gatt/bta_gattc_api.c
components/bt/bluedroid/bta/gatt/bta_gattc_cache.c
components/bt/bluedroid/bta/gatt/bta_gattc_ci.c
components/bt/bluedroid/bta/gatt/bta_gattc_main.c
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
components/bt/bluedroid/btc/core/btc_task.c
components/bt/bluedroid/btc/include/btc_task.h
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c
components/bt/bluedroid/btif/bta_gattc_co.c
components/bt/bluedroid/include/bt_target.h

index 4f68d81cc0c24c3073d6dd3f37c844c950112225..bfe7db4654da8e49fdc94a89df01b656cb890dba 100644 (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
+
index 0fcc503c8f7f7fde68df2c739b58ad608a6ab614..f5fea540be1a52df371f0ba9ddcce8d1a0497748 100644 (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
index f524c6df58dd98f0adb9d950f931229a9ad62139..acfbc7c79acc859f8fe7dbe9edd142fc0cc0e95b 100644 (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;
index 25c4978538e7645b9ba22cdb57e5394affca1a44..905b25a779b639bdc5f51495ea691a67ef69cd9d 100644 (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
 };
index f03b545e1bc6b00b9bb5e21df82397f0bc6155a0..41008cb2d6c0540a9c6406c46ba544e5b55afdd6 100644 (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
\ No newline at end of file
index b791538d7846569ac078325877407528284a6a1f..beaa235dedbcc8b6c6bbc9d546789053a9e734ec 100644 (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"
index b887cb32824cc9e9b37fa9dd908750f9a307b025..205060f95e3aaa909d29d8bc3e4ef15538417296 100644 (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 */
 
index 295c251bb4d611e7c1ce66823bf8d343979417fa..8c94a991c169dc6adb9263fe5f95a8fb76d48d40 100644 (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 */
index f13e3f0a1bd8705f371df6576270e2848c91ccfc..057e35813e710ead4905d52c3d04b6826590b24b 100644 (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 */
index 0a020d3d6335ce774c3c8d9377c4c8f30cb6e2f0..a9d512b73c5e97b818b4170be36ca59a963c8886 100644 (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>
 
index d576fdd7622c7a09dc91daae21088607a9c8c31c..98ff872728f2d0feb45872bd0c8a53d01485fcc3 100644 (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},
index bb8996974681c0f2e119011aec69a926cfc023ca..36a4757bf60e13dedc3c31c1dc01b2d1c06acbf9 100644 (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,
index 71e01c76e043dcc43693c230fcbd018b2b5ad443..5a7a5b2f6703a3ba89f1de1dc7f6e056575fd0f0 100644 (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
\ No newline at end of file
index 2a255885ad8ddc50409c0d0c7c0dea645fb825b6..380b7932b7387d554bd7ade77deaf8f83dfb5316 100644 (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_"
 
index 5cf0d79f1b81924d1f62d3c6798f3f31d5d56fc3..b5dd88a987b60aa4171298fa23f504d877c0c652 100644 (file)
 ******************************************************************************/
 #ifndef GATTC_INCLUDED
 #if BLE_INCLUDED == TRUE
-#define GATTC_INCLUDED         TRUE
+#define GATTC_INCLUDED         FALSE
 #else
 #define GATTC_INCLUDED         FALSE
 #endif