From 22ccf6c368712faca6ab26189b051f70b6bf6587 Mon Sep 17 00:00:00 2001 From: Yulong Date: Mon, 17 Apr 2017 22:53:43 -0400 Subject: [PATCH 01/15] component/bt:rebase the BT_BLE_separate to the new master --- components/bt/bluedroid/bta/ar/bta_ar_int.h | 3 + components/bt/bluedroid/bta/av/bta_av_int.h | 4 ++ components/bt/bluedroid/bta/dm/bta_dm_act.c | 36 +++++++--- components/bt/bluedroid/bta/dm/bta_dm_api.c | 17 +++-- components/bt/bluedroid/bta/dm/bta_dm_int.h | 14 +++- components/bt/bluedroid/bta/dm/bta_dm_pm.c | 2 + .../bt/bluedroid/bta/gatt/bta_gattc_cache.c | 6 ++ components/bt/bluedroid/bta/hh/bta_hh_cfg.c | 4 ++ components/bt/bluedroid/bta/hh/bta_hh_int.h | 2 + components/bt/bluedroid/bta/include/bta_api.h | 23 +++--- .../bt/bluedroid/bta/include/bta_ar_api.h | 4 ++ .../bt/bluedroid/bta/include/bta_av_api.h | 4 ++ .../bt/bluedroid/bta/include/bta_av_ci.h | 4 ++ .../bt/bluedroid/bta/include/bta_av_co.h | 4 ++ .../bt/bluedroid/bta/include/bta_av_sbc.h | 4 ++ .../bt/bluedroid/bta/include/bta_gatt_api.h | 2 +- .../bt/bluedroid/bta/include/bta_gattc_int.h | 3 +- .../bt/bluedroid/bta/include/bta_hh_api.h | 4 ++ .../bt/bluedroid/bta/include/bta_sdp_api.h | 5 ++ components/bt/bluedroid/bta/sdp/bta_sdp_act.c | 11 ++- components/bt/bluedroid/bta/sdp/bta_sdp_int.h | 4 ++ .../bt/bluedroid/btc/core/btc_ble_storage.c | 4 ++ components/bt/bluedroid/btc/core/btc_dm.c | 7 +- .../bluedroid/btc/include/btc_ble_storage.h | 5 +- .../btc/profile/std/a2dp/include/btc_av_co.h | 3 + .../btc/profile/std/gap/btc_gap_ble.c | 2 + .../btc/profile/std/hid/include/hid_conn.h | 3 +- .../btc/profile/std/hid/include/hidh_int.h | 4 ++ .../btc/profile/std/include/btc_av.h | 4 +- .../btc/profile/std/include/btc_av_api.h | 4 +- .../btc/profile/std/include/btc_avrc.h | 3 + .../btc/profile/std/include/btc_media.h | 3 +- components/bt/bluedroid/btif/bta_dm_co.c | 23 ++++-- components/bt/bluedroid/include/bt_target.h | 31 ++++++-- components/bt/bluedroid/include/bt_trace.h | 8 +-- .../bt/bluedroid/stack/a2dp/include/a2d_int.h | 4 +- .../bluedroid/stack/avdt/include/avdt_defs.h | 5 ++ .../bluedroid/stack/avdt/include/avdt_int.h | 4 ++ .../bluedroid/stack/avrc/include/avrc_int.h | 3 + components/bt/bluedroid/stack/btm/btm_acl.c | 25 ++++--- components/bt/bluedroid/stack/btm/btm_ble.c | 71 +++++++++++++++---- .../bt/bluedroid/stack/btm/btm_ble_addr.c | 19 +++-- .../bt/bluedroid/stack/btm/btm_ble_gap.c | 6 +- .../bt/bluedroid/stack/btm/btm_ble_privacy.c | 2 + components/bt/bluedroid/stack/btm/btm_sec.c | 2 +- components/bt/bluedroid/stack/btu/btu_hcif.c | 17 ++--- .../bt/bluedroid/stack/gap/include/gap_int.h | 4 +- components/bt/bluedroid/stack/gatt/gatt_api.c | 5 +- .../bt/bluedroid/stack/gatt/gatt_auth.c | 17 +++-- .../bt/bluedroid/stack/gatt/gatt_main.c | 33 ++++++++- .../bt/bluedroid/stack/gatt/gatt_utils.c | 4 +- .../bluedroid/stack/gatt/include/gatt_int.h | 2 + .../bt/bluedroid/stack/hcic/hciblecmds.c | 2 +- .../bt/bluedroid/stack/include/a2d_api.h | 4 +- .../bt/bluedroid/stack/include/a2d_sbc.h | 4 +- .../bt/bluedroid/stack/include/avrc_api.h | 5 +- .../bt/bluedroid/stack/include/avrc_defs.h | 4 +- .../bt/bluedroid/stack/include/btm_api.h | 9 ++- .../bt/bluedroid/stack/include/btm_int.h | 2 + .../bt/bluedroid/stack/include/hiddefs.h | 7 ++ .../bt/bluedroid/stack/include/hidh_api.h | 3 + .../bt/bluedroid/stack/include/l2c_api.h | 19 ++++- .../bt/bluedroid/stack/include/l2cap_client.h | 3 + .../bt/bluedroid/stack/include/sdp_api.h | 4 +- components/bt/bluedroid/stack/l2cap/l2c_api.c | 19 +++++ components/bt/bluedroid/stack/l2cap/l2c_ble.c | 2 +- components/bt/bluedroid/stack/l2cap/l2c_csm.c | 4 +- components/bt/bluedroid/stack/l2cap/l2c_fcr.c | 3 + .../bt/bluedroid/stack/l2cap/l2c_link.c | 56 ++++++++++----- .../bt/bluedroid/stack/l2cap/l2c_main.c | 16 ++++- .../bt/bluedroid/stack/l2cap/l2c_utils.c | 45 ++++++++---- .../bt/bluedroid/stack/sdp/include/sdpint.h | 4 +- components/bt/bluedroid/stack/sdp/sdp_api.c | 3 + components/bt/bluedroid/stack/sdp/sdp_db.c | 4 ++ components/bt/bluedroid/stack/sdp/sdp_main.c | 3 +- components/bt/bluedroid/stack/sdp/sdp_utils.c | 4 +- .../bt/bluedroid/stack/smp/include/smp_int.h | 4 +- .../bt/bluedroid/stack/smp/smp_br_main.c | 2 +- .../bluetooth/gatt_server/main/gatts_demo.c | 2 +- 79 files changed, 566 insertions(+), 158 deletions(-) diff --git a/components/bt/bluedroid/bta/ar/bta_ar_int.h b/components/bt/bluedroid/bta/ar/bta_ar_int.h index 4bbf20401b..e9997ec788 100644 --- a/components/bt/bluedroid/bta/ar/bta_ar_int.h +++ b/components/bt/bluedroid/bta/ar/bta_ar_int.h @@ -27,6 +27,7 @@ #include "bta_av_api.h" +#if (BTA_AR_INCLUDED == TRUE) #ifndef BTA_AR_DEBUG #define BTA_AR_DEBUG FALSE @@ -60,4 +61,6 @@ extern tBTA_AR_CB *bta_ar_cb_ptr; #define bta_ar_cb (*bta_ar_cb_ptr) #endif +#endif ///BTA_AR_INCLUDED == TRUE + #endif /* BTA_AR_INT_H */ diff --git a/components/bt/bluedroid/bta/av/bta_av_int.h b/components/bt/bluedroid/bta/av/bta_av_int.h index b4fd9755df..2409c3a480 100644 --- a/components/bt/bluedroid/bta/av/bta_av_int.h +++ b/components/bt/bluedroid/bta/av/bta_av_int.h @@ -31,6 +31,8 @@ #include "bta_av_co.h" #include "list.h" +#if (BTA_AV_INCLUDED == TRUE) + #define BTA_AV_DEBUG TRUE /***************************************************************************** ** Constants @@ -701,4 +703,6 @@ extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); extern void bta_av_vdp_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); extern void bta_av_reg_vdp (tAVDT_CS *p_cs, char *p_service_name, void *p_data); +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* BTA_AV_INT_H */ diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index a533bb74b5..0fcc503c8f 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -52,7 +52,9 @@ static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc, static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name); static void bta_dm_find_services ( BD_ADDR bd_addr); static void bta_dm_discover_next_device(void); +#if (SDP_INCLUDED == TRUE) static void bta_dm_sdp_callback (UINT16 sdp_status); +#endif ///SDP_INCLUDED == TRUE static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator); static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit); static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type); @@ -1195,6 +1197,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 UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->discover.num_uuid); #endif @@ -1231,6 +1234,7 @@ void bta_dm_discover (tBTA_DM_MSG *p_data) bta_dm_search_cb.name_discover_done = FALSE; memcpy(&bta_dm_search_cb.uuid, &p_data->discover.uuid, sizeof(tSDP_UUID)); bta_dm_discover_device(p_data->discover.bd_addr); +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1244,6 +1248,7 @@ void bta_dm_discover (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_di_disc_cmpl(tBTA_DM_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) tBTA_DM_DI_DISC_CMPL di_disc; memset(&di_disc, 0, sizeof(tBTA_DM_DI_DISC_CMPL)); @@ -1258,8 +1263,10 @@ void bta_dm_di_disc_cmpl(tBTA_DM_MSG *p_data) bta_dm_di_cb.p_di_db = NULL; bta_dm_search_cb.p_search_cback(BTA_DM_DI_DISC_CMPL_EVT, (tBTA_DM_SEARCH *) &di_disc); +#endif ///SDP_INCLUDED == TRUE } +#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_di_disc_callback @@ -1281,7 +1288,7 @@ static void bta_dm_di_disc_callback(UINT16 result) bta_sys_sendmsg(p_msg); } } - +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** ** Function bta_dm_disable_search_and_disc @@ -1295,12 +1302,13 @@ static void bta_dm_di_disc_callback(UINT16 result) *******************************************************************************/ static void bta_dm_disable_search_and_disc (void) { +#if (SDP_INCLUDED == TRUE) tBTA_DM_DI_DISC_CMPL di_disc; - +#endif ///SDP_INCLUDED == TRUE if (bta_dm_search_cb.state != BTA_DM_SEARCH_IDLE) { bta_dm_search_cancel(NULL); } - +#if (SDP_INCLUDED == TRUE) if (bta_dm_di_cb.p_di_db != NULL) { memset(&di_disc, 0, sizeof(tBTA_DM_DI_DISC_CMPL)); bdcpy(di_disc.bd_addr, bta_dm_search_cb.peer_bdaddr); @@ -1309,6 +1317,7 @@ static void bta_dm_disable_search_and_disc (void) bta_dm_di_cb.p_di_db = NULL; bta_dm_search_cb.p_search_cback(BTA_DM_DI_DISC_CMPL_EVT, NULL); } +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1323,6 +1332,7 @@ static void bta_dm_disable_search_and_disc (void) *******************************************************************************/ void bta_dm_di_disc (tBTA_DM_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) UINT16 result = BTA_FAILURE; tBTA_DM_MSG *p_msg; @@ -1346,6 +1356,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data) p_data->hdr.offset = result; bta_sys_sendmsg(p_msg); } +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1482,7 +1493,7 @@ void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) { - +#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_sdp_rec = NULL; tBTA_DM_MSG *p_msg; BOOLEAN scn_found = FALSE; @@ -1714,6 +1725,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) bta_sys_sendmsg(p_msg); } } +#endif ///SDP_INCLUDE == TRUE } /******************************************************************************* @@ -1839,12 +1851,13 @@ static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle) *******************************************************************************/ void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) UNUSED(p_data); if (bta_dm_search_cb.p_sdp_db) { GKI_freebuf(bta_dm_search_cb.p_sdp_db); bta_dm_search_cb.p_sdp_db = NULL; } - +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1878,13 +1891,14 @@ void bta_dm_queue_search (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_queue_disc (tBTA_DM_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) if (bta_dm_search_cb.p_search_queue) { GKI_freebuf(bta_dm_search_cb.p_search_queue); } bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER)); memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER)); - +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1936,6 +1950,7 @@ void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) UNUSED(p_data); if (bta_dm_search_cb.p_sdp_db) { GKI_freebuf(bta_dm_search_cb.p_sdp_db); @@ -1943,6 +1958,7 @@ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data) } bta_dm_search_cancel_notify(NULL); +#endif ///SDP_INCLUDED == TRUE } @@ -1983,7 +1999,7 @@ void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data) *******************************************************************************/ static void bta_dm_find_services ( BD_ADDR bd_addr) { - +#if (SDP_INCLUDED == TRUE) tSDP_UUID uuid; tBTA_DM_MSG *p_msg; @@ -2089,6 +2105,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr) bta_sys_sendmsg(p_msg); } } +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -2272,6 +2289,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr) } } +#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_sdp_callback @@ -2293,7 +2311,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status) } } - +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** ** Function bta_dm_inq_results_cb @@ -4102,6 +4120,7 @@ static void bta_dm_observe_cmpl_cb (void *p_result) static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data) { tBTM_STATUS status = BTM_SUCCESS; +#if (SMP_INCLUDED == TRUE) tBTA_DM_SEC sec_event; char *p_name = NULL; @@ -4215,6 +4234,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D status = BTM_NOT_AUTHORIZED; break; } +#endif ///SMP_INCLUDED == TRUE return status; } #endif /* SMP_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index aa58e8406e..5f81a616cf 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -279,6 +279,7 @@ void BTA_DmSearchCancel(void) void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) { +#if (SDP_INCLUDED == TRUE) tBTA_DM_API_DISCOVER *p_msg; if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) { @@ -291,9 +292,11 @@ void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, p_msg->sdp_search = sdp_search; bta_sys_sendmsg(p_msg); } - +#endif ///SDP_INCLUDED == TRUE } +#if (SDP_INCLUDED == TRUE) + /******************************************************************************* ** ** Function BTA_DmDiscoverUUID @@ -324,8 +327,8 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, memcpy( &p_msg->uuid, uuid, sizeof(tSDP_UUID) ); bta_sys_sendmsg(p_msg); } - } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -613,7 +616,7 @@ UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ) return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED); } - +#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** Device Identification (DI) Server Functions *******************************************************************************/ @@ -645,7 +648,7 @@ tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, return status; } - +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** ** Function bta_dmexecutecallback @@ -1393,7 +1396,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_ ** Returns void ** *******************************************************************************/ -#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search, tBTA_TRANSPORT transport) @@ -1447,7 +1450,7 @@ void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_service tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search, tBTA_TRANSPORT transport) { -#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport); #endif } @@ -1471,7 +1474,7 @@ void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_service void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) { -#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN); #endif diff --git a/components/bt/bluedroid/bta/dm/bta_dm_int.h b/components/bt/bluedroid/bta/dm/bta_dm_int.h index b2cdb0c331..f524c6df58 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/bta_dm_int.h @@ -201,6 +201,7 @@ typedef struct { #endif } tBTA_DM_API_SEARCH; +#if (SDP_INCLUDED == TRUE) /* data type for BTA_DM_API_DISCOVER_EVT */ typedef struct { BT_HDR hdr; @@ -215,12 +216,15 @@ typedef struct { #endif tSDP_UUID uuid; } tBTA_DM_API_DISCOVER; +#endif ///SDP_INCLUDED == TRUE /* data type for BTA_DM_API_DI_DISC_EVT */ typedef struct { BT_HDR hdr; BD_ADDR bd_addr; +#if (SDP_INCLUDED == TRUE) tBTA_DISCOVERY_DB *p_sdp_db; +#endif ///SDP_INCLUDED == TRUE UINT32 len; tBTA_DM_SEARCH_CBACK *p_cback; } tBTA_DM_API_DI_DISC; @@ -675,9 +679,9 @@ typedef union { tBTA_DM_API_REMOVE_DEVICE remove_dev; tBTA_DM_API_SEARCH search; - +#if (SDP_INCLUDED == TRUE) tBTA_DM_API_DISCOVER discover; - +#endif ///SDP_INCLUDED == TRUE tBTA_DM_API_BOND bond; tBTA_DM_API_BOND_CANCEL bond_cancel; @@ -918,7 +922,9 @@ typedef struct { tBTA_SERVICE_MASK services; tBTA_SERVICE_MASK services_to_search; tBTA_SERVICE_MASK services_found; +#if (SDP_INCLUDED == TRUE) tSDP_DISCOVERY_DB *p_sdp_db; +#endif ///SDP_INCLUDED == TRUE UINT16 state; BD_ADDR peer_bdaddr; BOOLEAN name_discover_done; @@ -928,7 +934,9 @@ typedef struct { tBTA_DM_MSG *p_search_queue; /* search or discover commands during search cancel stored here */ BOOLEAN wait_disc; BOOLEAN sdp_results; +#if (SDP_INCLUDED == TRUE) tSDP_UUID uuid; +#endif ///SDP_INCLUDED == TRUE UINT8 peer_scn; BOOLEAN sdp_search; BOOLEAN cancel_pending; /* inquiry cancel is pending */ @@ -955,7 +963,9 @@ typedef struct { /* DI control block */ typedef struct { +#if (SDP_INCLUDED == TRUE) tSDP_DISCOVERY_DB *p_di_db; /* pointer to the DI discovery database */ +#endif ///SDP_INCLUDED == TRUE UINT8 di_num; /* total local DI record number */ UINT32 di_handle[BTA_DI_NUM_MAX]; /* local DI record handle, the first one is primary record */ } tBTA_DM_DI_CB; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/bluedroid/bta/dm/bta_dm_pm.c index 10521ee075..988e570578 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_pm.c @@ -700,7 +700,9 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index) #endif BTM_ReadPowerMode(p_peer_dev->peer_bdaddr, &mode); +#if (BTM_SSR_INCLUDED == TRUE) p_rem_feat = BTM_ReadRemoteFeatures (p_peer_dev->peer_bdaddr); +#endif ///BTM_SSR_INCLUDED == TRUE #if (BTM_SSR_INCLUDED == TRUE) APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d, info:x%x", mode, index, p_peer_dev->info); if (mode != BTM_PM_MD_SNIFF || diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c index bd50064f1d..b887cb3282 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c @@ -788,6 +788,7 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb, *******************************************************************************/ void bta_gattc_sdp_callback (UINT16 sdp_status) { +#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_sdp_rec = NULL; tBT_UUID service_uuid; tSDP_PROTOCOL_ELEM pe; @@ -842,6 +843,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status) GKI_freebuf(bta_gattc_cb.p_sdp_db); bta_gattc_cb.p_sdp_db = NULL; bta_gattc_cb.sdp_conn_id = 0; +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* ** @@ -854,6 +856,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status) *******************************************************************************/ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb) { +#if (SDP_INCLUDED == TRUE) tSDP_UUID uuid; UINT16 num_attrs = 2; UINT16 attr_list[2]; @@ -881,6 +884,9 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE } } return status; +#else + return BTA_GATT_NO_RESOURCES; +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/hh/bta_hh_cfg.c b/components/bt/bluedroid/bta/hh/bta_hh_cfg.c index 5cdc0b7287..d80de5e8b9 100644 --- a/components/bt/bluedroid/bta/hh/bta_hh_cfg.c +++ b/components/bt/bluedroid/bta/hh/bta_hh_cfg.c @@ -26,6 +26,9 @@ #include "bt_target.h" #include "bta_hh_api.h" +#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) + + /* max number of device types supported by BTA */ #define BTA_HH_MAX_DEVT_SPT 9 @@ -58,3 +61,4 @@ const tBTA_HH_CFG bta_hh_cfg = { tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *) &bta_hh_cfg; +#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) \ No newline at end of file diff --git a/components/bt/bluedroid/bta/hh/bta_hh_int.h b/components/bt/bluedroid/bta/hh/bta_hh_int.h index a5374dac01..e3d296ee76 100644 --- a/components/bt/bluedroid/bta/hh/bta_hh_int.h +++ b/components/bt/bluedroid/bta/hh/bta_hh_int.h @@ -32,6 +32,7 @@ //#if BTA_HH_LE_INCLUDED == TRUE #include "bta_gatt_api.h" //#endif +#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) /* can be moved to bta_api.h */ #define BTA_HH_MAX_RPT_CHARS 8 @@ -395,5 +396,6 @@ extern void bta_hh_ci_load_rpt (tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); extern void bta_hh_trace_dev_db(void); #endif +#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) #endif diff --git a/components/bt/bluedroid/bta/include/bta_api.h b/components/bt/bluedroid/bta/include/bta_api.h index d428bed8e5..a645a25b1f 100644 --- a/components/bt/bluedroid/bta/include/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta_api.h @@ -635,7 +635,7 @@ typedef struct { } tBTA_DM_PIN_REQ; /* BLE related definition */ - +#if (SMP_INCLUDED == TRUE) #define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10) #define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x)) #define BTA_DM_AUTH_SMP_PASSKEY_FAIL BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL) @@ -655,7 +655,7 @@ typedef struct { #define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY) #define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL) #define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT) - +#endif ///SMP_INCLUDED == TRUE /* connection parameter boundary value and dummy value */ #define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN #define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX @@ -668,13 +668,14 @@ typedef struct { #define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX #define BTA_DM_BLE_CONN_PARAM_UNDEF BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be overwritten */ - +#if (SMP_INCLUDED == TRUE) #define BTA_LE_KEY_PENC BTM_LE_KEY_PENC /* encryption information of peer device */ #define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */ #define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */ #define BTA_LE_KEY_LENC BTM_LE_KEY_LENC /* master role security information:div */ #define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */ #define BTA_LE_KEY_LCSRK BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */ +#endif ///SMP_INCLUDED == TRUE typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */ @@ -702,10 +703,11 @@ typedef struct { BT_OCTET16 irk; BT_OCTET16 dhk; } tBTA_BLE_LOCAL_ID_KEYS; - +#if (SMP_INCLUDED == TRUE) #define BTA_DM_SEC_GRANTED BTA_SUCCESS #define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT #define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT +#endif ///SMP_INCLUDED == TRUE typedef UINT8 tBTA_DM_BLE_SEC_GRANT; @@ -810,6 +812,7 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ; #define BTA_AUTH_GEN_BOND BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */ #define BTA_AUTH_BONDS BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits */ +#if (SMP_INCLUDED == TRUE) #define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/ #define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */ #define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */ @@ -818,6 +821,7 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ; #define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND /* 1001 */ #define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM /* 1100 */ #define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */ +#endif ///SMP_INCLUDED == TRUE typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */ #define BTA_OOB_NONE BTM_OOB_NONE @@ -1285,7 +1289,7 @@ typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status typedef UINT8 tBTA_DM_ROUTE_PATH; - +#if (SDP_INCLUDED == TRUE) /* Device Identification (DI) data structure */ /* Used to set the DI record */ @@ -1294,6 +1298,7 @@ typedef tSDP_DI_RECORD tBTA_DI_RECORD; typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD; /* SDP discovery database */ typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB; +#endif ///SDP_INCLUDED == TRUE #ifndef BTA_DI_NUM_MAX #define BTA_DI_NUM_MAX 3 @@ -1448,7 +1453,7 @@ extern void BTA_DmSearchCancel(void); *******************************************************************************/ extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search); - +#if (SDP_INCLUDED == TRUE) // btla-specific ++ /******************************************************************************* ** @@ -1463,7 +1468,7 @@ extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, *******************************************************************************/ extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search); - +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** ** Function BTA_DmGetCachedRemoteName @@ -1619,7 +1624,7 @@ extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services ); *******************************************************************************/ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ); - +#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTA_DmSetLocalDiRecord @@ -1631,7 +1636,7 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ); *******************************************************************************/ extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, UINT32 *p_handle ); - +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** ** diff --git a/components/bt/bluedroid/bta/include/bta_ar_api.h b/components/bt/bluedroid/bta/include/bta_ar_api.h index af8ea535ef..acfac9df44 100644 --- a/components/bt/bluedroid/bta/include/bta_ar_api.h +++ b/components/bt/bluedroid/bta/include/bta_ar_api.h @@ -33,6 +33,8 @@ #include "bta_av_api.h" #include "bta_sys.h" +#if (BTA_AR_INCLUDED == TRUE) + /***************************************************************************** ** Constants and data types *****************************************************************************/ @@ -137,4 +139,6 @@ extern void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id); } #endif +#endif ///BTA_AR_INCLUDED == TRUE + #endif /* BTA_AR_API_H */ diff --git a/components/bt/bluedroid/bta/include/bta_av_api.h b/components/bt/bluedroid/bta/include/bta_av_api.h index 683b673693..24c359910c 100644 --- a/components/bt/bluedroid/bta/include/bta_av_api.h +++ b/components/bt/bluedroid/bta/include/bta_av_api.h @@ -31,6 +31,8 @@ #include "a2d_api.h" #include "bta_api.h" +#if (BTA_AV_INCLUDED == TRUE) + /***************************************************************************** ** Constants and data types *****************************************************************************/ @@ -805,4 +807,6 @@ void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p } #endif +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* BTA_AV_API_H */ diff --git a/components/bt/bluedroid/bta/include/bta_av_ci.h b/components/bt/bluedroid/bta/include/bta_av_ci.h index c95326f7dc..a537b8a4ca 100644 --- a/components/bt/bluedroid/bta/include/bta_av_ci.h +++ b/components/bt/bluedroid/bta/include/bta_av_ci.h @@ -26,6 +26,8 @@ #include "bta_av_api.h" +#if (BTA_AV_INCLUDED == TRUE) + /***************************************************************************** ** Function Declarations *****************************************************************************/ @@ -70,4 +72,6 @@ extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, } #endif +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* BTA_AV_CI_H */ diff --git a/components/bt/bluedroid/bta/include/bta_av_co.h b/components/bt/bluedroid/bta/include/bta_av_co.h index ce93cfbd05..c2f94b6352 100644 --- a/components/bt/bluedroid/bta/include/bta_av_co.h +++ b/components/bt/bluedroid/bta/include/bta_av_co.h @@ -27,6 +27,8 @@ #include "l2c_api.h" #include "bta_av_api.h" +#if (BTA_AV_INCLUDED == TRUE) + /***************************************************************************** ** Constants and data types *****************************************************************************/ @@ -386,4 +388,6 @@ extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay); *******************************************************************************/ extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay); +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* BTA_AV_CO_H */ diff --git a/components/bt/bluedroid/bta/include/bta_av_sbc.h b/components/bt/bluedroid/bta/include/bta_av_sbc.h index 59778edb8d..966ee61bba 100644 --- a/components/bt/bluedroid/bta/include/bta_av_sbc.h +++ b/components/bt/bluedroid/bta/include/bta_av_sbc.h @@ -25,6 +25,8 @@ #ifndef BTA_AV_SBC_H #define BTA_AV_SBC_H +#if (BTA_AV_INCLUDED == TRUE) + /***************************************************************************** ** constants *****************************************************************************/ @@ -215,5 +217,7 @@ extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap); *******************************************************************************/ extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt); +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* BTA_AV_SBC_H */ diff --git a/components/bt/bluedroid/bta/include/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta_gatt_api.h index f4c0e06f07..40b661c2ef 100644 --- a/components/bt/bluedroid/bta/include/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta_gatt_api.h @@ -40,7 +40,7 @@ #ifndef BTA_GATT_DEBUG -#define BTA_GATT_DEBUG FALSE +#define BTA_GATT_DEBUG TRUE #endif /***************************************************************************** diff --git a/components/bt/bluedroid/bta/include/bta_gattc_int.h b/components/bt/bluedroid/bta/include/bta_gattc_int.h index d50c66226e..9526860876 100644 --- a/components/bt/bluedroid/bta/include/bta_gattc_int.h +++ b/components/bt/bluedroid/bta/include/bta_gattc_int.h @@ -398,8 +398,9 @@ typedef struct { tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX]; tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX]; - +#if (SDP_INCLUDED == TRUE) tSDP_DISCOVERY_DB *p_sdp_db; +#endif ///SDP_INCLUDED == TRUE UINT16 sdp_conn_id; } tBTA_GATTC_CB; diff --git a/components/bt/bluedroid/bta/include/bta_hh_api.h b/components/bt/bluedroid/bta/include/bta_hh_api.h index d6b3174042..aa9fd0a236 100644 --- a/components/bt/bluedroid/bta/include/bta_hh_api.h +++ b/components/bt/bluedroid/bta/include/bta_hh_api.h @@ -20,6 +20,7 @@ #include "bta_api.h" #include "hidh_api.h" +#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) #if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) #include "gatt_api.h" @@ -538,4 +539,7 @@ extern void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id); } #endif +#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) + + #endif /* BTA_HH_API_H */ diff --git a/components/bt/bluedroid/bta/include/bta_sdp_api.h b/components/bt/bluedroid/bta/include/bta_sdp_api.h index c2df4bb957..6f27f5ccb0 100644 --- a/components/bt/bluedroid/bta/include/bta_sdp_api.h +++ b/components/bt/bluedroid/bta/include/bta_sdp_api.h @@ -30,6 +30,7 @@ #include "bta_api.h" #include "btm_api.h" +#if (SDP_INCLUDED == TRUE) /* status values */ #define BTA_SDP_SUCCESS 0 /* Successful operation. */ #define BTA_SDP_FAILURE 1 /* Generic failure. */ @@ -70,7 +71,9 @@ typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *use /* MCE configuration structure */ typedef struct { UINT16 sdp_db_size; /* The size of p_sdp_db */ +#if (SDP_INCLUDED == TRUE) tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ +#endif ///SDP_INCLUDED == TRUE } tBTA_SDP_CFG; #ifdef __cplusplus @@ -139,4 +142,6 @@ extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data); } #endif +#endif ///SDP_INCLUDED == TRUE + #endif /* BTA_SDP_API_H */ diff --git a/components/bt/bluedroid/bta/sdp/bta_sdp_act.c b/components/bt/bluedroid/bta/sdp/bta_sdp_act.c index de563b56c1..09bdf058f5 100644 --- a/components/bt/bluedroid/bta/sdp/bta_sdp_act.c +++ b/components/bt/bluedroid/bta/sdp/bta_sdp_act.c @@ -39,7 +39,8 @@ #include "btm_int.h" #include "sdp_api.h" -#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) +#if (SDP_INCLUDED == TRUE) + /***************************************************************************** ** Constants *****************************************************************************/ @@ -326,6 +327,7 @@ static void bta_create_sap_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { +#if (SDP_INCLUDED == TRUE) tSDP_DISC_ATTR *p_attr; tSDP_PROTOCOL_ELEM pe; @@ -348,6 +350,7 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE } record->hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size; record->hdr.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data; +#endif ///SDP_INCLUDED == TRUE } @@ -362,6 +365,7 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE *******************************************************************************/ static void bta_sdp_search_cback(UINT16 result, void *user_data) { +#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_rec = NULL; tBTA_SDP_SEARCH_COMP evt_data = {0}; // We need to zero-initialize tBTA_SDP_STATUS status = BTA_SDP_FAILURE; @@ -425,6 +429,7 @@ static void bta_sdp_search_cback(UINT16 result, void *user_data) bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, (tBTA_SDP *) &evt_data, (void *)&uuid->uu.uuid128); osi_free(user_data); // We no longer need the user data to track the search +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -455,6 +460,7 @@ void bta_sdp_enable(tBTA_SDP_MSG *p_data) *******************************************************************************/ void bta_sdp_search(tBTA_SDP_MSG *p_data) { +#if (SDP_INCLUDED == TRUE) int x = 0; // TODO: Leaks!!! but needed as user-data pointer tBT_UUID *bta_sdp_search_uuid = osi_malloc(sizeof(tBT_UUID)); @@ -509,6 +515,7 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data) /* else report the result when the cback is called */ +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -545,4 +552,4 @@ void bta_sdp_remove_record(tBTA_SDP_MSG *p_data) } } -#endif /* #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) */ +#endif ///SDP_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/bta/sdp/bta_sdp_int.h b/components/bt/bluedroid/bta/sdp/bta_sdp_int.h index 21be47e063..4f9f7d2cb8 100644 --- a/components/bt/bluedroid/bta/sdp/bta_sdp_int.h +++ b/components/bt/bluedroid/bta/sdp/bta_sdp_int.h @@ -31,6 +31,7 @@ #include "bta_api.h" #include "bta_sdp_api.h" +#if (SDP_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************/ @@ -105,4 +106,7 @@ extern void bta_sdp_search (tBTA_SDP_MSG *p_data); extern void bta_sdp_create_record(tBTA_SDP_MSG *p_data); extern void bta_sdp_remove_record(tBTA_SDP_MSG *p_data); +#endif ///SDP_INCLUDED == TRUE + #endif /* BTA_SDP_INT_H */ + diff --git a/components/bt/bluedroid/btc/core/btc_ble_storage.c b/components/bt/bluedroid/btc/core/btc_ble_storage.c index 820537c9e7..1c885f4b5c 100644 --- a/components/bt/bluedroid/btc/core/btc_ble_storage.c +++ b/components/bt/bluedroid/btc/core/btc_ble_storage.c @@ -20,6 +20,8 @@ #include "btc_ble_storage.h" #include "bta_gatts_co.h" +#if (SMP_INCLUDED == TRUE) + btc_dm_pairing_cb_t pairing_cb; btc_dm_local_key_cb_t ble_local_key_cb; @@ -485,4 +487,6 @@ void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET1 } LOG_DEBUG("%s *p_key_mask=0x%02x",__func__, *p_key_mask); } + +#endif ///SMP_INCLUDED == TRUE diff --git a/components/bt/bluedroid/btc/core/btc_dm.c b/components/bt/bluedroid/btc/core/btc_dm.c index 121ee9d466..e4658a8400 100644 --- a/components/bt/bluedroid/btc/core/btc_dm.c +++ b/components/bt/bluedroid/btc/core/btc_dm.c @@ -113,6 +113,7 @@ static void btc_disable_bluetooth_evt(void) future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_SUCCESS); } +#if (SMP_INCLUDED == TRUE) static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { /* Save link key, if not temporary */ @@ -147,7 +148,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) LOG_DEBUG("%s, authentication status = %x", __func__, status); return; + } +#endif ///SMP_INCLUDED == TRUE static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { @@ -303,8 +306,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) case BTA_DM_ENABLE_EVT: { btc_clear_services_mask(); btc_storage_load_bonded_devices(); +#if (SMP_INCLUDED == TRUE) //load the ble local key whitch has been store in the flash btc_dm_load_ble_local_keys(); +#endif ///SMP_INCLUDED == TRUE btc_enable_bluetooth_evt(p_data->enable.status); break; } @@ -334,7 +339,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) case BTA_DM_LINK_DOWN_EVT: case BTA_DM_HW_ERROR_EVT: -#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) +#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; diff --git a/components/bt/bluedroid/btc/include/btc_ble_storage.h b/components/bt/bluedroid/btc/include/btc_ble_storage.h index 1efbb0ec51..2884d6acf3 100644 --- a/components/bt/bluedroid/btc/include/btc_ble_storage.h +++ b/components/bt/bluedroid/btc/include/btc_ble_storage.h @@ -15,7 +15,7 @@ #include "bt_types.h" #include "bt_target.h" - +#if (SMP_INCLUDED == TRUE) #define BTC_LE_LOCAL_KEY_IR (1<<0) #define BTC_LE_LOCAL_KEY_IRK (1<<1) #define BTC_LE_LOCAL_KEY_DHK (1<<2) @@ -120,4 +120,5 @@ bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, void btc_dm_load_ble_local_keys(void); void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, - tBTA_BLE_LOCAL_ID_KEYS *p_id_keys); \ No newline at end of file + tBTA_BLE_LOCAL_ID_KEYS *p_id_keys); +#endif ///SMP_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h b/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h index 43a83002e4..9ec9b5d448 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h +++ b/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h @@ -17,6 +17,7 @@ #include "btc_media.h" +#if (BTA_AV_INCLUDED == TRUE) /******************************************************************************* ** Constants & Macros ********************************************************************************/ @@ -166,4 +167,6 @@ BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl); *******************************************************************************/ BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max); +#endif ///BTA_AV_INCLUDED == TRUE + #endif diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index f9ec31bba8..062c957e45 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -928,11 +928,13 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) break; } case BTC_GAP_BLE_SECURITY_RSP_EVT: { +#if (SMP_INCLUDED == TRUE) BD_ADDR bd_addr; tBTA_DM_BLE_SEC_GRANT res = arg->sec_rsp.accept ? BTA_DM_SEC_GRANTED : BTA_DM_SEC_PAIR_NOT_SPT; memcpy(bd_addr, arg->sec_rsp.bd_addr, sizeof(BD_ADDR)); BTA_DmBleSecurityGrant(bd_addr, res); break; +#endif ///SMP_INCLUDED == TRUE } default: break; diff --git a/components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h b/components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h index 220ae9a5bc..320b78fa32 100644 --- a/components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h +++ b/components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h @@ -25,7 +25,7 @@ #ifndef HID_CONN_H #define HID_CONN_H - +#if (HID_HOST_INCLUDED == TRUE) /* Define the HID Connection Block */ typedef struct hid_conn { @@ -65,4 +65,5 @@ typedef struct hid_conn { #define HIDD_SEC_CHN 3 #define HIDD_NOSEC_CHN 4 +#endif ///HID_HOST_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h b/components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h index afdb9308ef..a1d40781d7 100644 --- a/components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h +++ b/components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h @@ -29,6 +29,8 @@ #include "hid_conn.h" #include "l2c_api.h" +#if (HID_HOST_INCLUDED == TRUE) + enum { HID_DEV_NO_CONN, HID_DEV_CONNECTED @@ -88,4 +90,6 @@ extern tHID_HOST_CTB *hidh_cb_ptr; } #endif +#endif ///HID_HOST_INCLUDED == TRUE + #endif diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_av.h b/components/bt/bluedroid/btc/profile/std/include/btc_av.h index 92ab081499..8a8664cd21 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_av.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_av.h @@ -31,7 +31,7 @@ #include "btc_sm.h" #include "bta_av_api.h" - +#if (BTA_AV_INCLUDED == TRUE) /******************************************************************************* ** Type definitions for callback functions ********************************************************************************/ @@ -171,4 +171,6 @@ BOOLEAN btc_av_is_peer_edr(void); ********************************************************************************/ void btc_av_clear_remote_suspend_flag(void); +#endif ///BTA_AV_INCLUDED == TRUE + #endif /* __BTC_AV_H__ */ diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_av_api.h b/components/bt/bluedroid/btc/profile/std/include/btc_av_api.h index dc773bb9e3..c7672a0753 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_av_api.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_av_api.h @@ -32,7 +32,7 @@ #include "a2d_api.h" #include "a2d_sbc.h" - +#if (BTC_AV_INCLUDED == TRUE) /***************************************************************************** ** Constants and data types *****************************************************************************/ @@ -198,4 +198,6 @@ typedef struct { } #endif +#endif ///BTC_AV_INCLUDED == TRUE + #endif /* __BTC_AV_API_H__ */ diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h b/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h index b9efb9db34..3f16d10f3c 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h @@ -23,6 +23,7 @@ #include "bt_types.h" #include "bta_av_api.h" +#if (BTC_AV_INCLUDED == TRUE) #ifndef BTC_AVRC_TGT_INCLUDED #define BTC_AVRC_TGT_INCLUDED FALSE #endif @@ -71,4 +72,6 @@ BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr); ********************************************************************************/ void btc_avrc_call_handler(btc_msg_t *msg); +#endif ///BTC_AV_INCLUDED == TRUE + #endif /* __BTC_AVRC_H__ */ diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_media.h b/components/bt/bluedroid/btc/profile/std/include/btc_media.h index 3ff0d1e108..a25da98778 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_media.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_media.h @@ -28,6 +28,7 @@ #include "gki.h" #include "btc_av_api.h" +#if (BTA_AV_INCLUDED == TRUE) /******************************************************************************* ** Constants @@ -263,5 +264,5 @@ void btc_reset_decoder(UINT8 *p_av); int btc_a2dp_get_track_frequency(UINT8 frequency); int btc_a2dp_get_track_channel_count(UINT8 channeltype); void btc_a2dp_set_peer_sep(UINT8 sep); - +#endif ///BTA_AV_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/btif/bta_dm_co.c b/components/bt/bluedroid/btif/bta_dm_co.c index 269f517808..3c45d65ffe 100644 --- a/components/bt/bluedroid/btif/bta_dm_co.c +++ b/components/bt/bluedroid/btif/bta_dm_co.c @@ -22,15 +22,15 @@ #include "bta_sys.h" #include "bta_dm_co.h" #include "bta_dm_ci.h" +#include "btc_ble_storage.h" #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) #include "bt_utils.h" #if (BTM_OOB_INCLUDED == TRUE) #include "btif_dm.h" #endif #endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */ -#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) +#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) #include "bte_appl.h" -#include "btc_ble_storage.h" tBTE_APPL_CFG bte_appl_cfg = { #if SMP_INCLUDED == TRUE BTA_LE_AUTH_REQ_SC_MITM_BOND, // Authentication requirements @@ -369,12 +369,14 @@ void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size, tBTA_LE_KEY_TYPE *p_resp_key ) { UNUSED(bd_addr); +#if (SMP_INCLUDED == TRUE) BTIF_TRACE_ERROR("##################################"); BTIF_TRACE_ERROR("bta_dm_co_le_io_key_req: only setting max size to 16"); BTIF_TRACE_ERROR("##################################"); *p_max_key_size = 16; *p_init_key = *p_resp_key = (BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK); +#endif ///SMP_INCLUDED == TRUE } @@ -398,10 +400,11 @@ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OC BTIF_TRACE_DEBUG("bta_dm_co_ble_load_local_keys: Load local keys if any are persisted"); BTIF_TRACE_DEBUG("##################################"); btif_dm_get_ble_local_keys( p_key_mask, er, p_id_keys); -#else +#endif ///defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) btc_dm_get_ble_local_keys( p_key_mask, er, p_id_keys); LOG_WARN("bta_dm_co_ble_load_local_keys: func not ported\n"); -#endif +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -429,6 +432,7 @@ void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_LE_KEY_TYPE *p_init_key, tBTA_LE_KEY_TYPE *p_resp_key ) { +#if (SMP_INCLUDED == TRUE) UNUSED(bd_addr); /* if OOB is not supported, this call-out function does not need to do anything * otherwise, look for the OOB data associated with the address and set *p_oob_data accordingly @@ -458,41 +462,52 @@ void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) { *p_max_key_size = bte_appl_cfg.ble_max_key_size; } +#endif ///SMP_INCLUDED == TRUE } void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap) { +#if (SMP_INCLUDED == TRUE) if(ble_io_cap < BTM_IO_CAP_MAX ) { bte_appl_cfg.ble_io_cap = ble_io_cap; } else { APPL_TRACE_ERROR("%s error:Invalid io cap value.",__func__); } +#endif ///SMP_INCLUDED == TRUE } void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req) { +#if (SMP_INCLUDED == TRUE) bte_appl_cfg.ble_auth_req = ble_auth_req; +#endif ///SMP_INCLUDED == TRUE } void bta_dm_co_ble_set_init_key_req(UINT8 init_key) { +#if (SMP_INCLUDED == TRUE) init_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit bte_appl_cfg.ble_init_key &= init_key; +#endif ///SMP_INCLUDED == TRUE } void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key) { +#if (SMP_INCLUDED == TRUE) rsp_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit bte_appl_cfg.ble_init_key &= rsp_key; +#endif ///SMP_INCLUDED == TRUE } void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size) { +#if (SMP_INCLUDED == TRUE) if(ble_key_size > 7 && ble_key_size >= 16) { bte_appl_cfg.ble_max_key_size = ble_key_size; } else { APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size); } +#endif ///SMP_INCLUDED == TRUE } #endif diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index e684a0ecf4..7f9203828b 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -42,7 +42,7 @@ #include "dyn_mem.h" /* defines static and/or dynamic memory for components */ #if CONFIG_CLASSIC_BT_ENABLED - +#define CLASSIC_BT_INCLUDED TRUE #define BTA_SDP_INCLUDED TRUE #define BTA_PAN_INCLUDED FALSE #define BTA_HH_INCLUDED FALSE @@ -66,7 +66,7 @@ #define BTC_AV_INCLUDED TRUE #else /* #if CONFIG_CLASSIC_BT_ENABLED */ - +#define CLASSIC_BT_INCLUDED FALSE #define BTA_SDP_INCLUDED FALSE #define BTA_PAN_INCLUDED FALSE #define BTA_HH_INCLUDED FALSE @@ -635,7 +635,11 @@ #endif #ifndef BTM_LOCAL_IO_CAPS_BLE +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) #define BTM_LOCAL_IO_CAPS_BLE BTM_IO_CAP_KBDISP +#else +#define BTM_LOCAL_IO_CAPS_BLE 4 +#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE #endif /* The default MITM Protection Requirement (for Simple Pairing) @@ -684,6 +688,9 @@ #define L2CAP_CLIENT_INCLUDED FALSE #endif +/* The default connection link number set to 1, +** if the user want to support muti connction, should change it in the menuconfig */ +#define MAX_ACL_CONNECTIONS 1 /* The maximum number of simultaneous links that L2CAP can support. Up to 7*/ #ifndef MAX_ACL_CONNECTIONS @@ -694,12 +701,20 @@ /* The maximum number of simultaneous channels that L2CAP can support. Up to 16*/ #ifndef MAX_L2CAP_CHANNELS +#if (CLASSIC_BT_INCLUDED == TRUE) #define MAX_L2CAP_CHANNELS 8 +#else +#define MAX_L2CAP_CHANNELS 1 //Not support to create l2cap channels in the BLE only mode in this bluedroid version(6.0) +#endif ///CLASSIC_BT_INCLUDED == TRUE #endif /* The maximum number of simultaneous applications that can register with L2CAP. */ #ifndef MAX_L2CAP_CLIENTS +#if (CLASSIC_BT_INCLUDED == TRUE) #define MAX_L2CAP_CLIENTS 8 +#else +#define MAX_L2CAP_CLIENTS 1 //Not support to allocate a channel control block in BLE only mode +#endif ///CLASSIC_BT_INCLUDED == TRUE #endif /* The number of seconds of link inactivity before a link is disconnected. */ @@ -785,7 +800,11 @@ /* Used for features using fixed channels; set to zero if no fixed channels supported (BLE, etc.) */ /* Excluding L2CAP signaling channel and UCD */ #ifndef L2CAP_NUM_FIXED_CHNLS +#if (CLASSIC_BT_INCLUDED == TRUE) #define L2CAP_NUM_FIXED_CHNLS 32 +#else +#define L2CAP_NUM_FIXED_CHNLS 2 //There are just two fix channel in the BLE only mode(gatt,smp) +#endif ///CLASSIC_BT_INCLUDED == TRUE #endif /* First fixed channel supported */ @@ -853,7 +872,7 @@ * resolution, local address rotation etc. */ #ifndef BLE_PRIVACY_SPT -#define BLE_PRIVACY_SPT TRUE +#define BLE_PRIVACY_SPT FALSE #endif /* @@ -992,7 +1011,7 @@ ******************************************************************************/ #ifndef SMP_INCLUDED #if BLE_INCLUDED == TRUE -#define SMP_INCLUDED TRUE +#define SMP_INCLUDED FALSE #else #define SMP_INCLUDED FALSE #endif @@ -1036,7 +1055,7 @@ ******************************************************************************/ #ifndef SDP_INCLUDED -#define SDP_INCLUDED TRUE +#define SDP_INCLUDED FALSE //TRUE #endif /* This is set to enable SDP server functionality. */ @@ -1535,7 +1554,7 @@ Range: 2 octets /* This is set to enable use of GAP L2CAP connections. */ #ifndef GAP_CONN_INCLUDED -#if GAP_INCLUDED == TRUE +#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE) #define GAP_CONN_INCLUDED TRUE #else #define GAP_CONN_INCLUDED FALSE diff --git a/components/bt/bluedroid/include/bt_trace.h b/components/bt/bluedroid/include/bt_trace.h index 787c4c8aec..5d11ef5cbb 100644 --- a/components/bt/bluedroid/include/bt_trace.h +++ b/components/bt/bluedroid/include/bt_trace.h @@ -193,11 +193,11 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef BTM_INITIAL_TRACE_LEVEL -#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG #endif #ifndef L2CAP_INITIAL_TRACE_LEVEL -#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG #endif #ifndef RFCOMM_INITIAL_TRACE_LEVEL @@ -245,7 +245,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef APPL_INITIAL_TRACE_LEVEL -#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG #endif #ifndef BT_TRACE_APPL @@ -253,7 +253,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef GATT_INITIAL_TRACE_LEVEL -#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG #endif #ifndef SMP_INITIAL_TRACE_LEVEL diff --git a/components/bt/bluedroid/stack/a2dp/include/a2d_int.h b/components/bt/bluedroid/stack/a2dp/include/a2d_int.h index d362f3f5b0..89055bce99 100644 --- a/components/bt/bluedroid/stack/a2dp/include/a2d_int.h +++ b/components/bt/bluedroid/stack/a2dp/include/a2d_int.h @@ -25,7 +25,7 @@ #define A2D_INT_H #include "a2d_api.h" - +#if (A2D_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************/ @@ -77,5 +77,5 @@ extern void a2d_set_avdt_sdp_ver (UINT16 avdt_sdp_ver); #ifdef __cplusplus } #endif - +#endif ///A2D_INCLUDED == TRUE #endif /* A2D_INT_H */ diff --git a/components/bt/bluedroid/stack/avdt/include/avdt_defs.h b/components/bt/bluedroid/stack/avdt/include/avdt_defs.h index b6dbbc4f55..ad1d9d1efa 100644 --- a/components/bt/bluedroid/stack/avdt/include/avdt_defs.h +++ b/components/bt/bluedroid/stack/avdt/include/avdt_defs.h @@ -24,6 +24,9 @@ ******************************************************************************/ #ifndef AVDT_DEFS_H #define AVDT_DEFS_H +#include "bt_target.h" + +#if (AVDT_INCLUDED == TRUE) /***************************************************************************** ** constants @@ -199,5 +202,7 @@ #define AVDT_MSG_BLD_NOSP(p, nosp) \ *(p)++ = (UINT8) (nosp); +#endif ///AVRC_INCLUDED == TRUE + #endif /* AVDT_DEFS_H */ diff --git a/components/bt/bluedroid/stack/avdt/include/avdt_int.h b/components/bt/bluedroid/stack/avdt/include/avdt_int.h index 5c2939c495..5050f0668f 100644 --- a/components/bt/bluedroid/stack/avdt/include/avdt_int.h +++ b/components/bt/bluedroid/stack/avdt/include/avdt_int.h @@ -31,6 +31,8 @@ #include "l2c_api.h" #include "btm_api.h" +#if (AVRC_INCLUDED == TRUE) + #ifndef AVDT_DEBUG #define AVDT_DEBUG FALSE #endif @@ -741,4 +743,6 @@ extern const UINT8 avdt_msg_rej_2_evt[]; } #endif +#endif ///AVRC_INCLUDED == TRUE + #endif /* AVDT_INT_H */ diff --git a/components/bt/bluedroid/stack/avrc/include/avrc_int.h b/components/bt/bluedroid/stack/avrc/include/avrc_int.h index 9efafff733..ed0be01b21 100644 --- a/components/bt/bluedroid/stack/avrc/include/avrc_int.h +++ b/components/bt/bluedroid/stack/avrc/include/avrc_int.h @@ -29,6 +29,7 @@ #include "avct_defs.h" #include "avrc_api.h" +#if (AVRC_INCLUDED == TRUE) /* DEBUG FLAGS * * #define META_DEBUG_ENABLED @@ -152,4 +153,6 @@ extern BOOLEAN avrc_is_valid_opcode(UINT8 opcode); } #endif +#endif ///AVRC_INCLUDED == TRUE + #endif /* AVRC_INT_H */ diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 269737447f..b011ed5906 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -240,7 +240,8 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, #else p->conn_addr_type = BLE_ADDR_PUBLIC; memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN); - + BTM_TRACE_DEBUG ("conn_addr: RemBdAddr: %02x%02x%02x%02x%02x%02x\n", + p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]); #endif #endif p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE; @@ -276,18 +277,19 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, memcpy (p->peer_lmp_features, p_dev_rec->features, (HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages)); p->num_read_pages = p_dev_rec->num_read_pages; - +#if (CLASSIC_BT_INCLUDED == TRUE) const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); - +#endif ///CLASSIC_BT_INCLUDED == TRUE /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ btm_sec_set_peer_sec_caps(p, p_dev_rec); - +#if (CLASSIC_BT_INCLUDED == TRUE) BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); if (req_pend) { /* Request for remaining Security Features (if any) */ l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); } - btm_establish_continue (p); +#endif ///CLASSIC_BT_INCLUDED == TRUE + //btm_establish_continue (p); return; } } @@ -308,7 +310,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, && link_role == HCI_ROLE_SLAVE) { //do nothing in this case for fix the android7.0 cann't sent security request issue } else { - btm_establish_continue(p); + //btm_establish_continue(p); } } else #endif @@ -1479,9 +1481,9 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) UINT8 BTM_AllocateSCN(void) { +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 x; BTM_TRACE_DEBUG ("BTM_AllocateSCN\n"); - // stack reserves scn 1 for HFP, HSP we still do the correct way for (x = 1; x < BTM_MAX_SCN; x++) { if (!btm_cb.btm_scn[x]) { @@ -1489,7 +1491,7 @@ UINT8 BTM_AllocateSCN(void) return (x + 1); } } - +#endif ///CLASSIC_BT_INCLUDED == TRUE return (0); /* No free ports */ } @@ -1505,6 +1507,7 @@ UINT8 BTM_AllocateSCN(void) BOOLEAN BTM_TryAllocateSCN(UINT8 scn) { +#if (CLASSIC_BT_INCLUDED == TRUE) /* Make sure we don't exceed max port range. * Stack reserves scn 1 for HFP, HSP we still do the correct way. */ @@ -1517,6 +1520,7 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn) btm_cb.btm_scn[scn - 1] = TRUE; return TRUE; } +#endif ///CLASSIC_BT_INCLUDED == TRUE return (FALSE); /* Port was busy */ } @@ -1532,6 +1536,8 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn) *******************************************************************************/ BOOLEAN BTM_FreeSCN(UINT8 scn) { + +#if (CLASSIC_BT_INCLUDED == TRUE) BTM_TRACE_DEBUG ("BTM_FreeSCN \n"); if (scn <= BTM_MAX_SCN) { btm_cb.btm_scn[scn - 1] = FALSE; @@ -1539,6 +1545,9 @@ BOOLEAN BTM_FreeSCN(UINT8 scn) } else { return (FALSE); /* Illegal SCN passed in */ } +#else + return (FALSE); +#endif ///CLASSIC_BT_INCLUDED == TRUE } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/btm/btm_ble.c b/components/bt/bluedroid/stack/btm/btm_ble.c index 17f1d43e24..ddf5849cab 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/bluedroid/stack/btm/btm_ble.c @@ -432,6 +432,7 @@ void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey) *******************************************************************************/ void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_PASSKEY_ENTRY_FAIL; @@ -443,6 +444,7 @@ void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res) p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED; BTM_TRACE_DEBUG ("%s\n", __func__); SMP_ConfirmReply(bd_addr, res_smp); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -836,6 +838,7 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length) *******************************************************************************/ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback) { +#if (SMP_INCLUDED == TRUE) tBTM_RAND_ENC params; UINT8 *p_dest = params.param_buf; @@ -863,11 +866,10 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en (*p_enc_cplt_cback)(¶ms); /* Call the Encryption complete callback function */ } } +#endif ///SMP_INCLUDED == TRUE } -#if (SMP_INCLUDED == TRUE) - /******************************************************************************* ** ** Function btm_ble_get_enc_key_type @@ -878,6 +880,7 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en *******************************************************************************/ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_ble_increment_sign_ctr is_local=%d", is_local); @@ -893,6 +896,7 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) p_dev_rec->ble.keys.local_counter, p_dev_rec->ble.keys.counter); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -907,6 +911,7 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) *******************************************************************************/ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_ble_get_enc_key_type"); @@ -915,6 +920,8 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) *p_key_types = p_dev_rec->ble.key_type; return TRUE; } + +#endif ///SMP_INCLUDED == TRUE return FALSE; } @@ -928,6 +935,7 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) *******************************************************************************/ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BOOLEAN status = FALSE; BTM_TRACE_DEBUG ("btm_get_local_div"); @@ -946,6 +954,9 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) } BTM_TRACE_DEBUG ("btm_get_local_div status=%d (1-OK) DIV=0x%x", status, *p_div); return status; +#else + return FALSE; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -964,6 +975,7 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys, BOOLEAN pass_to_application) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; tBTM_LE_EVT_DATA cb_data; UINT8 i; @@ -1091,6 +1103,7 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY if (p_rec) { BTM_TRACE_DEBUG ("sec_flags=0x%x", p_rec->sec_flags); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1104,6 +1117,7 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY *******************************************************************************/ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; BTM_TRACE_DEBUG("btm_ble_update_sec_key_size enc_key_size = %d", enc_key_size); @@ -1111,6 +1125,7 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) if ((p_rec = btm_find_dev (bd_addr)) != NULL ) { p_rec->enc_key_size = enc_key_size; } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1124,6 +1139,7 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) *******************************************************************************/ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; if ((p_rec = btm_find_dev (bd_addr)) != NULL ) { @@ -1131,6 +1147,9 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) } else { return 0; } +#else + return 0; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1144,6 +1163,7 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) *******************************************************************************/ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); UINT8 req_sec_level = BTM_LE_SEC_NONE, cur_sec_level = BTM_LE_SEC_NONE; @@ -1195,6 +1215,8 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE req_sec_level, *p_sec_req_act); +#endif ///SMP_INCLUDED == TRUE + } /******************************************************************************* @@ -1213,6 +1235,7 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 link_role) { tBTM_STATUS cmd = BTM_NO_RESOURCES; +#if (SMP_INCLUDED == TRUE) tBTM_BLE_SEC_ACT sec_act = *(tBTM_BLE_SEC_ACT *)p_ref_data ; tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr); tBTM_BLE_SEC_REQ_ACT sec_req_act; @@ -1261,6 +1284,7 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin cmd = BTM_WRONG_MODE; break; } +#endif ///SMP_INCLUDED == TRUE return cmd; } @@ -1277,6 +1301,7 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin *******************************************************************************/ void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv) { +#if (SMP_INCLUDED == TRUE) tBTM_CB *p_cb = &btm_cb; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); BT_OCTET8 dummy_stk = {0}; @@ -1292,6 +1317,7 @@ void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv) btm_ble_ltk_request_reply(p_dev_rec->bd_addr, FALSE, dummy_stk); } } +#endif ///SMP_INCLUDED == TRUE } @@ -1307,11 +1333,14 @@ void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv) *******************************************************************************/ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) { +#if (SMP_INCLUDED == TRUE) tBTM_CB *p_cb = &btm_cb; tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bda); BT_OCTET8 dummy_rand = {0}; - tBTM_STATUS rt = BTM_NO_RESOURCES; +#endif ///SMP_INCLUDED == TRUE + tBTM_STATUS rt = BTM_NO_RESOURCES; +#if (SMP_INCLUDED == TRUE) BTM_TRACE_DEBUG ("btm_ble_start_encrypt"); if (!p_rec ) { @@ -1343,7 +1372,7 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) p_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; } } - +#endif ///SMP_INCLUDED == TRUE return rt; } @@ -1358,6 +1387,7 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) *******************************************************************************/ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); BOOLEAN enc_cback; @@ -1389,6 +1419,7 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) } /* to notify GATT to send data if any request is pending */ gatt_notify_enc_cmpl(p_dev_rec->ble.pseudo_addr); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1403,6 +1434,7 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) *******************************************************************************/ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bda); tBTM_CB *p_cb = &btm_cb; @@ -1425,6 +1457,7 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) btsnd_hcic_ble_ltk_req_neg_reply(btm_cb.enc_handle); } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1439,6 +1472,7 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data) { UINT8 callback_rc = BTM_SUCCESS; +#if (SMP_INCLUDED == TRUE) BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req"); if (btm_cb.api.p_le_callback) { /* the callback function implementation may change the IO capability... */ @@ -1508,6 +1542,7 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:0x%02x\n", p_data->io_cap, p_data->oob_data, p_data->auth_req); } +#endif ///SMP_INCLUDED == TRUE return callback_rc; } @@ -1524,13 +1559,14 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p UINT8 btm_ble_br_keys_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data) { UINT8 callback_rc = BTM_SUCCESS; +#if (SMP_INCLUDED) BTM_TRACE_DEBUG ("%s\n", __func__); if (btm_cb.api.p_le_callback) { /* the callback function implementation may change the IO capability... */ callback_rc = (*btm_cb.api.p_le_callback) (BTM_LE_IO_REQ_EVT, p_dev_rec->bd_addr, (tBTM_LE_EVT_DATA *)p_data); } - +#endif ///SMP_INCLUDED return callback_rc; } @@ -1673,10 +1709,13 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced) { #if (BLE_PRIVACY_SPT == TRUE ) UINT8 *p_data = p, peer_addr_type; -#endif +#endif ///BLE_PRIVACY_SPT == TRUE UINT8 role, status, bda_type; UINT16 handle; - BD_ADDR bda, local_rpa, peer_rpa; + BD_ADDR bda; +#if (BLE_PRIVACY_SPT == TRUE) + BD_ADDR local_rpa, peer_rpa; +#endif ///BLE_PRIVACY_SPT == TRUE UINT16 conn_interval, conn_latency, conn_timeout; BOOLEAN match = FALSE; UNUSED(evt_len); @@ -1686,7 +1725,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced) STREAM_TO_UINT8 (role, p); STREAM_TO_UINT8 (bda_type, p); STREAM_TO_BDADDR (bda, p); - + BTM_TRACE_ERROR("status = %d, handle = %d, role = %d, bda_type = %d",status,handle,role,bda_type); if (status == 0) { #if (BLE_PRIVACY_SPT == TRUE ) peer_addr_type = bda_type; @@ -1765,6 +1804,7 @@ void btm_ble_create_ll_conn_complete (UINT8 status) ******************************************************************************/ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); UINT8 res = 0; @@ -1870,12 +1910,10 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) } else { BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device"); } - +#endif ///SMP_INCLUDED == TRUE return 0; } -#endif /* SMP_INCLUDED */ - /******************************************************************************* ** ** Function BTM_BleDataSignature @@ -1895,10 +1933,13 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, BLE_SIGNATURE signature) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr); BTM_TRACE_DEBUG ("%s", __func__); +#endif ///SMP_INCLUDED == TRUE BOOLEAN ret = FALSE; +#if (SMP_INCLUDED == TRUE) if (p_rec == NULL) { BTM_TRACE_ERROR("%s-data signing can not be done from unknown device", __func__); } else { @@ -1929,6 +1970,7 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, GKI_freebuf(p_buf); } } +#endif ///SMP_INCLUDED == TRUE return ret; } @@ -1988,7 +2030,7 @@ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT *******************************************************************************/ BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr, UINT8 *p_le_dev_sec_flags, UINT8 *p_le_key_size) { -#if (BLE_INCLUDED == TRUE) +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; UINT16 dev_rec_sec_flags; #endif @@ -2125,6 +2167,7 @@ extern UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_notify_new_key(UINT8 key_type) { tBTM_BLE_LOCAL_KEYS *p_locak_keys = NULL; @@ -2235,6 +2278,7 @@ static void btm_ble_process_irk(tSMP_ENC *p) } } + /******************************************************************************* ** ** Function btm_ble_process_dhk @@ -2248,7 +2292,6 @@ static void btm_ble_process_irk(tSMP_ENC *p) *******************************************************************************/ static void btm_ble_process_dhk(tSMP_ENC *p) { -#if SMP_INCLUDED == TRUE UINT8 btm_ble_irk_pt = 0x01; tSMP_ENC output; @@ -2270,8 +2313,8 @@ static void btm_ble_process_dhk(tSMP_ENC *p) /* reset all identity root related key */ memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS)); } -#endif } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/btm/btm_ble_addr.c b/components/bt/bluedroid/stack/btm/btm_ble_addr.c index 95a2ad9cc1..5c4c772e6c 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_addr.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_addr.c @@ -193,7 +193,6 @@ void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p) } -#if SMP_INCLUDED == TRUE /******************************************************************************* ** Utility functions for Random address resolving *******************************************************************************/ @@ -207,6 +206,7 @@ void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p) ** Returns None. ** *******************************************************************************/ +#if SMP_INCLUDED == TRUE static void btm_ble_resolve_address_cmpl(void) { tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; @@ -250,8 +250,10 @@ static BOOLEAN btm_ble_proc_resolve_x(tSMP_ENC *p) return TRUE; } } + return FALSE; } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -265,13 +267,14 @@ static BOOLEAN btm_ble_proc_resolve_x(tSMP_ENC *p) *******************************************************************************/ BOOLEAN btm_ble_init_pseudo_addr (tBTM_SEC_DEV_REC *p_dev_rec, BD_ADDR new_pseudo_addr) { +#if (SMP_INCLUDED == TRUE) BD_ADDR dummy_bda = {0}; if (memcmp(p_dev_rec->ble.pseudo_addr, dummy_bda, BD_ADDR_LEN) == 0) { memcpy(p_dev_rec->ble.pseudo_addr, new_pseudo_addr, BD_ADDR_LEN); return TRUE; } - +#endif ///SMP_INCLUDED == TRUE return FALSE; } @@ -287,7 +290,7 @@ BOOLEAN btm_ble_init_pseudo_addr (tBTM_SEC_DEV_REC *p_dev_rec, BD_ADDR new_pseud BOOLEAN btm_ble_addr_resolvable (BD_ADDR rpa, tBTM_SEC_DEV_REC *p_dev_rec) { BOOLEAN rt = FALSE; - +#if (SMP_INCLUDED == TRUE) if (!BTM_BLE_IS_RESOLVE_BDA(rpa)) { return rt; } @@ -315,9 +318,11 @@ BOOLEAN btm_ble_addr_resolvable (BD_ADDR rpa, tBTM_SEC_DEV_REC *p_dev_rec) rt = TRUE; } } +#endif ///SMP_INCLUDED == TRUE return rt; } +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_ble_match_random_bda @@ -331,7 +336,6 @@ BOOLEAN btm_ble_addr_resolvable (BD_ADDR rpa, tBTM_SEC_DEV_REC *p_dev_rec) *******************************************************************************/ static BOOLEAN btm_ble_match_random_bda(UINT16 rec_index) { -#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) /* use the 3 MSB of bd address as prand */ tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; @@ -364,8 +368,8 @@ static BOOLEAN btm_ble_match_random_bda(UINT16 rec_index) btm_ble_resolve_address_cmpl(); return TRUE; } -#endif } +#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -379,6 +383,7 @@ static BOOLEAN btm_ble_match_random_bda(UINT16 rec_index) *******************************************************************************/ void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK *p_cback, void *p) { +#if (SMP_INCLUDED == TRUE) tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; BTM_TRACE_EVENT ("btm_ble_resolve_random_addr"); @@ -400,9 +405,11 @@ void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK *p_c } else { (*p_cback)(NULL, p); } -} #endif +} + + /******************************************************************************* ** address mapping between pseudo address and real connection address *******************************************************************************/ diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index 5864419e27..c2b356fc7c 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -903,9 +903,11 @@ static UINT8 btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB *p_cb, tBLE_ADDR_TYPE *p_peer_addr_type, tBLE_ADDR_TYPE *p_own_addr_type) { - UINT8 evt_type, i = BTM_SEC_MAX_DEVICE_RECORDS; + UINT8 evt_type; +#if BLE_PRIVACY_SPT == TRUE + UINT8 i = BTM_SEC_MAX_DEVICE_RECORDS; tBTM_SEC_DEV_REC *p_dev_rec; - +#endif ///BLE_PRIVACY_SPT == TRUE evt_type = (p_cb->connectable_mode == BTM_BLE_NON_CONNECTABLE) ? \ ((p_cb->scan_rsp) ? BTM_BLE_DISCOVER_EVT : BTM_BLE_NON_CONNECT_EVT )\ : BTM_BLE_CONNECT_EVT; diff --git a/components/bt/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/bluedroid/stack/btm/btm_ble_privacy.c index 08870d9e76..59aa49fbab 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_privacy.c @@ -733,6 +733,7 @@ BOOLEAN btm_ble_disable_resolving_list(UINT8 rl_mask, BOOLEAN to_resume ) BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec) { BOOLEAN rt = FALSE; +#if (SMP_INCLUDED == TRUE) UINT8 rl_mask = btm_cb.ble_ctr_cb.rl_state; BTM_TRACE_DEBUG("%s btm_cb.ble_ctr_cb.privacy_mode = %d\n", __func__, @@ -812,6 +813,7 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec) } else { BTM_TRACE_DEBUG("Device not a RPA enabled device\n"); } +#endif ///SMP_INCLUDED == TRUE return rt; } diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index 364c03f624..a54a8ce6b6 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -221,7 +221,7 @@ static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC * *******************************************************************************/ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) { -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE BT_OCTET16 temp_value = {0}; #endif diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index a3a4d9154f..36eaf89f75 100644 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -124,9 +124,9 @@ static void btu_ble_data_length_change_evt (UINT8 *p, UINT16 evt_len); #if (BLE_LLT_INCLUDED == TRUE) static void btu_ble_rc_param_req_evt(UINT8 *p); #endif -#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) +//#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len); -#endif +//#endif #endif @@ -304,7 +304,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_EVENT: STREAM_TO_UINT8 (ble_sub_code, p); - HCI_TRACE_DEBUG("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code); + HCI_TRACE_ERROR("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code); switch (ble_sub_code) { case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */ @@ -322,11 +322,11 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_LTK_REQ_EVT: /* received only at slave device */ btu_ble_proc_ltk_req(p); break; -#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) +//#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT: btu_ble_proc_enhanced_conn_cmpl(p, hci_evt_len); break; -#endif +//#endif #if (BLE_LLT_INCLUDED == TRUE) case HCI_BLE_RC_PARAM_REQ_EVT: btu_ble_rc_param_req_evt(p); @@ -1686,12 +1686,12 @@ static void btu_ble_ll_conn_complete_evt ( UINT8 *p, UINT16 evt_len) { btm_ble_conn_complete(p, evt_len, FALSE); } -#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) +//#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) static void btu_ble_proc_enhanced_conn_cmpl( UINT8 *p, UINT16 evt_len) { btm_ble_conn_complete(p, evt_len, TRUE); } -#endif +//#endif static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len) { /* LE connection update has completed successfully as a master. */ @@ -1712,13 +1712,14 @@ static void btu_ble_read_remote_feat_evt (UINT8 *p) static void btu_ble_proc_ltk_req (UINT8 *p) { +#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE UINT16 ediv, handle; UINT8 *pp; STREAM_TO_UINT16(handle, p); pp = p + 8; STREAM_TO_UINT16(ediv, pp); -#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE + btm_ble_ltk_request(handle, p, ediv); #endif /* This is empty until an upper layer cares about returning event */ diff --git a/components/bt/bluedroid/stack/gap/include/gap_int.h b/components/bt/bluedroid/stack/gap/include/gap_int.h index fbddf67c96..af7acf231a 100644 --- a/components/bt/bluedroid/stack/gap/include/gap_int.h +++ b/components/bt/bluedroid/stack/gap/include/gap_int.h @@ -127,8 +127,8 @@ typedef struct { tGAP_INFO blk[GAP_MAX_BLOCKS]; tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS]; UINT8 trace_level; - tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */ - tBTM_INQ_INFO *cur_inqptr; + //tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */ + //tBTM_INQ_INFO *cur_inqptr; #if GAP_CONN_INCLUDED == TRUE tGAP_CONN conn; diff --git a/components/bt/bluedroid/stack/gatt/gatt_api.c b/components/bt/bluedroid/stack/gatt/gatt_api.c index e0f633709d..5beffe8753 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/bluedroid/stack/gatt/gatt_api.c @@ -480,8 +480,9 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, case GATT_TRANSPORT_LE_BR_EDR: if (p_sreg->type == GATT_UUID_PRI_SERVICE) { p_uuid = gatts_get_service_uuid (p_sreg->p_db); - +#if (SDP_INCLUDED == TRUE) p_sreg->sdp_handle = gatt_add_sdp_record(p_uuid, p_sreg->s_hdl, p_sreg->e_hdl); +#endif ///SDP_INCLUDED == TRUE } break; default: @@ -531,9 +532,11 @@ void GATTS_StopService (UINT16 service_handle) /* Index 0 is reserved for GATT, and is never stopped */ if ( (ii > 0) && (ii < GATT_MAX_SR_PROFILES) && (gatt_cb.sr_reg[ii].in_use) ) { +#if(SDP_INCLUDED == TRUE) if (gatt_cb.sr_reg[ii].sdp_handle) { SDP_DeleteRecord(gatt_cb.sr_reg[ii].sdp_handle); } +#endif ///SDP_INCLUDED == TRUE gatt_remove_a_srv_from_list(&gatt_cb.srv_list_info, &gatt_cb.srv_list[ii]); gatt_cb.srv_list[ii].in_use = FALSE; memset (&gatt_cb.sr_reg[ii], 0, sizeof(tGATT_SR_REG)); diff --git a/components/bt/bluedroid/stack/gatt/gatt_auth.c b/components/bt/bluedroid/stack/gatt/gatt_auth.c index c7bdc13cdf..09f686bb95 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_auth.c +++ b/components/bt/bluedroid/stack/gatt/gatt_auth.c @@ -293,18 +293,22 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb ) BOOLEAN is_link_key_known = FALSE; BOOLEAN is_key_mitm = FALSE; UINT8 key_type; +#if (SMP_INCLUDED == TRUE) tBTM_BLE_SEC_REQ_ACT sec_act = BTM_LE_SEC_NONE; - +#endif ///SMP_INCLUDED == TRUE if (auth_req == GATT_AUTH_REQ_NONE ) { return act; } BTM_GetSecurityFlagsByTransport(p_tcb->peer_bda, &sec_flag, p_clcb->p_tcb->transport); - +#if (SMP_INCLUDED == TRUE) btm_ble_link_sec_check(p_tcb->peer_bda, auth_req, &sec_act); - +#endif ///SMP_INCLUDED == TRUE /* if a encryption is pending, need to wait */ - if (sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD && + if ( +#if (SMP_INCLUDED == TRUE) + sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD && +#endif ///SMP_INCLUDED == TRUE auth_req != GATT_AUTH_REQ_NONE) { return GATT_SEC_ENC_PENDING; } @@ -350,7 +354,10 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb ) if (!is_link_encrypted) { btm_ble_get_enc_key_type(p_tcb->peer_bda, &key_type); - if ( (key_type & BTM_LE_KEY_LCSRK) && + if ( +#if (SMP_INCLUDED == TRUE) + (key_type & BTM_LE_KEY_LCSRK) && +#endif ///SMP_INCLUDED == TRUE ((auth_req == GATT_AUTH_REQ_SIGNED_NO_MITM) || (auth_req == GATT_AUTH_REQ_SIGNED_MITM))) { act = GATT_SEC_SIGN_DATA; diff --git a/components/bt/bluedroid/stack/gatt/gatt_main.c b/components/bt/bluedroid/stack/gatt/gatt_main.c index d7997a847f..0a69ff1259 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/bluedroid/stack/gatt/gatt_main.c @@ -120,12 +120,12 @@ void gatt_init (void) fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */ L2CA_RegisterFixedChannel (L2CAP_ATT_CID, &fixed_reg); - +#if (CLASSIC_BT_INCLUDED == TRUE) /* Now, register with L2CAP for ATT PSM over BR/EDR */ if (!L2CA_Register (BT_PSM_ATT, (tL2CAP_APPL_INFO *) &dyn_info)) { GATT_TRACE_ERROR ("ATT Dynamic Registration failed"); } - +#endif ///CLASSIC_BT_INCLUDED == TRUE BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0); BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0); @@ -177,10 +177,13 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport if (transport == BT_TRANSPORT_LE) { p_tcb->att_lcid = L2CAP_ATT_CID; gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda); +#if (CLASSIC_BT_INCLUDED == TRUE) } else { if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) { gatt_ret = TRUE; } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } return gatt_ret; @@ -215,8 +218,10 @@ BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb) gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); ret = L2CA_CancelBleConnectReq (p_tcb->peer_bda); } +#if (CLASSIC_BT_INCLUDED == TRUE) } else { ret = L2CA_DisconnectReq(p_tcb->att_lcid); +#endif ///CLASSIC_BT_INCLUDED == TRUE } } else { GATT_TRACE_DEBUG ("gatt_disconnect already in closing state"); @@ -527,6 +532,7 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf) *******************************************************************************/ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id) { +#if (CLASSIC_BT_INCLUDED == TRUE) /* do we already have a control channel for this peer? */ UINT8 result = L2CAP_CONN_OK; tL2CAP_CFG_INFO cfg; @@ -563,6 +569,8 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 L2CA_ConfigReq(lcid, &cfg); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -577,6 +585,7 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 *******************************************************************************/ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tL2CAP_CFG_INFO cfg; @@ -608,6 +617,8 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) } } } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -622,6 +633,7 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) *******************************************************************************/ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tGATTS_SRV_CHG *p_srv_chg_clt = NULL; @@ -657,6 +669,8 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) } } } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -671,6 +685,7 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tGATTS_SRV_CHG *p_srv_chg_clt = NULL; /* look up clcb for this channel */ @@ -709,6 +724,8 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) } } } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -723,6 +740,7 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; UINT16 reason; @@ -745,6 +763,8 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) /* send disconnect callback */ gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -759,6 +779,7 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) *******************************************************************************/ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; UINT16 reason; UNUSED(result); @@ -780,6 +801,8 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -794,6 +817,7 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) *******************************************************************************/ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; /* look up clcb for this channel */ @@ -804,6 +828,8 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) } else { /* prevent buffer leak */ GKI_freebuf(p_buf); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* @@ -817,11 +843,14 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) *******************************************************************************/ static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested) { +#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid); if (p_tcb != NULL) { gatt_channel_congestion(p_tcb, congested); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/gatt/gatt_utils.c b/components/bt/bluedroid/stack/gatt/gatt_utils.c index fb8d51aec2..776004c11a 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/bluedroid/stack/gatt/gatt_utils.c @@ -1439,7 +1439,7 @@ tGATT_STATUS gatt_send_error_rsp (tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_cod return status; } - +#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_add_sdp_record @@ -1505,7 +1505,7 @@ UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl) return (sdp_handle); } - +#endif ///SDP_INCLUDED == TRUE #if GATT_CONFORMANCE_TESTING == TRUE /******************************************************************************* diff --git a/components/bt/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/bluedroid/stack/gatt/include/gatt_int.h index 5004f5bbfc..6412aed6a3 100644 --- a/components/bt/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/bluedroid/stack/gatt/include/gatt_int.h @@ -589,7 +589,9 @@ extern tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP); /* utility functions */ extern UINT8 *gatt_dbg_op_name(UINT8 op_code); +#if (SDP_INCLUDED == TRUE) extern UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl); +#endif ///SDP_INCLUDED == TRUE extern BOOLEAN gatt_parse_uuid_from_cmd(tBT_UUID *p_uuid, UINT16 len, UINT8 **p_data); extern UINT8 gatt_build_uuid_to_stream(UINT8 **p_dst, tBT_UUID uuid); extern BOOLEAN gatt_uuid_compare(tBT_UUID src, tBT_UUID tar); diff --git a/components/bt/bluedroid/stack/hcic/hciblecmds.c b/components/bt/bluedroid/stack/hcic/hciblecmds.c index 8fa4ae8b3e..3222ea5d71 100644 --- a/components/bt/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/bluedroid/stack/hcic/hciblecmds.c @@ -86,7 +86,7 @@ BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max, { BT_HDR *p; UINT8 *pp; - + HCI_TRACE_ERROR("####################adv_type = %d",adv_type); if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS)) == NULL) { return (FALSE); } diff --git a/components/bt/bluedroid/stack/include/a2d_api.h b/components/bt/bluedroid/stack/include/a2d_api.h index 2c2f410f61..1b999d5c4f 100644 --- a/components/bt/bluedroid/stack/include/a2d_api.h +++ b/components/bt/bluedroid/stack/include/a2d_api.h @@ -24,7 +24,7 @@ #ifndef A2D_API_H #define A2D_API_H #include "sdp_api.h" - +#if (A2D_INCLUDED == TRUE) /***************************************************************************** ** constants *****************************************************************************/ @@ -251,5 +251,5 @@ extern UINT8 A2D_BitsSet(UINT8 num); ** *******************************************************************************/ extern void A2D_Init(void); - +#endif ///A2D_INCLUDED #endif /* A2D_API_H */ diff --git a/components/bt/bluedroid/stack/include/a2d_sbc.h b/components/bt/bluedroid/stack/include/a2d_sbc.h index e9dbaa8809..98b63e46ca 100644 --- a/components/bt/bluedroid/stack/include/a2d_sbc.h +++ b/components/bt/bluedroid/stack/include/a2d_sbc.h @@ -23,7 +23,7 @@ ******************************************************************************/ #ifndef A2D_SBC_H #define A2D_SBC_H - +#if (A2D_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************/ @@ -208,4 +208,6 @@ extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, } #endif +#endif ///A2D_INCLUDED == TRUE + #endif /* A2D_SBC_H */ diff --git a/components/bt/bluedroid/stack/include/avrc_api.h b/components/bt/bluedroid/stack/include/avrc_api.h index dad8b3bd20..3ca3e2d76f 100644 --- a/components/bt/bluedroid/stack/include/avrc_api.h +++ b/components/bt/bluedroid/stack/include/avrc_api.h @@ -27,7 +27,7 @@ #include "avct_api.h" #include "sdp_api.h" #include "avrc_defs.h" - +#if (AVRC_INCLUDED == TRUE) /***************************************************************************** ** constants *****************************************************************************/ @@ -634,4 +634,7 @@ extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr); } #endif +#endif ///AVRC_INCLUDED == TRUE + + #endif /* AVRC_API_H */ diff --git a/components/bt/bluedroid/stack/include/avrc_defs.h b/components/bt/bluedroid/stack/include/avrc_defs.h index fe261a74fd..8a6254ef85 100644 --- a/components/bt/bluedroid/stack/include/avrc_defs.h +++ b/components/bt/bluedroid/stack/include/avrc_defs.h @@ -23,7 +23,9 @@ ******************************************************************************/ #ifndef _AVRC_DEFS_H #define _AVRC_DEFS_H +#include "bt_target.h" +#if (AVRC_INCLUDED == TRUE) /***************************************************************************** ** constants *****************************************************************************/ @@ -1356,5 +1358,5 @@ typedef union { tAVRC_RSP add_to_play; /* AddToNowPlaying */ } tAVRC_RESPONSE; - +#endif ///AVRC_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/stack/include/btm_api.h b/components/bt/bluedroid/stack/include/btm_api.h index 44d0d8e4fa..d48dc68b0a 100644 --- a/components/bt/bluedroid/stack/include/btm_api.h +++ b/components/bt/bluedroid/stack/include/btm_api.h @@ -1531,6 +1531,7 @@ typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result); /* LE related event and data structure */ +#if (SMP_INCLUDED == TRUE) #define BTM_LE_IO_REQ_EVT SMP_IO_CAP_REQ_EVT /* received IO_CAPABILITY_REQUEST event */ #define BTM_LE_SEC_REQUEST_EVT SMP_SEC_REQUEST_EVT /* security request event */ #define BTM_LE_KEY_NOTIF_EVT SMP_PASSKEY_NOTIF_EVT /* received USER_PASSKEY_NOTIFY event */ @@ -1546,8 +1547,10 @@ typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result); #define BTM_LE_COMPLT_EVT SMP_COMPLT_EVT /* SMP complete event */ #define BTM_LE_LAST_FROM_SMP BTM_LE_BR_KEYS_REQ_EVT #define BTM_LE_KEY_EVT BTM_LE_LAST_FROM_SMP + 1 /* KEY update event */ +#endif ///SMP_INCLUDED == TRUE typedef UINT8 tBTM_LE_EVT; +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) #define BTM_LE_KEY_NONE 0 #define BTM_LE_KEY_PENC SMP_SEC_KEY_TYPE_ENC /* encryption information of peer device */ #define BTM_LE_KEY_PID SMP_SEC_KEY_TYPE_ID /* identity key of the peer device */ @@ -1557,12 +1560,15 @@ typedef UINT8 tBTM_LE_EVT; #define BTM_LE_KEY_LENC (SMP_SEC_KEY_TYPE_ENC << 4) /* master role security information:div */ #define BTM_LE_KEY_LID (SMP_SEC_KEY_TYPE_ID << 4) /* master device ID key */ #define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 4) /* local CSRK has been deliver to peer */ +#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE typedef UINT8 tBTM_LE_KEY_TYPE; - +#if (SMP_INCLUDED == TRUE) #define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND /* 0 */ #define BTM_LE_AUTH_REQ_BOND SMP_AUTH_GEN_BOND /* 1 << 0 */ #define BTM_LE_AUTH_REQ_MITM SMP_AUTH_YN_BIT /* 1 << 2 */ +#endif ///SMP_INCLUDED == TRUE typedef UINT8 tBTM_LE_AUTH_REQ; +#if (SMP_INCLUDED == TRUE) #define BTM_LE_SC_SUPPORT_BIT SMP_SC_SUPPORT_BIT /* (1 << 3) */ #define BTM_LE_KP_SUPPORT_BIT SMP_KP_SUPPORT_BIT /* (1 << 4) */ @@ -1576,6 +1582,7 @@ typedef UINT8 tBTM_LE_AUTH_REQ; #define BTM_LE_SEC_NONE SMP_SEC_NONE #define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE /* 1 */ #define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED /* 4 */ +#endif ///SMP_INCLUDED == TRUE typedef UINT8 tBTM_LE_SEC; diff --git a/components/bt/bluedroid/stack/include/btm_int.h b/components/bt/bluedroid/stack/include/btm_int.h index 827114f0ce..7b7aac9805 100644 --- a/components/bt/bluedroid/stack/include/btm_int.h +++ b/components/bt/bluedroid/stack/include/btm_int.h @@ -759,7 +759,9 @@ typedef struct { ** ACL Management ****************************************************/ tACL_CONN acl_db[MAX_L2CAP_LINKS]; +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 btm_scn[BTM_MAX_SCN]; /* current SCNs: TRUE if SCN is in use */ +#endif ///CLASSIC_BT_INCLUDED == TRUE UINT16 btm_def_link_policy; UINT16 btm_def_link_super_tout; diff --git a/components/bt/bluedroid/stack/include/hiddefs.h b/components/bt/bluedroid/stack/include/hiddefs.h index c8c3d3cbbe..23777f3adf 100644 --- a/components/bt/bluedroid/stack/include/hiddefs.h +++ b/components/bt/bluedroid/stack/include/hiddefs.h @@ -24,8 +24,12 @@ #ifndef HIDDEFS_H #define HIDDEFS_H +#include "bt_target.h" +#if (HID_HOST_INCLUDED == TRUE) +#if (SDP_INCLUDED == TRUE) #include "sdp_api.h" +#endif ///SDP_INCLUDED == TRUE /* ** tHID_STATUS: HID result codes, returned by HID and device and host functions. */ @@ -149,8 +153,11 @@ typedef struct sdp_info { tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in the SDP record. This parameter is used if HID_DEV_USE_GLB_SDP_REC is set to FALSE.*/ +#if(SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_sdp_layer_rec; +#endif ///SDP_INCLUDED == TRUE } tHID_DEV_SDP_INFO; +#endif ///HID_HOST_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/stack/include/hidh_api.h b/components/bt/bluedroid/stack/include/hidh_api.h index 499e646253..29344df905 100644 --- a/components/bt/bluedroid/stack/include/hidh_api.h +++ b/components/bt/bluedroid/stack/include/hidh_api.h @@ -21,6 +21,7 @@ #include "hiddefs.h" #include "sdp_api.h" +#if (HID_HOST_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************/ @@ -232,4 +233,6 @@ extern UINT8 HID_HostSetTraceLevel (UINT8 new_level); } #endif +#endif ///HID_HOST_INCLUDED == TRUE + #endif /* HIDH_API_H */ diff --git a/components/bt/bluedroid/stack/include/l2c_api.h b/components/bt/bluedroid/stack/include/l2c_api.h index d79c17a1ba..f2a4d7c4c1 100644 --- a/components/bt/bluedroid/stack/include/l2c_api.h +++ b/components/bt/bluedroid/stack/include/l2c_api.h @@ -331,6 +331,7 @@ extern "C" { #endif +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_Register @@ -483,6 +484,8 @@ extern BOOLEAN L2CA_DisconnectReq (UINT16 cid); ** *******************************************************************************/ extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid); +#endif ///CLASSIC_BT_INCLUDED == TRUE + /******************************************************************************* ** @@ -497,6 +500,8 @@ extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid); *******************************************************************************/ extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data); +#if (CLASSIC_BT_INCLUDED == TRUE) + /******************************************************************************* ** ** Function L2CA_Ping @@ -519,6 +524,8 @@ extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb); ** *******************************************************************************/ extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback); +#endif ///CLASSIC_BT_INCLUDED == TRUE + // Given a local channel identifier, |lcid|, this function returns the bound remote // channel identifier, |rcid|, and the ACL link handle, |handle|. If |lcid| is not @@ -544,6 +551,7 @@ bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle); extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, BOOLEAN is_global); + /******************************************************************************* ** ** Function L2CA_SetIdleTimeoutByBdAddr @@ -566,6 +574,7 @@ extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout, tBT_TRANSPORT transport); + /******************************************************************************* ** ** Function L2CA_SetTraceLevel @@ -578,6 +587,7 @@ extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout, *******************************************************************************/ extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level); + /******************************************************************************* ** ** Function L2CA_SetDesireRole @@ -595,7 +605,7 @@ extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level); ** *******************************************************************************/ extern UINT8 L2CA_SetDesireRole (UINT8 new_role); - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_LocalLoopbackReq @@ -722,6 +732,7 @@ typedef void (tL2CA_RESERVE_CMPL_CBACK) (void); ** ACL link. *******************************************************************************/ extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout); +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -780,6 +791,8 @@ extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *******************************************************************************/ extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr); +#if (CLASSIC_BT_INCLUDED == TRUE) + /******************************************************************************* ** ** Function L2CA_GetChnlFcrMode @@ -792,6 +805,7 @@ extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr); ** *******************************************************************************/ extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid); +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* @@ -1044,6 +1058,7 @@ extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT #endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */ +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_GetCurrentConfig @@ -1060,6 +1075,8 @@ extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid, tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits, tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits); +#endif ///CLASSIC_BT_INCLUDED == TRUE + #if (BLE_INCLUDED == TRUE) /******************************************************************************* diff --git a/components/bt/bluedroid/stack/include/l2cap_client.h b/components/bt/bluedroid/stack/include/l2cap_client.h index 168c8db554..d18be32c4c 100644 --- a/components/bt/bluedroid/stack/include/l2cap_client.h +++ b/components/bt/bluedroid/stack/include/l2cap_client.h @@ -18,6 +18,7 @@ #ifndef _L2CAP_CLIENT_H_ #define _L2CAP_CLIENT_H_ +#if (defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE) //#include #include @@ -74,4 +75,6 @@ bool l2cap_client_is_connected(const l2cap_client_t *client); // |client| nor |packet| may be NULL. bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet); +#endif ///(defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE) + #endif /*_L2CAP_CLIENT_H_*/ diff --git a/components/bt/bluedroid/stack/include/sdp_api.h b/components/bt/bluedroid/stack/include/sdp_api.h index c35c124393..db11df5580 100644 --- a/components/bt/bluedroid/stack/include/sdp_api.h +++ b/components/bt/bluedroid/stack/include/sdp_api.h @@ -20,7 +20,7 @@ #include "bt_target.h" #include "sdpdefs.h" - +#if (SDP_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************/ @@ -721,4 +721,6 @@ BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid); } #endif +#endif ///SDP_INCLUDED == TRUE + #endif /* SDP_API_H */ diff --git a/components/bt/bluedroid/stack/l2cap/l2c_api.c b/components/bt/bluedroid/stack/l2cap/l2c_api.c index 156757d01d..5f5b854e41 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_api.c @@ -38,6 +38,7 @@ #include "btm_api.h" #include "allocator.h" +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_Register @@ -723,6 +724,9 @@ BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_cal } +#endif ///CLASSIC_BT_INCLUDED == TRUE + + bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle) { tL2C_CCB *control_block = l2cu_find_ccb_by_cid(NULL, lcid); @@ -785,6 +789,8 @@ BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, BOOLEAN is_global) return (TRUE); } + + /******************************************************************************* ** ** Function L2CA_SetIdleTimeoutByBdAddr @@ -837,6 +843,8 @@ BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout, tBT_TRANSPO return TRUE; } + + /******************************************************************************* ** ** Function L2CA_SetTraceLevel @@ -895,6 +903,8 @@ UINT8 L2CA_SetDesireRole (UINT8 new_role) return (l2cb.desire_role); } +#if (CLASSIC_BT_INCLUDED == TRUE) + /******************************************************************************* ** ** Function L2CA_LocalLoopbackReq @@ -1198,6 +1208,8 @@ BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout) return (TRUE); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + /******************************************************************************* ** @@ -1260,6 +1272,7 @@ BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr) return found_dev; } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_GetChnlFcrMode @@ -1284,6 +1297,9 @@ UINT8 L2CA_GetChnlFcrMode (UINT16 lcid) return (L2CAP_FCR_BASIC_MODE); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + + #if (L2CAP_NUM_FIXED_CHNLS > 0) /******************************************************************************* ** @@ -1299,6 +1315,7 @@ UINT8 L2CA_GetChnlFcrMode (UINT16 lcid) *******************************************************************************/ BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg) { + L2CAP_TRACE_ERROR ("L2CA_RegisterFixedChannel() CID: 0x%04x, %p", fixed_cid,p_freg); if ( (fixed_cid < L2CAP_FIRST_FIXED_CHNL) || (fixed_cid > L2CAP_LAST_FIXED_CHNL) ) { L2CAP_TRACE_ERROR ("L2CA_RegisterFixedChannel() Invalid CID: 0x%04x", fixed_cid); @@ -1638,6 +1655,7 @@ BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle #endif /* #if (L2CAP_NUM_FIXED_CHNLS > 0) */ +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function L2CA_GetCurrentConfig @@ -1723,6 +1741,7 @@ BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda) return TRUE; } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/bluedroid/stack/l2cap/l2c_ble.c index 70d2ba75a8..330d9791be 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_ble.c @@ -759,7 +759,7 @@ void l2c_link_processs_ble_num_bufs (UINT16 num_lm_ble_bufs) num_lm_ble_bufs = L2C_DEF_NUM_BLE_BUF_SHARED; l2cb.num_lm_acl_bufs -= L2C_DEF_NUM_BLE_BUF_SHARED; } - + L2CAP_TRACE_ERROR("#####################################num_lm_ble_bufs = %d",num_lm_ble_bufs); l2cb.num_lm_ble_bufs = l2cb.controller_le_xmit_window = num_lm_ble_bufs; } diff --git a/components/bt/bluedroid/stack/l2cap/l2c_csm.c b/components/bt/bluedroid/stack/l2cap/l2c_csm.c index 13d9beed57..1bcee70195 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_csm.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_csm.c @@ -35,7 +35,7 @@ #include "btm_int.h" #include "btu.h" #include "hcimsgs.h" - +#if (CLASSIC_BT_INCLUDED == TRUE) /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ @@ -1115,7 +1115,7 @@ static void l2c_csm_w4_l2ca_disconnect_rsp (tL2C_CCB *p_ccb, UINT16 event, void break; } } - +#endif ///CLASSIC_BT_INCLUDED == TRUE #if (BT_TRACE_VERBOSE == TRUE) /******************************************************************************* diff --git a/components/bt/bluedroid/stack/l2cap/l2c_fcr.c b/components/bt/bluedroid/stack/l2cap/l2c_fcr.c index 788d841e15..c31e4b7f33 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_fcr.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_fcr.c @@ -37,6 +37,8 @@ #include "btm_int.h" #include "btu.h" +#if (CLASSIC_BT_INCLUDED == TRUE) + /* Flag passed to retransmit_i_frames() when all packets should be retransmitted */ #define L2C_FCR_RETX_ALL_PKTS 0xFF @@ -2189,3 +2191,4 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked) } } #endif +#endif ///CLASSIC_BT_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index ed1787c426..09d7fae92f 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -150,7 +150,9 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) { tL2C_CONN_INFO ci; tL2C_LCB *p_lcb; +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; +#endif ///CLASSIC_BT_INCLUDED == TRUE tBTM_SEC_DEV_REC *p_dev_info = NULL; btm_acl_update_busy_level (BTM_BLI_PAGE_DONE_EVT); @@ -211,12 +213,12 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) l2c_process_held_packets(FALSE); btu_stop_timer (&p_lcb->timer_entry); - +#if (CLASSIC_BT_INCLUDED == TRUE) /* For all channels, send the event through their FSMs */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) { l2c_csm_execute (p_ccb, L2CEVT_LP_CONNECT_CFM, &ci); } - +#endif ///CLASSIC_BT_INCLUDED == TRUE if (p_lcb->p_echo_rsp_cb) { l2cu_send_peer_echo_req (p_lcb, NULL, 0); btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_ECHO_RSP_TOUT); @@ -232,7 +234,7 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) } else { /* Just in case app decides to try again in the callback context */ p_lcb->link_state = LST_DISCONNECTING; - +#if(CLASSIC_BT_INCLUDED == TRUE) /* Connection failed. For all channels, send the event through */ /* their FSMs. The CCBs should remove themselves from the LCB */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) { @@ -242,7 +244,7 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) p_ccb = pn; } - +#endif ///CLASSIC_BT_INCLUDED == TRUE p_lcb->disc_reason = status; /* Release the LCB */ if (p_lcb->ccb_queue.p_first_ccb == NULL) { @@ -276,8 +278,9 @@ void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data tL2C_LCB *p_lcb; tL2C_CCB *p_ccb; tL2C_CCB *p_next_ccb; +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 event; - +#endif ///CLASSIC_BT_INCLUDED == TRUE UNUSED(transport); L2CAP_TRACE_DEBUG ("l2c_link_sec_comp: %d, %p", status, p_ref_data); @@ -306,7 +309,9 @@ void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data switch (status) { case BTM_SUCCESS: L2CAP_TRACE_DEBUG ("ccb timer ticks: %u", p_ccb->timer_entry.ticks); +#if (CLASSIC_BT_INCLUDED == TRUE) event = L2CEVT_SEC_COMP; +#endif ///CLASSIC_BT_INCLUDED == TRUE break; case BTM_DELAY_CHECK: @@ -315,9 +320,14 @@ void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data return; default: +#if (CLASSIC_BT_INCLUDED == TRUE) event = L2CEVT_SEC_COMP_NEG; +#endif ///CLASSIC_BT_INCLUDED == TRUE + break; } +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_csm_execute (p_ccb, event, &ci); +#endif ///CLASSIC_BT_INCLUDED == TRUE break; } } @@ -337,7 +347,9 @@ void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) { tL2C_LCB *p_lcb; +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; +#endif ///CLASSIC_BT_INCLUDED == TRUE BOOLEAN status = TRUE; BOOLEAN lcb_is_free = TRUE; tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; @@ -366,6 +378,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) btm_ble_update_link_topology_mask(p_lcb->link_role, FALSE); } #endif +#if (CLASSIC_BT_INCLUDED == TRUE) /* Link is disconnected. For all channels, send the event through */ /* their FSMs. The CCBs should remove themselves from the LCB */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) { @@ -382,7 +395,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) } p_ccb = pn; } - +#endif ///CLASSIC_BT_INCLUDED == TRUE #if (BTM_SCO_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE) if (p_lcb->transport == BT_TRANSPORT_BR_EDR) @@ -469,8 +482,9 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) BOOLEAN l2c_link_hci_qos_violation (UINT16 handle) { tL2C_LCB *p_lcb; +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; - +#endif ///CLASSIC_BT_INCLUDED == TRUE /* See if we have a link control block for the connection */ p_lcb = l2cu_find_lcb_by_handle (handle); @@ -478,14 +492,14 @@ BOOLEAN l2c_link_hci_qos_violation (UINT16 handle) if (!p_lcb) { return (FALSE); } - +#if (CLASSIC_BT_INCLUDED == TRUE) /* For all channels, tell the upper layer about it */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) { if (p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb) { l2c_csm_execute (p_ccb, L2CEVT_LP_QOS_VIOLATION_IND, NULL); } } - +#endif ///CLASSIC_BT_INCLUDED == TRUE return (TRUE); } @@ -502,7 +516,9 @@ BOOLEAN l2c_link_hci_qos_violation (UINT16 handle) *******************************************************************************/ void l2c_link_timeout (tL2C_LCB *p_lcb) { +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; +#endif ///CLASSIC_BT_INCLUDED == TRUE UINT16 timeout; tBTM_STATUS rc; @@ -515,7 +531,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) (p_lcb->link_state == LST_CONNECT_HOLDING) || (p_lcb->link_state == LST_DISCONNECTING)) { p_lcb->p_pending_ccb = NULL; - +#if (CLASSIC_BT_INCLUDED == TRUE) /* For all channels, send a disconnect indication event through */ /* their FSMs. The CCBs should remove themselves from the LCB */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) { @@ -525,6 +541,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) p_ccb = pn; } +#endif ///CLASSIC_BT_INCLUDED == TRUE #if (BLE_INCLUDED == TRUE) if (p_lcb->link_state == LST_CONNECTING && l2cb.is_ble_connecting == TRUE) { @@ -547,7 +564,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) (*p_cb) (L2CAP_PING_RESULT_NO_RESP); L2CAP_TRACE_WARNING ("L2CAP - ping timeout"); - +#if (CLASSIC_BT_INCLUDED == TRUE) /* For all channels, send a disconnect indication event through */ /* their FSMs. The CCBs should remove themselves from the LCB */ for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) { @@ -557,6 +574,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) p_ccb = pn; } +#endif ///CLASSIC_BT_INCLUDED == TRUE } /* If no channels in use, drop the link. */ @@ -609,8 +627,9 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) void l2c_info_timeout (tL2C_LCB *p_lcb) { tL2C_CCB *p_ccb; +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CONN_INFO ci; - +#endif ///CLASSIC_BT_INCLUDED == TRUE /* If we timed out waiting for info response, just continue using basic if allowed */ if (p_lcb->w4_info_rsp) { /* If waiting for security complete, restart the info response timer */ @@ -622,7 +641,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb) } p_lcb->w4_info_rsp = FALSE; - +#if (CLASSIC_BT_INCLUDED == TRUE) /* If link is in process of being brought up */ if ((p_lcb->link_state != LST_DISCONNECTED) && (p_lcb->link_state != LST_DISCONNECTING)) { @@ -636,6 +655,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb) } } } +#endif ///CLASSIC_BT_INCLUDED == TRUE } } @@ -1021,7 +1041,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) { int xx; BOOLEAN single_write = FALSE; - + L2CAP_TRACE_ERROR("%s",__func__); /* Save the channel ID for faster counting */ if (p_buf) { if (p_ccb != NULL) { @@ -1048,6 +1068,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) ** This LCB will be served when receiving number of completed packet event. */ if (l2cb.is_cong_cback_context) { + L2CAP_TRACE_ERROR("l2cab is_cong_cback_context"); return; } @@ -1064,6 +1085,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) /* Loop through, starting at the next */ for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { /* If controller window is full, nothing to do */ + L2CAP_TRACE_DEBUG("window = %d,robin_unacked = %d,robin_quota=%d",l2cb.controller_le_xmit_window,l2cb.ble_round_robin_unacked,l2cb.ble_round_robin_quota); if (((l2cb.controller_xmit_window == 0 || (l2cb.round_robin_unacked >= l2cb.round_robin_quota)) #if (BLE_INCLUDED == TRUE) @@ -1082,7 +1104,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) if (p_lcb == &l2cb.lcb_pool[MAX_L2CAP_LINKS]) { p_lcb = &l2cb.lcb_pool[0]; } - + L2CAP_TRACE_DEBUG("in_use=%d,segment_being_sent=%d,link_state=%d,link_xmit_quota=%d",p_lcb->in_use,p_lcb->partial_segment_being_sent,p_lcb->link_state,p_lcb->link_xmit_quota); if ( (!p_lcb->in_use) || (p_lcb->partial_segment_being_sent) || (p_lcb->link_state != LST_CONNECTED) @@ -1125,6 +1147,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) #endif } else { /* if this is not round-robin service */ /* If a partial segment is being sent, can't send anything else */ + L2CAP_TRACE_DEBUG("partial_segment_being_sent=%d,link_state=%d,power_mode=%d",p_lcb->partial_segment_being_sent,p_lcb->link_state,L2C_LINK_CHECK_POWER_MODE (p_lcb)); if ( (p_lcb->partial_segment_being_sent) || (p_lcb->link_state != LST_CONNECTED) || (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) { @@ -1162,6 +1185,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) #endif { + L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb)); if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) { break; } @@ -1196,7 +1220,7 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf) UINT16 num_segs; UINT16 xmit_window, acl_data_size; const controller_t *controller = controller_get_interface(); - + L2CAP_TRACE_DEBUG("%s",__func__); if ((p_buf->len <= controller->get_acl_packet_size_classic() #if (BLE_INCLUDED == TRUE) && (p_lcb->transport == BT_TRANSPORT_BR_EDR)) || diff --git a/components/bt/bluedroid/stack/l2cap/l2c_main.c b/components/bt/bluedroid/stack/l2cap/l2c_main.c index 814bc9f85a..5938a12053 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_main.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_main.c @@ -255,7 +255,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) p_ccb = p_lcb->p_fixed_ccbs[rcv_cid - L2CAP_FIRST_FIXED_CHNL]; if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_fcr_proc_pdu (p_ccb, p_msg); +#endif ///CLASSIC_BT_INCLUDED == TRUE } else (*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) (rcv_cid, p_lcb->remote_bd_addr, p_msg); @@ -273,11 +275,15 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) } else { /* Basic mode packets go straight to the state machine */ if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) { +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_csm_execute (p_ccb, L2CEVT_L2CAP_DATA, p_msg); +#endif ///CLASSIC_BT_INCLUDED == TRUE } else { /* eRTM or streaming mode, so we need to validate states first */ if ((p_ccb->chnl_state == CST_OPEN) || (p_ccb->chnl_state == CST_CONFIG)) { +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_fcr_proc_pdu (p_ccb, p_msg); +#endif ///CLASSIC_BT_INCLUDED == TRUE } else { GKI_freebuf (p_msg); } @@ -298,6 +304,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) *******************************************************************************/ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) { +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 *p_pkt_end, *p_next_cmd, *p_cfg_end, *p_cfg_start; UINT8 cmd_code, cfg_code, cfg_len, id; tL2C_CONN_INFO con_info; @@ -731,6 +738,8 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) return; } } + +#endif ///CLASSIC_BT_INCLUDED == TRUE } /******************************************************************************* @@ -864,7 +873,7 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle) case BTU_TTYPE_L2CAP_LINK: l2c_link_timeout ((tL2C_LCB *)p_tle->param); break; - +#if (CLASSIC_BT_INCLUDED == TRUE) case BTU_TTYPE_L2CAP_CHNL: l2c_csm_execute (((tL2C_CCB *)p_tle->param), L2CEVT_TIMEOUT, NULL); break; @@ -872,7 +881,7 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle) case BTU_TTYPE_L2CAP_FCR_ACK: l2c_csm_execute (((tL2C_CCB *)p_tle->param), L2CEVT_ACK_TIMEOUT, NULL); break; - +#endif ///CLASSIC_BT_INCLUDED == TRUE case BTU_TTYPE_L2CAP_HOLD: /* Update the timeouts in the hold queue */ l2c_process_held_packets(TRUE); @@ -897,6 +906,7 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle) *******************************************************************************/ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) { +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; /* Find the channel control block. We don't know the link it is on. */ @@ -935,7 +945,7 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) if (p_ccb->cong_sent) { return (L2CAP_DW_CONGESTED); } - +#endif ///CLASSIC_BT_INCLUDED == TRUE return (L2CAP_DW_SUCCESS); } diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index e910d3cfb7..bf35e8b264 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -1479,9 +1479,9 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid) btu_stop_quick_timer (&p_ccb->fcrb.mon_retrans_timer); } // btla-specific -- - +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_fcr_stop_timer (p_ccb); - +#endif ///CLASSIC_BT_INCLUDED == TRUE p_ccb->ertm_info.preferred_mode = L2CAP_FCR_BASIC_MODE; /* Default mode for channel is basic mode */ p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_BASIC; /* Default mode for channel is basic mode */ p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_FCR_RX_POOL_ID; @@ -1613,9 +1613,9 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb) while (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { GKI_freebuf (GKI_dequeue (&p_ccb->xmit_hold_q)); } - +#if (CLASSIC_BT_INCLUDED == TRUE) l2c_fcr_cleanup (p_ccb); - +#endif ///CLASSIC_BT_INCLUDED == TRUE /* Channel may not be assigned to any LCB if it was just pre-reserved */ if ( (p_lcb) && ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) @@ -1812,8 +1812,9 @@ UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) BOOLEAN qos_type_ok = TRUE; BOOLEAN flush_to_ok = TRUE; BOOLEAN fcr_ok = TRUE; +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 fcr_status; - +#endif ///CLASSIC_BT_INCLUDED == TRUE /* Ignore FCR parameters for basic mode */ if (!p_cfg->fcr_present) { p_cfg->fcr.mode = L2CAP_FCR_BASIC_MODE; @@ -1879,7 +1880,7 @@ UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) p_cfg->qos_present = TRUE; p_cfg->qos = p_ccb->peer_cfg.qos; } - +#if (CLASSIC_BT_INCLUDED == TRUE) if ((fcr_status = l2c_fcr_process_peer_cfg_req (p_ccb, p_cfg)) == L2CAP_PEER_CFG_DISCONNECT) { /* Notify caller to disconnect the channel (incompatible modes) */ p_cfg->result = L2CAP_CFG_FAILED_NO_REASON; @@ -1889,6 +1890,7 @@ UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) } fcr_ok = (fcr_status == L2CAP_PEER_CFG_OK); +#endif ///CLASSIC_BT_INCLUDED == TRUE /* Return any unacceptable parameters */ if (mtu_ok && flush_to_ok && qos_type_ok && fcr_ok) { @@ -2048,6 +2050,7 @@ void l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { +#if (CLASSIC_BT_INCLUDED == TRUE) /* If peer wants QoS, we are allowed to change the values in a positive response */ if ( (p_cfg->qos_present) && (p_ccb->peer_cfg.qos_present) ) { p_ccb->peer_cfg.qos = p_cfg->qos; @@ -2056,6 +2059,7 @@ void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) } l2c_fcr_adj_our_rsp_options (p_ccb, p_cfg); +#endif ///CLASSIC_BT_INCLUDED == TRUE } @@ -2418,17 +2422,16 @@ void l2cu_set_non_flushable_pbf (BOOLEAN is_supported) *******************************************************************************/ void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda) { +#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_LCB *p_lcb; tL2C_CCB *p_ccb; tL2C_CCB *p_next_ccb; int xx; - L2CAP_TRACE_DEBUG ("l2cu_resubmit_pending_sec_req p_bda: %p", p_bda); /* If we are called with a BDA, only resubmit for that BDA */ if (p_bda) { p_lcb = l2cu_find_lcb_by_bd_addr (p_bda, BT_TRANSPORT_BR_EDR); - /* If we don't have one, this is an error */ if (p_lcb) { /* For all channels, send the event through their FSMs */ @@ -2449,8 +2452,9 @@ void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda) l2c_csm_execute (p_ccb, L2CEVT_SEC_RE_SEND_CMD, NULL); } } - } + } } +#endif ///CLASSIC_BT_INCLUDED == TRUE } #if L2CAP_CONFORMANCE_TESTING == TRUE @@ -2526,7 +2530,7 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR { #if (L2CAP_NUM_FIXED_CHNLS > 0) tL2C_CCB *p_ccb; - + L2CAP_TRACE_ERROR("%s,fixed_cid=%d,p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = %p",__func__,fixed_cid,p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]); /* If we already have a CCB, then simply return */ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] != NULL) { return (TRUE); @@ -2651,6 +2655,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb) *******************************************************************************/ void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb) { + L2CAP_TRACE_ERROR("%s",__func__); #if (BLE_INCLUDED == TRUE) if (p_lcb->transport == BT_TRANSPORT_BR_EDR) { /* ignore all not assigned BR/EDR channels */ @@ -2977,11 +2982,12 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb) if ( (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID) && (GKI_poolutilization (HCI_ACL_POOL_ID) > 90) ) { continue; } - +#if (CLASSIC_BT_INCLUDED == TRUE) /* If in eRTM mode, check for window closure */ if ( (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && (l2c_fcr_is_flow_controlled (p_ccb)) ) { continue; } +#endif ///CLASSIC_BT_INCLUDED == TRUE } } else { if (GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { @@ -3026,6 +3032,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb) ** Returns pointer to CCB or NULL ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static tL2C_CCB *l2cu_get_next_channel(tL2C_LCB *p_lcb) { tL2C_CCB *p_ccb; @@ -3065,6 +3072,8 @@ static tL2C_CCB *l2cu_get_next_channel(tL2C_LCB *p_lcb) return NULL; } +#endif ///CLASSIC_BT_INCLUDED == TRUE + #endif /* (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) */ /****************************************************************************** @@ -3080,7 +3089,7 @@ static tL2C_CCB *l2cu_get_next_channel(tL2C_LCB *p_lcb) BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) { tL2C_CCB *p_ccb; - BT_HDR *p_buf; + BT_HDR *p_buf = NULL; /* Highest priority are fixed channels */ #if (L2CAP_NUM_FIXED_CHNLS > 0) @@ -3093,6 +3102,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) /* eL2CAP option in use */ if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { +#if (CLASSIC_BT_INCLUDED == TRUE) if (p_ccb->fcrb.wait_ack || p_ccb->fcrb.remote_busy) { continue; } @@ -3107,18 +3117,20 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) if ( (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID) && (GKI_poolutilization (HCI_ACL_POOL_ID) > 90) ) { continue; } - /* If in eRTM mode, check for window closure */ if ( (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && (l2c_fcr_is_flow_controlled (p_ccb)) ) { continue; } } - if ((p_buf = l2c_fcr_get_next_xmit_sdu_seg(p_ccb, 0)) != NULL) { l2cu_check_channel_congestion (p_ccb); l2cu_set_acl_hci_header (p_buf, p_ccb); return (p_buf); } +#else + continue; +#endif ///CLASSIC_BT_INCLUDED == TRUE + } else { if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); @@ -3138,7 +3150,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) } } #endif - +#if (CLASSIC_BT_INCLUDED == TRUE) #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) /* get next serving channel in round-robin */ p_ccb = l2cu_get_next_channel_in_rr( p_lcb ); @@ -3152,9 +3164,11 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) } if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { + if ((p_buf = l2c_fcr_get_next_xmit_sdu_seg(p_ccb, 0)) == NULL) { return (NULL); } + } else { p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); if (NULL == p_buf) { @@ -3171,6 +3185,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) l2cu_check_channel_congestion (p_ccb); l2cu_set_acl_hci_header (p_buf, p_ccb); +#endif ///CLASSIC_BT_INCLUDED == TRUE return (p_buf); } diff --git a/components/bt/bluedroid/stack/sdp/include/sdpint.h b/components/bt/bluedroid/stack/sdp/include/sdpint.h index 9e935ea5ad..3e89606f0e 100644 --- a/components/bt/bluedroid/stack/sdp/include/sdpint.h +++ b/components/bt/bluedroid/stack/sdp/include/sdpint.h @@ -29,7 +29,7 @@ #include "sdp_api.h" #include "l2c_api.h" - +#if (SDP_INCLUDED == TRUE) /* Continuation length - we use a 2-byte offset */ #define SDP_CONTINUATION_LEN 2 #define SDP_MAX_CONTINUATION_LEN 16 /* As per the spec */ @@ -309,6 +309,6 @@ extern void sdp_disc_server_rsp (tCONN_CB *p_ccb, BT_HDR *p_msg); #define sdp_disc_server_rsp(p_ccb, p_msg) #endif - +#endif ///SDP_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/stack/sdp/sdp_api.c b/components/bt/bluedroid/stack/sdp/sdp_api.c index 1f5715913d..bc793c22be 100644 --- a/components/bt/bluedroid/stack/sdp/sdp_api.c +++ b/components/bt/bluedroid/stack/sdp/sdp_api.c @@ -37,6 +37,7 @@ #include "sdpint.h" #include "btu.h" +#if (SDP_INCLUDED == TRUE) /********************************************************************** ** C L I E N T F U N C T I O N P R O T O T Y P E S * ***********************************************************************/ @@ -1239,3 +1240,5 @@ UINT8 SDP_SetTraceLevel (UINT8 new_level) return (sdp_cb.trace_level); } + +#endif ///SDP_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/stack/sdp/sdp_db.c b/components/bt/bluedroid/stack/sdp/sdp_db.c index 2d3308ebfe..978c859739 100644 --- a/components/bt/bluedroid/stack/sdp/sdp_db.c +++ b/components/bt/bluedroid/stack/sdp/sdp_db.c @@ -37,6 +37,8 @@ #include "sdp_api.h" #include "sdpint.h" +#if (SDP_INCLUDED == TRUE) + #if SDP_SERVER_ENABLED == TRUE /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ @@ -964,3 +966,5 @@ INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len) return (offset); } #endif + +#endif ///SDP_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/stack/sdp/sdp_main.c b/components/bt/bluedroid/stack/sdp/sdp_main.c index 3511aee987..0b7e9aa403 100644 --- a/components/bt/bluedroid/stack/sdp/sdp_main.c +++ b/components/bt/bluedroid/stack/sdp/sdp_main.c @@ -42,7 +42,7 @@ #include "sdp_api.h" #include "sdpint.h" - +#if (SDP_INCLUDED == TRUE) /********************************************************************************/ /* G L O B A L S D P D A T A */ /********************************************************************************/ @@ -688,6 +688,7 @@ void sdp_conn_timeout (tCONN_CB *p_ccb) sdpu_release_ccb (p_ccb); } +#endif ///SDP_INCLUDED == TRUE diff --git a/components/bt/bluedroid/stack/sdp/sdp_utils.c b/components/bt/bluedroid/stack/sdp/sdp_utils.c index 38bac33f61..2a93fe5679 100644 --- a/components/bt/bluedroid/stack/sdp/sdp_utils.c +++ b/components/bt/bluedroid/stack/sdp/sdp_utils.c @@ -41,7 +41,7 @@ #include "btu.h" - +#if (SDP_INCLUDED == TRUE) static const UINT8 sdp_base_uuid[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }; @@ -1023,3 +1023,5 @@ void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128) uuid16_bo = ntohs(uuid16); memcpy(p_uuid128 + 2, &uuid16_bo, sizeof(uint16_t)); } + +#endif ///SDP_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/stack/smp/include/smp_int.h b/components/bt/bluedroid/stack/smp/include/smp_int.h index ad6e99ea53..734c3fcba3 100644 --- a/components/bt/bluedroid/stack/smp/include/smp_int.h +++ b/components/bt/bluedroid/stack/smp/include/smp_int.h @@ -24,7 +24,7 @@ #ifndef SMP_INT_H #define SMP_INT_H -#if BLE_INCLUDED == TRUE +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) #include "btu.h" #include "btm_ble_api.h" @@ -530,6 +530,6 @@ extern BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 len UINT16 tlen, UINT8 *p_signature); extern void print128(BT_OCTET16 x, const UINT8 *key_name); -#endif +#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE #endif /* SMP_INT_H */ diff --git a/components/bt/bluedroid/stack/smp/smp_br_main.c b/components/bt/bluedroid/stack/smp/smp_br_main.c index 1ccbc09712..8360bf9786 100644 --- a/components/bt/bluedroid/stack/smp/smp_br_main.c +++ b/components/bt/bluedroid/stack/smp/smp_br_main.c @@ -21,7 +21,7 @@ #include #include "smp_int.h" -#if BLE_INCLUDED == TRUE +#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) const char *const smp_br_state_name [SMP_BR_STATE_MAX + 1] = { "SMP_BR_STATE_IDLE", diff --git a/examples/bluetooth/gatt_server/main/gatts_demo.c b/examples/bluetooth/gatt_server/main/gatts_demo.c index 9114beaeba..1715b65fc2 100644 --- a/examples/bluetooth/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/gatt_server/main/gatts_demo.c @@ -259,7 +259,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i case ESP_GATTS_STOP_EVT: break; case ESP_GATTS_CONNECT_EVT: - ESP_LOGI(GATTS_TAG, "SERVICE_START_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:, is_conn %d\n", + ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONNECT_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:, is_conn %d\n", param->connect.conn_id, param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2], param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5], From 65ff8bd16079d1ed3768ec13c1144a70f77288c6 Mon Sep 17 00:00:00 2001 From: Yulong Date: Tue, 18 Apr 2017 05:42:55 -0400 Subject: [PATCH 02/15] l2cap can send data to low layer when close the classic bt. --- components/bt/bluedroid/stack/l2cap/l2c_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index 09d7fae92f..c22650d761 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -1185,7 +1185,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) #endif { - L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb)); + //L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb)); if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) { break; } From 0ddadc98a382721dbf454777dd1df3621e02b528 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 19 Apr 2017 03:44:01 -0400 Subject: [PATCH 03/15] separate the btm layer from SMP security --- components/bt/Kconfig | 7 + components/bt/bluedroid/include/bt_target.h | 2 +- components/bt/bluedroid/include/bt_trace.h | 179 ++++++++++++++++-- components/bt/bluedroid/stack/btm/btm_acl.c | 4 + components/bt/bluedroid/stack/btm/btm_ble.c | 3 +- components/bt/bluedroid/stack/btm/btm_dev.c | 7 +- .../bt/bluedroid/stack/btm/btm_devctl.c | 8 +- components/bt/bluedroid/stack/btm/btm_sec.c | 158 ++++++++++++++-- components/bt/bluedroid/stack/gap/gap_utils.c | 3 + .../bt/bluedroid/stack/include/btm_int.h | 7 +- 10 files changed, 335 insertions(+), 43 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index eaa3d1625f..da1d98055d 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -38,6 +38,13 @@ config BT_DRAM_RELEASE Enabling this option will release about 30K DRAM from Classic BT. The released DRAM will be used as system heap memory. +config BT_STACK_NO_LOG + bool "Close the bluedroid bt stack log print" + depends on BLUEDROID_ENABLED + default n + help + This select can save the rowdata code size + #disable now for app cpu due to a known issue config BTDM_CONTROLLER_RUN_APP_CPU bool "Run controller on APP CPU" diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index 7f9203828b..5cf0d79f1b 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -479,7 +479,7 @@ /* The size in bytes of the BTM inquiry database. 40 As Default */ #ifndef BTM_INQ_DB_SIZE -#define BTM_INQ_DB_SIZE 32 +#define BTM_INQ_DB_SIZE 1//32 #endif /* The default scan mode */ diff --git a/components/bt/bluedroid/include/bt_trace.h b/components/bt/bluedroid/include/bt_trace.h index 5d11ef5cbb..6a1f848309 100644 --- a/components/bt/bluedroid/include/bt_trace.h +++ b/components/bt/bluedroid/include/bt_trace.h @@ -18,6 +18,7 @@ #ifndef _BT_TRACE_H_ #define _BT_TRACE_H_ +#include "sdkconfig.h" #include #include "bt_types.h" @@ -270,11 +271,13 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #ifndef LOG_LEVEL #define LOG_LEVEL LOG_LEVEL_INFO #endif -#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0) -#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0) -#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0) -#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0) -#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0) + +#if !CONFIG_BT_STACK_NO_LOG +#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0) +#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0) +#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0) +#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0) +#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0) /* Define tracing for the HCI unit */ @@ -287,7 +290,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) */ #define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} #define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} #define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} @@ -303,7 +306,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) */ #define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} #define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} #define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} @@ -318,7 +321,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) /* Generic Access Profile traces */ #define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} #define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} #define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} /* define traces for HID Host */ @@ -340,7 +343,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} #define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} #define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} @@ -350,7 +353,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} #define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} /* AVDTP */ @@ -382,7 +385,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} #define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} /* Define tracing for the ATT/GATT unit */ @@ -396,7 +399,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) */ #define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} #define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} #define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} #define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} @@ -419,6 +422,158 @@ extern UINT8 btif_trace_level; #define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} #define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) BT_PRINTF(fmt, ## args);} +#else +#define LOG_ERROR(fmt, args...) +#define LOG_WARN(fmt, args...) +#define LOG_INFO(fmt, args...) +#define LOG_DEBUG(fmt, args...) +#define LOG_VERBOSE(fmt, args...) + +/* Define tracing for the HCI unit +*/ +#define HCI_TRACE_ERROR(fmt, args...) +#define HCI_TRACE_WARNING(fmt, args...) +#define HCI_TRACE_EVENT(fmt, args...) +#define HCI_TRACE_DEBUG(fmt, args...) + +/* Define tracing for BTM +*/ +#define BTM_TRACE_ERROR(fmt, args...) +#define BTM_TRACE_WARNING(fmt, args...) +#define BTM_TRACE_API(fmt, args...) +#define BTM_TRACE_EVENT(fmt, args...) +#define BTM_TRACE_DEBUG(fmt, args...) + +/* Define tracing for the L2CAP unit +*/ +#define L2CAP_TRACE_ERROR(fmt, args...) +#define L2CAP_TRACE_WARNING(fmt, args...) +#define L2CAP_TRACE_API(fmt, args...) +#define L2CAP_TRACE_EVENT(fmt, args...) +#define L2CAP_TRACE_DEBUG(fmt, args...) + +/* Define tracing for the SDP unit +*/ +#define SDP_TRACE_ERROR(fmt, args...) +#define SDP_TRACE_WARNING(fmt, args...) +#define SDP_TRACE_API(fmt, args...) +#define SDP_TRACE_EVENT(fmt, args...) +#define SDP_TRACE_DEBUG(fmt, args...) + +/* Define tracing for the RFCOMM unit +*/ +#define RFCOMM_TRACE_ERROR(fmt, args...) +#define RFCOMM_TRACE_WARNING(fmt, args...) +#define RFCOMM_TRACE_API(fmt, args...) +#define RFCOMM_TRACE_EVENT(fmt, args...) +#define RFCOMM_TRACE_DEBUG(fmt, args...) + +/* Generic Access Profile traces */ +#define GAP_TRACE_ERROR(fmt, args...) +#define GAP_TRACE_EVENT(fmt, args...) +#define GAP_TRACE_API(fmt, args...) +#define GAP_TRACE_WARNING(fmt, args...) + +/* define traces for HID Host */ +#define HIDH_TRACE_ERROR(fmt, args...) +#define HIDH_TRACE_WARNING(fmt, args...) +#define HIDH_TRACE_API(fmt, args...) +#define HIDH_TRACE_EVENT(fmt, args...) +#define HIDH_TRACE_DEBUG(fmt, args...) + +/* define traces for BNEP */ + +#define BNEP_TRACE_ERROR(fmt, args...) +#define BNEP_TRACE_WARNING(fmt, args...) +#define BNEP_TRACE_API(fmt, args...) +#define BNEP_TRACE_EVENT(fmt, args...) +#define BNEP_TRACE_DEBUG(fmt, args...) + +/* define traces for PAN */ + +#define PAN_TRACE_ERROR(fmt, args...) +#define PAN_TRACE_WARNING(fmt, args...) +#define PAN_TRACE_API(fmt, args...) +#define PAN_TRACE_EVENT(fmt, args...) +#define PAN_TRACE_DEBUG(fmt, args...) + +/* Define tracing for the A2DP profile +*/ +#define A2D_TRACE_ERROR(fmt, args...) +#define A2D_TRACE_WARNING(fmt, args...) +#define A2D_TRACE_EVENT(fmt, args...) +#define A2D_TRACE_DEBUG(fmt, args...) +#define A2D_TRACE_API(fmt, args...) + +/* AVDTP +*/ +#define AVDT_TRACE_ERROR(fmt, args...) +#define AVDT_TRACE_WARNING(fmt, args...) +#define AVDT_TRACE_EVENT(fmt, args...) +#define AVDT_TRACE_DEBUG(fmt, args...) +#define AVDT_TRACE_API(fmt, args...) + +/* Define tracing for the AVCTP protocol +*/ +#define AVCT_TRACE_ERROR(fmt, args...) +#define AVCT_TRACE_WARNING(fmt, args...) +#define AVCT_TRACE_EVENT(fmt, args...) +#define AVCT_TRACE_DEBUG(fmt, args...) +#define AVCT_TRACE_API(fmt, args...) + +/* Define tracing for the AVRCP profile +*/ +#define AVRC_TRACE_ERROR(fmt, args...) +#define AVRC_TRACE_WARNING(fmt, args...) +#define AVRC_TRACE_EVENT(fmt, args...) +#define AVRC_TRACE_DEBUG(fmt, args...) +#define AVRC_TRACE_API(fmt, args...) + +/* MCAP +*/ +#define MCA_TRACE_ERROR(fmt, args...) +#define MCA_TRACE_WARNING(fmt, args...) +#define MCA_TRACE_EVENT(fmt, args...) +#define MCA_TRACE_DEBUG(fmt, args...) +#define MCA_TRACE_API(fmt, args...) + +/* Define tracing for the ATT/GATT unit +*/ +#define GATT_TRACE_ERROR(fmt, args...) +#define GATT_TRACE_WARNING(fmt, args...) +#define GATT_TRACE_API(fmt, args...) +#define GATT_TRACE_EVENT(fmt, args...) +#define GATT_TRACE_DEBUG(fmt, args...) + +/* Define tracing for the SMP unit +*/ +#define SMP_TRACE_ERROR(fmt, args...) +#define SMP_TRACE_WARNING(fmt, args...) +#define SMP_TRACE_API(fmt, args...) +#define SMP_TRACE_EVENT(fmt, args...) +#define SMP_TRACE_DEBUG(fmt, args...) + +extern UINT8 btif_trace_level; + +// define traces for application +#define BTIF_TRACE_ERROR(fmt, args...) +#define BTIF_TRACE_WARNING(fmt, args...) +#define BTIF_TRACE_API(fmt, args...) +#define BTIF_TRACE_EVENT(fmt, args...) +#define BTIF_TRACE_DEBUG(fmt, args...) +#define BTIF_TRACE_VERBOSE(fmt, args...) + +/* define traces for application */ + +#define APPL_TRACE_ERROR(fmt, args...) +#define APPL_TRACE_WARNING(fmt, args...) +#define APPL_TRACE_API(fmt, args...) +#define APPL_TRACE_EVENT(fmt, args...) +#define APPL_TRACE_DEBUG(fmt, args...) +#define APPL_TRACE_VERBOSE(fmt, args...) +#endif ///CONFIG_BT_STACK_NO_LOG + + /* Simplified Trace Helper Macro */ #define bdld(fmt, args...) \ diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index b011ed5906..640268265c 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -2293,6 +2293,7 @@ void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, *******************************************************************************/ void btm_acl_resubmit_page (void) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BT_HDR *p_buf; UINT8 *pp; @@ -2315,6 +2316,7 @@ void btm_acl_resubmit_page (void) } else { btm_cb.paging = FALSE; } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2345,6 +2347,7 @@ void btm_acl_reset_paging (void) *******************************************************************************/ void btm_acl_paging (BT_HDR *p, BD_ADDR bda) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_acl_paging discing:%d, paging:%d BDA: %06x%06x\n", @@ -2376,6 +2379,7 @@ void btm_acl_paging (BT_HDR *p, BD_ADDR bda) btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/btm/btm_ble.c b/components/bt/bluedroid/stack/btm/btm_ble.c index ddf5849cab..d8f176c820 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/bluedroid/stack/btm/btm_ble.c @@ -71,6 +71,7 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr); BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; UINT8 i = 0; tBTM_INQ_INFO *p_info = NULL; @@ -132,7 +133,7 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d BTM_TRACE_DEBUG ("InqDb device_type =0x%x addr_type=0x%x", p_info->results.device_type, p_info->results.ble_addr_type); } - +#endif ///SMP_INCLUDED == TRUE return (TRUE); } diff --git a/components/bt/bluedroid/stack/btm/btm_dev.c b/components/bt/bluedroid/stack/btm/btm_dev.c index fc78e1e1bf..aa8c49fdd2 100644 --- a/components/bt/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/bluedroid/stack/btm/btm_dev.c @@ -63,6 +63,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY link_key, UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; int i, j; BOOLEAN found = FALSE; @@ -160,7 +161,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, p_dev_rec->rmt_io_caps = io_cap; p_dev_rec->device_type |= BT_DEVICE_TYPE_BREDR; - +#endif ///SMP_INCLUDED == TRUE return (TRUE); } @@ -395,6 +396,7 @@ BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr) *******************************************************************************/ tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0]; int i; @@ -408,6 +410,7 @@ tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle) return (p_dev_rec); } } +#endif ///SMP_INCLUDED == TRUE return (NULL); } @@ -459,7 +462,7 @@ tBTM_SEC_DEV_REC *btm_find_dev(BD_ADDR bd_addr) *******************************************************************************/ void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec) { -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0]; tBTM_SEC_DEV_REC temp_rec = *p_target_rec; diff --git a/components/bt/bluedroid/stack/btm/btm_devctl.c b/components/bt/bluedroid/stack/btm/btm_devctl.c index fe5fca55cc..45cc82cddb 100644 --- a/components/bt/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/bluedroid/stack/btm/btm_devctl.c @@ -143,12 +143,12 @@ static void reset_complete(void) /* Tell L2CAP that all connections are gone */ l2cu_device_reset (); - +#if (SMP_INCLUDED == TRUE) /* Clear current security state */ for (int devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++) { btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE; } - +#endif ///SMP_INCLUDED == TRUE /* After the reset controller should restore all parameters to defaults. */ btm_cb.btm_inq_vars.inq_counter = 1; btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW; @@ -187,9 +187,9 @@ static void reset_complete(void) l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble()); } #endif - +#if (SMP_INCLUDED == TRUE) BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len); - +#endif ///SMP_INCLUDED == TRUE for (int i = 0; i <= controller->get_last_features_classic_index(); i++) { btm_decode_ext_features_page(i, controller->get_features_classic(i)->as_array); } diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index a54a8ce6b6..76bdf2b59b 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -55,59 +55,68 @@ BOOLEAN (APPL_AUTH_WRITE_EXCEPTION)(BD_ADDR bd_addr); /******************************************************************************** ** L O C A L F U N C T I O N P R O T O T Y P E S * *********************************************************************************/ +#if (SMP_INCLUDED == TRUE) static tBTM_SEC_SERV_REC *btm_sec_find_first_serv (BOOLEAN is_originator, UINT16 psm); static tBTM_SEC_SERV_REC *btm_sec_find_next_serv (tBTM_SEC_SERV_REC *p_cur); static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm, UINT32 mx_proto_id, UINT32 mx_chan_id); - +#endif ///SMP_INCLUDED == TRUE static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec); +#if (SMP_INCLUDED == TRUE) static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle); static void btm_restore_mode(void); static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle); static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec); +#endif ///SMP_INCLUDED == TRUE static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state); -#if (BT_USE_TRACES == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) static char *btm_pair_state_descr (tBTM_PAIRING_STATE state); #endif static void btm_sec_check_pending_reqs(void); +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig, UINT32 mx_proto_id, UINT32 mx_chan_id, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); +#endif ///SMP_INCLUDED == TRUE static void btm_sec_bond_cancel_complete (void); +#if (SMP_INCLUDED == TRUE) static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec); - +#endif ///SMP_INCLUDED == TRUE static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec); BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[]); - +#if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle); +#endif ///SMP_INCLUDED == TRUE UINT8 btm_sec_start_role_switch (tBTM_SEC_DEV_REC *p_dev_rec); tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state); static BOOLEAN btm_sec_set_security_level ( CONNECTION_TYPE conn_type, char *p_name, UINT8 service_id, UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id, UINT32 mx_chan_id); - +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_dev_authenticated(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_dev_encrypted(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_dev_authorized(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec); static BOOLEAN btm_sec_is_serv_level0 (UINT16 psm); static UINT16 btm_sec_set_serv_level4_flags (UINT16 cur_security, BOOLEAN is_originator); +#endif ///SMP_INCLUDED == TRUE static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); +#if (SMP_INCLUDED == TRUE) static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, UINT8 encr_enable); - static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec); +#endif ///SMP_INCLUDED == TRUE /* TRUE - authenticated link key is possible */ static const BOOLEAN btm_sec_io_map [BTM_IO_CAP_MAX][BTM_IO_CAP_MAX] = { @@ -131,6 +140,7 @@ static const BOOLEAN btm_sec_io_map [BTM_IO_CAP_MAX][BTM_IO_CAP_MAX] = { ** Returns BOOLEAN TRUE or FALSE ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_dev_authenticated (tBTM_SEC_DEV_REC *p_dev_rec) { if (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED) { @@ -190,6 +200,7 @@ static BOOLEAN btm_dev_16_digit_authenticated(tBTM_SEC_DEV_REC *p_dev_rec) } return (FALSE); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -200,6 +211,7 @@ static BOOLEAN btm_dev_16_digit_authenticated(tBTM_SEC_DEV_REC *p_dev_rec) ** Returns BOOLEAN TRUE or FALSE ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec) { if (BTM_SEC_IS_SERVICE_TRUSTED(p_dev_rec->trusted_mask, p_serv_rec->service_id)) { @@ -207,7 +219,7 @@ static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC * } return (FALSE); } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function BTM_SecRegister @@ -280,6 +292,7 @@ BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (tBTM_LINK_KEY_CALLBACK *p_ca *******************************************************************************/ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) { +#if (SMP_INCLUDED == TRUE) int i; for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) { @@ -288,7 +301,7 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) return (TRUE); } } - +#endif ///SMP_INCLUDED == TRUE return (FALSE); } @@ -305,6 +318,7 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) *******************************************************************************/ BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) { +#if (SMP_INCLUDED == TRUE) int i; for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) { @@ -313,7 +327,7 @@ BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) return (TRUE); } } - +#endif ///SMP_INCLUDED == TRUE return (FALSE); } @@ -500,6 +514,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id, UINT32 mx_chan_id) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_SERV_REC *p_srec; UINT16 index; UINT16 first_unused_record = BTM_NO_AVAIL_SEC_SERVICES; @@ -691,6 +706,9 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na return (record_allocated); +#else + return FALSE; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -713,6 +731,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na *******************************************************************************/ UINT8 BTM_SecClrService (UINT8 service_id) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0]; UINT8 num_freed = 0; int i; @@ -731,6 +750,9 @@ UINT8 BTM_SecClrService (UINT8 service_id) } return (num_freed); +#else + return 0; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -751,6 +773,7 @@ UINT8 BTM_SecClrService (UINT8 service_id) *******************************************************************************/ UINT8 btm_sec_clr_service_by_psm (UINT16 psm) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0]; UINT8 num_freed = 0; int i; @@ -766,6 +789,9 @@ UINT8 btm_sec_clr_service_by_psm (UINT16 psm) BTM_TRACE_API("btm_sec_clr_service_by_psm psm:0x%x num_freed:%d\n", psm, num_freed); return (num_freed); +#else + return 0; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -814,6 +840,7 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda) *******************************************************************************/ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d\n", @@ -914,6 +941,7 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, btm_cb.pin_code_len_saved = pin_len; #endif btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -932,6 +960,7 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_STATUS status; UINT8 *p_features; @@ -1086,6 +1115,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, } return status; +#else + return BTM_MODE_UNSUPPORTED; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1159,6 +1191,7 @@ tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 tr *******************************************************************************/ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x\n", @@ -1225,7 +1258,7 @@ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) return BTM_NOT_AUTHORIZED; } } - +#endif ///SMP_INCLUDED == TRUE return BTM_WRONG_MODE; } @@ -1392,6 +1425,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE /******************************************************************************* * disconnect the ACL link, if it's not done yet. *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle) { UINT8 old_state = p_dev_rec->sec_state; @@ -1445,7 +1479,7 @@ static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UIN return status; } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function BTM_ConfirmReqReply @@ -1459,6 +1493,7 @@ static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UIN *******************************************************************************/ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_EVENT ("BTM_ConfirmReqReply() State: %s Res: %u", @@ -1488,6 +1523,7 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; btsnd_hcic_user_conf_reply (bd_addr, FALSE); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1506,6 +1542,7 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) { +#if (SMP_INCLUDED == TRUE) BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d\n", btm_pair_state_descr(btm_cb.pairing_state), res); @@ -1549,6 +1586,7 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) btm_cb.acl_disc_reason = HCI_SUCCESS; btsnd_hcic_user_passkey_reply (bd_addr, passkey); } +#endif ///SMP_INCLUDED == TRUE } #endif @@ -1569,10 +1607,12 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type) { +#if (SMP_INCLUDED == TRUE) /* This API only make sense between PASSKEY_REQ and SP complete */ if (btm_cb.pairing_state == BTM_PAIR_STATE_KEY_ENTRY) { btsnd_hcic_send_keypress_notif (bd_addr, type); } +#endif ///SMP_INCLUDED == TRUE } #endif @@ -1594,6 +1634,7 @@ void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type) *******************************************************************************/ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req) { +#if (SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d\n", btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap); @@ -1612,6 +1653,7 @@ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_A btsnd_hcic_io_cap_req_reply (bd_addr, io_cap, oob, auth_req); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1647,6 +1689,7 @@ tBTM_STATUS BTM_ReadLocalOobData(void) *******************************************************************************/ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r) { +#if (SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() - State: %s res: %d\n", __func__, btm_pair_state_descr(btm_cb.pairing_state), res); @@ -1665,6 +1708,7 @@ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_O btm_cb.acl_disc_reason = HCI_SUCCESS; btsnd_hcic_rem_oob_reply (bd_addr, c, r); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1882,6 +1926,7 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len) *******************************************************************************/ void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0]; @@ -1901,6 +1946,7 @@ void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id) break; } } +#endif ///SMP_INCLUDED == TRUE } /************************************************************************ @@ -1916,6 +1962,7 @@ void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id) ** Returns BOOLEAN ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_is_upgrade_possible(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN is_originator) { UINT16 mtm_check = is_originator ? BTM_SEC_OUT_MITM : BTM_SEC_IN_MITM; @@ -1953,6 +2000,7 @@ static BOOLEAN btm_sec_is_upgrade_possible(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN BTM_TRACE_DEBUG ("%s() is_possible: %d sec_flags: 0x%x\n", __func__, is_possible, p_dev_rec->sec_flags); return is_possible; } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1964,6 +2012,7 @@ static BOOLEAN btm_sec_is_upgrade_possible(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_check_upgrade(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN is_originator) { @@ -1998,6 +2047,7 @@ static void btm_sec_check_upgrade(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN is_origi } } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -2031,6 +2081,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle tBTM_SEC_CALLBACK *p_callback, void *p_ref_data) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SEC_SERV_REC *p_serv_rec; UINT16 security_required; @@ -2347,6 +2398,9 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle } return (rc); +#else + return BTM_MODE_UNSUPPORTED; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2376,6 +2430,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o UINT32 mx_proto_id, UINT32 mx_chan_id, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SEC_SERV_REC *p_serv_rec; tBTM_STATUS rc; @@ -2548,6 +2603,9 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o } return rc; +#else + return BTM_MODE_UNSUPPORTED; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2562,6 +2620,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o *******************************************************************************/ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); BTM_TRACE_ERROR ("%s\n", __func__); /* Some device may request a connection before we are done with the HCI_Reset sequence */ @@ -2618,6 +2677,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) p_dev_rec->sm4 |= BTM_SM4_CONN_PEND; } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2632,6 +2692,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) *******************************************************************************/ static void btm_sec_bond_cancel_complete (void) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) || @@ -2655,6 +2716,7 @@ static void btm_sec_bond_cancel_complete (void) btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS); } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2673,8 +2735,8 @@ void btm_create_conn_cancel_complete (UINT8 *p) UINT8 status; STREAM_TO_UINT8 (status, p); - BTM_TRACE_EVENT ("btm_create_conn_cancel_complete(): in State: %s status:%d\n", - btm_pair_state_descr(btm_cb.pairing_state), status); + //BTM_TRACE_EVENT ("btm_create_conn_cancel_complete(): in State: %s status:%d\n", + // btm_pair_state_descr(btm_cb.pairing_state), status); /* if the create conn cancel cmd was issued by the bond cancel, ** the application needs to be notified that bond cancel succeeded @@ -2706,6 +2768,7 @@ void btm_create_conn_cancel_complete (UINT8 *p) *******************************************************************************/ void btm_sec_check_pending_reqs (void) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_QUEUE_ENTRY *p_e; BUFFER_Q bq; @@ -2741,6 +2804,7 @@ void btm_sec_check_pending_reqs (void) GKI_freebuf (p_e); } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2754,9 +2818,11 @@ void btm_sec_check_pending_reqs (void) *******************************************************************************/ void btm_sec_init (UINT8 sec_mode) { +#if (SMP_INCLUDED == TRUE) btm_cb.security_mode = sec_mode; memset (btm_cb.pairing_bda, 0xff, BD_ADDR_LEN); btm_cb.max_collision_delay = BTM_SEC_MAX_COLLISION_DELAY; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2771,8 +2837,10 @@ void btm_sec_init (UINT8 sec_mode) *******************************************************************************/ void btm_sec_device_down (void) { +#if (SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() State: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state)); btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -2838,6 +2906,7 @@ void btm_sec_abort_access_req (BD_ADDR bd_addr) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec) { tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); @@ -2874,9 +2943,9 @@ static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec) p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]); btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ); - return (BTM_CMD_STARTED); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -2890,6 +2959,7 @@ static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec) *******************************************************************************/ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT8 status) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; int i; DEV_CLASS dev_class; @@ -3114,6 +3184,7 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT /* There is no next procedure or start of procedure failed, notify the waiting layer */ btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3160,6 +3231,7 @@ void btm_sec_rmt_host_support_feat_evt (UINT8 *p) *******************************************************************************/ void btm_io_capabilities_req (UINT8 *p) { +#if (SMP_INCLUDED == TRUE) tBTM_SP_IO_REQ evt_data; UINT8 err_code = 0; tBTM_SEC_DEV_REC *p_dev_rec; @@ -3335,6 +3407,7 @@ void btm_io_capabilities_req (UINT8 *p) btsnd_hcic_io_cap_req_reply(evt_data.bd_addr, evt_data.io_cap, evt_data.oob_data, evt_data.auth_req); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3349,6 +3422,7 @@ void btm_io_capabilities_req (UINT8 *p) *******************************************************************************/ void btm_io_capabilities_rsp (UINT8 *p) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SP_IO_RSP evt_data; @@ -3399,6 +3473,7 @@ void btm_io_capabilities_rsp (UINT8 *p) if (btm_cb.api.p_sp_callback) { (*btm_cb.api.p_sp_callback) (BTM_SP_IO_RSP_EVT, (tBTM_SP_EVT_DATA *)&evt_data); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3415,6 +3490,7 @@ void btm_io_capabilities_rsp (UINT8 *p) *******************************************************************************/ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) { +#if (SMP_INCLUDED == TRUE) tBTM_STATUS status = BTM_ERR_PROCESSING; tBTM_SP_EVT_DATA evt_data; UINT8 *p_bda = evt_data.cfm_req.bd_addr; @@ -3526,6 +3602,7 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) btsnd_hcic_user_passkey_neg_reply(p_bda); } #endif +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3566,6 +3643,7 @@ void btm_keypress_notif_evt (UINT8 *p) *******************************************************************************/ void btm_simple_pair_complete (UINT8 *p) { +#if (SMP_INCLUDED == TRUE) tBTM_SP_COMPLT evt_data; tBTM_SEC_DEV_REC *p_dev_rec; UINT8 status; @@ -3623,6 +3701,7 @@ void btm_simple_pair_complete (UINT8 *p) btm_sec_send_hci_disconnect (p_dev_rec, HCI_ERR_AUTH_FAILURE, p_dev_rec->hci_handle); } } +#endif ///SMP_INCLUDED == TRUE } #if BTM_OOB_INCLUDED == TRUE @@ -3710,6 +3789,7 @@ void btm_read_local_oob_complete (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_auth_collision (UINT16 handle) { tBTM_SEC_DEV_REC *p_dev_rec; @@ -3740,6 +3820,7 @@ static void btm_sec_auth_collision (UINT16 handle) } } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -3753,6 +3834,7 @@ static void btm_sec_auth_collision (UINT16 handle) *******************************************************************************/ void btm_sec_auth_complete (UINT16 handle, UINT8 status) { +#if (SMP_INCLUDED == TRUE) UINT8 old_sm4; tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); @@ -3931,6 +4013,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) if (status != BTM_CMD_STARTED) { btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3945,6 +4028,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) *******************************************************************************/ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE tACL_CONN *p_acl = NULL; @@ -4081,6 +4165,7 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) if (status != BTM_CMD_STARTED) { btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4093,6 +4178,7 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) ** Returns Pointer to the TLE struct ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle) { tBTM_SEC_DEV_REC *p_dev_rec = btm_cb.p_collided_dev_rec; @@ -4112,6 +4198,7 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle) p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL); } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -4125,6 +4212,7 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle) *******************************************************************************/ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); UINT8 res; BOOLEAN is_pairing_device = FALSE; @@ -4401,6 +4489,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) } } return; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4414,6 +4503,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) *******************************************************************************/ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); /* In some weird race condition we may not have a record */ @@ -4432,6 +4522,9 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) } return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle)); +#else + return BTM_MODE_UNSUPPORTED; +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4446,6 +4539,7 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) *******************************************************************************/ void btm_sec_disconnected (UINT16 handle, UINT8 reason) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); UINT8 old_pairing_flags = btm_cb.pairing_flags; int result = HCI_ERR_AUTH_FAILURE; @@ -4536,6 +4630,7 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) } BTM_TRACE_EVENT("%s after update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4550,6 +4645,7 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) *******************************************************************************/ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_type) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda); BOOLEAN we_are_bonding = FALSE; BOOLEAN ltk_derived_lk = FALSE; @@ -4664,6 +4760,7 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t } } } +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4677,6 +4774,7 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t *******************************************************************************/ void btm_sec_link_key_request (UINT8 *p_bda) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda); BTM_TRACE_EVENT ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x\n", @@ -4701,6 +4799,7 @@ void btm_sec_link_key_request (UINT8 *p_bda) /* The link key is not in the database and it is not known to the manager */ btsnd_hcic_link_key_neg_reply (p_bda); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4713,6 +4812,7 @@ void btm_sec_link_key_request (UINT8 *p_bda) ** Returns Pointer to the TLE struct ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) { tBTM_CB *p_cb = &btm_cb; @@ -4825,6 +4925,7 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) break; } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -4837,6 +4938,8 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) *******************************************************************************/ void btm_sec_pin_code_request (UINT8 *p_bda) { +#if (SMP_INCLUDED == TRUE) + tBTM_SEC_DEV_REC *p_dev_rec; tBTM_CB *p_cb = &btm_cb; @@ -4988,7 +5091,7 @@ void btm_sec_pin_code_request (UINT8 *p_bda) } } } - +#endif ///SMP_INCLUDED == TRUE return; } @@ -5329,6 +5432,7 @@ BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[]) ** Returns Pointer to the record or NULL ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static tBTM_SEC_SERV_REC *btm_sec_find_first_serv (CONNECTION_TYPE conn_type, UINT16 psm) { tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0]; @@ -5388,7 +5492,6 @@ static tBTM_SEC_SERV_REC *btm_sec_find_next_serv (tBTM_SEC_SERV_REC *p_cur) return (NULL); } - /******************************************************************************* ** ** Function btm_sec_find_mx_serv @@ -5427,7 +5530,7 @@ static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm, } return (NULL); } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5439,6 +5542,7 @@ static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm, ** Returns Pointer to the TLE struct ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle) { UNUSED(p_tle); @@ -5471,6 +5575,7 @@ static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec) p_dev_rec->sec_bd_name, p_dev_rec->link_key, p_dev_rec->link_key_type); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5504,6 +5609,7 @@ UINT32 *BTM_ReadTrustedMask (BD_ADDR bd_addr) ** Parameters: void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_restore_mode(void) { if (btm_cb.security_mode_changed) { @@ -5517,7 +5623,7 @@ static void btm_restore_mode(void) btsnd_hcic_write_pin_type (btm_cb.cfg.pin_type); } } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5531,6 +5637,7 @@ static void btm_restore_mode(void) *******************************************************************************/ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) { +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0]; for (int i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++, p_dev_rec++) { @@ -5539,6 +5646,7 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) return (p_dev_rec); } } +#endif ///SMP_INCLUDED == TRUE return (NULL); } @@ -5551,6 +5659,7 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) *******************************************************************************/ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) { +#if (SMP_INCLUDED == TRUE) tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; BTM_TRACE_EVENT ("%s() Old: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state)); @@ -5583,6 +5692,7 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE); } +#endif ///SMP_INCLUDED == TRUE } @@ -5593,7 +5703,7 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) ** Description Return state description for tracing ** *******************************************************************************/ -#if (BT_USE_TRACES == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) static char *btm_pair_state_descr (tBTM_PAIRING_STATE state) { #if (BT_TRACE_VERBOSE == TRUE) @@ -5655,6 +5765,7 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA ** Description Return state description for tracing ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig, UINT32 mx_proto_id, UINT32 mx_chan_id, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data) @@ -5682,7 +5793,6 @@ static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN return (FALSE); } - static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec) { UINT8 major = (UINT8)(p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK); @@ -5726,6 +5836,7 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec) return rv; } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5829,6 +5940,7 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec) ** Returns TRUE if the service is security mode 4 level 0 service ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_is_serv_level0(UINT16 psm) { if (psm == BT_PSM_SDP) { @@ -5881,6 +5993,7 @@ static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRA p_e = (tBTM_SEC_QUEUE_ENTRY *) GKI_getnext ((void *)p_e); } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5892,13 +6005,14 @@ static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRA ** connections only mode. ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static UINT16 btm_sec_set_serv_level4_flags(UINT16 cur_security, BOOLEAN is_originator) { UINT16 sec_level4_flags = is_originator ? BTM_SEC_OUT_LEVEL4_FLAGS : BTM_SEC_IN_LEVEL4_FLAGS; return cur_security | sec_level4_flags; } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function btm_sec_clear_ble_keys @@ -6022,6 +6136,7 @@ BOOLEAN btm_sec_find_bonded_dev (UINT8 start_idx, UINT8 *p_found_idx, tBTM_SEC_D ** Manager over BR). ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec) { UINT32 ext_feat; @@ -6061,4 +6176,5 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec) tACL_CONN *p = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); return (p && (p->link_role == BTM_ROLE_MASTER)); } +#endif ///SMP_INCLUDED == TRUE diff --git a/components/bt/bluedroid/stack/gap/gap_utils.c b/components/bt/bluedroid/stack/gap/gap_utils.c index d441fa11ec..6e242122db 100644 --- a/components/bt/bluedroid/stack/gap/gap_utils.c +++ b/components/bt/bluedroid/stack/gap/gap_utils.c @@ -21,6 +21,7 @@ //#include "bt_utils.h" #include "gap_int.h" +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function gap_allocate_cb @@ -136,3 +137,5 @@ UINT16 gap_convert_btm_status (tBTM_STATUS btm_status) return (GAP_ERR_PROCESSING); } } + +#endif ///CLASSIC_BT_INCLUDED == TRUE \ No newline at end of file diff --git a/components/bt/bluedroid/stack/include/btm_int.h b/components/bt/bluedroid/stack/include/btm_int.h index 7b7aac9805..c8d86e9ba5 100644 --- a/components/bt/bluedroid/stack/include/btm_int.h +++ b/components/bt/bluedroid/stack/include/btm_int.h @@ -817,9 +817,11 @@ typedef struct { tBTM_APPL_INFO api; #define BTM_SEC_MAX_RMT_NAME_CALLBACKS 2 - tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS]; + tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS]; +#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_collided_dev_rec; +#endif ///SMP_INCLUDED == TRUE TIMER_LIST_ENT sec_collision_tle; UINT32 collision_start_time; UINT32 max_collision_delay; @@ -830,6 +832,7 @@ typedef struct { BOOLEAN security_mode_changed; /* mode changed during bonding */ BOOLEAN pin_type_changed; /* pin type changed during bonding */ BOOLEAN sec_req_pending; /* TRUE if a request is pending */ +#if (SMP_INCLUDED == TRUE) // btla-specific ++ #ifdef PORCHE_PAIRING_CONFLICT UINT8 pin_code_len_saved; /* for legacy devices */ @@ -844,6 +847,7 @@ typedef struct { TIMER_LIST_ENT pairing_tle; /* Timer for pairing process */ UINT16 disc_handle; /* for legacy devices */ UINT8 disc_reason; /* for legacy devices */ +#endif ///SMP_INCLUDED == TRUE tBTM_SEC_SERV_REC sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS]; tBTM_SEC_DEV_REC sec_dev_rec[BTM_SEC_MAX_DEVICE_RECORDS]; tBTM_SEC_SERV_REC *p_out_serv; @@ -861,7 +865,6 @@ typedef struct { BOOLEAN paging; BOOLEAN discing; BUFFER_Q sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */ - #if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE)) char state_temp_buffer[BTM_STATE_BUFFER_SIZE]; #endif From 27235044738daaa7f81599f2af5080c0af1424fd Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 19 Apr 2017 05:16:24 -0400 Subject: [PATCH 04/15] add the GATTC_INCLUDED marco to close the bta_gattc module when not used the GATTC --- components/bt/bluedroid/api/esp_gattc_api.c | 3 ++ components/bt/bluedroid/bta/dm/bta_dm_act.c | 38 +++++++++---------- components/bt/bluedroid/bta/dm/bta_dm_int.h | 2 +- components/bt/bluedroid/bta/dm/bta_dm_main.c | 2 +- .../bt/bluedroid/bta/gatt/bta_gattc_act.c | 4 +- .../bt/bluedroid/bta/gatt/bta_gattc_api.c | 2 +- .../bt/bluedroid/bta/gatt/bta_gattc_cache.c | 4 +- .../bt/bluedroid/bta/gatt/bta_gattc_ci.c | 4 +- .../bt/bluedroid/bta/gatt/bta_gattc_main.c | 4 +- .../bt/bluedroid/bta/gatt/bta_gattc_utils.c | 2 +- components/bt/bluedroid/btc/core/btc_task.c | 2 + .../bt/bluedroid/btc/include/btc_task.h | 2 + .../btc/profile/std/gatt/btc_gattc.c | 3 ++ components/bt/bluedroid/btif/bta_gattc_co.c | 2 +- components/bt/bluedroid/include/bt_target.h | 2 +- 15 files changed, 43 insertions(+), 33 deletions(-) diff --git a/components/bt/bluedroid/api/esp_gattc_api.c b/components/bt/bluedroid/api/esp_gattc_api.c index 4f68d81cc0..bfe7db4654 100644 --- a/components/bt/bluedroid/api/esp_gattc_api.c +++ b/components/bt/bluedroid/api/esp_gattc_api.c @@ -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 + diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 0fcc503c8f..f5fea540be 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -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 diff --git a/components/bt/bluedroid/bta/dm/bta_dm_int.h b/components/bt/bluedroid/bta/dm/bta_dm_int.h index f524c6df58..acfbc7c79a 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/bta_dm_int.h @@ -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; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index 25c4978538..905b25a779 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -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 }; diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c index f03b545e1b..41008cb2d6 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c @@ -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 diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/bluedroid/bta/gatt/bta_gattc_api.c index b791538d78..beaa235ded 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_api.c @@ -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 #include "gki.h" diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c index b887cb3282..205060f95e 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c @@ -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 #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 */ diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_ci.c b/components/bt/bluedroid/bta/gatt/bta_gattc_ci.c index 295c251bb4..8c94a991c1 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_ci.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_ci.c @@ -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 @@ -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 */ diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_main.c b/components/bt/bluedroid/bta/gatt/bta_gattc_main.c index f13e3f0a1b..057e35813e 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_main.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_main.c @@ -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 @@ -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 */ diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c index 0a020d3d63..a9d512b73c 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c @@ -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 diff --git a/components/bt/bluedroid/btc/core/btc_task.c b/components/bt/bluedroid/btc/core/btc_task.c index d576fdd762..98ff872728 100644 --- a/components/bt/bluedroid/btc/core/btc_task.c +++ b/components/bt/bluedroid/btc/core/btc_task.c @@ -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}, diff --git a/components/bt/bluedroid/btc/include/btc_task.h b/components/bt/bluedroid/btc/include/btc_task.h index bb89969746..36a4757bf6 100644 --- a/components/bt/bluedroid/btc/include/btc_task.h +++ b/components/bt/bluedroid/btc/include/btc_task.h @@ -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, diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c index 71e01c76e0..5a7a5b2f67 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -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 diff --git a/components/bt/bluedroid/btif/bta_gattc_co.c b/components/bt/bluedroid/btif/bta_gattc_co.c index 2a255885ad..380b7932b7 100644 --- a/components/bt/bluedroid/btif/bta_gattc_co.c +++ b/components/bt/bluedroid/btif/bta_gattc_co.c @@ -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_" diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index 5cf0d79f1b..b5dd88a987 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -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 From 67863ec49554fa05397eb5740bf06ca0163ef866 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 19 Apr 2017 08:06:38 -0400 Subject: [PATCH 05/15] component/bt:Added the GATTS_INCLUDED macro to the bta layer --- examples/bluetooth/gatt_client/main/gattc_demo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/bluetooth/gatt_client/main/gattc_demo.c b/examples/bluetooth/gatt_client/main/gattc_demo.c index 2d852c8312..adbadcfc93 100644 --- a/examples/bluetooth/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/gatt_client/main/gattc_demo.c @@ -287,11 +287,12 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { uint8_t *adv_name = NULL; + char adv_name_char[31] = {0}; uint8_t adv_name_len = 0; switch (event) { case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: { //the unit of the duration is second - uint32_t duration = 10; + uint32_t duration = 30; esp_ble_gap_start_scanning(duration); break; } @@ -316,9 +317,9 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par for (int j = 0; j < adv_name_len; j++) { ESP_LOGI(GATTC_TAG, "%c", adv_name[j]); } - + memcpy(adv_name_char, adv_name, adv_name_len); if (adv_name != NULL) { - if (strcmp((char *)adv_name, device_name) == 0) { + if (strcmp(adv_name_char, device_name) == 0) { ESP_LOGI(GATTC_TAG, "Searched device %s", device_name); if (connect == false) { connect = true; From bc807a18d1b1265f45684384d18a045effc48461 Mon Sep 17 00:00:00 2001 From: Yulong Date: Thu, 20 Apr 2017 07:18:05 -0400 Subject: [PATCH 06/15] component/bt:Finish all the separate code from BT & BLE --- components/bt/Kconfig | 28 +++++++++++++++++++ components/bt/bluedroid/api/esp_gatts_api.c | 5 +++- components/bt/bluedroid/bta/dm/bta_dm_act.c | 6 +++- .../bt/bluedroid/bta/gatt/bta_gatts_act.c | 4 +-- .../bt/bluedroid/bta/gatt/bta_gatts_api.c | 2 +- .../bt/bluedroid/bta/gatt/bta_gatts_main.c | 4 +-- .../bt/bluedroid/bta/gatt/bta_gatts_utils.c | 4 +-- .../bt/bluedroid/bta/include/bta_gatt_api.h | 2 +- components/bt/bluedroid/btc/core/btc_task.c | 4 +++ .../btc/profile/esp/blufi/blufi_prf.c | 4 +++ .../btc/profile/esp/blufi/blufi_protocol.c | 3 ++ .../btc/profile/std/gatt/btc_gatts.c | 4 +++ components/bt/bluedroid/btif/bta_gatts_co.c | 2 +- .../bt/bluedroid/device/include/interop.h | 1 + components/bt/bluedroid/device/interop.c | 3 +- components/bt/bluedroid/hci/hci_hal_h4.c | 2 +- components/bt/bluedroid/include/bt_target.h | 25 +++++++++++++++-- components/bt/bluedroid/include/bt_trace.h | 10 +++---- .../bt/bluedroid/stack/btm/btm_ble_gap.c | 4 +-- components/bt/bluedroid/stack/btu/btu_init.c | 2 +- components/bt/bluedroid/stack/gap/gap_api.c | 2 +- components/bt/bluedroid/stack/gap/gap_ble.c | 7 +++-- .../bt/bluedroid/stack/gap/include/gap_int.h | 4 +-- components/bt/bluedroid/stack/gatt/gatt_api.c | 23 ++++++++++----- .../bt/bluedroid/stack/gatt/gatt_attr.c | 15 ++++++++-- .../bt/bluedroid/stack/gatt/gatt_auth.c | 11 ++++++-- components/bt/bluedroid/stack/gatt/gatt_cl.c | 4 +-- components/bt/bluedroid/stack/gatt/gatt_db.c | 4 +-- .../bt/bluedroid/stack/gatt/gatt_main.c | 13 ++++++++- components/bt/bluedroid/stack/gatt/gatt_sr.c | 6 ++-- .../bt/bluedroid/stack/gatt/gatt_utils.c | 25 +++++++++++++---- .../bluedroid/stack/gatt/include/gatt_int.h | 8 ++++-- .../bt/bluedroid/stack/l2cap/l2c_link.c | 2 +- .../bt/bluedroid/stack/l2cap/l2c_utils.c | 3 +- 34 files changed, 188 insertions(+), 58 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index da1d98055d..947142666f 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -38,6 +38,34 @@ config BT_DRAM_RELEASE Enabling this option will release about 30K DRAM from Classic BT. The released DRAM will be used as system heap memory. +config GATTS_ENABLE + bool "Set if enable the gatt server module(GATTS) in the stack or not" + depends on BLUEDROID_ENABLED + default y + help + This option can be close when the app work only on gatt client mode + +config GATTC_ENABLE + bool "Set if enable the gatt server module(GATTC) in the stack or not" + depends on BLUEDROID_ENABLED + default y + help + This option can be close when the app work only on gatt server mode + +config SMP_ENABLE + bool "Set if enable the ble security module (SMP module) or not" + depends on BLUEDROID_ENABLED + default y + help + This option can be close when the app not used the ble security connect. + +config BT_ACL_CONNECTIONS + int "Set the max connection number for the bt/ble device can accept, up to 7." + depends on BLUEDROID_ENABLED + default 4 + help + This setting is used for the max connection link for the bt/ble device + config BT_STACK_NO_LOG bool "Close the bluedroid bt stack log print" depends on BLUEDROID_ENABLED diff --git a/components/bt/bluedroid/api/esp_gatts_api.c b/components/bt/bluedroid/api/esp_gatts_api.c index 318dd25bf2..47b8f947a7 100644 --- a/components/bt/bluedroid/api/esp_gatts_api.c +++ b/components/bt/bluedroid/api/esp_gatts_api.c @@ -19,7 +19,8 @@ #include "btc_manage.h" #include "btc_gatts.h" #include "btc_gatt_util.h" - +#include "bt_target.h" +#if (GATTS_INCLUDED == TRUE) #define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type)) @@ -399,3 +400,5 @@ esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } + +#endif ///GATTS_INCLUDED \ No newline at end of file diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index f5fea540be..9af44bfc0c 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -81,7 +81,9 @@ static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); static void bta_dm_adjust_roles(BOOLEAN delay_role_switch); +#if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE) static char *bta_dm_get_remname(void); +#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result); static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport); @@ -2473,7 +2475,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name) BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback); -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE if (bta_dm_search_cb.transport == BT_TRANSPORT_LE ) { GAP_BleReadPeerPrefConnParams (bta_dm_search_cb.peer_bdaddr); } @@ -3492,6 +3494,7 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch) ** ** Returns char * - Pointer to the remote device name *******************************************************************************/ +#if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE) static char *bta_dm_get_remname(void) { char *p_name = (char *)bta_dm_search_cb.peer_name; @@ -3505,6 +3508,7 @@ static char *bta_dm_get_remname(void) return p_name; } +#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c index 83d5e4d7d7..6d75b864a0 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c @@ -26,7 +26,7 @@ #include "bt_target.h" -#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) +#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE) #include "utl.h" #include "gki.h" @@ -963,4 +963,4 @@ static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested) } } } -#endif /* BTA_GATT_INCLUDED */ +#endif /* GATTS_INCLUDED */ diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_api.c b/components/bt/bluedroid/bta/gatt/bta_gatts_api.c index 94f1d407e8..c56a9fa58a 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_api.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_api.c @@ -24,7 +24,7 @@ #include "bt_target.h" -#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) +#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE) #include #include "gki.h" diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_main.c b/components/bt/bluedroid/bta/gatt/bta_gatts_main.c index 4306709c8c..1340b13995 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_main.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_main.c @@ -24,7 +24,7 @@ #include "bt_target.h" -#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) +#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE) #include @@ -136,4 +136,4 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg) return (TRUE); } -#endif /* BTA_GATT_INCLUDED */ +#endif /* GATTS_INCLUDED */ diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_utils.c b/components/bt/bluedroid/bta/gatt/bta_gatts_utils.c index b79bdd0bcb..1904d74985 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_utils.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_utils.c @@ -24,7 +24,7 @@ #include "bt_target.h" -#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) +#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE) #include #include "utl.h" @@ -222,4 +222,4 @@ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src) -#endif +#endif /* GATTS_INCLUDED */ \ No newline at end of file diff --git a/components/bt/bluedroid/bta/include/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta_gatt_api.h index 40b661c2ef..f4c0e06f07 100644 --- a/components/bt/bluedroid/bta/include/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta_gatt_api.h @@ -40,7 +40,7 @@ #ifndef BTA_GATT_DEBUG -#define BTA_GATT_DEBUG TRUE +#define BTA_GATT_DEBUG FALSE #endif /***************************************************************************** diff --git a/components/bt/bluedroid/btc/core/btc_task.c b/components/bt/bluedroid/btc/core/btc_task.c index 98ff872728..40a08e44a1 100644 --- a/components/bt/bluedroid/btc/core/btc_task.c +++ b/components/bt/bluedroid/btc/core/btc_task.c @@ -41,14 +41,18 @@ static xQueueHandle xBtcQueue = 0; 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 }, +#if (GATTS_INCLUDED == TRUE) [BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler }, +#endif ///GATTS_INCLUDED == TRUE #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}, +#if (GATTS_INCLUDED == TRUE) [BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler }, +#endif ///GATTS_INCLUDED == TRUE [BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler }, #if CONFIG_CLASSIC_BT_ENABLED [BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL }, diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c index 7379192577..cf6e233056 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c @@ -35,6 +35,8 @@ #include "esp_blufi_api.h" +#if (GATTS_INCLUDED == TRUE) + #define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" #define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] @@ -915,3 +917,5 @@ uint16_t btc_blufi_get_version(void) { return BTC_BLUFI_VERSION; } + +#endif ///GATTS_INCLUDED == TRUE diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c index d4d617f000..c66649bf09 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c @@ -35,6 +35,7 @@ #include "esp_wifi.h" +#if (GATTS_INCLUDED == TRUE) extern tBLUFI_ENV blufi_env; void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len) @@ -247,3 +248,5 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len) break; } } + +#endif ///(GATTS_INCLUDED == TRUE) diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c index d2d6583933..4dcf8b8179 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -24,6 +24,8 @@ #include "btc_main.h" #include "esp_gatts_api.h" +#if (GATTS_INCLUDED == TRUE) + #define A2C_GATTS_EVT(_bta_event) (_bta_event) //BTA TO BTC EVT #define C2A_GATTS_EVT(_btc_event) (_btc_event) //BTC TO BTA EVT @@ -779,3 +781,5 @@ void btc_gatts_cb_handler(btc_msg_t *msg) btc_gatts_cb_param_copy_free(msg, p_data); } + +#endif ///GATTS_INCLUDED \ No newline at end of file diff --git a/components/bt/bluedroid/btif/bta_gatts_co.c b/components/bt/bluedroid/btif/bta_gatts_co.c index d6f0ca7317..77b6c35b15 100644 --- a/components/bt/bluedroid/btif/bta_gatts_co.c +++ b/components/bt/bluedroid/btif/bta_gatts_co.c @@ -19,7 +19,7 @@ #include "bta_api.h" #if( defined BLE_INCLUDED ) && (BLE_INCLUDED == TRUE) -#if( defined BTA_GATT_INCLUDED ) && (BTA_GATT_INCLUDED == TRUE) +#if( defined GATTS_INCLUDED ) && (GATTS_INCLUDED == TRUE) #include #include diff --git a/components/bt/bluedroid/device/include/interop.h b/components/bt/bluedroid/device/include/interop.h index 74394d95d4..a90c44ad29 100644 --- a/components/bt/bluedroid/device/include/interop.h +++ b/components/bt/bluedroid/device/include/interop.h @@ -21,6 +21,7 @@ #include #include "bt_defs.h" +#include "bt_target.h" typedef enum { // Disable secure connections diff --git a/components/bt/bluedroid/device/interop.c b/components/bt/bluedroid/device/interop.c index ffcbc0fe71..18d2a84fb7 100644 --- a/components/bt/bluedroid/device/interop.c +++ b/components/bt/bluedroid/device/interop.c @@ -26,6 +26,7 @@ #define CASE_RETURN_STR(const) case const: return #const; +#if (SMP_INCLUDED == TRUE) static const char *interop_feature_string(const interop_feature_t feature) { switch (feature) { @@ -37,7 +38,6 @@ static const char *interop_feature_string(const interop_feature_t feature) } // Interface functions - bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr) { assert(addr); @@ -56,3 +56,4 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr) return false; } +#endif ///SMP_INCLUDED == TRUE diff --git a/components/bt/bluedroid/hci/hci_hal_h4.c b/components/bt/bluedroid/hci/hci_hal_h4.c index f26365e3ac..021137511c 100644 --- a/components/bt/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/bluedroid/hci/hci_hal_h4.c @@ -195,7 +195,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) packet->offset++; packet->len--; if (type == HCI_BLE_EVENT) { - uint8_t len; + uint8_t len = 0; STREAM_TO_UINT8(len, stream); LOG_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n", packet->len, len); diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index b5dd88a987..7c3517bf1f 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -91,6 +91,27 @@ #endif /* #if CONFIG_CLASSIC_BT_ENABLED */ +#if (CONFIG_GATTS_ENABLE) +#define GATTS_INCLUDED TRUE +#else +#define GATTS_INCLUDED FALSE +#endif /* CONFIG_GATTS_ENABLE */ + +#if (CONFIG_GATTC_ENABLE) +#define GATTC_INCLUDED TRUE +#else +#define GATTC_INCLUDED FALSE +#endif /* CONFIG_GATTC_ENABLE */ + +#if (CONFIG_SMP_ENABLE) +#define SMP_INCLUDED TRUE +#define BLE_PRIVACY_SPT TRUE +#else +#define SMP_INCLUDED FALSE +#define BLE_PRIVACY_SPT FALSE +#endif /* CONFIG_GATTC_ENABLE */ + + //------------------Added from bdroid_buildcfg.h--------------------- #ifndef L2CAP_EXTFEA_SUPPORTED_MASK #define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS) @@ -479,7 +500,7 @@ /* The size in bytes of the BTM inquiry database. 40 As Default */ #ifndef BTM_INQ_DB_SIZE -#define BTM_INQ_DB_SIZE 1//32 +#define BTM_INQ_DB_SIZE 5//32 #endif /* The default scan mode */ @@ -803,7 +824,7 @@ #if (CLASSIC_BT_INCLUDED == TRUE) #define L2CAP_NUM_FIXED_CHNLS 32 #else -#define L2CAP_NUM_FIXED_CHNLS 2 //There are just two fix channel in the BLE only mode(gatt,smp) +#define L2CAP_NUM_FIXED_CHNLS 3 //There are just three fix channel in the BLE only mode(gatt,signal,smp) #endif ///CLASSIC_BT_INCLUDED == TRUE #endif diff --git a/components/bt/bluedroid/include/bt_trace.h b/components/bt/bluedroid/include/bt_trace.h index 6a1f848309..6324adf95f 100644 --- a/components/bt/bluedroid/include/bt_trace.h +++ b/components/bt/bluedroid/include/bt_trace.h @@ -171,7 +171,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) /* Enables or disables all trace messages. */ #ifndef BT_USE_TRACES -#define BT_USE_TRACES TRUE +#define BT_USE_TRACES FALSE #endif /****************************************************************************** @@ -194,11 +194,11 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef BTM_INITIAL_TRACE_LEVEL -#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG +#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif #ifndef L2CAP_INITIAL_TRACE_LEVEL -#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG +#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif #ifndef RFCOMM_INITIAL_TRACE_LEVEL @@ -246,7 +246,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef APPL_INITIAL_TRACE_LEVEL -#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG +#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif #ifndef BT_TRACE_APPL @@ -254,7 +254,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #endif #ifndef GATT_INITIAL_TRACE_LEVEL -#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG +#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif #ifndef SMP_INITIAL_TRACE_LEVEL diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index c2b356fc7c..49f491f06c 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -2165,7 +2165,7 @@ tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, t return BTM_BUSY; } -#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE) +#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) if (!GAP_BleReadPeerDevName(remote_bda, btm_ble_read_remote_name_cmpl)) { return BTM_BUSY; } @@ -2199,7 +2199,7 @@ BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda) tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars; BOOLEAN status = TRUE; -#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE) +#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) status = GAP_BleCancelReadPeerDevName(remote_bda); #endif diff --git a/components/bt/bluedroid/stack/btu/btu_init.c b/components/bt/bluedroid/stack/btu/btu_init.c index 2ed561bcf2..03a03f6e95 100644 --- a/components/bt/bluedroid/stack/btu/btu_init.c +++ b/components/bt/bluedroid/stack/btu/btu_init.c @@ -133,7 +133,7 @@ void btu_free_core(void) l2c_free(); #if BLE_INCLUDED == TRUE -#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true) +#if (defined(GATTS_INCLUDED) && GATTS_INCLUDED == true) gatt_free(); #endif #endif diff --git a/components/bt/bluedroid/stack/gap/gap_api.c b/components/bt/bluedroid/stack/gap/gap_api.c index aff689c340..32fa3b5407 100644 --- a/components/bt/bluedroid/stack/gap/gap_api.c +++ b/components/bt/bluedroid/stack/gap/gap_api.c @@ -69,7 +69,7 @@ void GAP_Init(void) gap_conn_init(); #endif -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE gap_attr_db_init(); #endif } diff --git a/components/bt/bluedroid/stack/gap/gap_ble.c b/components/bt/bluedroid/stack/gap/gap_ble.c index bf9ea08369..b81bae4c49 100644 --- a/components/bt/bluedroid/stack/gap/gap_ble.c +++ b/components/bt/bluedroid/stack/gap/gap_ble.c @@ -17,7 +17,7 @@ ******************************************************************************/ #include "bt_target.h" -#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) +#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) #include "bt_defs.h" #include @@ -513,11 +513,12 @@ BOOLEAN gap_ble_send_cl_read_request(tGAP_CLCB *p_clcb) param.service.s_handle = 1; param.service.e_handle = 0xFFFF; param.service.auth_req = 0; - +#if (GATTC_INCLUDED == TRUE) if (GATTC_Read(p_clcb->conn_id, GATT_READ_BY_TYPE, ¶m) == GATT_SUCCESS) { p_clcb->cl_op_uuid = uuid; started = TRUE; } +#endif ///GATTC_INCLUDED == TRUE } return started; @@ -784,7 +785,7 @@ BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda) return (TRUE); } -#endif /* BLE_INCLUDED */ +#endif /* BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE*/ diff --git a/components/bt/bluedroid/stack/gap/include/gap_int.h b/components/bt/bluedroid/stack/gap/include/gap_int.h index af7acf231a..f05b0ce292 100644 --- a/components/bt/bluedroid/stack/gap/include/gap_int.h +++ b/components/bt/bluedroid/stack/gap/include/gap_int.h @@ -135,7 +135,7 @@ typedef struct { #endif /* LE GAP attribute database */ -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM]; tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/ tGATT_IF gatt_if; @@ -147,7 +147,7 @@ extern tGAP_CB gap_cb; #if (GAP_CONN_INCLUDED == TRUE) extern void gap_conn_init(void); #endif -#if (BLE_INCLUDED == TRUE) +#if (BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) extern void gap_attr_db_init(void); #endif diff --git a/components/bt/bluedroid/stack/gatt/gatt_api.c b/components/bt/bluedroid/stack/gatt/gatt_api.c index 5beffe8753..ea39008cbb 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/bluedroid/stack/gatt/gatt_api.c @@ -65,6 +65,8 @@ UINT8 GATT_SetTraceLevel (UINT8 new_level) return (gatt_cb.trace_level); } + +#if (GATTS_INCLUDED == TRUE) /***************************************************************************** ** ** GATT SERVER API @@ -440,7 +442,9 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, tGATT_SR_REG *p_sreg; tGATT_HDL_LIST_ELEM *p_list = NULL; UINT8 i_sreg; +#if (SDP_INCLUDED == TRUE) tBT_UUID *p_uuid; +#endif ///SDP_INCLUDED == TRUE tGATT_REG *p_reg = gatt_get_regcb(gatt_if); tGATTS_PENDING_NEW_SRV_START *p_buf; @@ -479,8 +483,8 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, case GATT_TRANSPORT_BR_EDR: case GATT_TRANSPORT_LE_BR_EDR: if (p_sreg->type == GATT_UUID_PRI_SERVICE) { - p_uuid = gatts_get_service_uuid (p_sreg->p_db); #if (SDP_INCLUDED == TRUE) + p_uuid = gatts_get_service_uuid (p_sreg->p_db); p_sreg->sdp_handle = gatt_add_sdp_record(p_uuid, p_sreg->s_hdl, p_sreg->e_hdl); #endif ///SDP_INCLUDED == TRUE } @@ -761,7 +765,10 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 * status = gatts_get_attribute_value(&p_decl->svc_db, attr_handle, length, value); return status; } +#endif ///GATTS_INCLUDED == TRUE + +#if (GATTC_INCLUDED == TRUE) /*******************************************************************************/ /* GATT Profile Srvr Functions */ /*******************************************************************************/ @@ -1115,6 +1122,7 @@ tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle) return ret; } +#endif ///GATTC_INCLUDED == TRUE /*******************************************************************************/ /* */ @@ -1218,10 +1226,12 @@ void GATT_Deregister (tGATT_IF gatt_if) { tGATT_REG *p_reg = gatt_get_regcb(gatt_if); tGATT_TCB *p_tcb; - tGATT_CLCB *p_clcb; - UINT8 i, ii, j; + tGATT_CLCB *p_clcb; + UINT8 i, j; +#if (GATTS_INCLUDED == TRUE) + UINT8 ii; tGATT_SR_REG *p_sreg; - +#endif ///GATTS_INCLUDED == TRUE GATT_TRACE_API ("GATT_Deregister gatt_if=%d", gatt_if); /* Index 0 is GAP and is never deregistered */ if ( (gatt_if == 0) || (p_reg == NULL) ) { @@ -1233,16 +1243,15 @@ void GATT_Deregister (tGATT_IF gatt_if) /* todo an applcaiton can not be deregistered if its services is also used by other application deregisteration need to bed performed in an orderly fashion no check for now */ - +#if (GATTS_INCLUDED == TRUE) for (ii = 0, p_sreg = gatt_cb.sr_reg; ii < GATT_MAX_SR_PROFILES; ii++, p_sreg++) { if (p_sreg->in_use && (p_sreg->gatt_if == gatt_if)) { GATTS_StopService(p_sreg->s_hdl); } } - /* free all services db buffers if owned by this application */ gatt_free_srvc_db_buffer_app_id(&p_reg->app_uuid128); - +#endif ///GATTS_INCLUDED == TRUE /* When an application deregisters, check remove the link associated with the app */ for (i = 0, p_tcb = gatt_cb.tcb; i < GATT_MAX_PHY_CHANNEL; i++, p_tcb++) { diff --git a/components/bt/bluedroid/stack/gatt/gatt_attr.c b/components/bt/bluedroid/stack/gatt/gatt_attr.c index 421b17cab7..9d83bde333 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_attr.c +++ b/components/bt/bluedroid/stack/gatt/gatt_attr.c @@ -30,7 +30,7 @@ #include "gatt_int.h" #include "sdpdefs.h" -#if BLE_INCLUDED == TRUE +#if (BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) #define GATTP_MAX_NUM_INC_SVR 0 #define GATTP_MAX_CHAR_NUM 2 @@ -71,13 +71,14 @@ static tGATT_CBACK gatt_profile_cback = { ** Returns Connection ID ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR remote_bda) { UINT16 conn_id = GATT_INVALID_CONN_ID; GATT_GetConnIdIfConnected (gatt_cb.gatt_if, remote_bda, &conn_id, BT_TRANSPORT_LE); return conn_id; } - +#endif ///GATTS_INCLUDED == TRUE /******************************************************************************* ** ** Function gatt_profile_find_clcb_by_conn_id @@ -431,10 +432,12 @@ static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB *p_clcb) srvc_disc_param.e_handle = 0xffff; srvc_disc_param.service.len = 2; srvc_disc_param.service.uu.uuid16 = UUID_SERVCLASS_GATT_SERVER; +#if (GATTC_INCLUDED == TRUE) if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_SRVC_BY_UUID, &srvc_disc_param) != GATT_SUCCESS) { GATT_TRACE_ERROR("%s() - ccc service error", __FUNCTION__); gatt_config_ccc_complete(p_clcb); } +#endif ///GATTC_INCLUDED == TRUE break; case GATT_SVC_CHANGED_CHARACTERISTIC: /* discover service change char */ @@ -442,29 +445,35 @@ static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB *p_clcb) srvc_disc_param.e_handle = p_clcb->e_handle; srvc_disc_param.service.len = 2; srvc_disc_param.service.uu.uuid16 = GATT_UUID_GATT_SRV_CHGD; +#if (GATTC_INCLUDED == TRUE) if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_CHAR, &srvc_disc_param) != GATT_SUCCESS) { GATT_TRACE_ERROR("%s() - ccc char error", __FUNCTION__); gatt_config_ccc_complete(p_clcb); } +#endif ///GATTC_INCLUDED == TRUE break; case GATT_SVC_CHANGED_DESCRIPTOR: /* discover service change ccc */ srvc_disc_param.s_handle = p_clcb->s_handle; srvc_disc_param.e_handle = p_clcb->e_handle; +#if (GATTC_INCLUDED == TRUE) if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_CHAR_DSCPT, &srvc_disc_param) != GATT_SUCCESS) { GATT_TRACE_ERROR("%s() - ccc char descriptor error", __FUNCTION__); gatt_config_ccc_complete(p_clcb); } +#endif ///GATTC_INCLUDED == TRUE break; case GATT_SVC_CHANGED_CONFIGURE_CCCD: /* write ccc */ ccc_value.handle = p_clcb->s_handle; ccc_value.len = 2; ccc_value.value[0] = GATT_CLT_CONFIG_INDICATION; +#if (GATTC_INCLUDED == TRUE) if (GATTC_Write (p_clcb->conn_id, GATT_WRITE, &ccc_value) != GATT_SUCCESS) { GATT_TRACE_ERROR("%s() - write ccc error", __FUNCTION__); gatt_config_ccc_complete(p_clcb); } +#endif ///GATTC_INCLUDED == TRUE break; } } @@ -506,4 +515,4 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP gatt_cl_start_config_ccc(p_clcb); } -#endif /* BLE_INCLUDED */ +#endif /* BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/stack/gatt/gatt_auth.c b/components/bt/bluedroid/stack/gatt/gatt_auth.c index 09f686bb95..69934dd8bd 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_auth.c +++ b/components/bt/bluedroid/stack/gatt/gatt_auth.c @@ -72,7 +72,9 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb) p_signature)) { p_attr->len += BTM_BLE_AUTH_SIGN_LEN; gatt_set_ch_state(p_clcb->p_tcb, GATT_CH_OPEN); +#if (GATTC_INCLUDED == TRUE) gatt_act_write(p_clcb, GATT_SEC_SIGN_DATA); +#endif ///GATTC_INCLUDED == TRUE } else { gatt_end_operation(p_clcb, GATT_INTERNAL_ERROR, NULL); } @@ -96,7 +98,9 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb) void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) { UINT16 cmd_len; +#if (GATTS_INCLUDED == TRUE) UINT8 op_code; +#endif ///GATTS_INCLUDED == TRUE UINT8 *p, *p_orig = (UINT8 *)(p_buf + 1) + p_buf->offset; UINT32 counter; @@ -110,8 +114,10 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) STREAM_TO_UINT32(counter, p); if (BTM_BleVerifySignature(p_tcb->peer_bda, p_orig, cmd_len, counter, p)) { +#if (GATTS_INCLUDED == TRUE) STREAM_TO_UINT8(op_code, p_orig); gatt_server_handle_client_req (p_tcb, op_code, (UINT16)(p_buf->len - 1), p_orig); +#endif ///GATTS_INCLUDED == TRUE } else { /* if this is a bad signature, assume from attacker, ignore it */ GATT_TRACE_ERROR("Signature Verification Failed, data ignored"); @@ -133,14 +139,15 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s if (p_clcb && p_clcb->p_tcb && GKI_queue_is_empty(&p_clcb->p_tcb->pending_enc_clcb)) { gatt_set_sec_act(p_clcb->p_tcb, GATT_SEC_NONE); } - +#if (GATTC_INCLUDED == TRUE) if (!sec_check_ok) { gatt_end_operation(p_clcb, GATT_AUTH_FAIL, NULL); } else if (p_clcb->operation == GATTC_OPTYPE_WRITE) { gatt_act_write(p_clcb, sec_act); } else if (p_clcb->operation == GATTC_OPTYPE_READ) { gatt_act_read(p_clcb, p_clcb->counter); - } + } +#endif ///GATTC_INCLUDED == TRUE } /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/gatt/gatt_cl.c b/components/bt/bluedroid/stack/gatt/gatt_cl.c index fab35d5f03..753c44bbca 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_cl.c +++ b/components/bt/bluedroid/stack/gatt/gatt_cl.c @@ -24,7 +24,7 @@ #include "bt_target.h" -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE #include //#include "bt_utils.h" @@ -1162,4 +1162,4 @@ void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code, return; } -#endif /* BLE_INCLUDED */ +#endif /* BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/stack/gatt/gatt_db.c b/components/bt/bluedroid/stack/gatt/gatt_db.c index bb7c7ac974..1379b43b72 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_db.c +++ b/components/bt/bluedroid/stack/gatt/gatt_db.c @@ -24,7 +24,7 @@ #include "bt_target.h" -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE #include "bt_trace.h" //#include "bt_utils.h" @@ -1465,4 +1465,4 @@ static BOOLEAN gatts_db_add_service_declaration(tGATT_SVC_DB *p_db, tBT_UUID *p_ return rt; } -#endif /* BLE_INCLUDED */ +#endif /* BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/stack/gatt/gatt_main.c b/components/bt/bluedroid/stack/gatt/gatt_main.c index 0a69ff1259..14a963500a 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/bluedroid/stack/gatt/gatt_main.c @@ -132,7 +132,9 @@ void gatt_init (void) gatt_cb.hdl_cfg.gatt_start_hdl = GATT_GATT_START_HANDLE; gatt_cb.hdl_cfg.gap_start_hdl = GATT_GAP_START_HANDLE; gatt_cb.hdl_cfg.app_start_hdl = GATT_APP_START_HANDLE; +#if (GATTS_INCLUDED == TRUE) gatt_profile_db_init(); +#endif ///GATTS_INCLUDED == TRUE } @@ -146,6 +148,7 @@ void gatt_init (void) ** Returns void ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) void gatt_free(void) { int i; @@ -154,6 +157,7 @@ void gatt_free(void) gatt_free_hdl_buffer(&gatt_cb.hdl_list[i]); } } +#endif ///GATTS_INCLUDED == TRUE /******************************************************************************* ** @@ -450,11 +454,12 @@ static void gatt_channel_congestion(tGATT_TCB *p_tcb, BOOLEAN congested) UINT8 i = 0; tGATT_REG *p_reg = NULL; UINT16 conn_id; - +#if (GATTC_INCLUDED == TRUE) /* if uncongested, check to see if there is any more pending data */ if (p_tcb != NULL && congested == FALSE) { gatt_cl_send_next_cmd_inq(p_tcb); } +#endif ///GATTC_INCLUDED == TRUE /* notifying all applications for the connection up event */ for (i = 0, p_reg = gatt_cb.cl_rcb ; i < GATT_MAX_APPS; i++, p_reg++) { if (p_reg->in_use) { @@ -929,9 +934,13 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf) } else { /* message from client */ if ((op_code % 2) == 0) { +#if (GATTS_INCLUDED == TRUE) gatt_server_handle_client_req (p_tcb, op_code, msg_len, p); +#endif ///GATTS_INCLUDED == TRUE } else { +#if (GATTC_INCLUDED == TRUE) gatt_client_handle_server_rsp (p_tcb, op_code, msg_len, p); +#endif ///GATTC_INCLUDED == TRUE } } } else { @@ -981,6 +990,7 @@ void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda) *******************************************************************************/ void gatt_send_srv_chg_ind (BD_ADDR peer_bda) { +#if (GATTS_INCLUDED == TRUE) UINT8 handle_range[GATT_SIZE_OF_SRV_CHG_HNDL_RANGE]; UINT8 *p = handle_range; UINT16 conn_id; @@ -1001,6 +1011,7 @@ void gatt_send_srv_chg_ind (BD_ADDR peer_bda) (peer_bda[4] << 8) + peer_bda[5] ); } } +#endif ///GATTS_INCLUDED == TRUE } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/gatt/gatt_sr.c b/components/bt/bluedroid/stack/gatt/gatt_sr.c index 79d518398c..a35c3717c6 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_sr.c +++ b/components/bt/bluedroid/stack/gatt/gatt_sr.c @@ -25,7 +25,7 @@ #include "bt_target.h" //#include "bt_utils.h" -#if BLE_INCLUDED == TRUE +#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE #include #include "gatt_int.h" #include "l2c_api.h" @@ -1491,6 +1491,7 @@ static void gatts_proc_srv_chg_ind_ack(tGATT_TCB *p_tcb ) *******************************************************************************/ static void gatts_chk_pending_ind(tGATT_TCB *p_tcb ) { +#if (GATTS_INCLUDED == TRUE) tGATT_VALUE *p_buf = (tGATT_VALUE *)GKI_getfirst(&p_tcb->pending_ind_q); GATT_TRACE_DEBUG("gatts_chk_pending_ind"); @@ -1501,6 +1502,7 @@ static void gatts_chk_pending_ind(tGATT_TCB *p_tcb ) p_buf->value); GKI_freebuf(GKI_remove_from_queue (&p_tcb->pending_ind_q, p_buf)); } +#endif ///GATTS_INCLUDED == TRUE } /******************************************************************************* @@ -1645,4 +1647,4 @@ void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code, } } -#endif /* BLE_INCLUDED */ +#endif /* BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/stack/gatt/gatt_utils.c b/components/bt/bluedroid/stack/gatt/gatt_utils.c index 776004c11a..78b50789a8 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/bluedroid/stack/gatt/gatt_utils.c @@ -297,6 +297,7 @@ tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg) ** Returns Pointer to the allocated buffer, NULL no buffer available ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void) { UINT8 i; @@ -395,6 +396,8 @@ tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128, } return NULL; } +#endif ///GATTS_INCLUDED == TRUE + /******************************************************************************* ** ** Function gatt_free_attr_value_buffer @@ -451,6 +454,7 @@ void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p) ** Returns None ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id) { tGATT_HDL_LIST_ELEM *p_elem = &gatt_cb.hdl_list[0]; @@ -501,7 +505,6 @@ BOOLEAN gatt_is_last_attribute(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM return is_last_attribute; } - /******************************************************************************* ** ** Function gatt_update_last_pri_srv_info @@ -545,6 +548,8 @@ void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary) return; } +#endif ///GATTS_INCLUDED == TRUE + /******************************************************************************* ** ** Function gatt_add_a_srv_to_list @@ -1234,7 +1239,9 @@ void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle) GATT_TRACE_ERROR("gatt_rsp_timeout command queue out of sync, disconnect"); } else { p_clcb->retry_count++; +#if (GATTC_INCLUDED == TRUE) gatt_act_discovery(p_clcb); +#endif ///GATTC_INCLUDED == TRUE return; } } @@ -1296,6 +1303,7 @@ UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle) ** Returns 0 if not found. Otherwise index of th eservice. ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst) { UINT8 i_rcb = 0; @@ -1319,6 +1327,7 @@ UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid } return i_rcb; } +#endif ///GATTS_INCLUDED == TRUE /******************************************************************************* ** ** Function gatt_sr_find_i_rcb_by_handle @@ -1431,11 +1440,11 @@ tGATT_STATUS gatt_send_error_rsp (tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_cod } else { status = GATT_INSUF_RESOURCE; } - +#if (GATTS_INCLUDED == TRUE) if (deq) { gatt_dequeue_sr_cmd(p_tcb); } - +#endif ///GATTS_INCLUDED == TRUE return status; } @@ -1716,6 +1725,7 @@ UINT8 gatt_num_clcb_by_bd_addr(BD_ADDR bda) *******************************************************************************/ void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB *p_tcb ) { +#if (GATTS_INCLUDED == TRUE) UINT8 i; if (p_tcb) { @@ -1725,7 +1735,7 @@ void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB *p_tcb ) } } } - +#endif ///GATTS_INCLUDED == TRUE } /******************************************************************************* @@ -1740,6 +1750,7 @@ void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB *p_tcb ) BOOLEAN gatt_sr_is_cback_cnt_zero(tGATT_TCB *p_tcb ) { BOOLEAN status = TRUE; +#if (GATTS_INCLUDED == TRUE) UINT8 i; if (p_tcb) { @@ -1752,6 +1763,7 @@ BOOLEAN gatt_sr_is_cback_cnt_zero(tGATT_TCB *p_tcb ) } else { status = FALSE; } +#endif ///GATTS_INCLUDED == TRUE return status; } @@ -1794,6 +1806,7 @@ BOOLEAN gatt_sr_is_prep_cnt_zero(tGATT_TCB *p_tcb) *******************************************************************************/ void gatt_sr_reset_cback_cnt(tGATT_TCB *p_tcb ) { +#if (GATTS_INCLUDED == TRUE) UINT8 i; if (p_tcb) { @@ -1801,6 +1814,7 @@ void gatt_sr_reset_cback_cnt(tGATT_TCB *p_tcb ) p_tcb->sr_cmd.cback_cnt[i] = 0; } } +#endif ///GATTS_INCLUDED == TRUE } /******************************************************************************* @@ -1834,7 +1848,7 @@ void gatt_sr_reset_prep_cnt(tGATT_TCB *p_tcb ) *******************************************************************************/ void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first) { - +#if (GATTS_INCLUDED == TRUE) UINT8 idx = ((UINT8) gatt_if) - 1 ; if (p_tcb) { @@ -1849,6 +1863,7 @@ void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc } } } +#endif ///GATTS_INCLUDED == TRUE } diff --git a/components/bt/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/bluedroid/stack/gatt/include/gatt_int.h index 6412aed6a3..b538ed8b5c 100644 --- a/components/bt/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/bluedroid/stack/gatt/include/gatt_int.h @@ -385,7 +385,9 @@ typedef struct { /* server needs */ /* server response data */ +#if (GATTS_INCLUDED == TRUE) tGATT_SR_CMD sr_cmd; +#endif ///GATTS_INCLUDED == TRUE UINT16 indicate_handle; BUFFER_Q pending_ind_q; @@ -502,11 +504,12 @@ typedef struct { UINT16 next_handle; /* next available handle */ tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */ tGATT_IF gatt_if; +#if (GATTS_INCLUDED == TRUE) tGATT_HDL_LIST_INFO hdl_list_info; tGATT_HDL_LIST_ELEM hdl_list[GATT_MAX_SR_PROFILES]; tGATT_SRV_LIST_INFO srv_list_info; tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES]; - +#endif ///GATTS_INCLUDED == TRUE BUFFER_Q srv_chg_clt_q; /* service change clients queue */ BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */ tGATT_REG cl_rcb[GATT_MAX_APPS]; @@ -521,8 +524,9 @@ typedef struct { UINT8 err_status; UINT16 handle; #endif - +#if (GATTS_INCLUDED == TRUE) tGATT_PROFILE_CLCB profile_clcb[GATT_MAX_APPS]; +#endif ///GATTS_INCLUDED == TRUE UINT16 handle_of_h_r; /* Handle of the handles reused characteristic value */ tGATT_APPL_INFO cb_info; diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index c22650d761..8fd29844fd 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -1041,7 +1041,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) { int xx; BOOLEAN single_write = FALSE; - L2CAP_TRACE_ERROR("%s",__func__); + L2CAP_TRACE_DEBUG("%s",__func__); /* Save the channel ID for faster counting */ if (p_buf) { if (p_ccb != NULL) { diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index bf35e8b264..46123af177 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -2530,7 +2530,6 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR { #if (L2CAP_NUM_FIXED_CHNLS > 0) tL2C_CCB *p_ccb; - L2CAP_TRACE_ERROR("%s,fixed_cid=%d,p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = %p",__func__,fixed_cid,p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]); /* If we already have a CCB, then simply return */ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] != NULL) { return (TRUE); @@ -2918,7 +2917,7 @@ tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid) return (p_ccb); } -#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) +#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE && CLASSIC_BT_INCLUDED == TRUE) /****************************************************************************** ** From b5989a6b2606e1b932c58eeb9336a9547a492db3 Mon Sep 17 00:00:00 2001 From: Yulong Date: Fri, 21 Apr 2017 02:43:35 -0400 Subject: [PATCH 07/15] component/bt:Recovery the btm_establish_continue when created the acl connection --- components/bt/bluedroid/include/bt_target.h | 9 ++++----- components/bt/bluedroid/stack/btm/btm_acl.c | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index 7c3517bf1f..e1a898aabc 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -111,6 +111,9 @@ #define BLE_PRIVACY_SPT FALSE #endif /* CONFIG_GATTC_ENABLE */ +#if (CONFIG_BT_ACL_CONNECTIONS) +#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS +#endif /* CONFIG_BT_ACL_CONNECTIONS */ //------------------Added from bdroid_buildcfg.h--------------------- #ifndef L2CAP_EXTFEA_SUPPORTED_MASK @@ -709,10 +712,6 @@ #define L2CAP_CLIENT_INCLUDED FALSE #endif -/* The default connection link number set to 1, -** if the user want to support muti connction, should change it in the menuconfig */ -#define MAX_ACL_CONNECTIONS 1 - /* The maximum number of simultaneous links that L2CAP can support. Up to 7*/ #ifndef MAX_ACL_CONNECTIONS #define MAX_L2CAP_LINKS 3 @@ -984,7 +983,7 @@ #endif #ifndef GATT_MAX_PHY_CHANNEL -#define GATT_MAX_PHY_CHANNEL 7 +#define GATT_MAX_PHY_CHANNEL 1 #endif /* Used for conformance testing ONLY */ diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 640268265c..0b46a67761 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -289,7 +289,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); } #endif ///CLASSIC_BT_INCLUDED == TRUE - //btm_establish_continue (p); + btm_establish_continue (p); return; } } @@ -310,7 +310,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, && link_role == HCI_ROLE_SLAVE) { //do nothing in this case for fix the android7.0 cann't sent security request issue } else { - //btm_establish_continue(p); + btm_establish_continue(p); } } else #endif From 1016ab1c2a2634d90bd542af8d75b8d8732fd755 Mon Sep 17 00:00:00 2001 From: Yulong Date: Sun, 23 Apr 2017 00:48:23 -0400 Subject: [PATCH 08/15] component/bt:separate the smp_br_connect_callback from the BLE only mode --- components/bt/bluedroid/bta/include/bta_gattc_int.h | 2 +- components/bt/bluedroid/include/bt_target.h | 7 ++++--- components/bt/bluedroid/stack/l2cap/l2c_utils.c | 2 +- components/bt/bluedroid/stack/smp/smp_l2c.c | 9 +++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/bt/bluedroid/bta/include/bta_gattc_int.h b/components/bt/bluedroid/bta/include/bta_gattc_int.h index 9526860876..d04097b71e 100644 --- a/components/bt/bluedroid/bta/include/bta_gattc_int.h +++ b/components/bt/bluedroid/bta/include/bta_gattc_int.h @@ -320,7 +320,7 @@ typedef struct { } tBTA_GATTC_SERV; #ifndef BTA_GATTC_NOTIF_REG_MAX -#define BTA_GATTC_NOTIF_REG_MAX 15 +#define BTA_GATTC_NOTIF_REG_MAX 7//15 #endif typedef struct { diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index e1a898aabc..ce59d6c833 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -112,7 +112,8 @@ #endif /* CONFIG_GATTC_ENABLE */ #if (CONFIG_BT_ACL_CONNECTIONS) -#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS +#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS +#define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS #endif /* CONFIG_BT_ACL_CONNECTIONS */ //------------------Added from bdroid_buildcfg.h--------------------- @@ -724,7 +725,7 @@ #if (CLASSIC_BT_INCLUDED == TRUE) #define MAX_L2CAP_CHANNELS 8 #else -#define MAX_L2CAP_CHANNELS 1 //Not support to create l2cap channels in the BLE only mode in this bluedroid version(6.0) +#define MAX_L2CAP_CHANNELS 2 //Not support to create l2cap channels in the BLE only mode in this bluedroid version(6.0) #endif ///CLASSIC_BT_INCLUDED == TRUE #endif @@ -983,7 +984,7 @@ #endif #ifndef GATT_MAX_PHY_CHANNEL -#define GATT_MAX_PHY_CHANNEL 1 +#define GATT_MAX_PHY_CHANNEL 7 #endif /* Used for conformance testing ONLY */ diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 46123af177..2021f064c4 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -2654,7 +2654,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb) *******************************************************************************/ void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb) { - L2CAP_TRACE_ERROR("%s",__func__); + L2CAP_TRACE_DEBUG("%s",__func__); #if (BLE_INCLUDED == TRUE) if (p_lcb->transport == BT_TRANSPORT_BR_EDR) { /* ignore all not assigned BR/EDR channels */ diff --git a/components/bt/bluedroid/stack/smp/smp_l2c.c b/components/bt/bluedroid/stack/smp/smp_l2c.c index de0c1d0f0e..007c9ccb7b 100644 --- a/components/bt/bluedroid/stack/smp/smp_l2c.c +++ b/components/bt/bluedroid/stack/smp/smp_l2c.c @@ -38,10 +38,11 @@ static void smp_tx_complete_callback(UINT16 cid, UINT16 num_pkt); static void smp_connect_callback(UINT16 channel, BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT transport); static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf); - +#if (CLASSIC_BT_INCLUDED == TRUE) static void smp_br_connect_callback(UINT16 channel, BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT transport); static void smp_br_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf); +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -70,11 +71,12 @@ void smp_l2cap_if_init (void) fixed_reg.default_idle_tout = 60; /* set 60 seconds timeout, 0xffff default idle timeout */ L2CA_RegisterFixedChannel (L2CAP_SMP_CID, &fixed_reg); - +#if (CLASSIC_BT_INCLUDED == TRUE) fixed_reg.pL2CA_FixedConn_Cb = smp_br_connect_callback; fixed_reg.pL2CA_FixedData_Cb = smp_br_data_received; L2CA_RegisterFixedChannel (L2CAP_SMP_BR_CID, &fixed_reg); +#endif ///CLASSIC_BT_INCLUDED == TRUE } /******************************************************************************* @@ -227,6 +229,7 @@ static void smp_tx_complete_callback (UINT16 cid, UINT16 num_pkt) ** connected (conn = TRUE)/disconnected (conn = FALSE). ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static void smp_br_connect_callback(UINT16 channel, BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT transport) { @@ -319,4 +322,6 @@ static void smp_br_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf) GKI_freebuf (p_buf); } +#endif /* CLASSIC_BT_INCLUDED == TRUE */ + #endif /* SMP_INCLUDED == TRUE */ From 2cfde4dfd9451b9b7886dba2b8e9f2d406d1eae2 Mon Sep 17 00:00:00 2001 From: Yulong Date: Sun, 23 Apr 2017 05:52:18 -0400 Subject: [PATCH 09/15] compoent/bt:change the code style --- components/bt/bluedroid/bta/dm/bta_dm_act.c | 56 +++++++++++-------- components/bt/bluedroid/bta/dm/bta_dm_api.c | 5 +- components/bt/bluedroid/bta/dm/bta_dm_int.h | 4 ++ components/bt/bluedroid/bta/dm/bta_dm_main.c | 36 +++++++++++- .../bt/bluedroid/bta/gatt/bta_gattc_cache.c | 17 +++--- components/bt/bluedroid/bta/include/bta_api.h | 2 +- components/bt/bluedroid/bta/sdp/bta_sdp_act.c | 6 -- 7 files changed, 82 insertions(+), 44 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 9af44bfc0c..eb204c4353 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -50,7 +50,9 @@ static void bta_dm_inq_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir); static void bta_dm_inq_cmpl_cb (void *p_result); static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc, BD_NAME bd_name); static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name); +#if (SDP_INCLUDED == TRUE) static void bta_dm_find_services ( BD_ADDR bd_addr); +#endif ///SDP_INCLUDED == TRUE static void bta_dm_discover_next_device(void); #if (SDP_INCLUDED == TRUE) static void bta_dm_sdp_callback (UINT16 sdp_status); @@ -72,11 +74,11 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data); #endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */ static void bta_dm_set_eir (char *local_name); - +#if (SDP_INCLUDED == TRUE) static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result, tBTA_SERVICE_MASK *p_services_to_search, tBTA_SERVICE_MASK *p_services_found); - +#endif ///SDP_INCLUDED == TRUE static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); @@ -85,10 +87,10 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch); static char *bta_dm_get_remname(void); #endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result); - +#if (SDP_INCLUDED == TRUE) static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport); static void bta_dm_discover_device(BD_ADDR remote_bd_addr); - +#endif ///SDP_INCLUDED == TRUE static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status ); static void bta_dm_disable_search_and_disc(void); @@ -1197,9 +1199,9 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_discover (tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->discover.num_uuid); #endif @@ -1236,7 +1238,6 @@ void bta_dm_discover (tBTA_DM_MSG *p_data) bta_dm_search_cb.name_discover_done = FALSE; memcpy(&bta_dm_search_cb.uuid, &p_data->discover.uuid, sizeof(tSDP_UUID)); bta_dm_discover_device(p_data->discover.bd_addr); -#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1250,7 +1251,6 @@ void bta_dm_discover (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_di_disc_cmpl(tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) tBTA_DM_DI_DISC_CMPL di_disc; memset(&di_disc, 0, sizeof(tBTA_DM_DI_DISC_CMPL)); @@ -1265,10 +1265,8 @@ void bta_dm_di_disc_cmpl(tBTA_DM_MSG *p_data) bta_dm_di_cb.p_di_db = NULL; bta_dm_search_cb.p_search_cback(BTA_DM_DI_DISC_CMPL_EVT, (tBTA_DM_SEARCH *) &di_disc); -#endif ///SDP_INCLUDED == TRUE } -#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_di_disc_callback @@ -1332,9 +1330,9 @@ static void bta_dm_disable_search_and_disc (void) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_di_disc (tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) UINT16 result = BTA_FAILURE; tBTA_DM_MSG *p_msg; @@ -1358,8 +1356,8 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data) p_data->hdr.offset = result; bta_sys_sendmsg(p_msg); } -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -1370,6 +1368,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data) ** Returns TRUE if started to get remote name ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport) { tBTM_STATUS btm_status; @@ -1401,6 +1400,7 @@ static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT tr return (FALSE); } } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -1425,7 +1425,9 @@ void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data) /* start name and service discovery from the first device on inquiry result */ bta_dm_search_cb.name_discover_done = FALSE; bta_dm_search_cb.peer_name[0] = 0; +#if (SDP_INCLUDED == TRUE) bta_dm_discover_device(bta_dm_search_cb.p_btm_inq_info->results.remote_bd_addr); +#endif ///SDP_INCLUDED == TRUE } else { /* no devices, search complete */ bta_dm_search_cb.services = 0; @@ -1454,8 +1456,9 @@ void bta_dm_rmt_name (tBTA_DM_MSG *p_data) if ( p_data->rem_name.result.disc_res.bd_name[0] && bta_dm_search_cb.p_btm_inq_info) { bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name = TRUE; } - +#if (SDP_INCLUDED == TRUE) bta_dm_discover_device(bta_dm_search_cb.peer_bdaddr); +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1480,8 +1483,9 @@ void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data) p_btm_inq_info->appl_knows_rem_name = TRUE; } } - +#if (SDP_INCLUDED == TRUE) bta_dm_discover_device(p_data->rem_name.result.disc_res.bd_addr); +#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -1493,9 +1497,9 @@ void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_sdp_result (tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_sdp_rec = NULL; tBTA_DM_MSG *p_msg; BOOLEAN scn_found = FALSE; @@ -1727,8 +1731,8 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) bta_sys_sendmsg(p_msg); } } -#endif ///SDP_INCLUDE == TRUE } +#endif ///SDP_INCLUDE == TRUE /******************************************************************************* ** @@ -1748,7 +1752,9 @@ void bta_dm_search_cmpl (tBTA_DM_MSG *p_data) #endif if (p_data->hdr.layer_specific == BTA_DM_API_DI_DISCOVER_EVT) { + #if (SDP_INCLUDED == TRUE) bta_dm_di_disc_cmpl(p_data); + #endif ///SDP_INCLUDED == TRUE } else { bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, NULL); } @@ -1891,17 +1897,17 @@ void bta_dm_queue_search (tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_queue_disc (tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) if (bta_dm_search_cb.p_search_queue) { GKI_freebuf(bta_dm_search_cb.p_search_queue); } bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER)); memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER)); -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -1950,9 +1956,9 @@ void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) UNUSED(p_data); if (bta_dm_search_cb.p_sdp_db) { GKI_freebuf(bta_dm_search_cb.p_sdp_db); @@ -1960,8 +1966,8 @@ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data) } bta_dm_search_cancel_notify(NULL); -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* @@ -1999,9 +2005,9 @@ void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) static void bta_dm_find_services ( BD_ADDR bd_addr) { -#if (SDP_INCLUDED == TRUE) tSDP_UUID uuid; tBTA_DM_MSG *p_msg; @@ -2107,8 +2113,8 @@ static void bta_dm_find_services ( BD_ADDR bd_addr) bta_sys_sendmsg(p_msg); } } -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -2130,7 +2136,9 @@ static void bta_dm_discover_next_device(void) if ((bta_dm_search_cb.p_btm_inq_info = BTM_InqDbNext(bta_dm_search_cb.p_btm_inq_info)) != NULL) { bta_dm_search_cb.name_discover_done = FALSE; bta_dm_search_cb.peer_name[0] = 0; +#if (SDP_INCLUDED == TRUE) bta_dm_discover_device(bta_dm_search_cb.p_btm_inq_info->results.remote_bd_addr); +#endif ///SDP_INCLUDED == TRUE } else { /* no devices, search complete */ bta_dm_search_cb.services = 0; @@ -2152,6 +2160,7 @@ static void bta_dm_discover_next_device(void) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) static void bta_dm_discover_device(BD_ADDR remote_bd_addr) { tBTA_DM_MSG *p_msg; @@ -2291,7 +2300,6 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr) } } -#if (SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_sdp_callback @@ -3803,6 +3811,7 @@ static void bta_dm_set_eir (char *local_name) ** Returns None ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result, tBTA_SERVICE_MASK *p_services_to_search, tBTA_SERVICE_MASK *p_services_found) @@ -3861,6 +3870,7 @@ static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result, APPL_TRACE_ERROR("BTA EIR search result, services_to_search=0x%08X, services_found=0x%08X", *p_services_to_search, *p_services_found); } +#endif ///SDP_INCLUDED == TRUE #if (BTA_EIR_CANNED_UUID_LIST != TRUE) /******************************************************************************* @@ -4124,7 +4134,6 @@ static void bta_dm_observe_cmpl_cb (void *p_result) static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data) { tBTM_STATUS status = BTM_SUCCESS; -#if (SMP_INCLUDED == TRUE) tBTA_DM_SEC sec_event; char *p_name = NULL; @@ -4238,7 +4247,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D status = BTM_NOT_AUTHORIZED; break; } -#endif ///SMP_INCLUDED == TRUE return status; } #endif /* SMP_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 5f81a616cf..606ab3b075 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -276,10 +276,10 @@ void BTA_DmSearchCancel(void) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) { -#if (SDP_INCLUDED == TRUE) tBTA_DM_API_DISCOVER *p_msg; if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) { @@ -292,11 +292,8 @@ void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, p_msg->sdp_search = sdp_search; bta_sys_sendmsg(p_msg); } -#endif ///SDP_INCLUDED == TRUE } -#if (SDP_INCLUDED == TRUE) - /******************************************************************************* ** ** Function BTA_DmDiscoverUUID diff --git a/components/bt/bluedroid/bta/dm/bta_dm_int.h b/components/bt/bluedroid/bta/dm/bta_dm_int.h index acfbc7c79a..9177e2ac5e 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/bta_dm_int.h @@ -1162,10 +1162,14 @@ extern UINT8 bta_dm_get_av_count(void); extern void bta_dm_search_start (tBTA_DM_MSG *p_data); extern void bta_dm_search_cancel (tBTA_DM_MSG *p_data); extern void bta_dm_discover (tBTA_DM_MSG *p_data); +#if (SDP_INCLUDED == TRUE) extern void bta_dm_di_disc (tBTA_DM_MSG *p_data); +#endif ///SDP_INCLUDED == TRUE extern void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data); extern void bta_dm_rmt_name (tBTA_DM_MSG *p_data); +#if (SDP_INCLUDED == TRUE) extern void bta_dm_sdp_result (tBTA_DM_MSG *p_data); +#endif ///SDP_INCLUDED == TRUE extern void bta_dm_search_cmpl (tBTA_DM_MSG *p_data); extern void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data); extern void bta_dm_disc_result (tBTA_DM_MSG *p_data); diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index 905b25a779..f330460103 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -144,22 +144,32 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { enum { BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */ BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */ +#if (SDP_INCLUDED == TRUE) BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */ +#endif ///SDP_INCLUDED == TRUE BTA_DM_INQUIRY_CMPL, /* 3 bta_dm_inq_cmpl */ BTA_DM_REMT_NAME, /* 4 bta_dm_rmt_name */ +#if (SDP_INCLUDED == TRUE) BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */ +#endif ///SDP_INCLUDED == TRUE BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/ BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */ BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */ BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */ BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */ +#if (SDP_INCLUDED == TRUE) BTA_DM_QUEUE_DISC, /* 11 bta_dm_queue_disc */ +#endif ///SDP_INCLUDED == TRUE BTA_DM_SEARCH_CLEAR_QUEUE, /* 12 bta_dm_search_clear_queue */ BTA_DM_SEARCH_CANCEL_CMPL, /* 13 bta_dm_search_cancel_cmpl */ BTA_DM_SEARCH_CANCEL_NOTIFY, /* 14 bta_dm_search_cancel_notify */ +#if (SDP_INCLUDED == TRUE) BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, /* 15 bta_dm_search_cancel_transac_cmpl */ +#endif ///SDP_INCLUDED == TRUE BTA_DM_DISC_RMT_NAME, /* 16 bta_dm_disc_rmt_name */ +#if (SDP_INCLUDED == TRUE) BTA_DM_API_DI_DISCOVER, /* 17 bta_dm_di_disc */ +#endif ///SDP_INCLUDED == TRUE #if BLE_INCLUDED == TRUE BTA_DM_CLOSE_GATT_CONN, /* 18 bta_dm_close_gatt_conn */ #endif @@ -172,22 +182,32 @@ const tBTA_DM_ACTION bta_dm_search_action[] = { bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */ bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */ +#if (SDP_INCLUDED == TRUE) bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */ +#endif ///SDP_INCLUDED == TRUE bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */ bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */ +#if (SDP_INCLUDED == TRUE) bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */ +#endif ///SDP_INCLUDED == TRUE bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */ bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */ bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */ bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */ bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */ +#if (SDP_INCLUDED == TRUE) bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */ +#endif ///SDP_INCLUDED == TRUE bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */ bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */ bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */ +#if (SDP_INCLUDED == TRUE) bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */ +#endif ///SDP_INCLUDED == TRUE bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */ +#if (SDP_INCLUDED == TRUE) bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */ +#endif ///SDP_INCLUDED == TRUE #if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE , bta_dm_close_gatt_conn #endif @@ -207,15 +227,19 @@ const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = { /* Event Action 1 Action 2 Next State */ /* API_SEARCH */ {BTA_DM_API_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, /* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, +#if (SDP_INCLUDED == TRUE) /* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, +#endif ///SDP_INCLUDED == TRUE /* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, - /* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE} +#if (SDP_INCLUDED == TRUE) + /* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, +#endif ///SDP_INCLUDED == TRUE #if BLE_INCLUDED == TRUE - /* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE} + /* DISC_CLOSE_TOUT_EVT */ {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, #endif }; const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = { @@ -226,7 +250,9 @@ const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = { /* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, /* INQUIRY_CMPL */ {BTA_DM_INQUIRY_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, /* REMT_NAME_EVT */ {BTA_DM_REMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, +#if (SDP_INCLUDED == TRUE) /* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, +#endif ///SDP_INCLUDED == TRUE /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* DISCV_RES_EVT */ {BTA_DM_SEARCH_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}, /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE} @@ -241,12 +267,16 @@ const UINT8 bta_dm_search_search_cancelling_st_table[][BTA_DM_SEARCH_NUM_COLS] = /* Event Action 1 Action 2 Next State */ /* API_SEARCH */ {BTA_DM_QUEUE_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}, /* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CLEAR_QUEUE, BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_CANCELLING}, +#if (SDP_INCLUDED == TRUE) /* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}, +#endif ///SDP_INCLUDED == TRUE /* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, +#if (SDP_INCLUDED == TRUE) /* REMT_NAME_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, /* SDP_RESULT_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, /* DISCV_RES_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, +#endif ///SDP_INCLUDED == TRUE /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING} #if BLE_INCLUDED == TRUE /* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING} @@ -262,7 +292,9 @@ const UINT8 bta_dm_search_disc_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = { /* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, /* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, /* REMT_NAME_EVT */ {BTA_DM_DISC_RMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, +#if (SDP_INCLUDED == TRUE) /* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, +#endif ///SDP_INCLUDED == TRUE /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* DISCV_RES_EVT */ {BTA_DM_DISC_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}, /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE} diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c index 205060f95e..b2d082da90 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c @@ -41,9 +41,10 @@ // #include "osi/include/log.h" static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb); +#if (SDP_INCLUDED == TRUE) static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb); - #define BTA_GATT_SDP_DB_SIZE 4096 +#endif ///SDP_INCLUDED == TRUE /***************************************************************************** ** Constants @@ -457,7 +458,9 @@ tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV if (p_clcb->transport == BTA_TRANSPORT_LE) { status = bta_gattc_discover_procedure(conn_id, p_server_cb, disc_type); } else { + #if (SDP_INCLUDED == TRUE) status = bta_gattc_sdp_service_disc(conn_id, p_server_cb); + #endif ///SDP_INCLUDED == TRUE } } @@ -786,9 +789,9 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb, ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_gattc_sdp_callback (UINT16 sdp_status) { -#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_sdp_rec = NULL; tBT_UUID service_uuid; tSDP_PROTOCOL_ELEM pe; @@ -843,8 +846,9 @@ void bta_gattc_sdp_callback (UINT16 sdp_status) GKI_freebuf(bta_gattc_cb.p_sdp_db); bta_gattc_cb.p_sdp_db = NULL; bta_gattc_cb.sdp_conn_id = 0; -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE + /******************************************************************************* ** ** Function bta_gattc_sdp_service_disc @@ -854,9 +858,9 @@ void bta_gattc_sdp_callback (UINT16 sdp_status) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb) { -#if (SDP_INCLUDED == TRUE) tSDP_UUID uuid; UINT16 num_attrs = 2; UINT16 attr_list[2]; @@ -884,10 +888,9 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE } } return status; -#else - return BTA_GATT_NO_RESOURCES; -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE + /******************************************************************************* ** ** Function bta_gattc_disc_res_cback diff --git a/components/bt/bluedroid/bta/include/bta_api.h b/components/bt/bluedroid/bta/include/bta_api.h index a645a25b1f..501b8a5ad2 100644 --- a/components/bt/bluedroid/bta/include/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta_api.h @@ -1451,9 +1451,9 @@ extern void BTA_DmSearchCancel(void); ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search); -#if (SDP_INCLUDED == TRUE) // btla-specific ++ /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/sdp/bta_sdp_act.c b/components/bt/bluedroid/bta/sdp/bta_sdp_act.c index 09bdf058f5..702a5cf4f3 100644 --- a/components/bt/bluedroid/bta/sdp/bta_sdp_act.c +++ b/components/bt/bluedroid/bta/sdp/bta_sdp_act.c @@ -327,7 +327,6 @@ static void bta_create_sap_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { -#if (SDP_INCLUDED == TRUE) tSDP_DISC_ATTR *p_attr; tSDP_PROTOCOL_ELEM pe; @@ -350,7 +349,6 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE } record->hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size; record->hdr.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data; -#endif ///SDP_INCLUDED == TRUE } @@ -365,7 +363,6 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE *******************************************************************************/ static void bta_sdp_search_cback(UINT16 result, void *user_data) { -#if (SDP_INCLUDED == TRUE) tSDP_DISC_REC *p_rec = NULL; tBTA_SDP_SEARCH_COMP evt_data = {0}; // We need to zero-initialize tBTA_SDP_STATUS status = BTA_SDP_FAILURE; @@ -429,7 +426,6 @@ static void bta_sdp_search_cback(UINT16 result, void *user_data) bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, (tBTA_SDP *) &evt_data, (void *)&uuid->uu.uuid128); osi_free(user_data); // We no longer need the user data to track the search -#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* @@ -460,7 +456,6 @@ void bta_sdp_enable(tBTA_SDP_MSG *p_data) *******************************************************************************/ void bta_sdp_search(tBTA_SDP_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) int x = 0; // TODO: Leaks!!! but needed as user-data pointer tBT_UUID *bta_sdp_search_uuid = osi_malloc(sizeof(tBT_UUID)); @@ -515,7 +510,6 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data) /* else report the result when the cback is called */ -#endif ///SDP_INCLUDED == TRUE } /******************************************************************************* From 45999b69d669e4bdd7ed87a08cb1cd31141188d9 Mon Sep 17 00:00:00 2001 From: Yulong Date: Mon, 24 Apr 2017 23:46:37 -0400 Subject: [PATCH 10/15] component/bt: Set the style to the same, output the macro in the function. 1.After the separate, can save 15k~25k ram & 240k~460k code size(depending on the menuconfig). --- components/bt/bluedroid/bta/dm/bta_dm_act.c | 77 ++++++++---- components/bt/bluedroid/bta/dm/bta_dm_api.c | 21 ++-- components/bt/bluedroid/bta/dm/bta_dm_ci.c | 2 +- components/bt/bluedroid/bta/dm/bta_dm_int.h | 16 ++- components/bt/bluedroid/bta/dm/bta_dm_main.c | 21 +++- components/bt/bluedroid/bta/dm/bta_dm_pm.c | 9 +- .../bt/bluedroid/btc/core/btc_storage.c | 2 + .../btc/profile/std/gap/btc_gap_ble.c | 5 +- components/bt/bluedroid/include/bt_target.h | 8 +- components/bt/bluedroid/stack/btm/btm_acl.c | 25 ++-- components/bt/bluedroid/stack/btm/btm_ble.c | 80 ++++++------ components/bt/bluedroid/stack/btm/btm_sec.c | 115 +++++++----------- components/bt/bluedroid/stack/btu/btu_hcif.c | 58 +++++++-- components/bt/bluedroid/stack/gap/gap_conn.c | 3 +- .../bt/bluedroid/stack/gatt/gatt_auth.c | 18 ++- .../bt/bluedroid/stack/gatt/gatt_main.c | 2 + .../bt/bluedroid/stack/gatt/gatt_utils.c | 3 +- components/bt/bluedroid/stack/hcic/hcicmds.c | 5 +- .../bt/bluedroid/stack/include/btm_api.h | 2 + .../bt/bluedroid/stack/include/btm_int.h | 2 +- .../bt/bluedroid/stack/l2cap/l2c_utils.c | 4 +- 21 files changed, 280 insertions(+), 198 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index eb204c4353..d35265ea1f 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -57,10 +57,12 @@ static void bta_dm_discover_next_device(void); #if (SDP_INCLUDED == TRUE) static void bta_dm_sdp_callback (UINT16 sdp_status); #endif ///SDP_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator); static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit); static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type); static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); +#endif ///SMP_INCLUDED == TRUE static void bta_dm_local_name_cback(BD_ADDR bd_addr); static BOOLEAN bta_dm_check_av(UINT16 event); static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data); @@ -69,7 +71,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data); static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); /* Extended Inquiry Response */ -#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) +#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE) static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data); #endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */ @@ -86,7 +88,9 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch); #if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE) static char *bta_dm_get_remname(void); #endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result); +#endif ///SMP_INCLUDED == TRUE #if (SDP_INCLUDED == TRUE) static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport); static void bta_dm_discover_device(BD_ADDR remote_bd_addr); @@ -97,8 +101,8 @@ static void bta_dm_disable_search_and_disc(void); #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) #if ((defined SMP_INCLUDED) && (SMP_INCLUDED == TRUE)) 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); +#endif ///SMP_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); @@ -115,8 +119,9 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result); #define BTA_DM_BLE_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37|BTM_BLE_ADV_CHNL_38|BTM_BLE_ADV_CHNL_39) #endif #endif - +#if (SMP_INCLUDED == TRUE) static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr); +#endif ///SMP_INCLUDED == TRUE static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir); static void bta_dm_observe_cmpl_cb(void *p_result); static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle); @@ -203,6 +208,7 @@ const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl [BTA_MAX_SERVICE_ID] = { }; /* bta security callback */ +#if (SMP_INCLUDED == TRUE) const tBTM_APPL_INFO bta_security = { &bta_dm_authorize_cback, &bta_dm_pin_cback, @@ -210,22 +216,22 @@ const tBTM_APPL_INFO bta_security = { &bta_dm_authentication_complete_cback, &bta_dm_bond_cancel_complete_cback, #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) - &bta_dm_sp_cback + &bta_dm_sp_cback, #else NULL #endif #if BLE_INCLUDED == TRUE -#if SMP_INCLUDED == TRUE - , &bta_dm_ble_smp_cback -#endif - , &bta_dm_ble_id_key_cback -#endif + &bta_dm_ble_smp_cback, + &bta_dm_ble_id_key_cback, +#endif ///BLE_INCLUDED == TRUE }; +#endif ///SMP_INCLUDED == TRUE +#if (SDP_INCLUDED == TRUE) #define MAX_DISC_RAW_DATA_BUF (1024) UINT8 g_disc_raw_data_buf[MAX_DISC_RAW_DATA_BUF]; - +#endif ///SDP_INCLUDED == TRUE extern DEV_CLASS local_device_default_class; /******************************************************************************* @@ -331,7 +337,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status ) /* hw is ready, go on with BTA DM initialization */ memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb)); +#if (BTM_SSR_INCLUDED == TRUE) memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs)); +#endif ///BTM_SSR_INCLUDED == TRUE memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB)); memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class)); @@ -351,8 +359,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status ) bta_dm_search_cb.conn_id = BTA_GATT_INVALID_CONN_ID; #endif #endif - +#if (SMP_INCLUDED == TRUE) BTM_SecRegister((tBTM_APPL_INFO *)&bta_security); +#endif ///SMP_INCLUDED == TRUE BTM_SetDefaultLinkSuperTout(p_bta_dm_cfg->link_timeout); BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout); bta_dm_cb.cur_policy = p_bta_dm_cfg->policy_settings; @@ -371,10 +380,10 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status ) BTM_ReadLocalDeviceNameFromController((tBTM_CMPL_CB *)bta_dm_local_name_cback); bta_sys_rm_register((tBTA_SYS_CONN_CBACK *)bta_dm_rm_cback); - +#if (BTM_SSR_INCLUDED == TRUE) /* initialize bluetooth low power manager */ bta_dm_init_pm(); - +#endif ///BTM_SSR_INCLUDED == TRUE bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback); #if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) @@ -411,8 +420,9 @@ void bta_dm_disable (tBTA_DM_MSG *p_data) BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0); BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0); - +#if (BTM_SSR_INCLUDED == TRUE) bta_dm_disable_pm(); +#endif ///BTM_SSR_INCLUDED == TRUE bta_dm_disable_search_and_disc(); bta_dm_cb.disabling = TRUE; @@ -837,6 +847,7 @@ void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void bta_dm_bond (tBTA_DM_MSG *p_data) { tBTM_STATUS status; @@ -933,6 +944,7 @@ void bta_dm_pin_reply (tBTA_DM_MSG *p_data) } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -975,7 +987,9 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app if (policy & (HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)) { /* if clearing sniff/park, wake the link */ +#if (BTM_SSR_INCLUDED == TRUE) bta_dm_pm_active(p_dev->peer_bdaddr); +#endif ///BTM_SSR_INCLUDED == TRUE } break; @@ -1008,6 +1022,7 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void bta_dm_confirm(tBTA_DM_MSG *p_data) { tBTM_STATUS res = BTM_NOT_AUTHORIZED; @@ -1017,6 +1032,7 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data) } BTM_ConfirmReqReply(res, p_data->confirm.bd_addr); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1027,7 +1043,7 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data) ** Returns void ** *******************************************************************************/ -#if (BTM_OOB_INCLUDED == TRUE) +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) void bta_dm_loc_oob(tBTA_DM_MSG *p_data) { UNUSED(p_data); @@ -1073,7 +1089,7 @@ void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data) BTM_RemoteOobDataReply(res, p_data->ci_rmt_oob.bd_addr, p_data->ci_rmt_oob.c, p_data->ci_rmt_oob.r ); } -#endif /* BTM_OOB_INCLUDED */ +#endif /* BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE */ /******************************************************************************* ** @@ -1857,16 +1873,16 @@ static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle) ** Returns void ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data) { -#if (SDP_INCLUDED == TRUE) UNUSED(p_data); if (bta_dm_search_cb.p_sdp_db) { GKI_freebuf(bta_dm_search_cb.p_sdp_db); bta_dm_search_cb.p_sdp_db = NULL; } -#endif ///SDP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -2511,6 +2527,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator) { @@ -2554,8 +2571,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA return BTM_NOT_AUTHORIZED; } } - - + @@ -2568,7 +2584,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA ** Returns void ** *******************************************************************************/ -static void bta_dm_pinname_cback (void *p_data) + static void bta_dm_pinname_cback (void *p_data) { tBTM_REMOTE_DEV_NAME *p_result = (tBTM_REMOTE_DEV_NAME *)p_data; tBTA_DM_SEC sec_event; @@ -2901,6 +2917,9 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data) } #endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */ +#endif ///SMP_INCLUDED == TRUE + + /******************************************************************************* ** ** Function bta_dm_local_name_cback @@ -3267,10 +3286,10 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle) { UNUSED(p_tle); tBTA_SYS_HW_MSG *sys_enable_event; - +#if (BTM_SSR_INCLUDED == TRUE) /* disable the power managment module */ bta_dm_disable_pm(); - +#endif ///BTM_SSR_INCLUDED == TRUE /* register our callback to SYS HW manager */ bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback ); @@ -3333,7 +3352,9 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, } /* AV calls bta_sys_conn_open with the A2DP stream count as app_id */ if (BTA_ID_AV == id) { +#if (BTM_SSR_INCLUDED == TRUE) bta_dm_cb.cur_av_count = bta_dm_get_av_count(); +#endif ///BTM_SSR_INCLUDED == TRUE } } else if ( status == BTA_SYS_CONN_IDLE) { if (p_dev) { @@ -3342,7 +3363,9 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, /* get cur_av_count from connected services */ if (BTA_ID_AV == id) { +#if (BTM_SSR_INCLUDED == TRUE) bta_dm_cb.cur_av_count = bta_dm_get_av_count(); +#endif ///BTM_SSR_INCLUDED == TRUE } } APPL_TRACE_WARNING("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status); @@ -3383,6 +3406,7 @@ static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr) { UINT16 index = 0; @@ -3410,6 +3434,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr) #endif } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* @@ -3527,6 +3552,7 @@ static char *bta_dm_get_remname(void) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result) { @@ -3542,6 +3568,7 @@ static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result) bta_dm_cb.p_sec_cback(BTA_DM_BOND_CANCEL_CMPL_EVT, &sec_event); } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -4019,6 +4046,7 @@ void bta_dm_encrypt_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_ ** Returns None ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void bta_dm_set_encryption (tBTA_DM_MSG *p_data) { UINT8 i ; @@ -4050,6 +4078,7 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data) } } } +#endif ///SMP_INCLUDED == TRUE #if (BLE_INCLUDED == TRUE) /******************************************************************************* @@ -4249,7 +4278,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D } return status; } -#endif /* SMP_INCLUDED == TRUE */ /******************************************************************************* ** @@ -4386,6 +4414,7 @@ void bta_dm_security_grant (tBTA_DM_MSG *p_data) { BTM_SecurityGrant(p_data->ble_sec_grant.bd_addr, p_data->ble_sec_grant.res); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 606ab3b075..0ae3af50a1 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -338,6 +338,7 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void BTA_DmBond(BD_ADDR bd_addr) { tBTA_DM_API_BOND *p_msg; @@ -429,7 +430,7 @@ void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin } -#if (BTM_OOB_INCLUDED == TRUE) +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTA_DmLocalOob @@ -550,6 +551,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr) return BTA_SUCCESS; } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -685,10 +687,10 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param) ** BTA_FAIL if operation failed. ** *******************************************************************************/ +#if BLE_INCLUDED == TRUE +#if SMP_INCLUDED == TRUE void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type) { -#if BLE_INCLUDED == TRUE - tBTA_DM_API_ADD_BLEKEY *p_msg; if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) { @@ -702,7 +704,6 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_ bta_sys_sendmsg(p_msg); } -#endif } /******************************************************************************* @@ -722,7 +723,6 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_ *******************************************************************************/ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type) { -#if BLE_INCLUDED == TRUE tBTA_DM_API_ADD_BLE_DEVICE *p_msg; if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL) { @@ -735,7 +735,6 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY bta_sys_sendmsg(p_msg); } -#endif } /******************************************************************************* ** @@ -753,7 +752,6 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY *******************************************************************************/ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey) { -#if BLE_INCLUDED == TRUE tBTA_DM_API_PASSKEY_REPLY *p_msg; if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL) { @@ -768,7 +766,6 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey) } bta_sys_sendmsg(p_msg); } -#endif } /******************************************************************************* ** @@ -784,7 +781,6 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey) *******************************************************************************/ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept) { -#if BLE_INCLUDED == TRUE tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM)); if (p_msg != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM)); @@ -793,7 +789,6 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept) p_msg->accept = accept; bta_sys_sendmsg(p_msg); } -#endif } /******************************************************************************* @@ -810,7 +805,6 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept) *******************************************************************************/ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res) { -#if BLE_INCLUDED == TRUE tBTA_DM_API_BLE_SEC_GRANT *p_msg; if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL) { @@ -822,8 +816,9 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res) bta_sys_sendmsg(p_msg); } -#endif } +#endif ///SMP_INCLUDED == TRUE +#endif ///BLE_INCLUDED == TRUE /******************************************************************************* @@ -2062,6 +2057,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback, tBTA_DM_BLE_SEC_ACT sec_act) { @@ -2081,6 +2077,7 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR bta_sys_sendmsg(p_msg); } } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/dm/bta_dm_ci.c b/components/bt/bluedroid/bta/dm/bta_dm_ci.c index fe4c39b7b0..fb7d0e06d9 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_ci.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_ci.c @@ -30,7 +30,7 @@ #include "bta_dm_ci.h" -#if (BTM_OOB_INCLUDED == TRUE) +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_ci_io_req diff --git a/components/bt/bluedroid/bta/dm/bta_dm_int.h b/components/bt/bluedroid/bta/dm/bta_dm_int.h index 9177e2ac5e..adb5fc033d 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/bta_dm_int.h @@ -57,22 +57,24 @@ enum { BTA_DM_ACL_CHANGE_EVT, BTA_DM_API_ADD_DEVICE_EVT, BTA_DM_API_REMOVE_ACL_EVT, - +#if (SMP_INCLUDED == TRUE) /* security API events */ BTA_DM_API_BOND_EVT, BTA_DM_API_BOND_CANCEL_EVT, BTA_DM_API_PIN_REPLY_EVT, - +#endif ///SMP_INCLUDED == TRUE +#if (BTM_SSR_INCLUDED == TRUE) /* power manger events */ BTA_DM_PM_BTM_STATUS_EVT, BTA_DM_PM_TIMER_EVT, - +#endif ///BTM_SSR_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) /* simple pairing events */ BTA_DM_API_CONFIRM_EVT, BTA_DM_API_SET_ENCRYPTION_EVT, - -#if (BTM_OOB_INCLUDED == TRUE) +#endif ///SMP_INCLUDED == TRUE +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) BTA_DM_API_LOC_OOB_EVT, BTA_DM_CI_IO_REQ_EVT, BTA_DM_CI_RMT_OOB_EVT, @@ -80,11 +82,13 @@ enum { #if BLE_INCLUDED == TRUE +#if SMP_INCLUDED == TRUE BTA_DM_API_ADD_BLEKEY_EVT, BTA_DM_API_ADD_BLEDEVICE_EVT, BTA_DM_API_BLE_PASSKEY_REPLY_EVT, BTA_DM_API_BLE_CONFIRM_REPLY_EVT, BTA_DM_API_BLE_SEC_GRANT_EVT, +#endif ///SMP_INCLUDED == TRUE BTA_DM_API_BLE_SET_BG_CONN_TYPE, BTA_DM_API_BLE_CONN_PARAM_EVT, BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT, @@ -874,8 +878,10 @@ typedef struct { UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */ UINT8 wbt_scn; /* WIDCOMM Extensions SCN */ UINT8 num_master_only; +#if BTM_SSR_INCLUDED == TRUE UINT8 pm_id; tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER]; +#endif ///BTM_SSR_INCLUDED == TRUE UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */ UINT16 cur_policy; /* current default link policy */ UINT16 rs_event; /* the event waiting for role switch */ diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index f330460103..d7ebed1915 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -54,22 +54,23 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */ bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */ bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */ - +#if (SMP_INCLUDED == TRUE) /* security API events */ bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */ bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */ bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */ - +#endif ///SMP_INCLUDED == TRUE +#if (BTM_SSR_INCLUDED == TRUE) /* power manger events */ bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */ bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/ - +#endif ///BTM_SSR_INCLUDED == TRUE /* simple pairing events */ +#if (SMP_INCLUDED == TRUE) bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */ - bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */ - -#if (BTM_OOB_INCLUDED == TRUE) +#endif ///SMP_INCLUDED == TRUE +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */ bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */ bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */ @@ -77,11 +78,13 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { #if BLE_INCLUDED == TRUE +#if SMP_INCLUDED == TRUE bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */ bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */ bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */ bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */ bta_dm_security_grant, +#endif ///SMP_INCLUDED == TRUE bta_dm_ble_set_bg_conn_type, bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */ bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */ @@ -153,7 +156,9 @@ enum { BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */ #endif ///SDP_INCLUDED == TRUE BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/ +#if (SDP_INCLUDED == TRUE) BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */ +#endif ///SDP_INCLUDED == TRUE BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */ BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */ BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */ @@ -191,7 +196,9 @@ const tBTA_DM_ACTION bta_dm_search_action[] = { bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */ #endif ///SDP_INCLUDED == TRUE bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */ +#if (SDP_INCLUDED == TRUE) bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */ +#endif ///SDP_INCLUDED == TRUE bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */ bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */ bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */ @@ -232,7 +239,9 @@ const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = { #endif ///SDP_INCLUDED == TRUE /* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, +#if (SDP_INCLUDED == TRUE) /* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, +#endif ///SDP_INCLUDED == TRUE /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, /* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}, #if (SDP_INCLUDED == TRUE) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/bluedroid/bta/dm/bta_dm_pm.c index 988e570578..7550012eae 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_pm.c @@ -32,6 +32,7 @@ #include "bta_dm_int.h" #include "btm_api.h" +#if (BTM_SSR_INCLUDED == TRUE) static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_mode, @@ -45,6 +46,7 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive); static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable); static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer, UINT8 timer_idx); +#endif///BTM_SSR_INCLUDED == TRUE #if (BTM_SSR_INCLUDED == TRUE) #if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE) @@ -53,7 +55,6 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer, #define BTA_DM_PM_SSR_HH BTA_DM_PM_SSR1 #endif static void bta_dm_pm_ssr(BD_ADDR peer_addr); -#endif tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs; @@ -1015,6 +1016,8 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data) APPL_TRACE_EVENT("%s", __func__); bta_dm_pm_set_mode(p_data->pm_timer.bd_addr, p_data->pm_timer.pm_request, BTA_DM_PM_EXECUTE); } +#endif ///BTM_SSR_INCLUDED == TRUE + /******************************************************************************* ** @@ -1039,6 +1042,7 @@ tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr) return p_dev; } +#if (BTM_SSR_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_is_sco_active @@ -1158,3 +1162,6 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void) return cur_state; } #endif + +#endif ///BTM_SSR_INCLUDED == TRUE + diff --git a/components/bt/bluedroid/btc/core/btc_storage.c b/components/bt/bluedroid/btc/core/btc_storage.c index f3ae7a8b53..4f18cbfc91 100644 --- a/components/bt/bluedroid/btc/core/btc_storage.c +++ b/components/bt/bluedroid/btc/core/btc_storage.c @@ -90,8 +90,10 @@ static bt_status_t btc_in_fetch_bonded_devices(int add) uint2devclass((UINT32)cod, dev_class); } btc_config_get_int(name, "PinLength", &pin_length); +#if (SMP_INCLUDED == TRUE) BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0, (UINT8)linkkey_type, 0, pin_length); +#endif ///SMP_INCLUDED == TRUE } bt_linkkey_file_found = TRUE; } else { diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 062c957e45..1d2f7f820c 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -568,6 +568,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status) } } +#if (SMP_INCLUDED == TRUE) static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status) { UNUSED(bd_addr); @@ -575,7 +576,7 @@ static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transpor LOG_DEBUG("enc_status = %x\n", enc_status); return; } - +#endif ///SMP_INCLUDED == TRUE static void btc_ble_start_scanning(uint8_t duration, tBTA_DM_SEARCH_CBACK *results_cb, @@ -881,10 +882,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) btc_scan_rsp_data_raw_callback); break; case BTC_GAP_BLE_SET_ENCRYPTION_EVT: { +#if (SMP_INCLUDED == TRUE) BD_ADDR bd_addr; memcpy(bd_addr, arg->set_encryption.bd_addr, sizeof(BD_ADDR)); BTA_DmSetEncryption(bd_addr, BT_TRANSPORT_LE, btc_set_encryption_callback, (tBTA_DM_BLE_SEC_ACT)arg->set_encryption.sec_act); +#endif ///SMP_INCLUDED == TRUE break; } diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index ce59d6c833..1953476845 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -228,7 +228,7 @@ #endif #ifndef BT_USE_TRACES -#define BT_USE_TRACES TRUE +#define BT_USE_TRACES FALSE #endif #ifndef BT_TRACE_BTIF @@ -563,7 +563,11 @@ /* The number of SCO links. */ #ifndef BTM_MAX_SCO_LINKS +#if (CLASSIC_BT_INCLUDED == TRUE) #define BTM_MAX_SCO_LINKS 1 //3 +#else ///CLASSIC_BT_INCLUDED == TRUE +#define BTM_MAX_SCO_LINKS 0 +#endif ///CLASSIC_BT_INCLUDED == TRUE #endif /* The preferred type of SCO links (2-eSCO, 0-SCO). */ @@ -686,7 +690,7 @@ /* TRUE to include Sniff Subrating */ #ifndef BTM_SSR_INCLUDED -#define BTM_SSR_INCLUDED TRUE +#define BTM_SSR_INCLUDED FALSE #endif /************************* diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 0b46a67761..3260c10076 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -281,7 +281,9 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); #endif ///CLASSIC_BT_INCLUDED == TRUE /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ +#if (SMP_INCLUDED == TRUE) btm_sec_set_peer_sec_caps(p, p_dev_rec); +#endif ///SMP_INCLUDED == TRUE #if (CLASSIC_BT_INCLUDED == TRUE) BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); if (req_pend) { @@ -926,10 +928,10 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages) } const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); - +#if (SMP_INCLUDED == TRUE) /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ btm_sec_set_peer_sec_caps(p_acl_cb, p_dev_rec); - +#endif ///SMP_INCLUDED == TRUE BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); if (req_pend) { /* Request for remaining Security Features (if any) */ @@ -1478,10 +1480,9 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) ** Returns Allocated SCN number or 0 if none. ** *******************************************************************************/ - +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 BTM_AllocateSCN(void) { -#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 x; BTM_TRACE_DEBUG ("BTM_AllocateSCN\n"); // stack reserves scn 1 for HFP, HSP we still do the correct way @@ -1491,9 +1492,9 @@ UINT8 BTM_AllocateSCN(void) return (x + 1); } } -#endif ///CLASSIC_BT_INCLUDED == TRUE return (0); /* No free ports */ } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -1504,10 +1505,9 @@ UINT8 BTM_AllocateSCN(void) ** Returns Returns TRUE if server channel was available ** *******************************************************************************/ - +#if (CLASSIC_BT_INCLUDED == TRUE) BOOLEAN BTM_TryAllocateSCN(UINT8 scn) { -#if (CLASSIC_BT_INCLUDED == TRUE) /* Make sure we don't exceed max port range. * Stack reserves scn 1 for HFP, HSP we still do the correct way. */ @@ -1520,11 +1520,11 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn) btm_cb.btm_scn[scn - 1] = TRUE; return TRUE; } -#endif ///CLASSIC_BT_INCLUDED == TRUE return (FALSE); /* Port was busy */ } + /******************************************************************************* ** ** Function BTM_FreeSCN @@ -1536,8 +1536,6 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn) *******************************************************************************/ BOOLEAN BTM_FreeSCN(UINT8 scn) { - -#if (CLASSIC_BT_INCLUDED == TRUE) BTM_TRACE_DEBUG ("BTM_FreeSCN \n"); if (scn <= BTM_MAX_SCN) { btm_cb.btm_scn[scn - 1] = FALSE; @@ -1545,10 +1543,9 @@ BOOLEAN BTM_FreeSCN(UINT8 scn) } else { return (FALSE); /* Illegal SCN passed in */ } -#else return (FALSE); -#endif ///CLASSIC_BT_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -2345,9 +2342,9 @@ void btm_acl_reset_paging (void) ** Description send a paging command or queue it in btm_cb ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE) void btm_acl_paging (BT_HDR *p, BD_ADDR bda) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_acl_paging discing:%d, paging:%d BDA: %06x%06x\n", @@ -2379,8 +2376,8 @@ void btm_acl_paging (BT_HDR *p, BD_ADDR bda) btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/btm/btm_ble.c b/components/bt/bluedroid/stack/btm/btm_ble.c index d8f176c820..b7a47a5ed7 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/bluedroid/stack/btm/btm_ble.c @@ -68,10 +68,10 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr); ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; UINT8 i = 0; tBTM_INQ_INFO *p_info = NULL; @@ -133,9 +133,10 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d BTM_TRACE_DEBUG ("InqDb device_type =0x%x addr_type=0x%x", p_info->results.device_type, p_info->results.ble_addr_type); } -#endif ///SMP_INCLUDED == TRUE return (TRUE); } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -152,9 +153,9 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ +#if SMP_INCLUDED == TRUE BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_KEY_TYPE key_type) { -#if SMP_INCLUDED == TRUE tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("BTM_SecAddBleKey"); p_dev_rec = btm_find_dev (bd_addr); @@ -181,10 +182,11 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_ } #endif -#endif return (TRUE); } +#endif + /******************************************************************************* ** @@ -431,9 +433,9 @@ void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey) ** res - comparison result BTM_SUCCESS if success ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_PASSKEY_ENTRY_FAIL; @@ -445,8 +447,8 @@ void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res) p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED; BTM_TRACE_DEBUG ("%s\n", __func__); SMP_ConfirmReply(bd_addr, res_smp); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -837,9 +839,9 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback) { -#if (SMP_INCLUDED == TRUE) tBTM_RAND_ENC params; UINT8 *p_dest = params.param_buf; @@ -867,8 +869,8 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en (*p_enc_cplt_cback)(¶ms); /* Call the Encryption complete callback function */ } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* @@ -879,9 +881,9 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en ** Returns None ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_ble_increment_sign_ctr is_local=%d", is_local); @@ -897,8 +899,8 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) p_dev_rec->ble.keys.local_counter, p_dev_rec->ble.keys.counter); } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -910,9 +912,9 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local ) ** Returns p_key_type: output parameter to carry the key type value. ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_DEBUG ("btm_ble_get_enc_key_type"); @@ -922,7 +924,6 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) return TRUE; } -#endif ///SMP_INCLUDED == TRUE return FALSE; } @@ -936,7 +937,6 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types) *******************************************************************************/ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BOOLEAN status = FALSE; BTM_TRACE_DEBUG ("btm_get_local_div"); @@ -955,11 +955,9 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) } BTM_TRACE_DEBUG ("btm_get_local_div status=%d (1-OK) DIV=0x%x", status, *p_div); return status; -#else - return FALSE; -#endif ///SMP_INCLUDED == TRUE } + /******************************************************************************* ** ** Function btm_sec_save_le_key @@ -976,7 +974,6 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div) void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys, BOOLEAN pass_to_application) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; tBTM_LE_EVT_DATA cb_data; UINT8 i; @@ -1104,7 +1101,6 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY if (p_rec) { BTM_TRACE_DEBUG ("sec_flags=0x%x", p_rec->sec_flags); } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1118,7 +1114,6 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY *******************************************************************************/ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; BTM_TRACE_DEBUG("btm_ble_update_sec_key_size enc_key_size = %d", enc_key_size); @@ -1126,9 +1121,9 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) if ((p_rec = btm_find_dev (bd_addr)) != NULL ) { p_rec->enc_key_size = enc_key_size; } -#endif ///SMP_INCLUDED == TRUE } + /******************************************************************************* ** ** Function btm_ble_read_sec_key_size @@ -1140,7 +1135,6 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size) *******************************************************************************/ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec; if ((p_rec = btm_find_dev (bd_addr)) != NULL ) { @@ -1148,9 +1142,7 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) } else { return 0; } -#else return 0; -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1164,7 +1156,6 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr) *******************************************************************************/ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); UINT8 req_sec_level = BTM_LE_SEC_NONE, cur_sec_level = BTM_LE_SEC_NONE; @@ -1216,9 +1207,10 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE req_sec_level, *p_sec_req_act); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1300,9 +1292,9 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv) { -#if (SMP_INCLUDED == TRUE) tBTM_CB *p_cb = &btm_cb; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); BT_OCTET8 dummy_stk = {0}; @@ -1318,9 +1310,10 @@ void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv) btm_ble_ltk_request_reply(p_dev_rec->bd_addr, FALSE, dummy_stk); } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1386,9 +1379,9 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); BOOLEAN enc_cback; @@ -1420,8 +1413,9 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) } /* to notify GATT to send data if any request is pending */ gatt_notify_enc_cmpl(p_dev_rec->ble.pseudo_addr); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1433,9 +1427,9 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bda); tBTM_CB *p_cb = &btm_cb; @@ -1458,7 +1452,6 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) btsnd_hcic_ble_ltk_req_neg_reply(btm_cb.enc_handle); } } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1473,7 +1466,6 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data) { UINT8 callback_rc = BTM_SUCCESS; -#if (SMP_INCLUDED == TRUE) BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req"); if (btm_cb.api.p_le_callback) { /* the callback function implementation may change the IO capability... */ @@ -1543,9 +1535,10 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:0x%02x\n", p_data->io_cap, p_data->oob_data, p_data->auth_req); } -#endif ///SMP_INCLUDED == TRUE return callback_rc; } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1557,19 +1550,20 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) UINT8 btm_ble_br_keys_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data) { UINT8 callback_rc = BTM_SUCCESS; -#if (SMP_INCLUDED) BTM_TRACE_DEBUG ("%s\n", __func__); if (btm_cb.api.p_le_callback) { /* the callback function implementation may change the IO capability... */ callback_rc = (*btm_cb.api.p_le_callback) (BTM_LE_IO_REQ_EVT, p_dev_rec->bd_addr, (tBTM_LE_EVT_DATA *)p_data); } -#endif ///SMP_INCLUDED return callback_rc; } +#endif ///SMP_INCLUDED + #if (BLE_PRIVACY_SPT == TRUE ) /******************************************************************************* @@ -1803,9 +1797,9 @@ void btm_ble_create_ll_conn_complete (UINT8 status) ** Description This function is the SMP callback handler. ** ******************************************************************************/ +#if (SMP_INCLUDED == TRUE) UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); UINT8 res = 0; @@ -1911,9 +1905,10 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) } else { BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device"); } -#endif ///SMP_INCLUDED == TRUE return 0; } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1931,10 +1926,10 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) ** Returns TRUE if signing sucessul, otherwise FALSE. ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, BLE_SIGNATURE signature) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr); BTM_TRACE_DEBUG ("%s", __func__); @@ -1971,7 +1966,6 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, GKI_freebuf(p_buf); } } -#endif ///SMP_INCLUDED == TRUE return ret; } @@ -1994,7 +1988,6 @@ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT UINT8 *p_comp) { BOOLEAN verified = FALSE; -#if SMP_INCLUDED == TRUE tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr); UINT8 p_mac[BTM_CMAC_TLEN_SIZE]; @@ -2015,9 +2008,10 @@ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT } } } -#endif /* SMP_INCLUDED */ return verified; } +#endif /* SMP_INCLUDED */ + /******************************************************************************* ** @@ -2315,7 +2309,6 @@ static void btm_ble_process_dhk(tSMP_ENC *p) memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS)); } } -#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -2330,7 +2323,6 @@ static void btm_ble_process_dhk(tSMP_ENC *p) *******************************************************************************/ static void btm_ble_process_ir2(tBTM_RAND_ENC *p) { -#if SMP_INCLUDED == TRUE UINT8 btm_ble_dhk_pt = 0x03; tSMP_ENC output; @@ -2350,7 +2342,6 @@ static void btm_ble_process_ir2(tBTM_RAND_ENC *p) } else { memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS)); } -#endif } /******************************************************************************* @@ -2397,6 +2388,7 @@ void btm_ble_reset_id( void ) BTM_TRACE_DEBUG("Generating IR failed."); } } +#endif ///SMP_INCLUDED == TRUE #if BTM_BLE_CONFORMANCE_TESTING == TRUE /******************************************************************************* diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index 76bdf2b59b..6649961123 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -61,25 +61,21 @@ static tBTM_SEC_SERV_REC *btm_sec_find_next_serv (tBTM_SEC_SERV_REC *p_cur); static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm, UINT32 mx_proto_id, UINT32 mx_chan_id); -#endif ///SMP_INCLUDED == TRUE static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec); -#if (SMP_INCLUDED == TRUE) static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle); static void btm_restore_mode(void); static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle); static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec); -#endif ///SMP_INCLUDED == TRUE static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state); - +#endif ///SMP_INCLUDED == TRUE #if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) static char *btm_pair_state_descr (tBTM_PAIRING_STATE state); #endif - -static void btm_sec_check_pending_reqs(void); #if (SMP_INCLUDED == TRUE) +static void btm_sec_check_pending_reqs(void); static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig, UINT32 mx_proto_id, UINT32 mx_chan_id, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); @@ -88,8 +84,8 @@ static void btm_sec_bond_cancel_complete (void); #if (SMP_INCLUDED == TRUE) static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec); -#endif ///SMP_INCLUDED == TRUE static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec); +#endif ///SMP_INCLUDED == TRUE BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[]); #if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle); @@ -107,11 +103,9 @@ static BOOLEAN btm_dev_authorized(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec); static BOOLEAN btm_sec_is_serv_level0 (UINT16 psm); static UINT16 btm_sec_set_serv_level4_flags (UINT16 cur_security, BOOLEAN is_originator); -#endif ///SMP_INCLUDED == TRUE static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); -#if (SMP_INCLUDED == TRUE) static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, UINT8 encr_enable); static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec); @@ -242,10 +236,8 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE LOG_DEBUG("%s p_cb_info->p_le_callback == 0x%p\n", __func__, p_cb_info->p_le_callback); if (p_cb_info->p_le_callback) { -#if SMP_INCLUDED == TRUE BTM_TRACE_EVENT("%s SMP_Register( btm_proc_smp_cback )\n", __func__); SMP_Register(btm_proc_smp_cback); -#endif /* if no IR is loaded, need to regenerate all the keys */ if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) { btm_ble_reset_id(); @@ -290,9 +282,9 @@ BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (tBTM_LINK_KEY_CALLBACK *p_ca ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) { -#if (SMP_INCLUDED == TRUE) int i; for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) { @@ -301,9 +293,9 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) return (TRUE); } } -#endif ///SMP_INCLUDED == TRUE return (FALSE); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* @@ -316,9 +308,9 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) ** Returns TRUE if OK, else FALSE ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) { -#if (SMP_INCLUDED == TRUE) int i; for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) { @@ -327,9 +319,9 @@ BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) return (TRUE); } } -#endif ///SMP_INCLUDED == TRUE return (FALSE); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -729,9 +721,9 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na ** Returns Number of records that were freed. ** *******************************************************************************/ +#if (SDP_INCLUDED == TRUE) UINT8 BTM_SecClrService (UINT8 service_id) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0]; UINT8 num_freed = 0; int i; @@ -750,10 +742,8 @@ UINT8 BTM_SecClrService (UINT8 service_id) } return (num_freed); -#else - return 0; -#endif ///SMP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -771,9 +761,9 @@ UINT8 BTM_SecClrService (UINT8 service_id) ** Returns Number of records that were freed. ** *******************************************************************************/ +#if (SDP_INCLUDED== TRUE) UINT8 btm_sec_clr_service_by_psm (UINT16 psm) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0]; UINT8 num_freed = 0; int i; @@ -789,10 +779,8 @@ UINT8 btm_sec_clr_service_by_psm (UINT16 psm) BTM_TRACE_API("btm_sec_clr_service_by_psm psm:0x%x num_freed:%d\n", psm, num_freed); return (num_freed); -#else - return 0; -#endif ///SMP_INCLUDED == TRUE } +#endif ///SDP_INCLUDED== TRUE /******************************************************************************* ** @@ -838,9 +826,9 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda) ** trusted_mask - bitwise OR of trusted services (array of UINT32) ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d\n", @@ -941,8 +929,9 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, btm_cb.pin_code_len_saved = pin_len; #endif btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1168,14 +1157,13 @@ tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport, ** ** Note: After 2.1 parameters are not used and preserved here not to change API *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; -#if BLE_INCLUDED == TRUE if (BTM_UseLeLink(bd_addr)) { transport = BT_TRANSPORT_LE; } -#endif return btm_sec_bond_by_transport(bd_addr, transport, pin_len, p_pin, trusted_mask); } /******************************************************************************* @@ -1191,7 +1179,6 @@ tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 tr *******************************************************************************/ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x\n", @@ -1258,10 +1245,10 @@ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) return BTM_NOT_AUTHORIZED; } } -#endif ///SMP_INCLUDED == TRUE return BTM_WRONG_MODE; } + /******************************************************************************* ** ** Function BTM_SecGetDeviceLinkKey @@ -1286,6 +1273,7 @@ tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr, LINK_KEY link_key) } return (BTM_UNKNOWN_ADDR); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1338,6 +1326,7 @@ tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType (BD_ADDR bd_addr) ** BTM_MODE_UNSUPPORTED - if security manager not linked in. ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CBACK *p_callback, void *p_ref_data) { @@ -1425,7 +1414,6 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE /******************************************************************************* * disconnect the ACL link, if it's not done yet. *******************************************************************************/ -#if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle) { UINT8 old_state = p_dev_rec->sec_state; @@ -1539,10 +1527,9 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)). ** *******************************************************************************/ -#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) +#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE) void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) { -#if (SMP_INCLUDED == TRUE) BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d\n", btm_pair_state_descr(btm_cb.pairing_state), res); @@ -1586,9 +1573,8 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) btm_cb.acl_disc_reason = HCI_SUCCESS; btsnd_hcic_user_passkey_reply (bd_addr, passkey); } -#endif ///SMP_INCLUDED == TRUE } -#endif +#endif ///BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1604,19 +1590,17 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) ** type - notification type ** *******************************************************************************/ -#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) +#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE) void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type) { -#if (SMP_INCLUDED == TRUE) /* This API only make sense between PASSKEY_REQ and SP complete */ if (btm_cb.pairing_state == BTM_PAIR_STATE_KEY_ENTRY) { btsnd_hcic_send_keypress_notif (bd_addr, type); } -#endif ///SMP_INCLUDED == TRUE } -#endif +#endif ///BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE -#if BTM_OOB_INCLUDED == TRUE +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function BTM_IoCapRsp @@ -1634,7 +1618,6 @@ void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type) *******************************************************************************/ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req) { -#if (SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d\n", btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap); @@ -1653,7 +1636,6 @@ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_A btsnd_hcic_io_cap_req_reply (bd_addr, io_cap, oob, auth_req); } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1689,7 +1671,6 @@ tBTM_STATUS BTM_ReadLocalOobData(void) *******************************************************************************/ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r) { -#if (SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() - State: %s res: %d\n", __func__, btm_pair_state_descr(btm_cb.pairing_state), res); @@ -1708,7 +1689,6 @@ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_O btm_cb.acl_disc_reason = HCI_SUCCESS; btsnd_hcic_rem_oob_reply (bd_addr, c, r); } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1908,7 +1888,7 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len) return p_ret; } -#endif +#endif ///BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1924,9 +1904,9 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len) ** Returns void ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0]; @@ -1946,8 +1926,9 @@ void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id) break; } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE + /************************************************************************ ** I N T E R N A L F U N C T I O N S @@ -2766,9 +2747,9 @@ void btm_create_conn_cancel_complete (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_check_pending_reqs (void) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_QUEUE_ENTRY *p_e; BUFFER_Q bq; @@ -2804,8 +2785,9 @@ void btm_sec_check_pending_reqs (void) GKI_freebuf (p_e); } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -3229,9 +3211,9 @@ void btm_sec_rmt_host_support_feat_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_io_capabilities_req (UINT8 *p) { -#if (SMP_INCLUDED == TRUE) tBTM_SP_IO_REQ evt_data; UINT8 err_code = 0; tBTM_SEC_DEV_REC *p_dev_rec; @@ -3407,7 +3389,6 @@ void btm_io_capabilities_req (UINT8 *p) btsnd_hcic_io_cap_req_reply(evt_data.bd_addr, evt_data.io_cap, evt_data.oob_data, evt_data.auth_req); } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3422,7 +3403,6 @@ void btm_io_capabilities_req (UINT8 *p) *******************************************************************************/ void btm_io_capabilities_rsp (UINT8 *p) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_SP_IO_RSP evt_data; @@ -3473,7 +3453,6 @@ void btm_io_capabilities_rsp (UINT8 *p) if (btm_cb.api.p_sp_callback) { (*btm_cb.api.p_sp_callback) (BTM_SP_IO_RSP_EVT, (tBTM_SP_EVT_DATA *)&evt_data); } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -3487,10 +3466,9 @@ void btm_io_capabilities_rsp (UINT8 *p) ** ** Returns void ** -*******************************************************************************/ +*******************************************************************************/ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) { -#if (SMP_INCLUDED == TRUE) tBTM_STATUS status = BTM_ERR_PROCESSING; tBTM_SP_EVT_DATA evt_data; UINT8 *p_bda = evt_data.cfm_req.bd_addr; @@ -3602,9 +3580,9 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) btsnd_hcic_user_passkey_neg_reply(p_bda); } #endif -#endif ///SMP_INCLUDED == TRUE } + /******************************************************************************* ** ** Function btm_keypress_notif_evt @@ -3643,7 +3621,6 @@ void btm_keypress_notif_evt (UINT8 *p) *******************************************************************************/ void btm_simple_pair_complete (UINT8 *p) { -#if (SMP_INCLUDED == TRUE) tBTM_SP_COMPLT evt_data; tBTM_SEC_DEV_REC *p_dev_rec; UINT8 status; @@ -3701,10 +3678,11 @@ void btm_simple_pair_complete (UINT8 *p) btm_sec_send_hci_disconnect (p_dev_rec, HCI_ERR_AUTH_FAILURE, p_dev_rec->hci_handle); } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE -#if BTM_OOB_INCLUDED == TRUE + +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function btm_rem_oob_req @@ -3832,9 +3810,9 @@ static void btm_sec_auth_collision (UINT16 handle) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_auth_complete (UINT16 handle, UINT8 status) { -#if (SMP_INCLUDED == TRUE) UINT8 old_sm4; tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); @@ -4013,8 +3991,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) if (status != BTM_CMD_STARTED) { btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -4026,9 +4005,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE tACL_CONN *p_acl = NULL; @@ -4165,8 +4144,8 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) if (status != BTM_CMD_STARTED) { btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5142,6 +5121,7 @@ void btm_sec_update_clock_offset (UINT16 handle, UINT16 clock_offset) ** BTM_NO_RESOURCES - permission declined ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec) { BTM_TRACE_EVENT ("btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d\n", @@ -5271,7 +5251,6 @@ static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec) return (BTM_SUCCESS); } - /******************************************************************************* ** ** Function btm_sec_start_get_name @@ -5400,6 +5379,7 @@ static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec) btm_sec_start_get_name (p_dev_rec); return (BTM_CMD_STARTED); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5657,9 +5637,9 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) ** Description This function is called to change pairing state ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) { -#if (SMP_INCLUDED == TRUE) tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; BTM_TRACE_EVENT ("%s() Old: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state)); @@ -5692,8 +5672,8 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE); } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* @@ -5754,8 +5734,9 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA #endif (*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res); } - +#if (SMP_INCLUDED == TRUE) btm_sec_check_pending_reqs(); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -5836,7 +5817,6 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec) return rv; } -#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -5940,7 +5920,6 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec) ** Returns TRUE if the service is security mode 4 level 0 service ** *******************************************************************************/ -#if (SMP_INCLUDED == TRUE) static BOOLEAN btm_sec_is_serv_level0(UINT16 psm) { if (psm == BT_PSM_SDP) { diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index 36eaf89f75..e6d6cdb3db 100644 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -63,9 +63,13 @@ static void btu_hcif_extended_inquiry_result_evt (UINT8 *p); static void btu_hcif_connection_comp_evt (UINT8 *p); static void btu_hcif_connection_request_evt (UINT8 *p); static void btu_hcif_disconnection_comp_evt (UINT8 *p); +#if (SMP_INCLUDED == TRUE) static void btu_hcif_authentication_comp_evt (UINT8 *p); +#endif ///SMP_INCLUDED == TRUE static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len); +#if (SMP_INCLUDED == TRUE) static void btu_hcif_encryption_change_evt (UINT8 *p); +#endif ///SMP_INCLUDED == TRUE static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p); @@ -93,18 +97,20 @@ static void btu_hcif_esco_connection_chg_evt(UINT8 *p); /* Simple Pairing Events */ static void btu_hcif_host_support_evt (UINT8 *p); +#if (SMP_INCLUDED == TRUE) static void btu_hcif_io_cap_request_evt (UINT8 *p); static void btu_hcif_io_cap_response_evt (UINT8 *p); static void btu_hcif_user_conf_request_evt (UINT8 *p); static void btu_hcif_user_passkey_request_evt (UINT8 *p); static void btu_hcif_user_passkey_notif_evt (UINT8 *p); static void btu_hcif_keypress_notif_evt (UINT8 *p); - -#if BTM_OOB_INCLUDED == TRUE +#endif ///SMP_INCLUDED == TRUE +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE static void btu_hcif_rem_oob_request_evt (UINT8 *p); #endif - +#if (SMP_INCLUDED == TRUE) static void btu_hcif_simple_pair_complete_evt (UINT8 *p); +#endif ///SMP_INCLUDED == TRUE #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE static void btu_hcif_enhanced_flush_complete_evt (void); #endif @@ -118,8 +124,10 @@ static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len); static void btu_ble_process_adv_pkt (UINT8 *p); static void btu_ble_read_remote_feat_evt (UINT8 *p); static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len); +#if (SMP_INCLUDED == TRUE) static void btu_ble_proc_ltk_req (UINT8 *p); static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p); +#endif ///SMP_INCLUDED == TRUE static void btu_ble_data_length_change_evt (UINT8 *p, UINT16 evt_len); #if (BLE_LLT_INCLUDED == TRUE) static void btu_ble_rc_param_req_evt(UINT8 *p); @@ -173,17 +181,23 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_hcif_disconnection_comp_evt (p); break; case HCI_AUTHENTICATION_COMP_EVT: +#if (SMP_INCLUDED == TRUE) btu_hcif_authentication_comp_evt (p); +#endif ///SMP_INCLUDED == TRUE break; case HCI_RMT_NAME_REQUEST_COMP_EVT: btu_hcif_rmt_name_request_comp_evt (p, hci_evt_len); break; case HCI_ENCRYPTION_CHANGE_EVT: +#if (SMP_INCLUDED == TRUE) btu_hcif_encryption_change_evt (p); +#endif ///SMP_INCLUDED == TRUE break; #if BLE_INCLUDED == TRUE case HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT: +#if (SMP_INCLUDED == TRUE) btu_hcif_encryption_key_refresh_cmpl_evt(p); +#endif ///SMP_INCLUDED == TRUE break; #endif case HCI_READ_RMT_FEATURES_COMP_EVT: @@ -268,6 +282,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT: btu_hcif_host_support_evt (p); break; +#if (SMP_INCLUDED == TRUE) case HCI_IO_CAPABILITY_REQUEST_EVT: btu_hcif_io_cap_request_evt (p); break; @@ -280,11 +295,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_USER_PASSKEY_REQUEST_EVT: btu_hcif_user_passkey_request_evt (p); break; -#if BTM_OOB_INCLUDED == TRUE +#endif ///SMP_INCLUDED == TRUE +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE case HCI_REMOTE_OOB_DATA_REQUEST_EVT: btu_hcif_rem_oob_request_evt (p); break; #endif +#if (SMP_INCLUDED == TRUE) case HCI_SIMPLE_PAIRING_COMPLETE_EVT: btu_hcif_simple_pair_complete_evt (p); break; @@ -294,6 +311,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_KEYPRESS_NOTIFY_EVT: btu_hcif_keypress_notif_evt (p); break; +#endif ///SMP_INCLUDED == TRUE #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE case HCI_ENHANCED_FLUSH_COMPLETE_EVT: btu_hcif_enhanced_flush_complete_evt (); @@ -320,7 +338,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_ble_read_remote_feat_evt(p); break; case HCI_BLE_LTK_REQ_EVT: /* received only at slave device */ +#if (SMP_INCLUDED == TRUE) btu_ble_proc_ltk_req(p); +#endif ///SMP_INCLUDED == TRUE break; //#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT: @@ -600,6 +620,7 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btu_hcif_authentication_comp_evt (UINT8 *p) { UINT8 status; @@ -610,7 +631,7 @@ static void btu_hcif_authentication_comp_evt (UINT8 *p) btm_sec_auth_complete (handle, status); } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -646,6 +667,7 @@ static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btu_hcif_encryption_change_evt (UINT8 *p) { UINT8 status; @@ -659,6 +681,7 @@ static void btu_hcif_encryption_change_evt (UINT8 *p) btm_acl_encrypt_change (handle, status, encr_enable); btm_sec_encrypt_change (handle, status, encr_enable); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -854,7 +877,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l break; case HCI_READ_LOCAL_OOB_DATA: -#if BTM_OOB_INCLUDED == TRUE +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE btm_read_local_oob_complete(p); #endif break; @@ -880,7 +903,9 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l case HCI_BLE_RAND: case HCI_BLE_ENCRYPT: +#if (SMP_INCLUDED == TRUE) btm_ble_rand_enc_complete (p, opcode, (tBTM_RAND_ENC_CB *)p_cplt_cback); +#endif ///SMP_INCLUDED == TRUE break; case HCI_BLE_READ_ADV_CHNL_TX_POWER: @@ -1074,13 +1099,17 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c break; case HCI_AUTHENTICATION_REQUESTED: +#if (SMP_INCLUDED == TRUE) /* Device refused to start authentication. That should be treated as authentication failure. */ btm_sec_auth_complete (BTM_INVALID_HCI_HANDLE, status); +#endif ///SMP_INCLUDED == TRUE break; case HCI_SET_CONN_ENCRYPTION: +#if (SMP_INCLUDED == TRUE) /* Device refused to start encryption. That should be treated as encryption failure. */ btm_sec_encrypt_change (BTM_INVALID_HCI_HANDLE, status, FALSE); +#endif ///SMP_INCLUDED == TRUE break; #if BLE_INCLUDED == TRUE @@ -1527,6 +1556,7 @@ static void btu_hcif_host_support_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btu_hcif_io_cap_request_evt (UINT8 *p) { btm_io_capabilities_req(p); @@ -1562,7 +1592,6 @@ static void btu_hcif_user_conf_request_evt (UINT8 *p) btm_proc_sp_req_evt(BTM_SP_CFM_REQ_EVT, p); } - /******************************************************************************* ** ** Function btu_hcif_user_passkey_request_evt @@ -1604,6 +1633,8 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p) { btm_keypress_notif_evt(p); } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -1614,7 +1645,7 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ -#if BTM_OOB_INCLUDED == TRUE +#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE static void btu_hcif_rem_oob_request_evt (UINT8 *p) { btm_rem_oob_req(p); @@ -1630,11 +1661,12 @@ static void btu_hcif_rem_oob_request_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btu_hcif_simple_pair_complete_evt (UINT8 *p) { btm_simple_pair_complete(p); } - +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function btu_hcif_enhanced_flush_complete_evt @@ -1659,6 +1691,7 @@ static void btu_hcif_enhanced_flush_complete_evt (void) ** BLE Events ***********************************************/ #if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) +#if (SMP_INCLUDED == TRUE) static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p) { UINT8 status; @@ -1674,6 +1707,7 @@ static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p) btm_sec_encrypt_change (handle, status, enc_enable); } +#endif ///SMP_INCLUDED == TRUE static void btu_ble_process_adv_pkt (UINT8 *p) { @@ -1710,9 +1744,10 @@ static void btu_ble_read_remote_feat_evt (UINT8 *p) btm_ble_read_remote_features_complete(p); } +#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE static void btu_ble_proc_ltk_req (UINT8 *p) { -#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE + UINT16 ediv, handle; UINT8 *pp; @@ -1721,9 +1756,10 @@ static void btu_ble_proc_ltk_req (UINT8 *p) STREAM_TO_UINT16(ediv, pp); btm_ble_ltk_request(handle, p, ediv); -#endif /* This is empty until an upper layer cares about returning event */ } +#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE + static void btu_ble_data_length_change_evt(UINT8 *p, UINT16 evt_len) { diff --git a/components/bt/bluedroid/stack/gap/gap_conn.c b/components/bt/bluedroid/stack/gap/gap_conn.c index 7f5e0be39f..882e0b2d57 100644 --- a/components/bt/bluedroid/stack/gap/gap_conn.c +++ b/components/bt/bluedroid/stack/gap/gap_conn.c @@ -1165,9 +1165,10 @@ static void gap_release_ccb (tGAP_CCB *p_ccb) return; } } - +#if (SDP_INCLUDED == TRUE) /* Free the security record for this PSM */ BTM_SecClrService(service_id); +#endif ///SDP_INCLUDED == TRUE L2CA_DEREGISTER (psm); } diff --git a/components/bt/bluedroid/stack/gatt/gatt_auth.c b/components/bt/bluedroid/stack/gatt/gatt_auth.c index 69934dd8bd..138fb062f1 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_auth.c +++ b/components/bt/bluedroid/stack/gatt/gatt_auth.c @@ -41,6 +41,7 @@ ** Returns TRUE if encrypted, otherwise FALSE. ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb) { tGATT_VALUE *p_attr = (tGATT_VALUE *)p_clcb->p_attr_buf; @@ -84,6 +85,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb) return status; } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -95,6 +97,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb) ** Returns ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) { UINT16 cmd_len; @@ -125,6 +128,8 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) return; } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** ** Function gatt_sec_check_complete @@ -146,7 +151,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s gatt_act_write(p_clcb, sec_act); } else if (p_clcb->operation == GATTC_OPTYPE_READ) { gatt_act_read(p_clcb, p_clcb->counter); - } + } #endif ///GATTC_INCLUDED == TRUE } /******************************************************************************* @@ -299,8 +304,8 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb ) BOOLEAN is_link_encrypted = FALSE; BOOLEAN is_link_key_known = FALSE; BOOLEAN is_key_mitm = FALSE; - UINT8 key_type; #if (SMP_INCLUDED == TRUE) + UINT8 key_type; tBTM_BLE_SEC_REQ_ACT sec_act = BTM_LE_SEC_NONE; #endif ///SMP_INCLUDED == TRUE if (auth_req == GATT_AUTH_REQ_NONE ) { @@ -359,8 +364,9 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb ) /* this is a write command request check data signing required or not */ if (!is_link_encrypted) { +#if (SMP_INCLUDED == TRUE) btm_ble_get_enc_key_type(p_tcb->peer_bda, &key_type); - +#endif ///SMP_INCLUDED == TRUE if ( #if (SMP_INCLUDED == TRUE) (key_type & BTM_LE_KEY_LCSRK) && @@ -459,7 +465,9 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb) tGATT_SEC_ACTION gatt_sec_act; tBTM_BLE_SEC_ACT btm_ble_sec_act; BOOLEAN status = TRUE; +#if (SMP_INCLUDED == TRUE) tBTM_STATUS btm_status; +#endif ///SMP_INCLUDED == TRUE tGATT_SEC_ACTION sec_act_old = gatt_get_sec_act(p_tcb); gatt_sec_act = gatt_determine_sec_act(p_clcb); @@ -470,8 +478,10 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb) switch (gatt_sec_act ) { case GATT_SEC_SIGN_DATA: +#if (SMP_INCLUDED == TRUE) GATT_TRACE_DEBUG("gatt_security_check_start: Do data signing"); gatt_sign_data(p_clcb); +#endif ///SMP_INCLUDED == TRUE break; case GATT_SEC_ENCRYPT: case GATT_SEC_ENCRYPT_NO_MITM: @@ -479,11 +489,13 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb) if (sec_act_old < GATT_SEC_ENCRYPT) { GATT_TRACE_DEBUG("gatt_security_check_start: Encrypt now or key upgreade first"); gatt_convert_sec_action(gatt_sec_act, &btm_ble_sec_act); +#if (SMP_INCLUDED == TRUE) btm_status = BTM_SetEncryption(p_tcb->peer_bda, p_tcb->transport , gatt_enc_cmpl_cback, &btm_ble_sec_act); if ( (btm_status != BTM_SUCCESS) && (btm_status != BTM_CMD_STARTED)) { GATT_TRACE_ERROR("gatt_security_check_start BTM_SetEncryption failed btm_status=%d", btm_status); status = FALSE; } +#endif ///SMP_INCLUDED == TRUE } if (status) { gatt_add_pending_enc_channel_clcb (p_tcb, p_clcb); diff --git a/components/bt/bluedroid/stack/gatt/gatt_main.c b/components/bt/bluedroid/stack/gatt/gatt_main.c index 14a963500a..e96072abb1 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/bluedroid/stack/gatt/gatt_main.c @@ -930,7 +930,9 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf) if (pseudo_op_code < GATT_OP_CODE_MAX) { if (op_code == GATT_SIGN_CMD_WRITE) { +#if (SMP_INCLUDED == TRUE) gatt_verify_signature(p_tcb, p_buf); +#endif ///SMP_INCLUDED == TRUE } else { /* message from client */ if ((op_code % 2) == 0) { diff --git a/components/bt/bluedroid/stack/gatt/gatt_utils.c b/components/bt/bluedroid/stack/gatt/gatt_utils.c index 78b50789a8..4934c9b50f 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/bluedroid/stack/gatt/gatt_utils.c @@ -1380,8 +1380,9 @@ void gatt_sr_get_sec_info(BD_ADDR rem_bda, tBT_TRANSPORT transport, UINT8 *p_sec BTM_GetSecurityFlagsByTransport(rem_bda, &sec_flag, transport); sec_flag &= (GATT_SEC_FLAG_LKEY_UNAUTHED | GATT_SEC_FLAG_LKEY_AUTHED | GATT_SEC_FLAG_ENCRYPTED); - +#if (SMP_INCLUDED == TRUE) *p_key_size = btm_ble_read_sec_key_size(rem_bda); +#endif ///SMP_INCLUDED == TRUE *p_sec_flag = sec_flag; } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/hcic/hcicmds.c b/components/bt/bluedroid/stack/hcic/hcicmds.c index 920feaea2a..3a88561922 100644 --- a/components/bt/bluedroid/stack/hcic/hcicmds.c +++ b/components/bt/bluedroid/stack/hcic/hcicmds.c @@ -164,7 +164,9 @@ BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types, #if !defined (BT_10A) UINT8_TO_STREAM (pp, allow_switch); #endif +#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE) btm_acl_paging (p, dest); +#endif ///SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE return (TRUE); } @@ -489,8 +491,9 @@ BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode, UINT8_TO_STREAM (pp, page_scan_rep_mode); UINT8_TO_STREAM (pp, page_scan_mode); UINT16_TO_STREAM (pp, clock_offset); - +#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE) btm_acl_paging (p, bd_addr); +#endif ///SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE return (TRUE); } diff --git a/components/bt/bluedroid/stack/include/btm_api.h b/components/bt/bluedroid/stack/include/btm_api.h index d48dc68b0a..5f3d5e4227 100644 --- a/components/bt/bluedroid/stack/include/btm_api.h +++ b/components/bt/bluedroid/stack/include/btm_api.h @@ -2032,6 +2032,7 @@ tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, ** *******************************************************************************/ //extern +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 BTM_AllocateSCN(void); // btla-specific ++ @@ -2060,6 +2061,7 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn); *******************************************************************************/ //extern BOOLEAN BTM_FreeSCN(UINT8 scn); +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* diff --git a/components/bt/bluedroid/stack/include/btm_int.h b/components/bt/bluedroid/stack/include/btm_int.h index c8d86e9ba5..c732edd1ae 100644 --- a/components/bt/bluedroid/stack/include/btm_int.h +++ b/components/bt/bluedroid/stack/include/btm_int.h @@ -847,8 +847,8 @@ typedef struct { TIMER_LIST_ENT pairing_tle; /* Timer for pairing process */ UINT16 disc_handle; /* for legacy devices */ UINT8 disc_reason; /* for legacy devices */ -#endif ///SMP_INCLUDED == TRUE tBTM_SEC_SERV_REC sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS]; +#endif ///SMP_INCLUDED == TRUE tBTM_SEC_DEV_REC sec_dev_rec[BTM_SEC_MAX_DEVICE_RECORDS]; tBTM_SEC_SERV_REC *p_out_serv; tBTM_MKEY_CALLBACK *mkey_cback; diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 2021f064c4..8dd5ea33fa 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -1594,11 +1594,11 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb) if (!p_ccb->in_use) { return; } - +#if (SDP_INCLUDED == TRUE) if (p_rcb && (p_rcb->psm != p_rcb->real_psm)) { btm_sec_clr_service_by_psm(p_rcb->psm); } - +#endif ///SMP_INCLUDED == TRUE if (p_ccb->should_free_rcb) { osi_free(p_rcb); p_ccb->p_rcb = NULL; From 5544f98add14058727bc49ba894597d4dce62bd8 Mon Sep 17 00:00:00 2001 From: Yulong Date: Tue, 25 Apr 2017 04:55:29 -0400 Subject: [PATCH 11/15] component/bt:separate the SMP, GATT module set the macro output the function. 1. close classic bt, can save 233k code size; 2. close smp module, can save 136k code size; 3. close gattc module, can save 24k code size; 4. close gatts module, can save 16k code size; 4. close the bluedroid stack log, can save 120k code size. --- components/bt/bluedroid/bta/dm/bta_dm_act.c | 2 +- components/bt/bluedroid/bta/dm/bta_dm_pm.c | 5 +- components/bt/bluedroid/stack/btm/btm_acl.c | 2 + .../bt/bluedroid/stack/btm/btm_ble_gap.c | 2 + components/bt/bluedroid/stack/btm/btm_inq.c | 3 +- components/bt/bluedroid/stack/btm/btm_main.c | 2 + components/bt/bluedroid/stack/btm/btm_sec.c | 145 ++++++++++-------- components/bt/bluedroid/stack/btu/btu_hcif.c | 29 +++- .../bt/bluedroid/stack/gatt/att_protocol.c | 4 + .../bt/bluedroid/stack/gatt/gatt_main.c | 45 +++--- components/bt/bluedroid/stack/l2cap/l2c_api.c | 4 + components/bt/bluedroid/stack/l2cap/l2c_ble.c | 8 + .../bt/bluedroid/stack/l2cap/l2c_link.c | 7 +- .../bt/bluedroid/stack/l2cap/l2c_main.c | 15 +- .../bt/bluedroid/stack/l2cap/l2c_utils.c | 13 +- 15 files changed, 169 insertions(+), 117 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index d35265ea1f..cd0a7c4cc8 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -218,7 +218,7 @@ const tBTM_APPL_INFO bta_security = { #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) &bta_dm_sp_cback, #else - NULL + NULL, #endif #if BLE_INCLUDED == TRUE &bta_dm_ble_smp_cback, diff --git a/components/bt/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/bluedroid/bta/dm/bta_dm_pm.c index 7550012eae..4434dcbda2 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_pm.c @@ -1139,8 +1139,9 @@ static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisa BTM_SetLinkPolicy(p_dev->peer_bdaddr, &policy_setting); } +#endif ///BTM_SSR_INCLUDED == TRUE -#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) +#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_pm_obtain_controller_state @@ -1163,5 +1164,3 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void) } #endif -#endif ///BTM_SSR_INCLUDED == TRUE - diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 3260c10076..5b8ecb7852 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -934,8 +934,10 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages) #endif ///SMP_INCLUDED == TRUE BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); if (req_pend) { +#if (CLASSIC_BT_INCLUDED == TRUE) /* Request for remaining Security Features (if any) */ l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); +#endif ///CLASSIC_BT_INCLUDED == TRUE } } diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index 49f491f06c..23daef539b 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -2130,7 +2130,9 @@ void btm_ble_read_remote_name_cmpl(BOOLEAN status, BD_ADDR bda, UINT16 length, c } btm_process_remote_name(bda, bd_name, length + 1, hci_status); +#if (SMP_INCLUDED == TRUE) btm_sec_rmt_name_request_complete (bda, (UINT8 *)p_name, hci_status); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/btm/btm_inq.c b/components/bt/bluedroid/stack/btm/btm_inq.c index 6492cd42b4..ff0fcc5b04 100644 --- a/components/bt/bluedroid/stack/btm/btm_inq.c +++ b/components/bt/bluedroid/stack/btm/btm_inq.c @@ -2353,8 +2353,9 @@ void btm_inq_rmt_name_failed (void) } else { btm_process_remote_name (NULL, NULL, 0, HCI_ERR_UNSPECIFIED); } - +#if (SMP_INCLUDED == TRUE) btm_sec_rmt_name_request_complete (NULL, NULL, HCI_ERR_UNSPECIFIED); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/btm/btm_main.c b/components/bt/bluedroid/stack/btm/btm_main.c index 04408a8231..f067dded66 100644 --- a/components/bt/bluedroid/stack/btm/btm_main.c +++ b/components/bt/bluedroid/stack/btm/btm_main.c @@ -59,7 +59,9 @@ void btm_init (void) /* Initialize BTM component structures */ btm_inq_db_init(); /* Inquiry Database and Structures */ btm_acl_init(); /* ACL Database and Structures */ +#if (SMP_INCLUDED == TRUE) btm_sec_init(BTM_SEC_MODE_SP); /* Security Manager Database and Structures */ +#endif ///SMP_INCLUDED == TRUE #if BTM_SCO_INCLUDED == TRUE btm_sco_init(); /* SCO Database and Structures (If included) */ #endif diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index 6649961123..a8c5be6f5c 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -79,9 +79,7 @@ static void btm_sec_check_pending_reqs(void); static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig, UINT32 mx_proto_id, UINT32 mx_chan_id, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); -#endif ///SMP_INCLUDED == TRUE static void btm_sec_bond_cancel_complete (void); -#if (SMP_INCLUDED == TRUE) static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec); static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec); @@ -830,10 +828,10 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda) void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { tBTM_SEC_DEV_REC *p_dev_rec; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d\n", btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, pin_len, res); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE /* If timeout already expired or has been canceled, ignore the reply */ if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) { BTM_TRACE_WARNING ("BTM_PINCodeReply() - Wrong State: %d\n", btm_cb.pairing_state); @@ -946,10 +944,10 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, ** ** Note: After 2.1 parameters are not used and preserved here not to change API *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; tBTM_STATUS status; UINT8 *p_features; @@ -963,7 +961,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, /* Other security process is in progress */ if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_ERROR ("BTM_SecBond: already busy in state: %s\n", btm_pair_state_descr(btm_cb.pairing_state)); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE return (BTM_WRONG_MODE); } @@ -1091,8 +1091,10 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, /* We are accepting connection request from peer */ btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ); } +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_DEBUG ("State:%s sm4: 0x%x sec_state:%d\n", btm_pair_state_descr (btm_cb.pairing_state), p_dev_rec->sm4, p_dev_rec->sec_state); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE return BTM_CMD_STARTED; } @@ -1104,9 +1106,6 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, } return status; -#else - return BTM_MODE_UNSUPPORTED; -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -1128,7 +1127,6 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) { -#if SMP_INCLUDED == TRUE tBT_DEVICE_TYPE dev_type; tBLE_ADDR_TYPE addr_type; @@ -1138,9 +1136,9 @@ tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport, (transport == BT_TRANSPORT_BR_EDR && (dev_type & BT_DEVICE_TYPE_BREDR) == 0)) { return BTM_ILLEGAL_ACTION; } -#endif return btm_sec_bond_by_transport(bd_addr, transport, pin_len, p_pin, trusted_mask); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1180,10 +1178,10 @@ tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 tr tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) { tBTM_SEC_DEV_REC *p_dev_rec; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x\n", btm_pair_state_descr (btm_cb.pairing_state), btm_cb.pairing_flags); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if (((p_dev_rec = btm_find_dev (bd_addr)) == NULL) || (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) { return BTM_UNKNOWN_ADDR; @@ -1479,14 +1477,14 @@ static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UIN ** bd_addr - Address of the peer device ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("BTM_ConfirmReqReply() State: %s Res: %u", btm_pair_state_descr(btm_cb.pairing_state), res); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE /* If timeout already expired or has been canceled, ignore the reply */ if ( (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_NUMERIC_CONFIRM) || (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) { @@ -1511,8 +1509,8 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; btsnd_hcic_user_conf_reply (bd_addr, FALSE); } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -1530,9 +1528,10 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr) #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE) void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d\n", btm_pair_state_descr(btm_cb.pairing_state), res); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if ( (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) || (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) { return; @@ -1618,9 +1617,10 @@ void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type) *******************************************************************************/ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d\n", btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if ( (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS) || (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) { return; @@ -1671,9 +1671,10 @@ tBTM_STATUS BTM_ReadLocalOobData(void) *******************************************************************************/ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() - State: %s res: %d\n", __func__, btm_pair_state_descr(btm_cb.pairing_state), res); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE /* If timeout already expired or has been canceled, ignore the reply */ if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP) { return; @@ -2183,8 +2184,10 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle /* there are some devices (moto KRZR) which connects to several services at the same time */ /* we will process one after another */ if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) ) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() - busy - PSM:%d delayed state: %s mode:%d, sm4:0x%x\n", __func__, psm, btm_pair_state_descr(btm_cb.pairing_state), btm_cb.security_mode, p_dev_rec->sm4); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE BTM_TRACE_EVENT ("security_flags:x%x, sec_flags:x%x\n", security_required, p_dev_rec->sec_flags); rc = BTM_CMD_STARTED; if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || @@ -2446,9 +2449,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o /* there are some devices (moto phone) which connects to several services at the same time */ /* we will process one after another */ if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) ) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() service PSM:%d Proto:%d SCN:%d delayed state: %s\n", __func__, psm, mx_proto_id, mx_chan_id, btm_pair_state_descr(btm_cb.pairing_state)); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE rc = BTM_CMD_STARTED; if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || @@ -2514,9 +2518,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o (*p_callback) (bd_addr, transport, p_ref_data, (UINT8)rc); } } - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT("%s: return with rc = 0x%02x in delayed state %s\n", __FUNCTION__, rc, btm_pair_state_descr(btm_cb.pairing_state)); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE return rc; } @@ -2599,9 +2604,9 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); BTM_TRACE_ERROR ("%s\n", __func__); /* Some device may request a connection before we are done with the HCI_Reset sequence */ @@ -2658,8 +2663,8 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) p_dev_rec->sm4 |= BTM_SM4_CONN_PEND; } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -2671,9 +2676,9 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btm_sec_bond_cancel_complete (void) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) || @@ -2697,8 +2702,9 @@ static void btm_sec_bond_cancel_complete (void) btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS); } } -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -2724,7 +2730,9 @@ void btm_create_conn_cancel_complete (UINT8 *p) */ switch (status) { case HCI_SUCCESS: +#if (SMP_INCLUDED == TRUE) btm_sec_bond_cancel_complete(); +#endif ///SMP_INCLUDED == TRUE break; case HCI_ERR_CONNECTION_EXISTS: case HCI_ERR_NO_CONNECTION: @@ -2757,7 +2765,9 @@ void btm_sec_check_pending_reqs (void) /* First, resubmit L2CAP requests */ if (btm_cb.sec_req_pending) { btm_cb.sec_req_pending = FALSE; +#if (CLASSIC_BT_INCLUDED == TRUE) l2cu_resubmit_pending_sec_req (NULL); +#endif ///SMP_INCLUDED == TRUE } /* Now, re-submit anything in the mux queue */ @@ -2798,14 +2808,14 @@ void btm_sec_check_pending_reqs (void) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_init (UINT8 sec_mode) { -#if (SMP_INCLUDED == TRUE) btm_cb.security_mode = sec_mode; memset (btm_cb.pairing_bda, 0xff, BD_ADDR_LEN); btm_cb.max_collision_delay = BTM_SEC_MAX_COLLISION_DELAY; -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -2817,13 +2827,16 @@ void btm_sec_init (UINT8 sec_mode) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_device_down (void) { -#if (SMP_INCLUDED == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() State: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state)); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -2939,9 +2952,9 @@ static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT8 status) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; int i; DEV_CLASS dev_class; @@ -2976,7 +2989,7 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT /* Commenting out trace due to obf/compilation problems. */ -#if (BT_USE_TRACES == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) if (!p_bd_name) { p_bd_name = (UINT8 *)""; } @@ -3166,8 +3179,9 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT /* There is no next procedure or start of procedure failed, notify the waiting layer */ btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -3228,9 +3242,9 @@ void btm_io_capabilities_req (UINT8 *p) evt_data.io_cap = btm_cb.devcb.loc_io_caps; evt_data.oob_data = BTM_OOB_NONE; evt_data.auth_req = BTM_DEFAULT_AUTH_REQ; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT("%s: State: %s\n", __FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state)); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE p_dev_rec = btm_find_or_alloc_dev (evt_data.bd_addr); BTM_TRACE_DEBUG("%s:Security mode: %d, Num Read Remote Feat pages: %d\n", __FUNCTION__, @@ -3245,11 +3259,11 @@ void btm_io_capabilities_req (UINT8 *p) } p_dev_rec->sm4 |= BTM_SM4_TRUE; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT("%s: State: %s Flags: 0x%04x p_cur_service: %p\n", __FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, p_dev_rec->p_cur_service); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if (p_dev_rec->p_cur_service) { BTM_TRACE_EVENT("%s: cur_service psm: 0x%04x, security_flags: 0x%04x\n", __FUNCTION__, p_dev_rec->p_cur_service->psm, @@ -3381,11 +3395,11 @@ void btm_io_capabilities_req (UINT8 *p) /* send the response right now. Save the current IO capability in the control block */ btm_cb.devcb.loc_auth_req = evt_data.auth_req; btm_cb.devcb.loc_io_caps = evt_data.io_cap; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT("%s: State: %s IO_CAP:%d oob_data:%d auth_req:%d", __FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state), evt_data.io_cap, evt_data.oob_data, evt_data.auth_req); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE btsnd_hcic_io_cap_req_reply(evt_data.bd_addr, evt_data.io_cap, evt_data.oob_data, evt_data.auth_req); } @@ -3476,11 +3490,11 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) /* All events start with bd_addr */ STREAM_TO_BDADDR (p_bda, p); - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("btm_proc_sp_req_evt() BDA: %08x%04x event: 0x%x, State: %s\n", (p_bda[0] << 24) + (p_bda[1] << 16) + (p_bda[2] << 8) + p_bda[3], (p_bda[4] << 8) + p_bda[5], event, btm_pair_state_descr(btm_cb.pairing_state)); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if ( ((p_dev_rec = btm_find_dev (p_bda)) != NULL) && (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && (memcmp (btm_cb.pairing_bda, p_bda, BD_ADDR_LEN) == 0) ) { @@ -3635,10 +3649,10 @@ void btm_simple_pair_complete (UINT8 *p) (evt_data.bd_addr[4] << 8) + evt_data.bd_addr[5]); return; } - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("btm_simple_pair_complete() Pair State: %s Status:%d sec_state: %u\n", btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE evt_data.status = BTM_ERR_PROCESSING; if (status == HCI_SUCCESS) { evt_data.status = BTM_SUCCESS; @@ -3820,7 +3834,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) /* Commenting out trace due to obf/compilation problems. */ -#if (BT_USE_TRACES == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) if (p_dev_rec) { BTM_TRACE_EVENT ("Security Manager: auth_complete PairState: %s handle:%u status:%d dev->sec_state: %u Bda:%08x, RName:%s\n", btm_pair_state_descr (btm_cb.pairing_state), @@ -4126,7 +4140,9 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) if (BTM_SEC_STATE_DELAY_FOR_ENC == p_dev_rec->sec_state) { p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; p_dev_rec->p_callback = NULL; +#if (CLASSIC_BT_INCLUDED == TRUE) l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); +#endif ///CLASSIC_BT_INCLUDED == TRUE } return; } @@ -4189,9 +4205,9 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); UINT8 res; BOOLEAN is_pairing_device = FALSE; @@ -4203,7 +4219,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) BTM_TRACE_ERROR ("%s\n", __func__); /* Commenting out trace due to obf/compilation problems. */ -#if (BT_USE_TRACES == TRUE) +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) if (p_dev_rec) { BTM_TRACE_EVENT ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x RName:%s\n", btm_pair_state_descr(btm_cb.pairing_state), handle, status, enc_mode, @@ -4468,7 +4484,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) } } return; -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4482,7 +4497,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) *******************************************************************************/ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); /* In some weird race condition we may not have a record */ @@ -4501,9 +4515,6 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) } return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle)); -#else - return BTM_MODE_UNSUPPORTED; -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4518,7 +4529,6 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason) *******************************************************************************/ void btm_sec_disconnected (UINT16 handle, UINT8 reason) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); UINT8 old_pairing_flags = btm_cb.pairing_flags; int result = HCI_ERR_AUTH_FAILURE; @@ -4545,12 +4555,12 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) /* clear unused flags */ p_dev_rec->sm4 &= BTM_SM4_TRUE; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) uint8_t *bd_addr = (uint8_t *)p_dev_rec->bd_addr; BTM_TRACE_EVENT("%s sec_req:x%x state:%s reason:%d bd_addr:%02x:%02x:%02x:%02x:%02x:%02x" " remote_name:%s\n", __func__, p_dev_rec->security_required, btm_pair_state_descr(btm_cb.pairing_state), reason, bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5], p_dev_rec->sec_bd_name); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE BTM_TRACE_EVENT("%s before update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags); /* If we are in the process of bonding we need to tell client that auth failed */ @@ -4609,7 +4619,6 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) } BTM_TRACE_EVENT("%s after update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags); -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4624,7 +4633,6 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) *******************************************************************************/ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_type) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda); BOOLEAN we_are_bonding = FALSE; BOOLEAN ltk_derived_lk = FALSE; @@ -4739,7 +4747,6 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t } } } -#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -4753,7 +4760,6 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t *******************************************************************************/ void btm_sec_link_key_request (UINT8 *p_bda) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda); BTM_TRACE_EVENT ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x\n", @@ -4778,8 +4784,8 @@ void btm_sec_link_key_request (UINT8 *p_bda) /* The link key is not in the database and it is not known to the manager */ btsnd_hcic_link_key_neg_reply (p_bda); -#endif ///SMP_INCLUDED == TRUE } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -4811,10 +4817,10 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) /* coverity[UNUSED_VALUE] pointer p_dev_rec is actually used several times... This is a Coverity false-positive, i.e. a fake issue. */ p_dev_rec = btm_find_dev (p_cb->pairing_bda); - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("btm_sec_pairing_timeout() State: %s Flags: %u\n", btm_pair_state_descr(p_cb->pairing_state), p_cb->pairing_flags); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE switch (p_cb->pairing_state) { case BTM_PAIR_STATE_WAIT_PIN_REQ: btm_sec_bond_cancel_complete(); @@ -4899,12 +4905,13 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) break; default: +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_WARNING ("btm_sec_pairing_timeout() not processed state: %s\n", btm_pair_state_descr(btm_cb.pairing_state)); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); break; } } -#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** @@ -4917,8 +4924,6 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle) *******************************************************************************/ void btm_sec_pin_code_request (UINT8 *p_bda) { -#if (SMP_INCLUDED == TRUE) - tBTM_SEC_DEV_REC *p_dev_rec; tBTM_CB *p_cb = &btm_cb; @@ -4926,10 +4931,11 @@ void btm_sec_pin_code_request (UINT8 *p_bda) UINT8 default_pin_code_len = 4; PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30}; #endif +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x\n", btm_pair_state_descr(btm_cb.pairing_state), (p_bda[0] << 8) + p_bda[1], (p_bda[2] << 24) + (p_bda[3] << 16) + (p_bda[4] << 8) + p_bda[5] ); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) && (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) { @@ -4944,9 +4950,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda) } } else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) || memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) { +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_WARNING ("btm_sec_pin_code_request() rejected - state: %s\n", btm_pair_state_descr(btm_cb.pairing_state)); - +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE #ifdef PORCHE_PAIRING_CONFLICT /* reply pin code again due to counter in_rand when local initiates pairing */ BTM_TRACE_EVENT ("btm_sec_pin_code_request from remote dev. for local initiated pairing\n"); @@ -5070,9 +5077,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda) } } } -#endif ///SMP_INCLUDED == TRUE return; } +#endif ///SMP_INCLUDED == TRUE + /******************************************************************************* ** @@ -5541,7 +5549,7 @@ static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle) /******************************************************************************* ** -** Function btm_sec_link_key_request +** Function btm_send_link_key_notif ** ** Description This function is called when controller requests link key ** @@ -5641,10 +5649,11 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state) { tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; - +#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE) BTM_TRACE_EVENT ("%s() Old: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state)); BTM_TRACE_EVENT ("%s() New: %s pairing_flags:0x%x\n\n", __func__, btm_pair_state_descr(new_state), btm_cb.pairing_flags); +#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE btm_cb.pairing_state = new_state; diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index e6d6cdb3db..b0bca897e5 100644 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -81,9 +81,11 @@ static void btu_hcif_flush_occured_evt (void); static void btu_hcif_role_change_evt (UINT8 *p); static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p); static void btu_hcif_mode_change_evt (UINT8 *p); +#if (SMP_INCLUDED == TRUE) static void btu_hcif_pin_code_request_evt (UINT8 *p); static void btu_hcif_link_key_request_evt (UINT8 *p); static void btu_hcif_link_key_notification_evt (UINT8 *p); +#endif ///SMP_INCLUDED == TRUE static void btu_hcif_loopback_command_evt (void); static void btu_hcif_data_buf_overflow_evt (void); static void btu_hcif_max_slots_changed_evt (void); @@ -235,6 +237,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_MODE_CHANGE_EVT: btu_hcif_mode_change_evt (p); break; +#if (SMP_INCLUDED == TRUE) case HCI_PIN_CODE_REQUEST_EVT: btu_hcif_pin_code_request_evt (p); break; @@ -244,6 +247,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_LINK_KEY_NOTIFICATION_EVT: btu_hcif_link_key_notification_evt (p); break; +#endif ///SMP_INCLUDED == TRUE case HCI_LOOPBACK_COMMAND_EVT: btu_hcif_loopback_command_evt (); break; @@ -517,7 +521,9 @@ static void btu_hcif_connection_comp_evt (UINT8 *p) UINT16 handle; BD_ADDR bda; UINT8 link_type; +#if SMP_INCLUDED == TRUE UINT8 enc_mode; +#endif ///SMP_INCLUDED == TRUE #if BTM_SCO_INCLUDED == TRUE tBTM_ESCO_DATA esco_data; #endif @@ -526,13 +532,15 @@ static void btu_hcif_connection_comp_evt (UINT8 *p) STREAM_TO_UINT16 (handle, p); STREAM_TO_BDADDR (bda, p); STREAM_TO_UINT8 (link_type, p); +#if (SMP_INCLUDED == TRUE) STREAM_TO_UINT8 (enc_mode, p); - +#endif ///SMP_INCLUDED == TRUE handle = HCID_GET_HANDLE (handle); if (link_type == HCI_LINK_TYPE_ACL) { +#if (SMP_INCLUDED == TRUE) btm_sec_connected (bda, handle, status, enc_mode); - +#endif ///SMP_INCLUDED == TRUE l2c_link_hci_conn_comp (status, handle, bda); } #if BTM_SCO_INCLUDED == TRUE @@ -564,11 +572,12 @@ static void btu_hcif_connection_request_evt (UINT8 *p) STREAM_TO_BDADDR (bda, p); STREAM_TO_DEVCLASS (dc, p); STREAM_TO_UINT8 (link_type, p); - /* Pass request to security manager to check connect filters before */ /* passing request to l2cap */ if (link_type == HCI_LINK_TYPE_ACL) { +#if (SMP_INCLUDED == TRUE) btm_sec_conn_req (bda, dc); +#endif ///SMP_INCLUDED == TRUE } #if BTM_SCO_INCLUDED == TRUE else { @@ -606,9 +615,10 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p) #else l2c_link_hci_disc_comp (handle, reason); #endif /* BTM_SCO_INCLUDED */ - +#if (SMP_INCLUDED == TRUE) /* Notify security manager */ btm_sec_disconnected (handle, reason); +#endif ///SMP_INCLUDED == TRUE } /******************************************************************************* @@ -653,8 +663,9 @@ static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len) evt_len -= (1 + BD_ADDR_LEN); btm_process_remote_name (bd_addr, p, evt_len, status); - +#if (SMP_INCLUDED == TRUE) btm_sec_rmt_name_request_complete (bd_addr, p, status); +#endif ///SMP_INCLUDED == TRUE } @@ -1055,8 +1066,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c case HCI_RMT_NAME_REQUEST: /* Tell inquiry processing that we are done */ btm_process_remote_name (NULL, NULL, 0, status); - +#if (SMP_INCLUDED == TRUE) btm_sec_rmt_name_request_complete (NULL, NULL, status); +#endif ///SMP_INCLUDED == TRUE break; case HCI_QOS_SETUP_COMP_EVT: @@ -1082,7 +1094,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c if (p_cmd != NULL) { p_cmd++; STREAM_TO_BDADDR (bd_addr, p_cmd); +#if (SMP_INCLUDED == TRUE) btm_sec_connected (bd_addr, HCI_INVALID_HANDLE, status, 0); +#endif ///SMP_INCLUDED == TRUE l2c_link_hci_conn_comp (status, HCI_INVALID_HANDLE, bd_addr); } break; @@ -1337,6 +1351,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len) ** Returns void ** *******************************************************************************/ +#if (SMP_INCLUDED == TRUE) static void btu_hcif_pin_code_request_evt (UINT8 *p) { BD_ADDR bda; @@ -1368,7 +1383,6 @@ static void btu_hcif_link_key_request_evt (UINT8 *p) btm_sec_link_key_request (bda); } - /******************************************************************************* ** ** Function btu_hcif_link_key_notification_evt @@ -1390,6 +1404,7 @@ static void btu_hcif_link_key_notification_evt (UINT8 *p) btm_sec_link_key_notification (bda, key, key_type); } +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* diff --git a/components/bt/bluedroid/stack/gatt/att_protocol.c b/components/bt/bluedroid/stack/gatt/att_protocol.c index 50150fa32a..15bd0b2303 100644 --- a/components/bt/bluedroid/stack/gatt/att_protocol.c +++ b/components/bt/bluedroid/stack/gatt/att_protocol.c @@ -345,7 +345,11 @@ tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP) if (p_tcb->att_lcid == L2CAP_ATT_CID) { l2cap_ret = L2CA_SendFixedChnlData (L2CAP_ATT_CID, p_tcb->peer_bda, p_toL2CAP); } else { +#if (CLASSIC_BT_INCLUDED == TRUE) l2cap_ret = (UINT16) L2CA_DataWrite (p_tcb->att_lcid, p_toL2CAP); +#else + l2cap_ret = L2CAP_DW_FAILED; +#endif ///CLASSIC_BT_INCLUDED == TRUE } if (l2cap_ret == L2CAP_DW_FAILED) { diff --git a/components/bt/bluedroid/stack/gatt/gatt_main.c b/components/bt/bluedroid/stack/gatt/gatt_main.c index e96072abb1..1e2c00c1fa 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/bluedroid/stack/gatt/gatt_main.c @@ -48,7 +48,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect UINT16 reason, tBT_TRANSPORT transport); static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf); static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest); - +#if (CLASSIC_BT_INCLUDED == TRUE) static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id); static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result); @@ -57,9 +57,10 @@ static void gatt_l2cif_config_cfm_cback (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cf static void gatt_l2cif_disconnect_ind_cback (UINT16 l2cap_cid, BOOLEAN ack_needed); static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result); static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg); +#endif ///CLASSIC_BT_INCLUDED == TRUE static void gatt_send_conn_cback (tGATT_TCB *p_tcb); +#if (CLASSIC_BT_INCLUDED == TRUE) static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested); - static const tL2CAP_APPL_INFO dyn_info = { gatt_l2cif_connect_ind_cback, gatt_l2cif_connect_cfm_cback, @@ -73,6 +74,7 @@ static const tL2CAP_APPL_INFO dyn_info = { gatt_l2cif_congest_cback, NULL } ; +#endif ///SMP_INCLUDED == TRUE #if GATT_DYNAMIC_MEMORY == FALSE tGATT_CB gatt_cb; @@ -412,7 +414,9 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect gatt_send_conn_cback(p_tcb); } if (check_srv_chg) { +#if (GATTS_INCLUDED == TRUE) gatt_chk_srv_chg (p_srv_chg_clt); +#endif ///GATTS_INCLUDED == TRUE } } /* this is incoming connection or background connection callback */ @@ -427,7 +431,9 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect gatt_send_conn_cback (p_tcb); if (check_srv_chg) { +#if (GATTS_INCLUDED == TRUE) gatt_chk_srv_chg (p_srv_chg_clt); +#endif ///GATTS_INCLUDED == TRUE } } else { GATT_TRACE_ERROR("CCB max out, no rsources"); @@ -535,9 +541,9 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf) ** Returns void ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id) { -#if (CLASSIC_BT_INCLUDED == TRUE) /* do we already have a control channel for this peer? */ UINT8 result = L2CAP_CONN_OK; tL2CAP_CFG_INFO cfg; @@ -574,7 +580,6 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 L2CA_ConfigReq(lcid, &cfg); } -#endif ///CLASSIC_BT_INCLUDED == TRUE } @@ -590,7 +595,6 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 *******************************************************************************/ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tL2CAP_CFG_INFO cfg; @@ -622,8 +626,6 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) } } } -#endif ///CLASSIC_BT_INCLUDED == TRUE - } /******************************************************************************* @@ -638,7 +640,6 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result) *******************************************************************************/ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tGATTS_SRV_CHG *p_srv_chg_clt = NULL; @@ -656,7 +657,9 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) gatt_set_ch_state(p_tcb, GATT_CH_OPEN); if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL) { +#if (GATTS_INCLUDED == TRUE) gatt_chk_srv_chg(p_srv_chg_clt); +#endif ///GATTS_INCLUDED == TRUE } else { if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda)) { gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda); @@ -674,8 +677,6 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) } } } -#endif ///CLASSIC_BT_INCLUDED == TRUE - } /******************************************************************************* @@ -690,7 +691,6 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; tGATTS_SRV_CHG *p_srv_chg_clt = NULL; /* look up clcb for this channel */ @@ -717,7 +717,9 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) if (p_tcb->ch_flags & GATT_L2C_CFG_CFM_DONE) { gatt_set_ch_state(p_tcb, GATT_CH_OPEN); if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL) { +#if (GATTS_INCLUDED == TRUE) gatt_chk_srv_chg(p_srv_chg_clt); +#endif ///GATTS_INCLUDED == TRUE } else { if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda)) { gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda); @@ -729,8 +731,6 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) } } } -#endif ///CLASSIC_BT_INCLUDED == TRUE - } /******************************************************************************* @@ -745,7 +745,6 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; UINT16 reason; @@ -768,8 +767,6 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) /* send disconnect callback */ gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR); } -#endif ///CLASSIC_BT_INCLUDED == TRUE - } /******************************************************************************* @@ -784,7 +781,6 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) *******************************************************************************/ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; UINT16 reason; UNUSED(result); @@ -806,8 +802,6 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR); } -#endif ///CLASSIC_BT_INCLUDED == TRUE - } /******************************************************************************* @@ -822,7 +816,6 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result) *******************************************************************************/ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb; /* look up clcb for this channel */ @@ -833,7 +826,6 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) } else { /* prevent buffer leak */ GKI_freebuf(p_buf); } -#endif ///CLASSIC_BT_INCLUDED == TRUE } @@ -848,15 +840,14 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf) *******************************************************************************/ static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested) { -#if (CLASSIC_BT_INCLUDED == TRUE) tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid); if (p_tcb != NULL) { gatt_channel_congestion(p_tcb, congested); } -#endif ///CLASSIC_BT_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -990,9 +981,9 @@ void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda) ** Returns void ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) void gatt_send_srv_chg_ind (BD_ADDR peer_bda) { -#if (GATTS_INCLUDED == TRUE) UINT8 handle_range[GATT_SIZE_OF_SRV_CHG_HNDL_RANGE]; UINT8 *p = handle_range; UINT16 conn_id; @@ -1013,9 +1004,9 @@ void gatt_send_srv_chg_ind (BD_ADDR peer_bda) (peer_bda[4] << 8) + peer_bda[5] ); } } -#endif ///GATTS_INCLUDED == TRUE } + /******************************************************************************* ** ** Function gatt_chk_srv_chg @@ -1034,6 +1025,8 @@ void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt) gatt_send_srv_chg_ind(p_srv_chg_clt->bda); } } +#endif ///GATTS_INCLUDED == TRUE + /******************************************************************************* ** @@ -1087,6 +1080,7 @@ void gatt_init_srv_chg (void) ** Returns void ** *******************************************************************************/ +#if (GATTS_INCLUDED == TRUE) void gatt_proc_srv_chg (void) { UINT8 start_idx, found_idx; @@ -1113,6 +1107,7 @@ void gatt_proc_srv_chg (void) } } } +#endif ///GATTS_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/l2cap/l2c_api.c b/components/bt/bluedroid/stack/l2cap/l2c_api.c index 5f5b854e41..1d2c1b047b 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_api.c @@ -1754,11 +1754,13 @@ BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda) ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data) { L2CAP_TRACE_API ("L2CA_DataWrite() CID: 0x%04x Len: %d", cid, p_data->len); return l2c_data_write (cid, p_data, L2CAP_FLUSHABLE_CH_BASED); } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** @@ -1806,12 +1808,14 @@ BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable) ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags) { L2CAP_TRACE_API ("L2CA_DataWriteEx() CID: 0x%04x Len: %d Flags:0x%04X", cid, p_data->len, flags); return l2c_data_write (cid, p_data, flags); } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/bluedroid/stack/l2cap/l2c_ble.c index 330d9791be..acdbd4fc86 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_ble.c @@ -272,13 +272,17 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, if (!p_lcb) { p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE); if (!p_lcb) { +#if (SMP_INCLUDED == TRUE) btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION); L2CAP_TRACE_ERROR ("l2cble_scanner_conn_comp - failed to allocate LCB"); +#endif ///SMP_INCLUDED == TRUE return; } else { if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts)) { +#if (SMP_INCLUDED == TRUE) btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION); L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB"); +#endif ///SMP_INCLUDED == TRUE return ; } } @@ -371,12 +375,16 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ if (!p_lcb) { p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE); if (!p_lcb) { +#if (SMP_INCLUDED == TRUE) btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION); +#endif ///SMP_INCLUDED == TRUE L2CAP_TRACE_ERROR ("l2cble_advertiser_conn_comp - failed to allocate LCB"); return; } else { if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts)) { +#if (SMP_INCLUDED == TRUE) btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION); +#endif ///SMP_INCLUDED == TRUE L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB"); return ; } diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index 8fd29844fd..14c56c56ec 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -519,9 +519,10 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) #if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; #endif ///CLASSIC_BT_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) UINT16 timeout; tBTM_STATUS rc; - +#endif ///SMP_INCLUDED == TRUE L2CAP_TRACE_EVENT ("L2CAP - l2c_link_timeout() link state %d first CCB %p is_bonding:%d", p_lcb->link_state, p_lcb->ccb_queue.p_first_ccb, p_lcb->is_bonding); @@ -577,6 +578,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) #endif ///CLASSIC_BT_INCLUDED == TRUE } +#if (SMP_INCLUDED == TRUE) /* If no channels in use, drop the link. */ if (!p_lcb->ccb_queue.p_first_ccb) { rc = btm_sec_disconnect (p_lcb->handle, HCI_ERR_PEER_USER); @@ -611,7 +613,8 @@ void l2c_link_timeout (tL2C_LCB *p_lcb) } else { /* Check in case we were flow controlled */ l2c_link_check_send_pkts (p_lcb, NULL, NULL); - } + } +#endif ///SMP_INCLUDED == TRUE } } diff --git a/components/bt/bluedroid/stack/l2cap/l2c_main.c b/components/bt/bluedroid/stack/l2cap/l2c_main.c index 5938a12053..3c5e4d1495 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_main.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_main.c @@ -41,8 +41,9 @@ /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len); - +#endif ///CLASSIC_BT_INCLUDED == TRUE /********************************************************************************/ /* G L O B A L L 2 C A P D A T A */ /********************************************************************************/ @@ -217,7 +218,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) if (rcv_cid == L2CAP_SIGNALLING_CID) { //counter_add("l2cap.sig.rx.bytes", l2cap_len); //counter_add("l2cap.sig.rx.pkts", 1); +#if (CLASSIC_BT_INCLUDED == TRUE) process_l2cap_cmd (p_lcb, p, l2cap_len); +#endif ///CLASSIC_BT_INCLUDED == TRUE GKI_freebuf (p_msg); } else if (rcv_cid == L2CAP_CONNECTIONLESS_CID) { //counter_add("l2cap.ch2.rx.bytes", l2cap_len); @@ -302,9 +305,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) ** Returns void ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) { -#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 *p_pkt_end, *p_next_cmd, *p_cfg_end, *p_cfg_start; UINT8 cmd_code, cfg_code, cfg_len, id; tL2C_CONN_INFO con_info; @@ -739,8 +742,9 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) } } -#endif ///CLASSIC_BT_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE + /******************************************************************************* ** @@ -904,9 +908,9 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle) ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) { -#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_CCB *p_ccb; /* Find the channel control block. We don't know the link it is on. */ @@ -945,7 +949,8 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) if (p_ccb->cong_sent) { return (L2CAP_DW_CONGESTED); } -#endif ///CLASSIC_BT_INCLUDED == TRUE return (L2CAP_DW_SUCCESS); } +#endif ///CLASSIC_BT_INCLUDED == TRUE + diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 8dd5ea33fa..eb5490bd29 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -2048,9 +2048,9 @@ void l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) ** Returns void ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { -#if (CLASSIC_BT_INCLUDED == TRUE) /* If peer wants QoS, we are allowed to change the values in a positive response */ if ( (p_cfg->qos_present) && (p_ccb->peer_cfg.qos_present) ) { p_ccb->peer_cfg.qos = p_cfg->qos; @@ -2059,8 +2059,8 @@ void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) } l2c_fcr_adj_our_rsp_options (p_ccb, p_cfg); -#endif ///CLASSIC_BT_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE /******************************************************************************* @@ -2420,9 +2420,9 @@ void l2cu_set_non_flushable_pbf (BOOLEAN is_supported) ** Returns void ** *******************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda) { -#if (CLASSIC_BT_INCLUDED == TRUE) tL2C_LCB *p_lcb; tL2C_CCB *p_ccb; tL2C_CCB *p_next_ccb; @@ -2454,8 +2454,8 @@ void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda) } } } -#endif ///CLASSIC_BT_INCLUDED == TRUE } +#endif ///CLASSIC_BT_INCLUDED == TRUE #if L2CAP_CONFORMANCE_TESTING == TRUE /******************************************************************************* @@ -2592,7 +2592,9 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR *******************************************************************************/ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb) { +#if (SMP_INCLUDED == TRUE) tBTM_STATUS rc; +#endif ///SMP_INCLUDED == TRUE UINT16 timeout = p_lcb->idle_timeout; #if (L2CAP_NUM_FIXED_CHNLS > 0) @@ -2612,7 +2614,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb) if (timeout == 0) { L2CAP_TRACE_DEBUG ("l2cu_no_dynamic_ccbs() IDLE timer 0, disconnecting link"); - +#if (SMP_INCLUDED == TRUE) rc = btm_sec_disconnect (p_lcb->handle, HCI_ERR_PEER_USER); if (rc == BTM_CMD_STARTED) { l2cu_process_fixed_disc_cback(p_lcb); @@ -2632,6 +2634,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb) /* probably no buffer to send disconnect */ timeout = BT_1SEC_TIMEOUT; } +#endif ///SMP_INCLUDED == TRUE } if (timeout != 0xFFFF) { From 572e3207952793f098a93f84f50fdb606e119a4e Mon Sep 17 00:00:00 2001 From: Yulong Date: Tue, 25 Apr 2017 22:47:16 -0400 Subject: [PATCH 12/15] component/bt:change the kconfig. 1.change the rowdata to rodata; 2.change BT_ACL_CONNECTIONS to Maximum BT/BLE connection count. 3. change the comments of bt_target.h:505 from 40 to 5. --- components/bt/Kconfig | 10 +++++----- components/bt/bluedroid/include/bt_target.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 947142666f..81eb765efd 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -39,21 +39,21 @@ config BT_DRAM_RELEASE The released DRAM will be used as system heap memory. config GATTS_ENABLE - bool "Set if enable the gatt server module(GATTS) in the stack or not" + bool "Include GATT server module(GATTS)" depends on BLUEDROID_ENABLED default y help - This option can be close when the app work only on gatt client mode + This option can be disabled when the app work only on gatt client mode config GATTC_ENABLE - bool "Set if enable the gatt server module(GATTC) in the stack or not" + bool "Include GATT client module(GATTC)" depends on BLUEDROID_ENABLED default y help This option can be close when the app work only on gatt server mode config SMP_ENABLE - bool "Set if enable the ble security module (SMP module) or not" + bool "Include BT security module(SMP)" depends on BLUEDROID_ENABLED default y help @@ -64,7 +64,7 @@ config BT_ACL_CONNECTIONS depends on BLUEDROID_ENABLED default 4 help - This setting is used for the max connection link for the bt/ble device + Maximum BT/BLE connection count config BT_STACK_NO_LOG bool "Close the bluedroid bt stack log print" diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index 1953476845..9a77e6c8f8 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -502,9 +502,9 @@ #define BTM_SCO_DATA_SIZE_MAX 240 #endif -/* The size in bytes of the BTM inquiry database. 40 As Default */ +/* The size in bytes of the BTM inquiry database. 5 As Default */ #ifndef BTM_INQ_DB_SIZE -#define BTM_INQ_DB_SIZE 5//32 +#define BTM_INQ_DB_SIZE 5 #endif /* The default scan mode */ From 891257b4dd2c17432eb842d9c5d129f657854db3 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 26 Apr 2017 02:28:34 -0400 Subject: [PATCH 13/15] component/bt:Change the bt Kconfig BT_ACL_CONNECTIONS from int to choice. --- components/bt/Kconfig | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 81eb765efd..91d738d37a 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -59,13 +59,39 @@ config SMP_ENABLE help This option can be close when the app not used the ble security connect. -config BT_ACL_CONNECTIONS - int "Set the max connection number for the bt/ble device can accept, up to 7." +choice BT_ACL_CONNECTIONS + prompt "BT/BLE MAX ACL CONNECTIONS" depends on BLUEDROID_ENABLED - default 4 + default BT_ACL_CONNECTION_4 help Maximum BT/BLE connection count +config BT_ACL_CONNECTION_1 + bool "1 ACL CONNECT" +config BT_ACL_CONNECTION_2 + bool "2 ACL CONNECT" +config BT_ACL_CONNECTION_3 + bool "3 ACL CONNECT" +config BT_ACL_CONNECTION_4 + bool "4 ACL CONNECT" +config BT_ACL_CONNECTION_5 + bool "5 ACL CONNECT" +config BT_ACL_CONNECTION_6 + bool "6 ACL CONNECT" +config BT_ACL_CONNECTION_7 + bool "7 ACL CONNECT" +endchoice + +config BT_ACL_CONNECTIONS + int + default 1 if BT_ACL_CONNECTION_1 + default 2 if BT_ACL_CONNECTION_2 + default 3 if BT_ACL_CONNECTION_3 + default 4 if BT_ACL_CONNECTION_4 + default 5 if BT_ACL_CONNECTION_5 + default 6 if BT_ACL_CONNECTION_6 + default 7 if BT_ACL_CONNECTION_7 + config BT_STACK_NO_LOG bool "Close the bluedroid bt stack log print" depends on BLUEDROID_ENABLED From c31953a005d85f782cbaff184e16778caa832065 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 26 Apr 2017 04:23:45 -0400 Subject: [PATCH 14/15] component/bt:Fixted the bug of HCI comment timeout error. 1. remove the SMP_INCLUDED == TRUE insite the btm_find_dev_by_handle function. 2. change the Kconfig with BT_ACL_CONNECTIONS --- components/bt/Kconfig | 14 +++++++------- components/bt/bluedroid/stack/btm/btm_dev.c | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 91d738d37a..154df1b687 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -59,6 +59,13 @@ config SMP_ENABLE help This option can be close when the app not used the ble security connect. +config BT_STACK_NO_LOG + bool "Close the bluedroid bt stack log print" + depends on BLUEDROID_ENABLED + default n + help + This select can save the rodata code size + choice BT_ACL_CONNECTIONS prompt "BT/BLE MAX ACL CONNECTIONS" depends on BLUEDROID_ENABLED @@ -92,13 +99,6 @@ config BT_ACL_CONNECTIONS default 6 if BT_ACL_CONNECTION_6 default 7 if BT_ACL_CONNECTION_7 -config BT_STACK_NO_LOG - bool "Close the bluedroid bt stack log print" - depends on BLUEDROID_ENABLED - default n - help - This select can save the rowdata code size - #disable now for app cpu due to a known issue config BTDM_CONTROLLER_RUN_APP_CPU bool "Run controller on APP CPU" diff --git a/components/bt/bluedroid/stack/btm/btm_dev.c b/components/bt/bluedroid/stack/btm/btm_dev.c index aa8c49fdd2..cf445d1239 100644 --- a/components/bt/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/bluedroid/stack/btm/btm_dev.c @@ -396,7 +396,6 @@ BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr) *******************************************************************************/ tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle) { -#if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0]; int i; @@ -410,7 +409,6 @@ tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle) return (p_dev_rec); } } -#endif ///SMP_INCLUDED == TRUE return (NULL); } From 54aaeacb32e17e00c705d1c375cd7e55bf9b90d0 Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 26 Apr 2017 05:27:21 -0400 Subject: [PATCH 15/15] component/bt:Change the bt Kconfig BT_ACL_CONNECTIONS type from choice to int(range). --- components/bt/Kconfig | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 154df1b687..33dc944456 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -66,39 +66,14 @@ config BT_STACK_NO_LOG help This select can save the rodata code size -choice BT_ACL_CONNECTIONS - prompt "BT/BLE MAX ACL CONNECTIONS" +config BT_ACL_CONNECTIONS + int "BT/BLE MAX ACL CONNECTIONS(1~7)" depends on BLUEDROID_ENABLED - default BT_ACL_CONNECTION_4 + range 1 7 + default 4 help Maximum BT/BLE connection count -config BT_ACL_CONNECTION_1 - bool "1 ACL CONNECT" -config BT_ACL_CONNECTION_2 - bool "2 ACL CONNECT" -config BT_ACL_CONNECTION_3 - bool "3 ACL CONNECT" -config BT_ACL_CONNECTION_4 - bool "4 ACL CONNECT" -config BT_ACL_CONNECTION_5 - bool "5 ACL CONNECT" -config BT_ACL_CONNECTION_6 - bool "6 ACL CONNECT" -config BT_ACL_CONNECTION_7 - bool "7 ACL CONNECT" -endchoice - -config BT_ACL_CONNECTIONS - int - default 1 if BT_ACL_CONNECTION_1 - default 2 if BT_ACL_CONNECTION_2 - default 3 if BT_ACL_CONNECTION_3 - default 4 if BT_ACL_CONNECTION_4 - default 5 if BT_ACL_CONNECTION_5 - default 6 if BT_ACL_CONNECTION_6 - default 7 if BT_ACL_CONNECTION_7 - #disable now for app cpu due to a known issue config BTDM_CONTROLLER_RUN_APP_CPU bool "Run controller on APP CPU"