component/bt:Finish all the separate code from BT & BLE

This commit is contained in:
Yulong 2017-04-20 07:18:05 -04:00
parent 67863ec495
commit bc807a18d1
34 changed files with 188 additions and 58 deletions

View file

@ -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

View file

@ -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

View file

@ -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
/*******************************************************************************
**

View file

@ -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 */

View file

@ -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 <string.h>
#include "gki.h"

View file

@ -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 <string.h>
@ -136,4 +136,4 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
return (TRUE);
}
#endif /* BTA_GATT_INCLUDED */
#endif /* GATTS_INCLUDED */

View file

@ -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 <string.h>
#include "utl.h"
@ -222,4 +222,4 @@ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src)
#endif
#endif /* GATTS_INCLUDED */

View file

@ -40,7 +40,7 @@
#ifndef BTA_GATT_DEBUG
#define BTA_GATT_DEBUG TRUE
#define BTA_GATT_DEBUG FALSE
#endif
/*****************************************************************************

View file

@ -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 },

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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 <stdlib.h>
#include <string.h>

View file

@ -21,6 +21,7 @@
#include <stdbool.h>
#include "bt_defs.h"
#include "bt_target.h"
typedef enum {
// Disable secure connections

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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 <string.h>
@ -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, &param) == 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*/

View file

@ -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

View file

@ -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++) {

View file

@ -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 */

View file

@ -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
}
/*******************************************************************************
**

View file

@ -24,7 +24,7 @@
#include "bt_target.h"
#if BLE_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
#include <string.h>
//#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 */

View file

@ -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 */

View file

@ -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
}
/*******************************************************************************

View file

@ -25,7 +25,7 @@
#include "bt_target.h"
//#include "bt_utils.h"
#if BLE_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE
#include <string.h>
#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 */

View file

@ -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
}

View file

@ -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;

View file

@ -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) {

View file

@ -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)
/******************************************************************************
**