summaryrefslogtreecommitdiffstats
path: root/bta/gatt
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2012-09-18 01:35:44 -0700
committerMatthew Xie <mattx@google.com>2012-09-18 16:26:28 -0700
commit6ef101187774e30ddba6b46bbedef549a42196ad (patch)
treef36eb347f03083671640fbc750171e3b951e0082 /bta/gatt
parentf80d3d045eab5f002be4b5e8a3d2d376fdf7581a (diff)
downloadexternal_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.zip
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.gz
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.bz2
Initual Bluetooth open source release
First release under Apache source license with updated header files and whitespace cleanups. Also fixed file permission to remove executable bit from source files. Change-Id: I7155903edfc2f491c1cbbd0db108f207852caaa0
Diffstat (limited to 'bta/gatt')
-rw-r--r--bta/gatt/bta_gattc_act.c329
-rw-r--r--bta/gatt/bta_gattc_api.c254
-rw-r--r--bta/gatt/bta_gattc_cache.c315
-rw-r--r--bta/gatt/bta_gattc_ci.c48
-rw-r--r--bta/gatt/bta_gattc_int.h78
-rw-r--r--bta/gatt/bta_gattc_main.c60
-rw-r--r--bta/gatt/bta_gattc_utils.c90
-rw-r--r--bta/gatt/bta_gatts_act.c125
-rw-r--r--bta/gatt/bta_gatts_api.c94
-rw-r--r--bta/gatt/bta_gatts_int.h51
-rw-r--r--bta/gatt/bta_gatts_main.c46
-rw-r--r--bta/gatt/bta_gatts_utils.c46
12 files changed, 842 insertions, 694 deletions
diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c
index ce0c209..5cacf03 100644
--- a/bta/gatt/bta_gattc_act.c
+++ b/bta/gatt/bta_gattc_act.c
@@ -1,14 +1,27 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_act.c
-**
-** Description: This file contains the GATT client action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT client action functions for the state
+ * machine.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -29,10 +42,10 @@
/*****************************************************************************
** Constants
*****************************************************************************/
-static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
+static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
BOOLEAN connected, tGATT_DISCONN_REASON reason);
-static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
+static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
tGATT_CL_COMPLETE *p_data);
static tGATT_CBACK bta_gattc_cl_cback =
@@ -74,7 +87,7 @@ static const char *bta_gattc_op_code_name[] =
** Function bta_gattc_register
**
** Description Register a GATT client application with BTA.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -82,7 +95,7 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
{
tBTA_GATTC cb_data;
UINT8 i;
- tBT_UUID *p_app_uuid = &p_data->api_reg.app_uuid;
+ tBT_UUID *p_app_uuid = &p_data->api_reg.app_uuid;
tBTA_GATTC_INT_START_IF *p_buf;
@@ -108,7 +121,7 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
// btla-specific ++
memcpy(&(cb_data.reg_oper.app_uuid),p_app_uuid,sizeof(tBT_UUID));
// btla-specific --
-
+
cb_data.reg_oper.status = BTA_GATT_OK;
if ((p_buf = (tBTA_GATTC_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL)
@@ -161,7 +174,7 @@ void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
** Function bta_gattc_deregister_cmpl
**
** Description De-Register a GATT client application with BTA completed.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -190,7 +203,7 @@ void bta_gattc_int_deregister_cmpl(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_IF client
** Function bta_gattc_deregister_cmpl
**
** Description De-Register a GATT client application with BTA completed.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -218,7 +231,7 @@ void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_IF client_if)
** Function bta_gattc_deregister
**
** Description De-Register a GATT client application with BTA.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -248,7 +261,7 @@ void bta_gattc_int_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
else
{
APPL_TRACE_ERROR1("bta_gattc_int_deregister Deregister Failed, unknown client_if: %d", p_data->int_dereg.client_if);
- }
+ }
}
@@ -257,7 +270,7 @@ void bta_gattc_int_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_deregister
**
** Description De-Register a GATT client application with BTA.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -279,8 +292,8 @@ void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
p_clreg->dereg_pending = TRUE;
buf.event = BTA_GATTC_API_CLOSE_EVT;
- buf.layer_specific = p_cb->clcb[i].bta_conn_id;
- bta_gattc_close(&p_cb->clcb[i], (tBTA_GATTC_DATA *)&buf) ;
+ buf.layer_specific = p_cb->clcb[i].bta_conn_id;
+ bta_gattc_close(&p_cb->clcb[i], (tBTA_GATTC_DATA *)&buf) ;
}
}
}
@@ -290,14 +303,14 @@ void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
else
{
APPL_TRACE_ERROR1("bta_gattc_deregister Deregister Failed, unknown client_if: %d", p_data->api_dereg.client_if);
- }
+ }
}
/*******************************************************************************
**
** Function bta_gattc_process_api_open
**
-** Description process connect API request.
-**
+** Description process connect API request.
+**
** Returns void
**
*******************************************************************************/
@@ -320,8 +333,8 @@ void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
{
APPL_TRACE_ERROR0("No resources to open a new connection.");
- bta_gattc_send_open_cback(p_clreg,
- BTA_GATT_NO_RESOURCES,
+ bta_gattc_send_open_cback(p_clreg,
+ BTA_GATT_NO_RESOURCES,
p_msg->api_conn.remote_bda,
BTA_GATT_INVALID_CONN_ID);
}
@@ -333,7 +346,7 @@ void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
}
else
{
- APPL_TRACE_ERROR1("bta_gattc_process_api_open Failed, unknown client_if: %d",
+ APPL_TRACE_ERROR1("bta_gattc_process_api_open Failed, unknown client_if: %d",
p_msg->api_conn.client_if);
}
}
@@ -341,8 +354,8 @@ void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
**
** Function bta_gattc_process_api_open_cancel
**
-** Description process connect API request.
-**
+** Description process connect API request.
+**
** Returns void
**
*******************************************************************************/
@@ -383,8 +396,8 @@ void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p
**
** Function bta_gattc_cancel_open_error
**
-** Description
-**
+** Description
+**
** Returns void
**
*******************************************************************************/
@@ -400,8 +413,8 @@ void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_dat
**
** Function bta_gattc_open_error
**
-** Description
-**
+** Description
+**
** Returns void
**
*******************************************************************************/
@@ -409,8 +422,8 @@ void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
APPL_TRACE_ERROR0("Connection already opened. wrong state");
- bta_gattc_send_open_cback(p_clcb->p_rcb,
- BTA_GATT_ALREADY_OPEN,
+ bta_gattc_send_open_cback(p_clcb->p_rcb,
+ BTA_GATT_ALREADY_OPEN,
p_clcb->bda,
p_clcb->bta_conn_id);
}
@@ -418,8 +431,8 @@ void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
**
** Function bta_gattc_open_fail
**
-** Description
-**
+** Description
+**
** Returns void
**
*******************************************************************************/
@@ -435,14 +448,14 @@ void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_open
**
** Description Process API connection function.
-**
+**
** Returns void
**
*******************************************************************************/
void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
tBTA_GATTC_DATA gattc_data;
-
+
/* open/hold a connection */
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, TRUE))
{
@@ -453,10 +466,10 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
else
{
/* a connected remote device */
- if (GATT_GetConnIdIfConnected(p_clcb->p_rcb->client_if,
- p_data->api_conn.remote_bda,
+ if (GATT_GetConnIdIfConnected(p_clcb->p_rcb->client_if,
+ p_data->api_conn.remote_bda,
&p_clcb->bta_conn_id))
- {
+ {
gattc_data.hdr.layer_specific = p_clcb->bta_conn_id;
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, &gattc_data);
@@ -469,7 +482,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_init_bk_conn
**
** Description Process API Open for a background connection
-**
+**
** Returns void
**
*******************************************************************************/
@@ -486,19 +499,19 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, FALSE))
{
status = BTA_GATT_ERROR;
- APPL_TRACE_ERROR0("bta_gattc_init_bk_conn failed");
+ APPL_TRACE_ERROR0("bta_gattc_init_bk_conn failed");
}
else
{
status = BTA_GATT_OK;
/* if is a connected remote device */
- if (GATT_GetConnIdIfConnected(p_data->client_if,
- p_data->remote_bda,
+ if (GATT_GetConnIdIfConnected(p_data->client_if,
+ p_data->remote_bda,
&conn_id))
- {
+ {
if ((p_clcb = bta_gattc_clcb_alloc(p_data->client_if, p_data->remote_bda)) != NULL)
- {
+ {
gattc_data.hdr.layer_specific = p_clcb->bta_conn_id = conn_id;
/* open connection */
@@ -508,7 +521,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
}
}
}
-
+
/* open failure, report OPEN_EVT */
if (status != BTA_GATT_OK)
{
@@ -520,7 +533,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
** Function bta_gattc_cancel_bk_conn
**
** Description Process API Cancel Open for a background connection
-**
+**
** Returns void
**
*******************************************************************************/
@@ -542,7 +555,7 @@ void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data)
}
}
p_clreg = bta_gattc_cl_get_regcb(p_data->client_if);
-
+
if (p_clreg && p_clreg->p_cback)
{
(*p_clreg->p_cback)(BTA_GATTC_CANCEL_OPEN_EVT, (tBTA_GATTC *)&status);
@@ -553,8 +566,8 @@ void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data)
**
** Function bta_gattc_int_cancel_open_ok
**
-** Description
-**
+** Description
+**
** Returns void
**
*******************************************************************************/
@@ -574,8 +587,8 @@ void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
**
** Function bta_gattc_cancel_open
**
-** Description
-**
+** Description
+**
** Returns void
**
*******************************************************************************/
@@ -600,7 +613,7 @@ void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_conn
**
** Description receive connection callback from stack
-**
+**
** Returns void
**
*******************************************************************************/
@@ -628,8 +641,8 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
else /* cache is building */
p_clcb->state = BTA_GATTC_DISCOVER_ST;
}
-
- else
+
+ else
{
/* a pending service handle change indication */
if (p_clcb->p_srcb->srvc_hdl_chg)
@@ -639,23 +652,23 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
}
}
-
+
if (p_clcb->p_rcb)
- {
- bta_gattc_send_open_cback(p_clcb->p_rcb,
- BTA_GATT_OK,
- p_clcb->bda,
- p_clcb->bta_conn_id);
+ {
+ bta_gattc_send_open_cback(p_clcb->p_rcb,
+ BTA_GATT_OK,
+ p_clcb->bda,
+ p_clcb->bta_conn_id);
}
}
}
-
+
/*******************************************************************************
**
** Function bta_gattc_close_fail
**
** Description close a connection.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -681,7 +694,7 @@ void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_api_close
**
** Description close a GATTC connection.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -692,10 +705,10 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
tBTA_GATTC cb_data;
APPL_TRACE_DEBUG1("bta_gattc_close conn_id=%d",p_clcb->bta_conn_id);
-
+
if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT)
p_clcb->status = GATT_Disconnect(p_clcb->bta_conn_id);
-
+
cb_data.close.client_if = p_clcb->p_rcb->client_if;
cb_data.close.conn_id = p_clcb->bta_conn_id;
cb_data.close.status = p_clcb->status;
@@ -721,7 +734,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
bta_gattc_deregister_cmpl(p_clreg, p_clreg->client_if);
}
-
+
}
/*******************************************************************************
@@ -729,7 +742,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_reset_discover_st
**
** Description when a SRCB finished discovery, tell all related clcb.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -750,9 +763,9 @@ void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb)
**
** Function bta_gattc_set_discover_st
**
-** Description when a SRCB start discovery, tell all related clcb and set
+** Description when a SRCB start discovery, tell all related clcb and set
** the state.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -777,7 +790,7 @@ void bta_gattc_set_discover_st(tBTA_GATTC_SERV *p_srcb)
** Function bta_gattc_start_discover
**
** Description Start a discovery on server.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -789,7 +802,7 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_clcb->p_q_cmd != NULL && p_clcb->auto_update == BTA_GATTC_NO_SCHEDULE &&
p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE)
{
- p_clcb->auto_update = BTA_GATTC_DISC_WAITING;
+ p_clcb->auto_update = BTA_GATTC_DISC_WAITING;
p_clcb->state = BTA_GATTC_CONN_ST; /* set clcb state */
}
else /* no pending operation, start discovery right away */
@@ -823,7 +836,7 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_disc_cmpl
**
** Description discovery on server is finished
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -856,7 +869,7 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_read
**
** Description Read an attribute
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -901,7 +914,7 @@ void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_read_multi
**
** Description read multiple
-**
+**
** Returns None.
*********************************************************************************/
void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
@@ -910,7 +923,7 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
tBTA_GATT_STATUS status = BTA_GATT_OK;
tGATT_READ_PARAM read_param;
tBTA_GATTC_OP_CMPL op_cmpl;
- tBTA_GATTC_ATTR_ID *p_id;
+ tBTA_GATTC_ATTR_ID *p_id;
tBT_UUID dummy_uuid;
if (bta_gattc_enqueue(p_clcb, p_data))
@@ -975,7 +988,7 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_write
**
** Description Write an attribute
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1026,7 +1039,7 @@ void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_execute
**
** Description send execute write
-**
+**
** Returns None.
*********************************************************************************/
void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
@@ -1056,13 +1069,13 @@ void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_confirm
**
** Description send handle value confirmation
-**
+**
** Returns None.
**
*******************************************************************************/
void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
- UINT16 handle;
+ UINT16 handle;
tBT_UUID null_uuid = {0};
if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
@@ -1086,7 +1099,7 @@ void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_read_cmpl
**
** Description read complete
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1103,10 +1116,10 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
if (p_data->p_cmpl != NULL && p_data->status == BTA_GATT_OK)
{
- if (bta_gattc_handle2id(p_clcb->p_srcb,
- p_data->p_cmpl->att_value.handle,
- &cb_data.read.srvc_id,
- &cb_data.read.char_id,
+ if (bta_gattc_handle2id(p_clcb->p_srcb,
+ p_data->p_cmpl->att_value.handle,
+ &cb_data.read.srvc_id,
+ &cb_data.read.char_id,
&cb_data.read.descr_type) == FALSE)
{
cb_data.read.status = BTA_GATT_INTERNAL_ERROR;
@@ -1115,11 +1128,11 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
else
{
cb_data.read.status = bta_gattc_pack_read_cb_data(p_clcb->p_srcb,
- cb_data.read.descr_type,
- &p_data->p_cmpl->att_value,
+ cb_data.read.descr_type,
+ &p_data->p_cmpl->att_value,
&read_value);
cb_data.read.p_value = &read_value;
- }
+ }
}
else
{
@@ -1141,7 +1154,7 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
** Function bta_gattc_write_cmpl
**
** Description read complete
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1154,8 +1167,8 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
if (p_data->p_cmpl != NULL)
{
- bta_gattc_handle2id(p_clcb->p_srcb, p_data->p_cmpl->handle,
- &cb_data.write.srvc_id, &cb_data.write.char_id,
+ bta_gattc_handle2id(p_clcb->p_srcb, p_data->p_cmpl->handle,
+ &cb_data.write.srvc_id, &cb_data.write.char_id,
&cb_data.write.descr_type);
}
else
@@ -1188,7 +1201,7 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
** Function bta_gattc_exec_cmpl
**
** Description execute write complete
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1202,7 +1215,7 @@ void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
/* execute complete, callback */
cb_data.exec_cmpl.conn_id = p_clcb->bta_conn_id;
- cb_data.exec_cmpl.status = p_data->status;
+ cb_data.exec_cmpl.status = p_data->status;
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_EXEC_EVT, &cb_data);
@@ -1214,7 +1227,7 @@ void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
** Function bta_gattc_op_cmpl
**
** Description operation completed.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1242,11 +1255,11 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if ( mapped_op > GATTC_OPTYPE_INDICATION) mapped_op = 0;
#if (BT_TRACE_VERBOSE == TRUE)
- APPL_TRACE_ERROR3("expect op:(%s :0x%04x), receive unexpected operation (%s).",
- bta_gattc_op_code_name[mapped_op] , p_clcb->p_q_cmd->hdr.event,
+ APPL_TRACE_ERROR3("expect op:(%s :0x%04x), receive unexpected operation (%s).",
+ bta_gattc_op_code_name[mapped_op] , p_clcb->p_q_cmd->hdr.event,
bta_gattc_op_code_name[op]);
#else
- APPL_TRACE_ERROR3("expect op:(%u :0x%04x), receive unexpected operation (%u).",
+ APPL_TRACE_ERROR3("expect op:(%u :0x%04x), receive unexpected operation (%u).",
mapped_op , p_clcb->p_q_cmd->hdr.event, op);
#endif
return;
@@ -1255,8 +1268,8 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* service handle change void the response, discard it */
if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING)
{
- p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
- bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
+ p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
+ bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
}
else if (op == GATTC_OPTYPE_READ)
bta_gattc_read_cmpl(p_clcb, &p_data->op_cmpl);
@@ -1267,7 +1280,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
else if (op == GATTC_OPTYPE_EXE_WRITE)
bta_gattc_exec_cmpl(p_clcb, &p_data->op_cmpl);
/*
- else if (op == GATTC_OPTYPE_CONFIG) // API to be added
+ else if (op == GATTC_OPTYPE_CONFIG) // API to be added
{
}
*/
@@ -1278,13 +1291,13 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_op_cmpl
**
** Description operation completed.
-**
+**
** Returns None.
**
*******************************************************************************/
void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
- /* receive op complete when discovery is started, ignore the response,
+ /* receive op complete when discovery is started, ignore the response,
and wait for discovery finish and resent */
APPL_TRACE_DEBUG1("bta_gattc_ignore_op_cmpl op = %d", p_data->hdr.layer_specific);
@@ -1294,7 +1307,7 @@ void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_search
**
** Description start a search in the local server cache
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1321,7 +1334,7 @@ void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
**
** Description enqueue a command into control block, usually because discovery
** operation is busy.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1334,7 +1347,7 @@ void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_cache_open
**
** Description open a NV cache for loading
-**
+**
** Returns void
**
*******************************************************************************/
@@ -1343,7 +1356,7 @@ void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
bta_gattc_set_discover_st(p_clcb->p_srcb);
APPL_TRACE_DEBUG1("bta_gattc_cache_open conn_id=%d",p_clcb->bta_conn_id);
- bta_gattc_co_cache_open(p_clcb->p_srcb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
+ bta_gattc_co_cache_open(p_clcb->p_srcb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
p_clcb->bta_conn_id, FALSE);
}
/*******************************************************************************
@@ -1351,7 +1364,7 @@ void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_start_load
**
** Description start cache loading by sending callout open cache
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1364,8 +1377,8 @@ void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_data->ci_open.status == BTA_GATT_OK)
{
p_clcb->p_srcb->attr_index = 0;
- bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
- BTA_GATTC_CI_CACHE_LOAD_EVT,
+ bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
+ BTA_GATTC_CI_CACHE_LOAD_EVT,
p_clcb->p_srcb->attr_index,
p_clcb->bta_conn_id);
}
@@ -1398,7 +1411,7 @@ void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_ci_load
**
** Description cache loading received.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1409,8 +1422,8 @@ void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
p_clcb->bta_conn_id, p_data->ci_load.status );
bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
- if ((p_data->ci_load.status == BTA_GATT_OK ||
- p_data->ci_load.status == BTA_GATT_MORE) &&
+ if ((p_data->ci_load.status == BTA_GATT_OK ||
+ p_data->ci_load.status == BTA_GATT_MORE) &&
p_data->ci_load.num_attr > 0)
{
bta_gattc_rebuild_cache(p_clcb->p_srcb, p_data->ci_load.num_attr, p_data->ci_load.attr, p_clcb->p_srcb->attr_index);
@@ -1425,9 +1438,9 @@ void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
p_clcb->p_srcb->attr_index += p_data->ci_load.num_attr;
- bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
- BTA_GATTC_CI_CACHE_LOAD_EVT,
- p_clcb->p_srcb->attr_index,
+ bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
+ BTA_GATTC_CI_CACHE_LOAD_EVT,
+ p_clcb->p_srcb->attr_index,
p_clcb->bta_conn_id);
}
}
@@ -1443,7 +1456,7 @@ void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_ci_load
**
** Description cache loading received.
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1455,7 +1468,7 @@ void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (!bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id))
{
p_clcb->p_srcb->attr_index = 0;
- bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
+ bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
bta_gattc_reset_discover_st(p_clcb->p_srcb);
}
}
@@ -1465,7 +1478,7 @@ void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** Function bta_gattc_fail
**
** Description report API call failure back to apps
-**
+**
** Returns None.
**
*******************************************************************************/
@@ -1482,17 +1495,17 @@ void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
** bta_gattc_cmpl_cback
**
** Description callback functions to GATT client stack.
-**
+**
** Returns void
**
*******************************************************************************/
-static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
+static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
BOOLEAN connected, tGATT_DISCONN_REASON reason)
{
BT_HDR *p_buf;
tBTA_GATTC_CLCB *p_clcb = NULL;
- APPL_TRACE_DEBUG4("bta_gattc_conn_cback: cif = %d connected = %d conn_id = %d reaosn = 0x%04x",
+ APPL_TRACE_DEBUG4("bta_gattc_conn_cback: cif = %d connected = %d conn_id = %d reaosn = 0x%04x",
gattc_if, connected, conn_id, reason);
if (connected)
@@ -1500,7 +1513,7 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
/* outgoing connection : locate a logic channel */
if ((p_clcb = bta_gattc_find_clcb_by_cif(gattc_if, bda)) == NULL)
{
-
+
#if BLE_INCLUDED == TRUE
/* for a background connection */
if (L2CA_GetBleConnRole(bda)== HCI_ROLE_MASTER &&
@@ -1554,15 +1567,15 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
** Function bta_gattc_process_srvc_chg_ind
**
** Description process service change indication.
-**
+**
** Returns None.
**
*******************************************************************************/
-BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
+BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
tBTA_GATTC_RCB *p_clrcb,
- tBTA_GATTC_SERV *p_srcb,
- tBTA_GATTC_CLCB *p_clcb,
- tBTA_GATTC_NOTIFY *p_notify,
+ tBTA_GATTC_SERV *p_srcb,
+ tBTA_GATTC_CLCB *p_clcb,
+ tBTA_GATTC_NOTIFY *p_notify,
UINT16 handle)
{
tBT_UUID gattp_uuid, srvc_chg_uuid;
@@ -1587,12 +1600,12 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
if ( ++ p_srcb->update_count == bta_gattc_num_reg_app())
{
/* not an opened connection; or connection busy */
- /* search for first available clcb and start discovery */
+ /* search for first available clcb and start discovery */
if (p_clcb == NULL || (p_clcb && p_clcb->p_q_cmd != NULL))
{
for (i = 0 ; i < BTA_GATTC_CLCB_MAX; i ++)
{
- if (bta_gattc_cb.clcb[i].in_use &&
+ if (bta_gattc_cb.clcb[i].in_use &&
bta_gattc_cb.clcb[i].p_srcb == p_srcb &&
bta_gattc_cb.clcb[i].p_q_cmd == NULL)
{
@@ -1603,18 +1616,18 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
}
/* send confirmation here if this is an indication, it should always be */
GATTC_SendHandleValueConfirm(conn_id, handle);
-
+
/* if connection available, refresh cache by doing discovery now */
if (p_clcb != NULL)
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
- }
+ }
/* notify applicationf or service change */
if (p_clrcb->p_cback != NULL)
{
APPL_TRACE_ERROR0("bta_gattc_process_srvc_chg_ind 2");
(* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)p_srcb->server_bda);
}
-
+
}
return processed;
@@ -1625,17 +1638,17 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
** Function bta_gattc_proc_other_indication
**
** Description process all non-service change indication/notification.
-**
+**
** Returns None.
**
*******************************************************************************/
-void bta_gattc_proc_other_indication(tBTA_GATTC_CLCB *p_clcb, UINT8 op,
+void bta_gattc_proc_other_indication(tBTA_GATTC_CLCB *p_clcb, UINT8 op,
tGATT_CL_COMPLETE *p_data,
tBTA_GATTC_NOTIFY *p_notify)
{
APPL_TRACE_DEBUG2("bta_gattc_proc_other_indication check \
- p_data->att_value.handle=%d p_data->handle=%d",
- p_data->att_value.handle, p_data->handle);
+ p_data->att_value.handle=%d p_data->handle=%d",
+ p_data->att_value.handle, p_data->handle);
APPL_TRACE_DEBUG1("is_notify", p_notify->is_notify);
p_notify->is_notify = (op == GATTC_OPTYPE_INDICATION) ? FALSE : TRUE;
@@ -1646,20 +1659,20 @@ void bta_gattc_proc_other_indication(tBTA_GATTC_CLCB *p_clcb, UINT8 op,
if (p_clcb->p_rcb->p_cback)
(*p_clcb->p_rcb->p_cback)(BTA_GATTC_NOTIF_EVT, (tBTA_GATTC *)p_notify);
-
+
}
/*******************************************************************************
**
** Function bta_gattc_process_indicate
**
** Description process indication/notification.
-**
+**
** Returns None.
**
*******************************************************************************/
void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPLETE *p_data)
{
- UINT16 handle = p_data->att_value.handle;
+ UINT16 handle = p_data->att_value.handle;
tBTA_GATTC_CLCB *p_clcb ;
tBTA_GATTC_RCB *p_clrcb = NULL;
tBTA_GATTC_SERV *p_srcb = NULL;
@@ -1687,9 +1700,9 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL
p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
- if (bta_gattc_handle2id(p_srcb, handle,
- &notify.char_id.srvc_id,
- &notify.char_id.char_id,
+ if (bta_gattc_handle2id(p_srcb, handle,
+ &notify.char_id.srvc_id,
+ &notify.char_id.char_id,
&notify.descr_type))
{
/* if non-service change indication/notification, forward to application */
@@ -1706,8 +1719,8 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL
p_clcb->bta_conn_id = conn_id;
/* send connection event */
- bta_gattc_send_open_cback(p_clrcb,
- BTA_GATT_OK,
+ bta_gattc_send_open_cback(p_clrcb,
+ BTA_GATT_OK,
remote_bda,
conn_id);
}
@@ -1717,17 +1730,17 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL
}
}
- if (p_clcb != NULL)
- bta_gattc_proc_other_indication(p_clcb, op, p_data, &notify);
+ if (p_clcb != NULL)
+ bta_gattc_proc_other_indication(p_clcb, op, p_data, &notify);
}
/* no one intersted and need ack? */
else if (op == GATTC_OPTYPE_INDICATION)
{
- APPL_TRACE_DEBUG0("no one interested, ack now");
- GATTC_SendHandleValueConfirm(conn_id, handle);
+ APPL_TRACE_DEBUG0("no one interested, ack now");
+ GATTC_SendHandleValueConfirm(conn_id, handle);
}
}
- }
+ }
else
{
APPL_TRACE_ERROR1("Indi/Notif for Unknown handle[0x%04x], can not find in local cache.", handle);
@@ -1739,18 +1752,18 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL
** Function bta_gattc_cmpl_cback
**
** Description client operation complete callback register with BTE GATT.
-**
+**
** Returns None.
**
*******************************************************************************/
-static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
+static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
tGATT_CL_COMPLETE *p_data)
{
tBTA_GATTC_CLCB *p_clcb ;
tBTA_GATTC_OP_CMPL *p_buf;
UINT16 len = sizeof(tBTA_GATTC_OP_CMPL) + sizeof(tGATT_CL_COMPLETE);
- APPL_TRACE_DEBUG3("bta_gattc_cmpl_cback: conn_id = %d op = %d status = %d",
+ APPL_TRACE_DEBUG3("bta_gattc_cmpl_cback: conn_id = %d op = %d status = %d",
conn_id, op, status);
/* notification and indication processed right away */
@@ -1761,7 +1774,7 @@ static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
}
/* for all other operation, not expected if w/o connection */
else if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) == NULL)
- {
+ {
APPL_TRACE_ERROR1("bta_gattc_cmpl_cback unknown conn_id = %d, ignore data", conn_id);
return;
}
diff --git a/bta/gatt/bta_gattc_api.c b/bta/gatt/bta_gattc_api.c
index 4a87ddf..1cace7d 100644
--- a/bta/gatt/bta_gattc_api.c
+++ b/bta/gatt/bta_gattc_api.c
@@ -1,17 +1,29 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_api.c
-**
-** Description: This is the implementation of the API for GATT module
-** of BTA.
-**
-** Copyright (c) 2010-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2010-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the implementation of the API for GATT module of BTA.
+ *
+ ******************************************************************************/
#include "bt_target.h"
-
+
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
#include <string.h>
@@ -34,13 +46,13 @@ static const tBTA_SYS_REG bta_gatt_reg =
**
** Function BTA_GATTC_AppRegister
**
-** Description This function is called to register application callbacks
+** Description This function is called to register application callbacks
** with BTA GATTC module.
**
** Parameters p_app_uuid - applicaiton UUID
** p_client_cb - pointer to the application callback function.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
@@ -68,12 +80,12 @@ void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
**
** Function BTA_GATTC_AppDeregister
**
-** Description This function is called to deregister an application
+** Description This function is called to deregister an application
** from BTA GATTC module.
**
** Parameters client_if - client interface identifier.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
@@ -95,7 +107,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
**
** Description Open a direct connection or add a background auto connection
** bd address
-**
+**
** Parameters client_if: server interface.
** remote_bda: remote device BD address.
** is_direct: direct connection or background auto connection
@@ -127,7 +139,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_dire
**
** Description Cancel a direct open connection or remove a background auto connection
** bd address
-**
+**
** Parameters client_if: server interface.
** remote_bda: remote device BD address.
** is_direct: direct connection or background auto connection
@@ -157,7 +169,7 @@ void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN i
** Function BTA_GATTC_Close
**
** Description Close a connection to a GATT server.
-**
+**
** Parameters conn_id: connectino ID to be closed.
**
** Returns void
@@ -182,16 +194,16 @@ void BTA_GATTC_Close(UINT16 conn_id)
**
** Function BTA_GATTC_ServiceSearchRequest
**
-** Description This function is called to request a GATT service discovery
+** Description This function is called to request a GATT service discovery
** on a GATT server. This function report service search result
** by a callback event, and followed by a service search complete
** event.
**
-** Parameters conn_id: connection ID.
+** Parameters conn_id: connection ID.
** p_srvc_uuid: a UUID of the service application is interested in.
** If Null, discover for all services.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
@@ -223,19 +235,19 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
** Description This function is called to find the first charatceristic of the
** service on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
+** Parameters conn_id: connection ID which identify the server.
** p_srvc_id: the service ID of which the characteristic is belonged to.
** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
-** characteristic.
-** p_char_result: output parameter which will store the GATT
+** characteristic.
+** p_char_result: output parameter which will store the GATT
** characteristic ID.
** p_property: output parameter to carry the characteristic property.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id,
- tBT_UUID *p_char_uuid_cond,
+tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id,
+ tBT_UUID *p_char_uuid_cond,
tBTA_GATTC_CHAR_ID *p_char_result,
tBTA_GATT_CHAR_PROP *p_property)
{
@@ -244,8 +256,8 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_s
if (!p_srvc_id || !p_char_result)
return BTA_GATT_ILLEGAL_PARAMETER;
- if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR, p_srvc_id, NULL,
- p_char_uuid_cond, &p_char_result->char_id, p_property))
+ if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR, p_srvc_id, NULL,
+ p_char_uuid_cond, &p_char_result->char_id, p_property))
== BTA_GATT_OK)
{
memcpy(&p_char_result->srvc_id, p_srvc_id, sizeof(tBTA_GATT_SRVC_ID));
@@ -261,21 +273,21 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_s
** Description This function is called to find the next charatceristic of the
** service on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_char_id: start the characteristic search from the next record
+** Parameters conn_id: connection ID which identify the server.
+** p_start_char_id: start the characteristic search from the next record
** after the one identified by char_id.
** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
-** characteristic.
-** p_char_result: output parameter which will store the GATT
-** characteristic ID.
+** characteristic.
+** p_char_result: output parameter which will store the GATT
+** characteristic ID.
** p_property: output parameter to carry the characteristic property.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
+tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
tBTA_GATTC_CHAR_ID *p_start_char_id,
- tBT_UUID *p_char_uuid_cond,
+ tBT_UUID *p_char_uuid_cond,
tBTA_GATTC_CHAR_ID *p_char_result,
tBTA_GATT_CHAR_PROP *p_property)
{
@@ -284,12 +296,12 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
if (!p_start_char_id || !p_char_result)
return BTA_GATT_ILLEGAL_PARAMETER;
- if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR,
+ if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR,
&p_start_char_id->srvc_id,
&p_start_char_id->char_id,
- p_char_uuid_cond,
+ p_char_uuid_cond,
&p_char_result->char_id,
- p_property))
+ p_property))
== BTA_GATT_OK)
{
memcpy(&p_char_result->srvc_id, &p_start_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
@@ -305,18 +317,18 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
** Description This function is called to find the first charatceristic descriptor of the
** charatceristic on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
+** Parameters conn_id: connection ID which identify the server.
** p_char_id: the characteristic ID of which the descriptor is belonged to.
** p_descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
-** characteristic.
-** p_descr_result: output parameter which will store the GATT
+** characteristic.
+** p_descr_result: output parameter which will store the GATT
** characteristic descriptor ID.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
- tBT_UUID *p_descr_uuid_cond,
+tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
+ tBT_UUID *p_descr_uuid_cond,
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
{
tBTA_GATT_STATUS status;
@@ -326,13 +338,13 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_I
memset(p_descr_result, 0, sizeof(tBTA_GATTC_CHAR_DESCR_ID));
- if ((status = bta_gattc_query_cache(conn_id,
- BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
- &p_char_id->srvc_id,
- &p_char_id->char_id,
- p_descr_uuid_cond,
- &p_descr_result->char_id.char_id,
- NULL))
+ if ((status = bta_gattc_query_cache(conn_id,
+ BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
+ &p_char_id->srvc_id,
+ &p_char_id->char_id,
+ p_descr_uuid_cond,
+ &p_descr_result->char_id.char_id,
+ NULL))
== BTA_GATT_OK)
{
memcpy(&p_descr_result->descr_type, &p_descr_result->char_id.char_id.uuid, sizeof(tBT_UUID));
@@ -349,20 +361,20 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_I
** Description This function is called to find the next charatceristic of the
** service on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_descr_id: start the characteristic search from the next record
+** Parameters conn_id: connection ID which identify the server.
+** p_start_descr_id: start the characteristic search from the next record
** after the one identified by p_start_descr_id.
-** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
-** the first available characteristic descriptor.
-** p_descr_result: output parameter which will store the GATT
-** characteristic descriptor ID.
+** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
+** the first available characteristic descriptor.
+** p_descr_result: output parameter which will store the GATT
+** characteristic descriptor ID.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
+tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
- tBT_UUID *p_descr_uuid_cond,
+ tBT_UUID *p_descr_uuid_cond,
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
{
tBTA_GATT_STATUS status;
@@ -372,18 +384,18 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
memset(p_descr_result, 0, sizeof(tBTA_GATTC_CHAR_DESCR_ID));
- if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
+ if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
&p_start_descr_id->char_id.srvc_id,
&p_start_descr_id->char_id.char_id,
- p_descr_uuid_cond,
+ p_descr_uuid_cond,
&p_descr_result->char_id.char_id,
- (void *)&p_start_descr_id->descr_type))
+ (void *)&p_start_descr_id->descr_type))
== BTA_GATT_OK)
{
memcpy(&p_descr_result->descr_type, &p_descr_result->char_id.char_id.uuid, sizeof(tBT_UUID));
memcpy(&p_descr_result->char_id, p_start_descr_id, sizeof(tBTA_GATTC_CHAR_ID));
}
-
+
return status;
}
@@ -395,14 +407,14 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
** Description This function is called to find the first included service of the
** service on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
-** p_srvc_id: the service ID of which the characteristic is belonged to.
+** Parameters conn_id: connection ID which identify the server.
+** p_srvc_id: the service ID of which the characteristic is belonged to.
** p_uuid_cond: Characteristic UUID, if NULL find the first available
-** characteristic.
-** p_result: output parameter which will store the GATT ID
+** characteristic.
+** p_result: output parameter which will store the GATT ID
** of the included service found.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id,
@@ -413,13 +425,13 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SR
if (!p_srvc_id || !p_result)
return BTA_GATT_ILLEGAL_PARAMETER;
- if ((status = bta_gattc_query_cache(conn_id,
- BTA_GATTC_ATTR_TYPE_INCL_SRVC,
+ if ((status = bta_gattc_query_cache(conn_id,
+ BTA_GATTC_ATTR_TYPE_INCL_SRVC,
p_srvc_id,
NULL,
- p_uuid_cond,
+ p_uuid_cond,
&p_result->incl_svc_id.id,
- (tBTA_GATT_CHAR_PROP *)&p_result->incl_svc_id.is_primary))
+ (tBTA_GATT_CHAR_PROP *)&p_result->incl_svc_id.is_primary))
== BTA_GATT_OK)
{
memcpy(&p_result->srvc_id, p_srvc_id, sizeof(tBTA_GATT_SRVC_ID));
@@ -434,20 +446,20 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SR
** Description This function is called to find the next included service of the
** service on the given server.
**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_id: start the search from the next record
-** after the one identified by p_start_id.
+** Parameters conn_id: connection ID which identify the server.
+** p_start_id: start the search from the next record
+** after the one identified by p_start_id.
** p_uuid_cond: Included service UUID, if NULL find the first available
-** included service.
-** p_result: output parameter which will store the GATT ID
+** included service.
+** p_result: output parameter which will store the GATT ID
** of the included service found.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
+tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
tBTA_GATTC_INCL_SVC_ID *p_start_id,
- tBT_UUID *p_uuid_cond,
+ tBT_UUID *p_uuid_cond,
tBTA_GATTC_INCL_SVC_ID *p_result)
{
tBTA_GATT_STATUS status;
@@ -455,13 +467,13 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
if (!p_start_id || !p_result)
return BTA_GATT_ILLEGAL_PARAMETER;
- if ((status = bta_gattc_query_cache(conn_id,
- BTA_GATTC_ATTR_TYPE_INCL_SRVC,
+ if ((status = bta_gattc_query_cache(conn_id,
+ BTA_GATTC_ATTR_TYPE_INCL_SRVC,
&p_start_id->srvc_id,
&p_start_id->incl_svc_id.id,
- p_uuid_cond,
+ p_uuid_cond,
&p_result->incl_svc_id.id,
- (tBTA_GATT_CHAR_PROP *)&p_result->incl_svc_id.is_primary))
+ (tBTA_GATT_CHAR_PROP *)&p_result->incl_svc_id.is_primary))
== BTA_GATT_OK)
{
memcpy(&p_result->srvc_id, &p_start_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
@@ -480,10 +492,10 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
** Parameters conn_id - connectino ID.
** p_char_id - characteritic ID to read.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
+void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
tBTA_GATT_AUTH_REQ auth_req)
{
tBTA_GATTC_API_READ *p_buf;
@@ -513,10 +525,10 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
** Parameters conn_id - connection ID.
** p_char_descr_id - characteritic descriptor ID to read.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
+void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
tBTA_GATTC_CHAR_DESCR_ID *p_descr_id,
tBTA_GATT_AUTH_REQ auth_req)
{
@@ -549,7 +561,7 @@ void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
** Parameters conn_id - connectino ID.
** p_read_multi - pointer to the read multiple parameter.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
@@ -557,7 +569,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
{
tBTA_GATTC_API_READ_MULTI *p_buf;
tBTA_GATTC_ATTR_ID *p_value;
- UINT16 len = (UINT16)(sizeof(tBTA_GATTC_API_READ_MULTI) +
+ UINT16 len = (UINT16)(sizeof(tBTA_GATTC_API_READ_MULTI) +
p_read_multi->num_attr * sizeof(tBTA_GATTC_ATTR_ID));
UINT8 i;
@@ -598,11 +610,11 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
** len: length of the data to be written.
** p_value - the value to be written.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
- tBTA_GATTC_CHAR_ID *p_char_id,
+void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
+ tBTA_GATTC_CHAR_ID *p_char_id,
tBTA_GATTC_WRITE_TYPE write_type,
UINT16 len,
UINT8 *p_value,
@@ -645,16 +657,16 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
** write_type - write type.
** p_value - the value to be written.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
- tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
+void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
+ tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
tBTA_GATTC_WRITE_TYPE write_type,
tBTA_GATT_UNFMT *p_data,
tBTA_GATT_AUTH_REQ auth_req)
{
- tBTA_GATTC_API_WRITE *p_buf;
+ tBTA_GATTC_API_WRITE *p_buf;
UINT16 len = sizeof(tBTA_GATTC_API_WRITE) + p_data->len;
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL)
@@ -695,10 +707,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
** len: length of the data to be written.
** p_value - the value to be written.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
+void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
UINT16 offset, UINT16 len, UINT8 *p_value,
tBTA_GATT_AUTH_REQ auth_req)
{
@@ -739,7 +751,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
** Parameters conn_id - connection ID.
** is_execute - execute or cancel.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
@@ -769,15 +781,15 @@ void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
** Parameters conn_id - connection ID.
** p_char_id - characteristic ID to confirm.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
{
- tBTA_GATTC_API_CONFIRM *p_buf;
+ tBTA_GATTC_API_CONFIRM *p_buf;
- APPL_TRACE_API3("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
- conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16); //toto
+ APPL_TRACE_API3("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
+ conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16); //toto
if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
{
@@ -805,11 +817,11 @@ void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
** bda - target GATT server.
** p_char_id - pointer to GATT characteristic ID.
**
-** Returns OK if registration succeed, otherwise failed.
+** Returns OK if registration succeed, otherwise failed.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
- BD_ADDR bda,
+tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
+ BD_ADDR bda,
tBTA_GATTC_CHAR_ID *p_char_id)
{
tBTA_GATTC_RCB *p_clreg;
@@ -822,7 +834,7 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
return status;
}
- /* lock other GKI task */
+ /* lock other GKI task */
GKI_sched_lock();
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
@@ -850,11 +862,11 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
else
{
APPL_TRACE_ERROR1("Client_if: %d Not Registered", client_if);
- }
+ }
GKI_sched_unlock();
- return status;
+ return status;
}
/*******************************************************************************
@@ -867,11 +879,11 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
** bda - target GATT server.
** p_char_id - pointer to GATT characteristic ID.
**
-** Returns OK if deregistration succeed, otherwise failed.
+** Returns OK if deregistration succeed, otherwise failed.
**
*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
- BD_ADDR bda,
+tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
+ BD_ADDR bda,
tBTA_GATTC_CHAR_ID *p_char_id)
{
tBTA_GATTC_RCB *p_clreg;
@@ -884,7 +896,7 @@ tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
return status;
}
- /* lock other GKI task */
+ /* lock other GKI task */
GKI_sched_lock();
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
@@ -907,16 +919,16 @@ tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
status = BTA_GATT_ERROR;
APPL_TRACE_ERROR0("registration not found");
- }
+ }
}
else
{
APPL_TRACE_ERROR1("Client_if: %d Not Registered", client_if);
- }
+ }
GKI_sched_unlock();
- return status;
+ return status;
}
#endif /* BTA_GATT_INCLUDED */
diff --git a/bta/gatt/bta_gattc_cache.c b/bta/gatt/bta_gattc_cache.c
index 7234598..3774df4 100644
--- a/bta/gatt/bta_gattc_cache.c
+++ b/bta/gatt/bta_gattc_cache.c
@@ -1,14 +1,27 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_cache.c
-**
-** Description: This file contains the GATT client discovery
-** procedures and cache related functions.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT client discovery procedures and cache
+ * related functions.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -33,7 +46,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
*****************************************************************************/
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
-static char *bta_gattc_attr_type[] =
+static char *bta_gattc_attr_type[] =
{
"I", /* Included Service */
"C", /* Characteristic */
@@ -52,7 +65,7 @@ static char *bta_gattc_attr_type[] =
*******************************************************************************/
static void bta_gattc_display_cache_server(tBTA_GATTC_CACHE *p_cache)
{
- UINT8 i = 0, j;
+ UINT8 i = 0, j;
tBTA_GATTC_CACHE *p_cur_srvc = p_cache;
tBTA_GATTC_CACHE_ATTR *p_attr;
@@ -60,10 +73,10 @@ static void bta_gattc_display_cache_server(tBTA_GATTC_CACHE *p_cache)
while (p_cur_srvc)
{
- APPL_TRACE_ERROR6("Service[%d]: handle[%d ~ %d] %s[0x%04x] inst[%d]",
- i, p_cur_srvc->s_handle, p_cur_srvc->e_handle,
- ((p_cur_srvc->service_uuid.id.uuid.len == 2) ? "uuid16" : "uuid128"),
- p_cur_srvc->service_uuid.id.uuid.uu.uuid16,
+ APPL_TRACE_ERROR6("Service[%d]: handle[%d ~ %d] %s[0x%04x] inst[%d]",
+ i, p_cur_srvc->s_handle, p_cur_srvc->e_handle,
+ ((p_cur_srvc->service_uuid.id.uuid.len == 2) ? "uuid16" : "uuid128"),
+ p_cur_srvc->service_uuid.id.uuid.uu.uuid16,
p_cur_srvc->service_uuid.id.inst_id);
i ++;
@@ -72,7 +85,7 @@ static void bta_gattc_display_cache_server(tBTA_GATTC_CACHE *p_cache)
for (j = 0; p_attr; j ++ )
{
APPL_TRACE_ERROR6("\t Attr[0x%04x] handle[%d] uuid[0x%04x] inst[%d] type[%s] prop[0x%1x]",
- j + 1, p_attr->attr_handle, p_attr->p_uuid->uuid16, p_attr->inst_id,
+ j + 1, p_attr->attr_handle, p_attr->p_uuid->uuid16, p_attr->inst_id,
bta_gattc_attr_type[p_attr->attr_type], p_attr->property);
p_attr = p_attr->p_next;
@@ -95,7 +108,7 @@ static void bta_gattc_display_cache_server(tBTA_GATTC_CACHE *p_cache)
*******************************************************************************/
static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC *p_rec, UINT8 num_rec)
{
- UINT8 i;
+ UINT8 i;
tBTA_GATTC_ATTR_REC *pp = p_rec;
APPL_TRACE_ERROR0("<================Start Explore Queue =============>");
@@ -116,7 +129,7 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC *p_rec, UINT8 n
** Function bta_gattc_alloc_cache_buf
**
** Description Allocate a GKI buffer for database cache.
-**
+**
** Returns status
**
*******************************************************************************/
@@ -149,7 +162,7 @@ BT_HDR *bta_gattc_alloc_cache_buf(tBTA_GATTC_SERV *p_srvc_cb)
** Function bta_gattc_init_cache
**
** Description Initialize the database cache and discovery related resources.
-**
+**
** Returns status
**
*******************************************************************************/
@@ -170,8 +183,8 @@ tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb)
else
{
p_srvc_cb->total_srvc = 0;
- p_srvc_cb->cur_srvc_idx =
- p_srvc_cb->cur_char_idx =
+ p_srvc_cb->cur_srvc_idx =
+ p_srvc_cb->cur_char_idx =
p_srvc_cb->next_avail_idx = 0;
if (bta_gattc_alloc_cache_buf(p_srvc_cb) == NULL)
@@ -245,13 +258,13 @@ static UINT8 bta_gattc_get_char_inst_id(tBTA_GATTC_CACHE *p_service_cache, tBT_U
** Function bta_gattc_add_srvc_to_cache
**
** Description Add a service into database cache.
-**
+**
** Returns status
**
*******************************************************************************/
-static tBTA_GATT_STATUS bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
+static tBTA_GATT_STATUS bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
UINT16 s_handle, UINT16 e_handle,
- tBT_UUID *p_uuid,
+ tBT_UUID *p_uuid,
BOOLEAN is_primary, UINT8 srvc_inst)
{
tBTA_GATTC_CACHE *p_new_srvc = NULL;
@@ -274,7 +287,7 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
p_new_srvc->e_handle = e_handle;
p_new_srvc->service_uuid.is_primary = is_primary;
memcpy(&p_new_srvc->service_uuid.id.uuid, p_uuid, sizeof(tBT_UUID));
- p_new_srvc->service_uuid.id.inst_id = srvc_inst;
+ p_new_srvc->service_uuid.id.inst_id = srvc_inst;
p_new_srvc->p_next = NULL;
if (p_srvc_cb->p_cur_srvc != NULL)
@@ -301,13 +314,13 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
** Function bta_gattc_add_attr_to_cache
**
** Description Add an attribute into database cache buffer.
-**
+**
** Returns status
**
*******************************************************************************/
-static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
- UINT16 handle,
- tBT_UUID *p_uuid,
+static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
+ UINT16 handle,
+ tBT_UUID *p_uuid,
UINT8 property,
tBTA_GATTC_ATTR_TYPE type)
{
@@ -368,7 +381,7 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
p_srvc_cb->p_cur_srvc->p_last_attr = p_attr;
-#if 0
+#if 0
//#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
bta_gattc_display_cache_server(p_srvc_cb->p_srvc_cache);
#endif
@@ -410,7 +423,7 @@ void bta_gattc_get_disc_range(tBTA_GATTC_SERV *p_srvc_cb, UINT16 *p_s_hdl, UINT1
** Function bta_gattc_discover_pri_service
**
** Description Start primary service discovery
-**
+**
** Returns status of the operation.
**
*******************************************************************************/
@@ -434,7 +447,7 @@ tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV
** Function bta_gattc_discover_procedure
**
** Description Start a particular type of discovery procedure on server.
-**
+**
** Returns status of the operation.
**
*******************************************************************************/
@@ -448,7 +461,7 @@ tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p
if (disc_type == GATT_DISC_SRVC_ALL || disc_type == GATT_DISC_SRVC_BY_UUID)
{
param.s_handle = 1;
- param.e_handle = 0xFFFF;
+ param.e_handle = 0xFFFF;
}
else
{
@@ -472,7 +485,7 @@ tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p
** Function bta_gattc_start_disc_include_srvc
**
** Description Start discovery for included service
-**
+**
** Returns status of the operation.
**
*******************************************************************************/
@@ -487,7 +500,7 @@ tBTA_GATT_STATUS bta_gattc_start_disc_include_srvc(UINT16 conn_id, tBTA_GATTC_SE
** Function bta_gattc_start_disc_char
**
** Description Start discovery for characteristic
-**
+**
** Returns status of the operation.
**
*******************************************************************************/
@@ -504,7 +517,7 @@ tBTA_GATT_STATUS bta_gattc_start_disc_char(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
** Function bta_gattc_start_disc_char_dscp
**
** Description Start discovery for characteristic descriptor
-**
+**
** Returns none.
**
*******************************************************************************/
@@ -521,7 +534,7 @@ void bta_gattc_start_disc_char_dscp(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
** Function bta_gattc_explore_srvc
**
** Description process the service discovery complete event
-**
+**
** Returns status
**
*******************************************************************************/
@@ -543,10 +556,10 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
if (p_srvc_cb->cur_srvc_idx < p_srvc_cb->total_srvc)
{
/* add the first service into cache */
- if (bta_gattc_add_srvc_to_cache (p_srvc_cb,
- p_rec->s_handle,
- p_rec->e_handle,
- &p_rec->uuid,
+ if (bta_gattc_add_srvc_to_cache (p_srvc_cb,
+ p_rec->s_handle,
+ p_rec->e_handle,
+ &p_rec->uuid,
p_rec->is_primary,
p_rec->srvc_inst_id) == 0)
{
@@ -563,7 +576,7 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
#endif
/* save cache to NV */
p_clcb->p_srcb->state = BTA_GATTC_SERV_SAVE;
- bta_gattc_co_cache_open(p_srvc_cb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
+ bta_gattc_co_cache_open(p_srvc_cb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
conn_id, TRUE);
//bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL);
}
@@ -572,7 +585,7 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
** Function bta_gattc_incl_srvc_disc_cmpl
**
** Description process the relationship discovery complete event
-**
+**
** Returns status
**
*******************************************************************************/
@@ -588,7 +601,7 @@ static void bta_gattc_incl_srvc_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srv
** Function bta_gattc_char_disc_cmpl
**
** Description process the characteristic discovery complete event
-**
+**
** Returns status
**
*******************************************************************************/
@@ -602,10 +615,10 @@ static void bta_gattc_char_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
if (p_srvc_cb->total_char > 0)
{
/* add the first characteristic into cache */
- bta_gattc_add_attr_to_cache (p_srvc_cb,
- p_rec->s_handle,
+ bta_gattc_add_attr_to_cache (p_srvc_cb,
+ p_rec->s_handle,
&p_rec->uuid,
- p_rec->property,
+ p_rec->property,
BTA_GATTC_ATTR_TYPE_CHAR);
/* start discoverying characteristic descriptor , if failed, disc for next char*/
@@ -613,7 +626,7 @@ static void bta_gattc_char_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
}
else /* otherwise start with next service */
{
- p_srvc_cb->cur_srvc_idx ++;
+ p_srvc_cb->cur_srvc_idx ++;
bta_gattc_explore_srvc (conn_id, p_srvc_cb);
}
@@ -623,7 +636,7 @@ static void bta_gattc_char_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
** Function bta_gattc_char_dscpt_disc_cmpl
**
** Description process the char descriptor discovery complete event
-**
+**
** Returns status
**
*******************************************************************************/
@@ -635,10 +648,10 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
{
p_rec = p_srvc_cb->p_srvc_list + (++ p_srvc_cb->cur_char_idx);
/* add the next characteristic into cache */
- bta_gattc_add_attr_to_cache (p_srvc_cb,
- p_rec->s_handle,
- &p_rec->uuid,
- p_rec->property,
+ bta_gattc_add_attr_to_cache (p_srvc_cb,
+ p_rec->s_handle,
+ &p_rec->uuid,
+ p_rec->property,
BTA_GATTC_ATTR_TYPE_CHAR);
/* start discoverying next characteristic for char descriptor */
@@ -650,12 +663,12 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_ERROR0("all char has been explored");
#endif
- p_srvc_cb->cur_srvc_idx ++;
+ p_srvc_cb->cur_srvc_idx ++;
bta_gattc_explore_srvc (conn_id, p_srvc_cb);
}
}
-static BOOLEAN bta_gattc_srvc_in_list(tBTA_GATTC_SERV *p_srvc_cb, UINT16 s_handle,
+static BOOLEAN bta_gattc_srvc_in_list(tBTA_GATTC_SERV *p_srvc_cb, UINT16 s_handle,
UINT16 e_handle, tBT_UUID uuid)
{
tBTA_GATTC_ATTR_REC *p_rec = NULL;
@@ -672,7 +685,7 @@ static BOOLEAN bta_gattc_srvc_in_list(tBTA_GATTC_SERV *p_srvc_cb, UINT16 s_handl
for (i = 0; i < p_srvc_cb->next_avail_idx; i ++)
{
p_rec = p_srvc_cb->p_srvc_list + i;
-
+
/* a new service should not have any overlap with other service handle range */
if (p_rec->s_handle == s_handle || p_rec->e_handle == e_handle)
{
@@ -688,12 +701,12 @@ static BOOLEAN bta_gattc_srvc_in_list(tBTA_GATTC_SERV *p_srvc_cb, UINT16 s_handl
** Function bta_gattc_add_srvc_to_list
**
** Description Add a service into explore pending list
-**
+**
** Returns status
**
*******************************************************************************/
-static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
- UINT16 s_handle, UINT16 e_handle,
+static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
+ UINT16 s_handle, UINT16 e_handle,
tBT_UUID uuid, BOOLEAN is_primary)
{
tBTA_GATTC_ATTR_REC *p_rec = NULL;
@@ -705,13 +718,13 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
p_srvc_cb->total_srvc ++;
- APPL_TRACE_DEBUG2("bta_gattc_add_srvc_to_list handle = %d, service type = 0x%04x",
+ APPL_TRACE_DEBUG2("bta_gattc_add_srvc_to_list handle = %d, service type = 0x%04x",
s_handle, uuid.uu.uuid16);
p_rec->s_handle = s_handle;
p_rec->e_handle = e_handle;
p_rec->is_primary = is_primary;
- p_rec->srvc_inst_id = bta_gattc_get_srvc_inst_id(p_srvc_cb, uuid);
+ p_rec->srvc_inst_id = bta_gattc_get_srvc_inst_id(p_srvc_cb, uuid);
memcpy(&p_rec->uuid, &uuid, sizeof(tBT_UUID));
p_srvc_cb->next_avail_idx ++;
@@ -730,12 +743,12 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
** Function bta_gattc_add_char_to_list
**
** Description Add a characteristic into explore pending list
-**
+**
** Returns status
**
*******************************************************************************/
-static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb,
- UINT16 decl_handle, UINT16 value_handle,
+static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb,
+ UINT16 decl_handle, UINT16 value_handle,
tBT_UUID uuid, UINT8 property)
{
tBTA_GATTC_ATTR_REC *p_rec = NULL;
@@ -794,7 +807,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
if(((sdp_status == SDP_SUCCESS) || (sdp_status == SDP_DB_FULL)) && p_srvc_cb != NULL)
{
- do
+ do
{
/* find a service record, report it */
p_sdp_rec = SDP_FindServiceInDb(bta_gattc_cb.p_sdp_db,
@@ -810,7 +823,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
end_handle = (UINT16) pe.params[1];
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
- APPL_TRACE_EVENT3("Found ATT service [0x%04x] handle[0x%04x ~ 0x%04x]",
+ APPL_TRACE_EVENT3("Found ATT service [0x%04x] handle[0x%04x ~ 0x%04x]",
service_uuid.uu.uuid16, start_handle, end_handle);
#endif
@@ -818,9 +831,9 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
p_srvc_cb != NULL)
{
/* discover services result, add services into a service list */
- bta_gattc_add_srvc_to_list(p_srvc_cb,
- start_handle,
- end_handle,
+ bta_gattc_add_srvc_to_list(p_srvc_cb,
+ start_handle,
+ end_handle,
service_uuid,
TRUE);
}
@@ -829,7 +842,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
APPL_TRACE_ERROR2("invalid start_handle = %d end_handle = %d", start_handle, end_handle);
}
}
-
+
}
}
@@ -862,7 +875,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
tSDP_UUID uuid;
UINT16 num_attrs = 2;
UINT16 attr_list[2];
- tBTA_GATT_STATUS status = BTA_GATT_ERROR;
+ tBTA_GATT_STATUS status = BTA_GATT_ERROR;
memset (&uuid, 0, sizeof(tSDP_UUID));
@@ -870,7 +883,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
uuid.uu.uuid16 = UUID_PROTOCOL_ATT;
if((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL)
- {
+ {
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@@ -895,7 +908,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
** bta_gattc_disc_cmpl_cback
**
** Description callback functions to GATT client stack.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -912,17 +925,17 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
{
case GATT_DISC_SRVC_ALL:
/* discover services result, add services into a service list */
- bta_gattc_add_srvc_to_list(p_srvc_cb,
- p_data->handle,
- p_data->value.group_value.e_handle,
+ bta_gattc_add_srvc_to_list(p_srvc_cb,
+ p_data->handle,
+ p_data->value.group_value.e_handle,
p_data->value.group_value.service_type,
TRUE);
break;
case GATT_DISC_SRVC_BY_UUID:
- bta_gattc_add_srvc_to_list(p_srvc_cb,
- p_data->handle,
- p_data->value.handle,
+ bta_gattc_add_srvc_to_list(p_srvc_cb,
+ p_data->handle,
+ p_data->value.handle,
p_data->type,
TRUE);
break;
@@ -931,20 +944,20 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
/* add included service into service list if it's secondary or it never showed up
in the primary service search */
pri_srvc = bta_gattc_srvc_in_list(p_srvc_cb,
- p_data->value.incl_service.s_handle,
+ p_data->value.incl_service.s_handle,
p_data->value.incl_service.e_handle,
p_data->value.incl_service.service_type);
if (!pri_srvc)
- bta_gattc_add_srvc_to_list(p_srvc_cb,
- p_data->value.incl_service.s_handle,
- p_data->value.incl_service.e_handle,
+ bta_gattc_add_srvc_to_list(p_srvc_cb,
+ p_data->value.incl_service.s_handle,
+ p_data->value.incl_service.e_handle,
p_data->value.incl_service.service_type,
FALSE);
/* add into database */
- bta_gattc_add_attr_to_cache(p_srvc_cb,
- p_data->handle,
- &p_data->value.incl_service.service_type,
+ bta_gattc_add_attr_to_cache(p_srvc_cb,
+ p_data->handle,
+ &p_data->value.incl_service.service_type,
pri_srvc,
BTA_GATTC_ATTR_TYPE_INCL_SRVC);
break;
@@ -1008,7 +1021,7 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
** Returns the handle mapped. 0 if not found.
**
*******************************************************************************/
-UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id,
+UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id,
tBTA_GATT_ID *p_char_id, tBT_UUID descr_uuid)
{
tBTA_GATTC_CACHE *p_cache = p_srcb->p_srvc_cache;
@@ -1021,8 +1034,8 @@ UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service
while (p_cache && !done)
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
- APPL_TRACE_DEBUG3("Service: handle[%d] uuid[0x%04x] inst[%d]",
- p_cache->s_handle, p_cache->service_uuid.id.uuid.uu.uuid16,
+ APPL_TRACE_DEBUG3("Service: handle[%d] uuid[0x%04x] inst[%d]",
+ p_cache->s_handle, p_cache->service_uuid.id.uuid.uu.uuid16,
p_cache->service_uuid.id.inst_id);
#endif
p_attr = p_cache->p_attr;
@@ -1036,7 +1049,7 @@ UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_DEBUG5("\t Attr[0x%04x] handle[0x%04x] uuid[0x%04x] inst[%d] type[%d]",
j + 1, p_attr->attr_handle, p_attr->p_uuid->uuid16, p_attr->inst_id, p_attr->attr_type);
-#endif
+#endif
bta_gattc_pack_attr_uuid(p_attr, &attr_uuid);
if (bta_gattc_uuid_compare(p_char_id->uuid, attr_uuid, TRUE) &&
@@ -1119,8 +1132,8 @@ BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SR
while (p_cache)
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
- APPL_TRACE_DEBUG3("Service: handle[%d] uuid[0x%04x] inst[%d]",
- p_cache->s_handle, p_cache->service_uuid.id.uuid.uu.uuid16,
+ APPL_TRACE_DEBUG3("Service: handle[%d] uuid[0x%04x] inst[%d]",
+ p_cache->s_handle, p_cache->service_uuid.id.uuid.uu.uuid16,
p_cache->service_uuid.id.inst_id);
#endif
/* a service found */
@@ -1138,7 +1151,7 @@ BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SR
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_DEBUG5("\t Attr[0x%04x] handle[0x%04x] uuid[0x%04x] inst[%d] type[%d]",
- j + 1, p_attr->attr_handle, p_attr->p_uuid->uuid16, p_attr->inst_id, p_attr->attr_type);
+ j + 1, p_attr->attr_handle, p_attr->p_uuid->uuid16, p_attr->inst_id, p_attr->attr_type);
#endif
if (p_attr->attr_type == BTA_GATTC_ATTR_TYPE_CHAR)
p_char = p_attr;
@@ -1150,7 +1163,7 @@ BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SR
if (p_attr->attr_type == BTA_GATTC_ATTR_TYPE_CHAR_DESCR)
{
bta_gattc_pack_attr_uuid(p_attr, p_descr_type);
-
+
if (p_char != NULL)
{
bta_gattc_pack_attr_uuid(p_char, &p_char_id->uuid);
@@ -1191,14 +1204,14 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID uuid)
{
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
tBTA_GATTC_CACHE *p_cache = p_srcb->p_srvc_cache;
- tBTA_GATTC cb_data;
+ tBTA_GATTC cb_data;
while (p_cache)
{
if (bta_gattc_uuid_compare(uuid, p_cache->service_uuid.id.uuid, FALSE))
{
//#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
- APPL_TRACE_DEBUG3("found service [0x%04x], inst[%d] handle [%d]",
+ APPL_TRACE_DEBUG3("found service [0x%04x], inst[%d] handle [%d]",
p_cache->service_uuid.id.uuid.uu.uuid16,
p_cache->service_uuid.id.inst_id,
p_cache->s_handle);
@@ -1208,10 +1221,10 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID uuid)
memset(&cb_data, 0, sizeof(tBTA_GATTC));
cb_data.srvc_res.conn_id = p_clcb->bta_conn_id;
- memcpy(&cb_data.srvc_res.service_uuid, &p_cache->service_uuid ,sizeof(tBTA_GATT_SRVC_ID));
+ memcpy(&cb_data.srvc_res.service_uuid, &p_cache->service_uuid ,sizeof(tBTA_GATT_SRVC_ID));
(* p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_RES_EVT, &cb_data);
- //todo (tBTA_GATTC *)&p_cache->service_uuid);
+ //todo (tBTA_GATTC *)&p_cache->service_uuid);
}
}
p_cache = p_cache->p_next;
@@ -1226,16 +1239,16 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID uuid)
** Parameter p_result: output parameter to store the characteristic/
** included service GATT ID.
**
-** Returns GATT_ERROR is no recording found. BTA_GATT_OK if record found.
+** Returns GATT_ERROR is no recording found. BTA_GATT_OK if record found.
**
*******************************************************************************/
-static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
- tBTA_GATTC_ATTR_TYPE attr_type,
- tBTA_GATT_SRVC_ID *p_service_id,
- tBTA_GATT_ID *p_start_rec,
+static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
+ tBTA_GATTC_ATTR_TYPE attr_type,
+ tBTA_GATT_SRVC_ID *p_service_id,
+ tBTA_GATT_ID *p_start_rec,
tBT_UUID * p_uuid_cond,
tBTA_GATT_ID *p_result,
- void *p_param)
+ void *p_param)
{
tBTA_GATTC_CACHE *p_cache = p_srcb->p_srvc_cache;
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
@@ -1254,7 +1267,7 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
p_service_id->is_primary == p_cache->service_uuid.is_primary)
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
- APPL_TRACE_DEBUG2("found matching service [0x%04x], inst[%d]",
+ APPL_TRACE_DEBUG2("found matching service [0x%04x], inst[%d]",
p_cache->service_uuid.id.uuid.uu.uuid16,
p_cache->service_uuid.id.inst_id);
#endif
@@ -1264,9 +1277,9 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_DEBUG5("\t Attr[%d] handle[0x%04x] uuid[0x%04x] inst[%d] type[%d]",
- j + 1, p_attr->attr_handle,
- p_attr->p_uuid->uuid16,
- p_attr->inst_id,
+ j + 1, p_attr->attr_handle,
+ p_attr->p_uuid->uuid16,
+ p_attr->inst_id,
p_attr->attr_type);
#endif
bta_gattc_pack_attr_uuid(p_attr, &p_result->uuid);
@@ -1276,7 +1289,7 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
/* find the starting record first */
if (bta_gattc_uuid_compare(p_start_rec->uuid, p_result->uuid, FALSE) &&
p_start_rec->inst_id == p_attr->inst_id &&
- (attr_type == p_attr->attr_type ||
+ (attr_type == p_attr->attr_type ||
/* find descriptor would look for characteristic first */
(attr_type == BTA_GATTC_ATTR_TYPE_CHAR_DESCR && p_attr->attr_type == BTA_GATTC_ATTR_TYPE_CHAR)))
{
@@ -1296,7 +1309,7 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
{
break;
}
- else
+ else
{
if (start_descr.len != 0 && !descr_found)
{
@@ -1321,7 +1334,7 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
if (bta_gattc_uuid_compare(uuid_cond, p_result->uuid, FALSE) &&
attr_type == p_attr->attr_type)
{
-
+
APPL_TRACE_DEBUG0("found char handle mapping characteristic");
p_result->inst_id = p_attr->inst_id;
@@ -1345,7 +1358,7 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
{
APPL_TRACE_ERROR0("In the given service, can not find matching record");
}
- break;
+ break;
}
p_cache = p_cache->p_next;
@@ -1360,30 +1373,30 @@ static tBTA_GATT_STATUS bta_gattc_find_record(tBTA_GATTC_SERV *p_srcb,
**
** Description search local cache for matching attribute record.
**
-** Parameters conn_id: connection ID which identify the server.
+** Parameters conn_id: connection ID which identify the server.
** p_srvc_id: the service ID of which the characteristic is belonged to.
-** *p_start_rec: start the search from the next record
+** *p_start_rec: start the search from the next record
** after the one identified by *p_start_rec.
** p_uuid_cond: UUID, if NULL find the first available
-** characteristic/included service.
-** p_output: output parameter which will store the GATT ID
+** characteristic/included service.
+** p_output: output parameter which will store the GATT ID
** of the characteristic /included service found.
**
-** Returns BTA_GATT_ERROR is no recording found. BTA_GATT_OK if record found.
+** Returns BTA_GATT_ERROR is no recording found. BTA_GATT_OK if record found.
**
*******************************************************************************/
-tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id,
- tBTA_GATTC_ATTR_TYPE query_type,
- tBTA_GATT_SRVC_ID *p_srvc_id,
+tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id,
+ tBTA_GATTC_ATTR_TYPE query_type,
+ tBTA_GATT_SRVC_ID *p_srvc_id,
tBTA_GATT_ID *p_start_rec,
- tBT_UUID *p_uuid_cond,
+ tBT_UUID *p_uuid_cond,
tBTA_GATT_ID *p_output,
void *p_param)
{
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
- /* lock other GKI task */
+ /* lock other GKI task */
GKI_sched_lock();
APPL_TRACE_DEBUG0("bta_gattc_query_cache");
@@ -1392,15 +1405,15 @@ tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id,
{
if (p_clcb->state == BTA_GATTC_CONN_ST)
{
- if (p_clcb->p_srcb &&
+ if (p_clcb->p_srcb &&
!p_clcb->p_srcb->p_srvc_list && /* no active discovery */
p_clcb->p_srcb->p_srvc_cache)
{
- status = bta_gattc_find_record(p_clcb->p_srcb,
- query_type,
- p_srvc_id,
- p_start_rec,
- p_uuid_cond,
+ status = bta_gattc_find_record(p_clcb->p_srcb,
+ query_type,
+ p_srvc_id,
+ p_start_rec,
+ p_uuid_cond,
p_output,
p_param);
}
@@ -1420,7 +1433,7 @@ tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id,
else
{
APPL_TRACE_ERROR1("Unknown conn ID: %d", conn_id);
- }
+ }
GKI_sched_unlock();
return status;
@@ -1432,12 +1445,12 @@ tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id,
**
** Description rebuild server cache from NV cache.
**
-** Parameters
+** Parameters
**
** Returns None.
**
*******************************************************************************/
-void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
+void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index)
{
/* first attribute loading, initialize buffer */
@@ -1462,10 +1475,10 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
switch (p_attr->attr_type)
{
case BTA_GATTC_ATTR_TYPE_SRVC:
- bta_gattc_add_srvc_to_cache(p_srvc_cb,
- p_attr->s_handle,
- p_attr->e_handle,
- &p_attr->uuid,
+ bta_gattc_add_srvc_to_cache(p_srvc_cb,
+ p_attr->s_handle,
+ p_attr->e_handle,
+ &p_attr->uuid,
p_attr->is_primary,
p_attr->id);
break;
@@ -1473,12 +1486,12 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
case BTA_GATTC_ATTR_TYPE_CHAR:
case BTA_GATTC_ATTR_TYPE_CHAR_DESCR:
case BTA_GATTC_ATTR_TYPE_INCL_SRVC:
- bta_gattc_add_attr_to_cache(p_srvc_cb,
- p_attr->s_handle,
- &p_attr->uuid,
- p_attr->prop,
+ bta_gattc_add_attr_to_cache(p_srvc_cb,
+ p_attr->s_handle,
+ &p_attr->uuid,
+ p_attr->prop,
p_attr->attr_type);
- break;
+ break;
}
p_attr ++;
num_attr --;
@@ -1489,12 +1502,12 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
**
** Function bta_gattc_fill_nv_attr
**
-** Description fill a NV attribute entry value
+** Description fill a NV attribute entry value
**
** Returns None.
**
*******************************************************************************/
-void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_handle,
+void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_handle,
UINT16 e_handle, UINT8 id, tBT_UUID uuid, UINT8 prop, BOOLEAN is_primary)
{
p_attr->s_handle = s_handle;
@@ -1527,13 +1540,13 @@ BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
while (p_cur_srvc && i < BTA_GATTC_NV_LOAD_MAX)
{
if (offset ++ >= p_srvc_cb->attr_index)
- {
+ {
bta_gattc_fill_nv_attr(&nv_attr[i++],
BTA_GATTC_ATTR_TYPE_SRVC,
- p_cur_srvc->s_handle,
- p_cur_srvc->e_handle,
+ p_cur_srvc->s_handle,
+ p_cur_srvc->e_handle,
p_cur_srvc->service_uuid.id.inst_id,
- p_cur_srvc->service_uuid.id.uuid,
+ p_cur_srvc->service_uuid.id.uuid,
0,
p_cur_srvc->service_uuid.is_primary);
}
@@ -1555,10 +1568,10 @@ BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
bta_gattc_fill_nv_attr(&nv_attr[i++],
p_attr->attr_type,
- p_attr->attr_handle,
+ p_attr->attr_handle,
0,
p_attr->inst_id,
- uuid,
+ uuid,
p_attr->property,
FALSE);
}
@@ -1568,7 +1581,7 @@ BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
if (i > 0)
{
- bta_gattc_co_cache_save(p_srvc_cb->server_bda, BTA_GATTC_CI_CACHE_SAVE_EVT, i,
+ bta_gattc_co_cache_save(p_srvc_cb->server_bda, BTA_GATTC_CI_CACHE_SAVE_EVT, i,
nv_attr, p_srvc_cb->attr_index, conn_id);
p_srvc_cb->attr_index += i;
diff --git a/bta/gatt/bta_gattc_ci.c b/bta/gatt/bta_gattc_ci.c
index f5b4f41..212126f 100644
--- a/bta/gatt/bta_gattc_ci.c
+++ b/bta/gatt/bta_gattc_ci.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_ci.c
-**
-** Description: This is the implementation file for the GATT
-** call-in functions.
-**
-** Copyright (c) 2010, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2010-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the implementation file for the GATT call-in functions.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -33,7 +45,7 @@
** status - BTA_GATT_OK if full buffer of data,
** BTA_GATT_FAIL if an error has occurred.
**
-** Returns void
+** Returns void
**
*******************************************************************************/
void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS status,
@@ -57,18 +69,18 @@ void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
**
** Description This function sends an event to BTA indicating the phone has
** load the servere cache and ready to send it to the stack.
-**
+**
** Parameters server_bda - server BDA of this cache.
** num_bytes_read - number of bytes read into the buffer
** specified in the read callout-function.
** status - BTA_GATT_OK if full buffer of data,
** BTA_GATT_FAIL if an error has occurred.
**
-** Returns void
+** Returns void
**
*******************************************************************************/
-void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
- tBTA_GATTC_NV_ATTR *p_attr, tBTA_GATT_STATUS status,
+void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
+ tBTA_GATTC_NV_ATTR *p_attr, tBTA_GATT_STATUS status,
UINT16 conn_id)
{
tBTA_GATTC_CI_LOAD *p_evt;
@@ -98,14 +110,14 @@ void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
**
** Description This function sends an event to BTA indicating the phone has
** save the servere cache.
-**
+**
** Parameters server_bda - server BDA of this cache.
** evt - callin event code.
** status - BTA_GATT_OK if full buffer of data,
** BTA_GATT_ERROR if an error has occurred.
*8 conn_id - for this NV operation for.
**
-** Returns void
+** Returns void
**
*******************************************************************************/
void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS status,
diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h
index 4ae7697..407e5d8 100644
--- a/bta/gatt/bta_gattc_int.h
+++ b/bta/gatt/bta_gattc_int.h
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_int.h
-**
-** Description: This is the private file for the file transfer
-** client (FTC).
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the private file for the file transfer client (FTC).
+ *
+ ******************************************************************************/
#ifndef BTA_GATTC_INT_H
#define BTA_GATTC_INT_H
@@ -26,7 +38,7 @@
enum
{
BTA_GATTC_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_GATTC),
- BTA_GATTC_INT_OPEN_FAIL_EVT,
+ BTA_GATTC_INT_OPEN_FAIL_EVT,
BTA_GATTC_API_CANCEL_OPEN_EVT,
BTA_GATTC_INT_CANCEL_OPEN_OK_EVT,
@@ -40,11 +52,11 @@ enum
BTA_GATTC_API_CONFIRM_EVT,
BTA_GATTC_API_READ_MULTI_EVT,
- BTA_GATTC_INT_CONN_EVT,
+ BTA_GATTC_INT_CONN_EVT,
BTA_GATTC_INT_DISCOVER_EVT,
BTA_GATTC_DISCOVER_CMPL_EVT,
BTA_GATTC_OP_CMPL_EVT,
- BTA_GATTC_INT_DISCONN_EVT,
+ BTA_GATTC_INT_DISCONN_EVT,
/* for cache loading/saving */
BTA_GATTC_START_CACHE_EVT,
@@ -61,12 +73,12 @@ enum
typedef UINT16 tBTA_GATTC_INT_EVT;
/* max client application GATTC can support */
-#ifndef BTA_GATTC_CL_MAX
+#ifndef BTA_GATTC_CL_MAX
#define BTA_GATTC_CL_MAX 4
#endif
/* max known devices GATTC can support */
-#ifndef BTA_GATTC_KNOWN_SR_MAX
+#ifndef BTA_GATTC_KNOWN_SR_MAX
#define BTA_GATTC_KNOWN_SR_MAX 4
#endif
@@ -87,7 +99,7 @@ typedef struct
typedef struct
{
BT_HDR hdr;
- tBTA_GATTC_IF client_if;
+ tBTA_GATTC_IF client_if;
}tBTA_GATTC_INT_START_IF;
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
@@ -145,7 +157,7 @@ typedef struct
BT_HDR hdr;
UINT8 op_code;
tGATT_STATUS status;
- tBTA_GATTC_CMPL *p_cmpl;
+ tBTA_GATTC_CMPL *p_cmpl;
}tBTA_GATTC_OP_CMPL;
typedef struct
@@ -178,10 +190,10 @@ typedef union
tBTA_GATTC_OP_CMPL op_cmpl;
tBTA_GATTC_CI_EVT ci_open;
tBTA_GATTC_CI_EVT ci_save;
- tBTA_GATTC_CI_LOAD ci_load;
+ tBTA_GATTC_CI_LOAD ci_load;
- tBTA_GATTC_INT_START_IF int_start_if;
- tBTA_GATTC_INT_DEREG int_dereg;
+ tBTA_GATTC_INT_START_IF int_start_if;
+ tBTA_GATTC_INT_DEREG int_dereg;
} tBTA_GATTC_DATA;
@@ -213,9 +225,9 @@ typedef struct gattc_svc_cache
tBTA_GATT_SRVC_ID service_uuid;
tBTA_GATTC_CACHE_ATTR *p_attr;
tBTA_GATTC_CACHE_ATTR *p_last_attr;
- UINT16 s_handle;
+ UINT16 s_handle;
UINT16 e_handle;
- struct gattc_svc_cache *p_next;
+ struct gattc_svc_cache *p_next;
// btla-specific ++
} __attribute__((packed)) tBTA_GATTC_CACHE;
// btla-specific --
@@ -308,7 +320,7 @@ typedef struct
UINT16 bta_conn_id; /* client channel ID, unique for clcb */
BD_ADDR bda;
tBTA_GATTC_RCB *p_rcb; /* pointer to the registration CB */
- tBTA_GATTC_SERV *p_srcb; /* server cache CB */
+ tBTA_GATTC_SERV *p_srcb; /* server cache CB */
tBTA_GATTC_DATA *p_q_cmd; /* command in queue waiting for execution */
#define BTA_GATTC_NO_SCHEDULE 0
@@ -346,10 +358,10 @@ typedef struct
tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX];
tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX];
-
+
tSDP_DISCOVERY_DB *p_sdp_db;
UINT16 sdp_conn_id;
-}tBTA_GATTC_CB;
+}tBTA_GATTC_CB;
/*****************************************************************************
** Global data
@@ -405,16 +417,16 @@ extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_dat
extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
-extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
-extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
+extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
+extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
-extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
BD_ADDR remote_bda, UINT16 conn_id);
/* utility functions */
-extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda); //todo
+extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda); //todo
extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
@@ -442,9 +454,9 @@ extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type
extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID uuid);
-extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
- tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
- tBTA_GATT_ID *p_output, void *p_property);
+extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
+ tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
+ tBTA_GATT_ID *p_output, void *p_property);
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
diff --git a/bta/gatt/bta_gattc_main.c b/bta/gatt/bta_gattc_main.c
index 5016c46..a1fb536 100644
--- a/bta/gatt/bta_gattc_main.c
+++ b/bta/gatt/bta_gattc_main.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_main.c
-**
-** Description: This file contains the GATT client main functions
-** and state machine.
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT client main functions and state machine.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -33,7 +45,7 @@ enum
//BTA_GATTC_OPEN_FAIL_IN_CONN, //<--- need to remove this?
BTA_GATTC_OPEN_ERROR,
BTA_GATTC_CANCEL_OPEN,
- BTA_GATTC_CANCEL_OPEN_OK,
+ BTA_GATTC_CANCEL_OPEN_OK,
BTA_GATTC_CANCEL_OPEN_ERROR,
BTA_GATTC_CONN,
BTA_GATTC_START_DISCOVER,
@@ -72,7 +84,7 @@ const tBTA_GATTC_ACTION bta_gattc_action[] =
bta_gattc_cancel_open,
bta_gattc_cancel_open_ok,
bta_gattc_cancel_open_error,
- bta_gattc_conn,
+ bta_gattc_conn,
bta_gattc_start_discover,
bta_gattc_disc_cmpl,
@@ -85,7 +97,7 @@ const tBTA_GATTC_ACTION bta_gattc_action[] =
bta_gattc_op_cmpl,
bta_gattc_search,
bta_gattc_fail,
- bta_gattc_confirm,
+ bta_gattc_confirm,
bta_gattc_execute,
bta_gattc_read_multi,
bta_gattc_ci_open,
@@ -126,7 +138,7 @@ static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] =
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
-/* ===> for cache loading, saving */
+/* ===> for cache loading, saving */
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
@@ -172,7 +184,7 @@ static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] =
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_CONN_ST},
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST},
-/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
+/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
@@ -190,7 +202,7 @@ static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] =
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
-/* ===> for cache loading, saving */
+/* ===> for cache loading, saving */
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_CACHE_OPEN, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
@@ -204,7 +216,7 @@ static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] =
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
-/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
+/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
@@ -217,11 +229,11 @@ static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] =
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
-/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
+/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
-/* ===> for cache loading, saving */
+/* ===> for cache loading, saving */
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_CI_OPEN, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_CI_LOAD, BTA_GATTC_DISCOVER_ST},
@@ -259,7 +271,7 @@ static char *gattc_state_code(tBTA_GATTC_STATE state_code);
** Function bta_gattc_sm_execute
**
** Description State machine event handling function for GATTC
-**
+**
**
** Returns void
**
@@ -316,7 +328,7 @@ void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA
** Function bta_gattc_hdl_event
**
** Description GATT client main event handling function.
-**
+**
**
** Returns void
**
@@ -383,7 +395,7 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
**
** Function gattc_evt_code
**
-** Description
+** Description
**
** Returns void
**
@@ -448,7 +460,7 @@ static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
**
** Function gattc_state_code
**
-** Description
+** Description
**
** Returns void
**
diff --git a/bta/gatt/bta_gattc_utils.c b/bta/gatt/bta_gattc_utils.c
index 227129c..a36e26c 100644
--- a/bta/gatt/bta_gattc_utils.c
+++ b/bta/gatt/bta_gattc_utils.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_utils.c
-**
-** Description: This file contains the GATT client utility
-** function.
-**
-** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT client utility function.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -155,12 +167,12 @@ tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bd
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++)
{
- if (p_clcb->in_use &&
+ if (p_clcb->in_use &&
p_clcb->p_rcb->client_if == client_if &&
p_clcb->p_srcb &&
bdcmp(p_clcb->p_srcb->server_bda, remote_bda) == 0)
return p_clcb;
- }
+ }
return NULL;
}
/*******************************************************************************
@@ -182,7 +194,7 @@ tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id)
if (p_clcb->in_use &&
p_clcb->bta_conn_id == conn_id)
return p_clcb;
- }
+ }
return NULL;
}
@@ -205,14 +217,14 @@ tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_b
if (!bta_gattc_cb.clcb[i_clcb].in_use)
{
#if BTA_GATT_DEBUG == TRUE
- APPL_TRACE_DEBUG1("bta_gattc_clcb_alloc: found clcb[%d] available",i_clcb);
+ APPL_TRACE_DEBUG1("bta_gattc_clcb_alloc: found clcb[%d] available",i_clcb);
#endif
p_clcb = &bta_gattc_cb.clcb[i_clcb];
p_clcb->in_use = TRUE;
bdcpy(p_clcb->bda, remote_bda);
p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
-
+
if ((p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL)
p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda);
@@ -265,7 +277,7 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
{
if (p_clcb)
- {
+ {
if (p_clcb->p_srcb->num_clcb)
p_clcb->p_srcb->num_clcb --;
@@ -274,12 +286,12 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
utl_freebuf((void **)&p_clcb->p_q_cmd);
- APPL_TRACE_ERROR2("bta_gattc_clcb_dealloc in_use=%d conn_id=%d",p_clcb->in_use, p_clcb->bta_conn_id);
+ APPL_TRACE_ERROR2("bta_gattc_clcb_dealloc in_use=%d conn_id=%d",p_clcb->in_use, p_clcb->bta_conn_id);
memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB));
}
else
{
- APPL_TRACE_ERROR0("bta_gattc_clcb_dealloc p_clcb=NULL");
+ APPL_TRACE_ERROR0("bta_gattc_clcb_dealloc p_clcb=NULL");
}
}
@@ -405,7 +417,7 @@ BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
**
** Description pack UUID into a stream.
**
-** Returns
+** Returns
**
*******************************************************************************/
void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR *p_attr, tBT_UUID *p_uuid)
@@ -433,18 +445,18 @@ void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR *p_attr, tBT_UUID *p_uuid)
**
** Description check if the service notificaition has been registered.
**
-** Returns
+** Returns
**
*******************************************************************************/
-BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb,
- tBTA_GATTC_NOTIFY *p_notify)
+BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb,
+ tBTA_GATTC_NOTIFY *p_notify)
{
UINT8 i;
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
{
if (p_clreg->notif_reg[i].in_use &&
- bdcmp(p_clreg->notif_reg[i].remote_bda, p_srcb->server_bda) == 0 &&
+ bdcmp(p_clreg->notif_reg[i].remote_bda, p_srcb->server_bda) == 0 &&
(bta_gattc_uuid_compare(p_clreg->notif_reg[i].char_id.srvc_id.id.uuid, p_notify->char_id.srvc_id.id.uuid, FALSE) &&
p_clreg->notif_reg[i].char_id.srvc_id.id.inst_id == p_notify->char_id.srvc_id.id.inst_id &&
p_clreg->notif_reg[i].char_id.srvc_id.is_primary == p_notify->char_id.srvc_id.is_primary &&
@@ -499,28 +511,28 @@ void bta_gattc_clear_notif_registration(UINT16 conn_id)
**
** Description pack the data from read response into callback data structure.
**
-** Returns
+** Returns
**
*******************************************************************************/
-tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID descr_uuid,
+tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID descr_uuid,
tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value)
{
UINT8 i = 0, *pp = p_attr->value;
tBT_UUID uuid = {LEN_UUID_16, {GATT_UUID_CHAR_AGG_FORMAT}};
UINT16 handle;
tBTA_GATT_STATUS status = BTA_GATT_OK;
-
- /* GATT_UUID_CHAR_AGG_FORMAT */
+
+ /* GATT_UUID_CHAR_AGG_FORMAT */
if (bta_gattc_uuid_compare (uuid, descr_uuid, TRUE))
{
while (p_attr->len >= 2 && i < BTA_GATTC_MULTI_MAX)
{
STREAM_TO_UINT16(handle, pp);
- if (bta_gattc_handle2id(p_srcb,
- handle,
- &p_value->aggre_value.pre_format[i].char_id.srvc_id,
- &p_value->aggre_value.pre_format[i].char_id.char_id,
+ if (bta_gattc_handle2id(p_srcb,
+ handle,
+ &p_value->aggre_value.pre_format[i].char_id.srvc_id,
+ &p_value->aggre_value.pre_format[i].char_id.char_id,
&p_value->aggre_value.pre_format[i].descr_type) == FALSE)
{
status = BTA_GATT_INTERNAL_ERROR;
@@ -557,7 +569,7 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BO
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++)
{
- if (p_bg_tck->in_use &&
+ if (p_bg_tck->in_use &&
bdcmp(p_bg_tck->remote_bda, remote_bda) == 0)
{
if (add)
@@ -576,9 +588,9 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BO
}
else /* adding a new device mask */
{
- for (i = 0, p_bg_tck = &bta_gattc_cb.bg_track[0];
+ for (i = 0, p_bg_tck = &bta_gattc_cb.bg_track[0];
i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++)
- {
+ {
if (!p_bg_tck->in_use)
{
p_bg_tck->in_use = TRUE;
@@ -608,7 +620,7 @@ BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda)
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++)
{
- if (p_bg_tck->in_use &&
+ if (p_bg_tck->in_use &&
bdcmp(p_bg_tck->remote_bda, remote_bda) == 0)
{
if ((p_bg_tck->cif_mask &(1 <<(client_if - 1))) != 0)
@@ -624,10 +636,10 @@ BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda)
**
** Description send open callback
**
-** Returns
+** Returns
**
*******************************************************************************/
-void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
BD_ADDR remote_bda, UINT16 conn_id)
{
tBTA_GATTC cb_data;
@@ -640,7 +652,7 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
cb_data.open.client_if = p_clreg->client_if;
cb_data.open.conn_id = conn_id;
bdcpy(cb_data.open.remote_bda, remote_bda);
-
+
(*p_clreg->p_cback)(BTA_GATTC_OPEN_EVT, &cb_data);
}
}
diff --git a/bta/gatt/bta_gatts_act.c b/bta/gatt/bta_gatts_act.c
index cb56a32..1b47598 100644
--- a/bta/gatt/bta_gatts_act.c
+++ b/bta/gatt/bta_gatts_act.c
@@ -1,14 +1,27 @@
-/*****************************************************************************
-**
-** Name: bta_gatts_act.c
-**
-** Description: This file contains the GATT Server action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT Server action functions for the state
+ * machine.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -28,9 +41,9 @@ static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG
static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected, tGATT_DISCONN_REASON reason);
static void bta_gatts_send_request_cback (UINT16 conn_id,
- UINT32 trans_id,
+ UINT32 trans_id,
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data);
-static tGATT_CBACK bta_gatts_cback =
+static tGATT_CBACK bta_gatts_cback =
{
bta_gatts_conn_cback,
NULL,
@@ -73,8 +86,8 @@ static void bta_gatts_nv_save_cback(BOOLEAN is_add, tGATTS_HNDL_RANGE *p_hndl_ra
*******************************************************************************/
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req, tGATTS_SRV_CHG_RSP *p_rsp)
{
- return bta_gatts_co_srv_chg((tBTA_GATTS_SRV_CHG_CMD) cmd,
- (tBTA_GATTS_SRV_CHG_REQ *) p_req,
+ return bta_gatts_co_srv_chg((tBTA_GATTS_SRV_CHG_CMD) cmd,
+ (tBTA_GATTS_SRV_CHG_REQ *) p_req,
(tBTA_GATTS_SRV_CHG_RSP *) p_rsp);
}
@@ -165,8 +178,8 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
p_cb->rcb[first_unuse].in_use = TRUE;
p_cb->rcb[first_unuse].p_cback = p_msg->api_reg.p_cback;
memcpy(&p_cb->rcb[first_unuse].app_uuid, &p_msg->api_reg.app_uuid, sizeof(tBT_UUID));
- cb_data.reg_oper.server_if =
- p_cb->rcb[first_unuse].gatt_if = GATT_Register(&p_msg->api_reg.app_uuid, &bta_gatts_cback);
+ cb_data.reg_oper.server_if =
+ p_cb->rcb[first_unuse].gatt_if = GATT_Register(&p_msg->api_reg.app_uuid, &bta_gatts_cback);
if ( !p_cb->rcb[first_unuse].gatt_if)
{
status = BTA_GATT_NO_RESOURCES;
@@ -236,7 +249,7 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
tBTA_GATTS cb_data;
cb_data.reg_oper.server_if = p_msg->api_dereg.server_if;
- cb_data.reg_oper.status = status;
+ cb_data.reg_oper.status = status;
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
{
@@ -244,13 +257,13 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
{
p_cback = p_cb->rcb[i].p_cback;
status = BTA_GATT_OK;
-
+
/* deregister the app */
GATT_Deregister(p_cb->rcb[i].gatt_if);
/* reset cb */
memset(&p_cb->rcb[i], 0, sizeof(tBTA_GATTS_RCB));
- cb_data.reg_oper.status = status;
+ cb_data.reg_oper.status = status;
break;
}
}
@@ -275,7 +288,7 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
*******************************************************************************/
void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
- UINT8 rcb_idx;
+ UINT8 rcb_idx;
tBTA_GATTS cb_data;
UINT8 srvc_idx;
UINT16 service_id = 0;
@@ -292,10 +305,10 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
if ((srvc_idx = bta_gatts_alloc_srvc_cb(p_cb, rcb_idx)) != BTA_GATTS_INVALID_APP)
{
/* create the service now */
- service_id = GATTS_CreateService (p_cb->rcb[rcb_idx].gatt_if,
- &p_msg->api_create_svc.service_uuid,
+ service_id = GATTS_CreateService (p_cb->rcb[rcb_idx].gatt_if,
+ &p_msg->api_create_svc.service_uuid,
p_msg->api_create_svc.inst,
- p_msg->api_create_svc.num_handle,
+ p_msg->api_create_svc.num_handle,
p_msg->api_create_svc.is_pri);
if (service_id != 0)
@@ -310,7 +323,7 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
// btla-specific ++
cb_data.create.is_primary = p_msg->api_create_svc.is_pri;
// btla-specific --
- cb_data.create.server_if = p_cb->rcb[rcb_idx].gatt_if;
+ cb_data.create.server_if = p_cb->rcb[rcb_idx].gatt_if;
}
else
{
@@ -342,7 +355,7 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
*******************************************************************************/
void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb,tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
UINT16 attr_id = 0;
tBTA_GATTS cb_data;
@@ -376,8 +389,8 @@ void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb,tBTA_GATTS_DATA *
*******************************************************************************/
void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
- UINT16 attr_id = 0;
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ UINT16 attr_id = 0;
tBTA_GATTS cb_data;
attr_id = GATTS_AddCharacteristic(p_msg->api_add_char.hdr.layer_specific,
@@ -414,12 +427,12 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
*******************************************************************************/
void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
- UINT16 attr_id = 0;
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ UINT16 attr_id = 0;
tBTA_GATTS cb_data;
attr_id = GATTS_AddCharDescriptor(p_msg->api_add_char_descr.hdr.layer_specific,
- p_msg->api_add_char_descr.perm,
+ p_msg->api_add_char_descr.perm,
&p_msg->api_add_char_descr.descr_uuid);
cb_data.add_result.server_if = p_rcb->gatt_if;
@@ -453,13 +466,13 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
*******************************************************************************/
void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
tBTA_GATTS cb_data;
cb_data.srvc_oper.server_if = p_rcb->gatt_if;
cb_data.srvc_oper.service_id = p_msg->api_add_incl_srvc.hdr.layer_specific;
- if (GATTS_DeleteService(p_rcb->gatt_if,
+ if (GATTS_DeleteService(p_rcb->gatt_if,
&p_srvc_cb->service_uuid,
p_srvc_cb->inst_num))
{
@@ -486,7 +499,7 @@ void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
*******************************************************************************/
void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
tBTA_GATTS cb_data;
cb_data.srvc_oper.server_if = p_rcb->gatt_if;
@@ -519,7 +532,7 @@ void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_
*******************************************************************************/
void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
{
- tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
+ tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
tBTA_GATTS cb_data;
GATTS_StopService(p_srvc_cb->service_id);
@@ -544,14 +557,14 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_m
void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
- if (GATTS_SendRsp (p_msg->api_rsp.hdr.layer_specific,
- p_msg->api_rsp.trans_id,
- p_msg->api_rsp.status,
+ if (GATTS_SendRsp (p_msg->api_rsp.hdr.layer_specific,
+ p_msg->api_rsp.trans_id,
+ p_msg->api_rsp.status,
(tGATTS_RSP *)p_msg->api_rsp.p_rsp) != GATT_SUCCESS)
{
APPL_TRACE_ERROR0("Sending response failed");
}
-
+
}
/*******************************************************************************
**
@@ -574,17 +587,17 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
if (p_msg->api_indicate.need_confirm)
- status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
- p_msg->api_indicate.attr_id,
- p_msg->api_indicate.len,
+ status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
+ p_msg->api_indicate.attr_id,
+ p_msg->api_indicate.len,
p_msg->api_indicate.value);
else
- status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
- p_msg->api_indicate.attr_id,
- p_msg->api_indicate.len,
+ status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
+ p_msg->api_indicate.attr_id,
+ p_msg->api_indicate.len,
p_msg->api_indicate.value);
- if (status != GATT_SUCCESS &&
+ if (status != GATT_SUCCESS &&
p_msg->api_indicate.need_confirm &&
p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)
{
@@ -602,7 +615,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
**
** Function bta_gatts_open
**
-** Description
+** Description
**
** Returns none.
**
@@ -633,7 +646,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
**
** Function bta_gatts_cancel_open
**
-** Description
+** Description
**
** Returns none.
**
@@ -666,7 +679,7 @@ void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
**
** Function bta_gatts_close
**
-** Description
+** Description
**
** Returns none.
**
@@ -698,7 +711,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
APPL_TRACE_ERROR1("Unknown connection ID: %d", p_msg->hdr.layer_specific);
}
-
+
}
@@ -712,7 +725,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
**
*******************************************************************************/
static void bta_gatts_send_request_cback (UINT16 conn_id,
- UINT32 trans_id,
+ UINT32 trans_id,
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data)
{
tBTA_GATTS cb_data;
@@ -725,7 +738,7 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
{
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
- APPL_TRACE_DEBUG3 ("bta_gatts_send_request_cback conn_id=%d trans_id=%d req_type=%d", conn_id, trans_id, req_type);
+ APPL_TRACE_DEBUG3 ("bta_gatts_send_request_cback conn_id=%d trans_id=%d req_type=%d", conn_id, trans_id, req_type);
if (p_rcb && p_rcb->p_cback)
{
@@ -755,15 +768,15 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
** Returns none.
**
*******************************************************************************/
-static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
+static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
BOOLEAN connected, tGATT_DISCONN_REASON reason)
{
tBTA_GATTS cb_data;
- UINT8 evt = connected ? BTA_GATTS_CONNECT_EVT: BTA_GATTS_DISCONNECT_EVT;
+ UINT8 evt = connected ? BTA_GATTS_CONNECT_EVT: BTA_GATTS_DISCONNECT_EVT;
tBTA_GATTS_RCB *p_reg;
- APPL_TRACE_DEBUG4 ("bta_gatts_conn_cback gatt_if=%d conn_id=%d connected=%d reason = 0x%04d",
- gatt_if, conn_id, connected, reason);
+ APPL_TRACE_DEBUG4 ("bta_gatts_conn_cback gatt_if=%d conn_id=%d connected=%d reason = 0x%04d",
+ gatt_if, conn_id, connected, reason);
APPL_TRACE_DEBUG6("bta_gatts_conn_cback bda :%02x-%02x-%02x-%02x-%02x-%02x ",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
diff --git a/bta/gatt/bta_gatts_api.c b/bta/gatt/bta_gatts_api.c
index 77a8f6e..65df0a6 100644
--- a/bta/gatt/bta_gatts_api.c
+++ b/bta/gatt/bta_gatts_api.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gatts_api.c
-**
-** Description: This is the implementation of the API for GATT server
-** of BTA.
-**
-** Copyright (c) 2010-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2010-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the implementation of the API for GATT server of BTA.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -34,13 +46,13 @@ static const tBTA_SYS_REG bta_gatts_reg =
**
** Function BTA_GATTS_AppRegister
**
-** Description This function is called to register application callbacks
+** Description This function is called to register application callbacks
** with BTA GATTS module.
**
** Parameters p_app_uuid - applicaiton UUID
** p_cback - pointer to the application callback function.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback)
@@ -75,7 +87,7 @@ void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback)
** Function BTA_GATTS_AppDeregister
**
** Description De-register with GATT Server.
-**
+**
** Parameters app_id: applicatino ID.
**
** Returns void
@@ -100,11 +112,11 @@ void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if)
** Function BTA_GATTS_CreateService
**
** Description Create a service. When service creation is done, a callback
-** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
+** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
** and service ID to the profile. The service ID obtained in
** the callback function needs to be used when adding included
** service and characteristics/descriptors into the service.
-**
+**
** Parameters app_id: Profile ID this service is belonged to.
** p_service_uuid: service UUID.
** inst: instance ID number of this service.
@@ -114,7 +126,7 @@ void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if)
** Returns void
**
*******************************************************************************/
-void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid, UINT8 inst,
+void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid, UINT8 inst,
UINT16 num_handle, BOOLEAN is_primary)
{
tBTA_GATTS_API_CREATE_SRVC *p_buf;
@@ -140,8 +152,8 @@ void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
** Description This function is called to add an included service. After included
** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
** is reported the included service ID.
-**
-** Parameters service_id: service ID to which this included service is to
+**
+** Parameters service_id: service ID to which this included service is to
** be added.
** included_service_id: the service ID to be included.
**
@@ -152,8 +164,8 @@ void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id)
{
tBTA_GATTS_API_ADD_INCL_SRVC *p_buf;
- if ((p_buf =
- (tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
+ if ((p_buf =
+ (tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
!= NULL)
{
p_buf->hdr.event = BTA_GATTS_API_ADD_INCL_SRVC_EVT;
@@ -171,14 +183,14 @@ void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id)
** Function BTA_GATTS_AddCharacteristic
**
** Description This function is called to add a characteristic into a service.
-**
-** Parameters service_id: service ID to which this included service is to
+**
+** Parameters service_id: service ID to which this included service is to
** be added.
** p_char_uuid : Characteristic UUID.
** perm : Characteristic value declaration attribute permission.
** property : Characteristic Properties
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
@@ -208,19 +220,19 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
**
** Function BTA_GATTS_AddCharDescriptor
**
-** Description This function is called to add characteristic descriptor. When
+** Description This function is called to add characteristic descriptor. When
** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
** to report the status and an ID number for this descriptor.
**
-** Parameters service_id: service ID to which this charatceristic descriptor is to
+** Parameters service_id: service ID to which this charatceristic descriptor is to
** be added.
** perm: descriptor access permission.
-** p_descr_uuid: descriptor UUID.
+** p_descr_uuid: descriptor UUID.
**
-** Returns returns status.
+** Returns returns status.
**
*******************************************************************************/
-void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
+void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
tBTA_GATT_PERM perm,
tBT_UUID * p_descr_uuid)
{
@@ -250,12 +262,12 @@ void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
**
** Function BTA_GATTS_DeleteService
**
-** Description This function is called to delete a service. When this is done,
+** Description This function is called to delete a service. When this is done,
** a callback event BTA_GATTS_DELETE_EVT is report with the status.
**
-** Parameters service_id: service_id to be deleted.
+** Parameters service_id: service_id to be deleted.
**
-** Returns returns none.
+** Returns returns none.
**
*******************************************************************************/
void BTA_GATTS_DeleteService(UINT16 service_id)
@@ -283,7 +295,7 @@ void BTA_GATTS_DeleteService(UINT16 service_id)
** Parameters service_id: the service ID to be started.
** sup_transport: supported trasnport.
**
-** Returns None.
+** Returns None.
**
*******************************************************************************/
void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport)
@@ -310,7 +322,7 @@ void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transpor
**
** Parameters service_id - service to be topped.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void BTA_GATTS_StopService(UINT16 service_id)
@@ -340,10 +352,10 @@ void BTA_GATTS_StopService(UINT16 service_id)
** p_data: data to indicate.
** need_confirm - if this indication expects a confirmation or not.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 data_len,
+void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 data_len,
UINT8 *p_data, BOOLEAN need_confirm)
{
tBTA_GATTS_API_INDICATION *p_buf;
@@ -380,10 +392,10 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
** status - response status
** p_msg - response data.
**
-** Returns None
+** Returns None
**
*******************************************************************************/
-void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
+void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg)
{
tBTA_GATTS_API_RSP *p_buf;
@@ -418,7 +430,7 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
**
** Description Open a direct open connection or add a background auto connection
** bd address
-**
+**
** Parameters server_if: server interface.
** remote_bda: remote device BD address.
** is_direct: direct connection or background auto connection
@@ -449,7 +461,7 @@ void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_dire
**
** Description Cancel a direct open connection or remove a background auto connection
** bd address
-**
+**
** Parameters server_if: server interface.
** remote_bda: remote device BD address.
** is_direct: direct connection or background auto connection
@@ -477,7 +489,7 @@ void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN i
** Function BTA_GATTS_Close
**
** Description Close a connection a remote device.
-**
+**
** Parameters conn_id: connectino ID to be closed.
**
** Returns void
diff --git a/bta/gatt/bta_gatts_int.h b/bta/gatt/bta_gatts_int.h
index 77945f0..4810c05 100644
--- a/bta/gatt/bta_gatts_int.h
+++ b/bta/gatt/bta_gatts_int.h
@@ -1,13 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gatts_int.h
-**
-** Description: This is the private file for the BTA GATT server.
-**
-** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the private file for the BTA GATT server.
+ *
+ ******************************************************************************/
#ifndef BTA_GATTS_INT_H
#define BTA_GATTS_INT_H
@@ -27,7 +40,7 @@ enum
BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
BTA_GATTS_INT_START_IF_EVT,
BTA_GATTS_API_DEREG_EVT,
- BTA_GATTS_API_CREATE_SRVC_EVT,
+ BTA_GATTS_API_CREATE_SRVC_EVT,
BTA_GATTS_API_INDICATION_EVT,
BTA_GATTS_API_ADD_INCL_SRVC_EVT,
@@ -68,7 +81,7 @@ typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;
typedef struct
{
- BT_HDR hdr;
+ BT_HDR hdr;
tBTA_GATTS_IF server_if;
tBT_UUID service_uuid;
UINT16 num_handle;
@@ -79,7 +92,7 @@ typedef struct
typedef struct
{
- BT_HDR hdr;
+ BT_HDR hdr;
tBT_UUID char_uuid;
tBTA_GATT_PERM perm;
tBTA_GATT_CHAR_PROP property;
@@ -88,16 +101,16 @@ typedef struct
typedef struct
{
- BT_HDR hdr;
+ BT_HDR hdr;
UINT16 included_service_id;
}tBTA_GATTS_API_ADD_INCL_SRVC;
typedef struct
{
- BT_HDR hdr;
+ BT_HDR hdr;
tBT_UUID descr_uuid;
- tBTA_GATT_PERM perm;
+ tBTA_GATT_PERM perm;
}tBTA_GATTS_API_ADD_DESCR;
typedef struct
@@ -166,15 +179,15 @@ typedef struct
typedef struct
{
tBT_UUID service_uuid; /* service UUID */
- UINT16 service_id; /* service handle */
+ UINT16 service_id; /* service handle */
UINT8 inst_num; /* instance ID */
- UINT8 rcb_idx;
+ UINT8 rcb_idx;
UINT8 idx; /* self index of serviec CB */
BOOLEAN in_use;
}tBTA_GATTS_SRVC_CB;
-
+
/* GATT server control block */
typedef struct
{
diff --git a/bta/gatt/bta_gatts_main.c b/bta/gatt/bta_gatts_main.c
index 6870016..e2b2494 100644
--- a/bta/gatt/bta_gatts_main.c
+++ b/bta/gatt/bta_gatts_main.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gatts_main.c
-**
-** Description: This file contains the GATT server main functions
-** and state machine.
-**
-** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT server main functions and state machine.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -43,7 +55,7 @@ tBTA_GATTS_CB bta_gatts_cb;
** Function bta_gatts_hdl_event
**
** Description BTA GATT server main event handling function.
-**
+**
**
** Returns void
**
@@ -72,19 +84,19 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
break;
case BTA_GATTS_API_INDICATION_EVT:
- bta_gatts_indicate_handle(p_cb,(tBTA_GATTS_DATA *) p_msg);
+ bta_gatts_indicate_handle(p_cb,(tBTA_GATTS_DATA *) p_msg);
break;
case BTA_GATTS_API_OPEN_EVT:
- bta_gatts_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
+ bta_gatts_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
break;
case BTA_GATTS_API_CANCEL_OPEN_EVT:
- bta_gatts_cancel_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
+ bta_gatts_cancel_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
break;
case BTA_GATTS_API_CLOSE_EVT:
- bta_gatts_close(p_cb,(tBTA_GATTS_DATA *) p_msg);
+ bta_gatts_close(p_cb,(tBTA_GATTS_DATA *) p_msg);
break;
case BTA_GATTS_API_RSP_EVT:
@@ -98,7 +110,7 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
case BTA_GATTS_API_START_SRVC_EVT:
case BTA_GATTS_API_STOP_SRVC_EVT:
- p_srvc_cb = bta_gatts_find_srvc_cb_by_srvc_id(p_cb,
+ p_srvc_cb = bta_gatts_find_srvc_cb_by_srvc_id(p_cb,
((tBTA_GATTS_DATA *)p_msg)->api_add_incl_srvc.hdr.layer_specific);
if (p_srvc_cb != NULL)
diff --git a/bta/gatt/bta_gatts_utils.c b/bta/gatt/bta_gatts_utils.c
index 8f00793..5145c95 100644
--- a/bta/gatt/bta_gatts_utils.c
+++ b/bta/gatt/bta_gatts_utils.c
@@ -1,14 +1,26 @@
-/*****************************************************************************
-**
-** Name: bta_gattc_utils.c
-**
-** Description: This file contains the GATT client utility
-** function.
-**
-** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the GATT client utility function.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -124,7 +136,7 @@ tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT
APPL_TRACE_DEBUG1("bta_gatts_find_srvc_cb_by_srvc_id service_id=%d", service_id);
for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++)
{
- if (p_cb->srvc_cb[i].in_use &&
+ if (p_cb->srvc_cb[i].in_use &&
p_cb->srvc_cb[i].service_id == service_id)
{
APPL_TRACE_DEBUG1("bta_gatts_find_srvc_cb_by_srvc_id found service cb index =%d", i);
@@ -150,14 +162,14 @@ tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT
{
if (/* middle service */
(i < (BTA_GATTS_MAX_SRVC_NUM - 1) &&
- p_cb->srvc_cb[i].in_use &&
- p_cb->srvc_cb[i + 1].in_use &&
+ p_cb->srvc_cb[i].in_use &&
+ p_cb->srvc_cb[i + 1].in_use &&
attr_id >= p_cb->srvc_cb[i].service_id &&
attr_id < p_cb->srvc_cb[i + 1].service_id) ||
/* last active service */
(i < (BTA_GATTS_MAX_SRVC_NUM - 1) &&
- p_cb->srvc_cb[i].in_use &&
- !p_cb->srvc_cb[i + 1].in_use &&
+ p_cb->srvc_cb[i].in_use &&
+ !p_cb->srvc_cb[i + 1].in_use &&
attr_id >= p_cb->srvc_cb[i].service_id) ||
/* last service incb */
(i == (BTA_GATTS_MAX_SRVC_NUM - 1) &&
@@ -220,4 +232,4 @@ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src)
-#endif
+#endif