summaryrefslogtreecommitdiffstats
path: root/stack/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 /stack/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 'stack/gatt')
-rw-r--r--stack/gatt/att_protocol.c99
-rw-r--r--stack/gatt/gatt_api.c247
-rw-r--r--stack/gatt/gatt_attr.c62
-rw-r--r--stack/gatt/gatt_auth.c67
-rw-r--r--stack/gatt/gatt_cl.c216
-rw-r--r--stack/gatt/gatt_db.c233
-rw-r--r--stack/gatt/gatt_int.h107
-rw-r--r--stack/gatt/gatt_main.c108
-rw-r--r--stack/gatt/gatt_sr.c230
-rw-r--r--stack/gatt/gatt_utils.c341
10 files changed, 919 insertions, 791 deletions
diff --git a/stack/gatt/att_protocol.c b/stack/gatt/att_protocol.c
index f3c3a28..a114a33 100644
--- a/stack/gatt/att_protocol.c
+++ b/stack/gatt/att_protocol.c
@@ -1,16 +1,29 @@
-/*****************************************************************************
-**
-** Name: att_protocl.c
-**
-** Description: this file contains ATT protocol functions
-**
-**
-** Copyright (c) 2008-2010, Broadcom Corp, All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2008-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 ATT protocol functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
-
+
#if BLE_INCLUDED == TRUE
#include "gatt_int.h"
@@ -43,7 +56,7 @@ BT_HDR *attp_build_mtu_cmd(UINT8 op_code, UINT16 rx_mtu)
UINT16_TO_STREAM (p, rx_mtu);
p_buf->offset = L2CAP_MIN_OFFSET;
- p_buf->len = GATT_HDR_SIZE; /* opcode + 2 bytes mtu */
+ p_buf->len = GATT_HDR_SIZE; /* opcode + 2 bytes mtu */
}
return p_buf;
}
@@ -103,7 +116,7 @@ BT_HDR *attp_build_err_cmd(UINT8 cmd_code, UINT16 err_handle, UINT8 reason)
UINT8_TO_STREAM (p, GATT_RSP_ERROR);
UINT8_TO_STREAM (p, cmd_code);
UINT16_TO_STREAM(p, err_handle);
- UINT8_TO_STREAM (p, reason);
+ UINT8_TO_STREAM (p, reason);
p_buf->offset = L2CAP_MIN_OFFSET;
/* GATT_HDR_SIZE (1B ERR_RSP op code+ 2B handle) + 1B cmd_op_code + 1B status */
@@ -153,7 +166,7 @@ BT_HDR *attp_build_read_handles_cmd (UINT16 payload_size, tGATT_FIND_TYPE_VALUE
{
BT_HDR *p_buf = NULL;
UINT8 *p;
- UINT16 len = p_value_type->value_len;
+ UINT16 len = p_value_type->value_len;
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
{
@@ -199,7 +212,7 @@ BT_HDR *attp_build_read_multi_cmd(UINT16 payload_size, UINT16 num_handle, UINT16
p_buf->len = 1;
UINT8_TO_STREAM (p, GATT_REQ_READ_MULTI);
-
+
for (i = 0; i < num_handle && p_buf->len + 2 <= payload_size; i ++)
{
UINT16_TO_STREAM (p, *(p_handle + i));
@@ -239,7 +252,7 @@ BT_HDR *attp_build_handle_cmd(UINT8 op_code, UINT16 handle, UINT16 offset)
{
UINT16_TO_STREAM (p, offset);
p_buf->len += 2;
- }
+ }
}
@@ -279,7 +292,7 @@ BT_HDR *attp_build_opcode_cmd(UINT8 op_code)
** Returns None.
**
*******************************************************************************/
-BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
+BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
UINT16 offset, UINT16 len, UINT8 *p_data)
{
BT_HDR *p_buf = NULL;
@@ -298,12 +311,12 @@ BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
p_pair_len = p;
pair_len = len + 2;
UINT8_TO_STREAM (p, pair_len);
- p_buf->len += 1;
+ p_buf->len += 1;
}
if (op_code != GATT_RSP_READ_BLOB && op_code != GATT_RSP_READ)
{
UINT16_TO_STREAM (p, handle);
- p_buf->len += 2;
+ p_buf->len += 2;
}
if (op_code == GATT_REQ_PREPARE_WRITE ||op_code == GATT_RSP_PREPARE_WRITE )
@@ -313,7 +326,7 @@ BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
}
if (len > 0 && p_data != NULL)
- {
+ {
/* ensure data not exceed MTU size */
if (payload_size - p_buf->len < len)
{
@@ -351,7 +364,7 @@ BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
if (l2cap_ret == L2CAP_DW_FAILED)
{
- GATT_TRACE_ERROR1("ATT failed to pass msg:0x%0x to L2CAP",
+ GATT_TRACE_ERROR1("ATT failed to pass msg:0x%0x to L2CAP",
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
GKI_freebuf(p_toL2CAP);
return FALSE;
@@ -371,7 +384,7 @@ BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
*******************************************************************************/
BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg)
{
- BT_HDR *p_cmd = NULL;
+ BT_HDR *p_cmd = NULL;
UINT16 offset = 0;
switch (op_code)
@@ -388,14 +401,14 @@ BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg)
case GATT_RSP_READ:
case GATT_HANDLE_VALUE_NOTIF:
case GATT_HANDLE_VALUE_IND:
- p_cmd = attp_build_value_cmd(p_tcb->payload_size,
- op_code,
+ p_cmd = attp_build_value_cmd(p_tcb->payload_size,
+ op_code,
p_msg->attr_value.handle,
offset,
- p_msg->attr_value.len,
+ p_msg->attr_value.len,
p_msg->attr_value.value);
break;
-
+
case GATT_RSP_WRITE:
p_cmd = attp_build_opcode_cmd(op_code);
break;
@@ -427,14 +440,14 @@ BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg)
**
** Function attp_send_sr_msg
**
-** Description This function sends the server response or indication message
+** Description This function sends the server response or indication message
** to client.
**
** Parameter p_tcb: pointer to the connecton control block.
** p_msg: pointer to message parameters structure.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
-**
+**
**
*******************************************************************************/
tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg)
@@ -468,9 +481,9 @@ tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg)
UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR *p_cmd)
{
UINT8 att_ret = GATT_SUCCESS;
-
+
if (p_tcb != NULL)
- {
+ {
cmd_code &= ~GATT_AUTH_SIGN_MASK;
if (p_tcb->pending_cl_req == p_tcb->next_slot_inq ||
@@ -501,7 +514,7 @@ UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR
**
** Function attp_send_cl_msg
**
-** Description This function sends the client request or confirmation message
+** Description This function sends the client request or confirmation message
** to server.
**
** Parameter p_tcb: pointer to the connectino control block.
@@ -510,13 +523,13 @@ UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR
** p_msg: pointer to message parameters structure.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
-**
+**
**
*******************************************************************************/
tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, tGATT_CL_MSG *p_msg)
{
tGATT_STATUS status = GATT_NO_RESOURCES;
- BT_HDR *p_cmd = NULL;
+ BT_HDR *p_cmd = NULL;
UINT16 offset = 0, handle;
if (p_tcb != NULL)
@@ -540,9 +553,9 @@ tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
GATT_HANDLE_IS_VALID (p_msg->browse.e_handle) &&
p_msg->browse.s_handle <= p_msg->browse.e_handle)
{
- p_cmd = attp_build_browse_cmd(op_code,
- p_msg->browse.s_handle,
- p_msg->browse.e_handle,
+ p_cmd = attp_build_browse_cmd(op_code,
+ p_msg->browse.s_handle,
+ p_msg->browse.e_handle,
p_msg->browse.uuid);
}
else
@@ -555,7 +568,7 @@ tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
case GATT_REQ_READ:
handle = (op_code == GATT_REQ_READ) ? p_msg->handle: p_msg->read_blob.handle;
/* handle checking */
- if (GATT_HANDLE_IS_VALID (handle))
+ if (GATT_HANDLE_IS_VALID (handle))
{
p_cmd = attp_build_handle_cmd(op_code, handle, offset);
}
@@ -575,7 +588,7 @@ tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
case GATT_SIGN_CMD_WRITE:
if (GATT_HANDLE_IS_VALID (p_msg->attr_value.handle))
{
- p_cmd = attp_build_value_cmd (p_tcb->payload_size,
+ p_cmd = attp_build_value_cmd (p_tcb->payload_size,
op_code, p_msg->attr_value.handle,
offset,
p_msg->attr_value.len,
@@ -589,14 +602,14 @@ tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
p_cmd = attp_build_exec_write_cmd(op_code, p_msg->exec_write);
break;
- case GATT_REQ_FIND_TYPE_VALUE:
- p_cmd = attp_build_read_handles_cmd(p_tcb->payload_size, &p_msg->find_type_value);
+ case GATT_REQ_FIND_TYPE_VALUE:
+ p_cmd = attp_build_read_handles_cmd(p_tcb->payload_size, &p_msg->find_type_value);
break;
case GATT_REQ_READ_MULTI:
- p_cmd = attp_build_read_multi_cmd(p_tcb->payload_size,
- p_msg->read_multi.num_handles,
- p_msg->read_multi.handles);
+ p_cmd = attp_build_read_multi_cmd(p_tcb->payload_size,
+ p_msg->read_multi.num_handles,
+ p_msg->read_multi.handles);
break;
default:
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c
index c01d617..7845f3c 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.c
@@ -1,13 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatt_api.c
-**
-** Description: this file contains GATT interface functions
-**
-**
-** Copyright (c) 1999-2011, Broadcom Corp, All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 1999-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 GATT interface functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -60,8 +73,8 @@ UINT8 GATT_SetTraceLevel (UINT8 new_level)
** Function GATTS_AddHandleRange
**
** Description This function add the allocated handles range for the specifed
-** application UUID, service UUID and service instance
-**
+** application UUID, service UUID and service instance
+**
** Parameter p_hndl_range: pointer to allocated handles information
**
** Returns TRUE if handle range is added sucessfully; otherwise FALSE.
@@ -76,7 +89,7 @@ BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range)
if ((p_buf = gatt_alloc_hdl_buffer()) != NULL)
{
p_buf->asgn_range = *p_hndl_range;
- status = gatt_add_an_item_to_list(&gatt_cb.hdl_list_info, p_buf);
+ status = gatt_add_an_item_to_list(&gatt_cb.hdl_list_info, p_buf);
}
return status;
}
@@ -87,7 +100,7 @@ BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range)
** Function GATTS_NVRegister
**
** Description Application manager calls this function to register for
-** NV save callback function. There can be one and only one
+** NV save callback function. There can be one and only one
** NV save callback function.
**
** Parameter p_cb_info : callback informaiton
@@ -138,11 +151,11 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
tBT_UUID *p_app_uuid128;
- GATT_TRACE_API0 ("GATTS_CreateService" );
+ GATT_TRACE_API0 ("GATTS_CreateService" );
if (p_reg == NULL)
{
- GATT_TRACE_ERROR1 ("Inavlid gatt_if=%d", gatt_if);
+ GATT_TRACE_ERROR1 ("Inavlid gatt_if=%d", gatt_if);
return(0);
}
@@ -151,7 +164,7 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
if ((p_list = gatt_find_hdl_buffer_by_app_id(p_app_uuid128, p_svc_uuid, svc_inst)) != NULL)
{
s_hdl = p_list->asgn_range.s_handle;
- GATT_TRACE_DEBUG0 ("Service already been created!!");
+ GATT_TRACE_DEBUG0 ("Service already been created!!");
}
else
{
@@ -183,14 +196,14 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
/* check for space */
if (num_handles > (0xFFFF - s_hdl + 1))
{
- GATT_TRACE_ERROR2 ("GATTS_ReserveHandles: no handles, s_hdl: %u needed: %u", s_hdl, num_handles);
+ GATT_TRACE_ERROR2 ("GATTS_ReserveHandles: no handles, s_hdl: %u needed: %u", s_hdl, num_handles);
return(0);
}
if ( (p_list = gatt_alloc_hdl_buffer()) == NULL)
{
/* No free entry */
- GATT_TRACE_ERROR0 ("GATTS_ReserveHandles: no free handle blocks");
+ GATT_TRACE_ERROR0 ("GATTS_ReserveHandles: no free handle blocks");
return(0);
}
@@ -211,7 +224,7 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
if ( (p_buf = gatt_add_pending_new_srv_start(&p_list->asgn_range)) == NULL)
{
/* No free entry */
- GATT_TRACE_ERROR0 ("gatt_add_pending_new_srv_start: no free blocks");
+ GATT_TRACE_ERROR0 ("gatt_add_pending_new_srv_start: no free blocks");
if (p_list)
{
@@ -221,13 +234,13 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
return(0);
}
- GATT_TRACE_DEBUG0 ("Add a new srv chg item");
+ GATT_TRACE_DEBUG0 ("Add a new srv chg item");
}
}
if (!gatts_init_service_db(&p_list->svc_db, *p_svc_uuid, is_pri, s_hdl , num_handles))
{
- GATT_TRACE_ERROR0 ("GATTS_ReserveHandles: service DB initialization failed");
+ GATT_TRACE_ERROR0 ("GATTS_ReserveHandles: service DB initialization failed");
if (p_list)
{
gatt_remove_an_item_from_list(p_list_info, p_list);
@@ -239,11 +252,11 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
return(0);
}
- GATT_TRACE_DEBUG6 ("GATTS_CreateService(success): handles needed:%u s_hdl=%u e_hdl=%u %s[%x] is_primary=%d",
+ GATT_TRACE_DEBUG6 ("GATTS_CreateService(success): handles needed:%u s_hdl=%u e_hdl=%u %s[%x] is_primary=%d",
num_handles, p_list->asgn_range.s_handle , p_list->asgn_range.e_handle,
((p_list->asgn_range.svc_uuid.len == 2) ? "uuid16": "uuid128" ),
p_list->asgn_range.svc_uuid.uu.uuid16,
- p_list->asgn_range.is_primary);
+ p_list->asgn_range.is_primary);
return(s_hdl);
}
@@ -257,7 +270,7 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
** Parameter service_handle : To which service this included service is added to.
** include_svc_handle : included service handle.
**
-** Returns included service attribute handle. If 0, add included service
+** Returns included service attribute handle. If 0, add included service
** fail.
**
*******************************************************************************/
@@ -277,8 +290,8 @@ UINT16 GATTS_AddIncludeService (UINT16 service_handle, UINT16 include_svc_handle
return 0;
}
- return gatts_add_included_service(&p_decl->svc_db,
- p_incl_decl->asgn_range.s_handle,
+ return gatts_add_included_service(&p_decl->svc_db,
+ p_incl_decl->asgn_range.s_handle,
p_incl_decl->asgn_range.e_handle,
p_incl_decl->asgn_range.svc_uuid);
}
@@ -314,34 +327,34 @@ UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
((perm & GATT_WRITE_SIGNED_PERM) && !(property & GATT_CHAR_PROP_BIT_AUTH)) )
{
GATT_TRACE_DEBUG2("Invalid configuration property=0x%x perm=0x%x ", property, perm);
- return 0;
+ return 0;
}
- return gatts_add_characteristic(&p_decl->svc_db,
- perm,
+ return gatts_add_characteristic(&p_decl->svc_db,
+ perm,
property,
- p_char_uuid);
+ p_char_uuid);
}
/*******************************************************************************
**
** Function GATTS_AddCharDescriptor
**
-** Description This function is called to add a characteristic descriptor
-** into a service database. Add descriptor should follow add char
-** to which it belongs, and next add char should be done only
+** Description This function is called to add a characteristic descriptor
+** into a service database. Add descriptor should follow add char
+** to which it belongs, and next add char should be done only
** after all add descriptors for the previous char.
**
-** Parameter service_handle : To which service this characteristic descriptor
+** Parameter service_handle : To which service this characteristic descriptor
** is added to.
-** perm : Characteristic value declaration attribute
+** perm : Characteristic value declaration attribute
** permission.
** p_descr_uuid : Characteristic descriptor UUID
**
-** Returns Characteristic descriptor attribute handle. 0 if add
+** Returns Characteristic descriptor attribute handle. 0 if add
** characteristic descriptor failed.
**
*******************************************************************************/
-UINT16 GATTS_AddCharDescriptor (UINT16 service_handle,
+UINT16 GATTS_AddCharDescriptor (UINT16 service_handle,
tGATT_PERM perm,
tBT_UUID * p_descr_uuid)
{
@@ -352,15 +365,15 @@ UINT16 GATTS_AddCharDescriptor (UINT16 service_handle,
GATT_TRACE_DEBUG0("Service not created");
return 0;
}
- if (p_descr_uuid == NULL ||
+ if (p_descr_uuid == NULL ||
(p_descr_uuid->len != LEN_UUID_128 && p_descr_uuid->len != LEN_UUID_16))
{
GATT_TRACE_DEBUG0("Illegal parameter");
return 0;
}
- return gatts_add_char_descr(&p_decl->svc_db,
- perm,
+ return gatts_add_char_descr(&p_decl->svc_db,
+ perm,
p_descr_uuid);
}
@@ -387,26 +400,26 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
tBT_UUID *p_app_uuid128;
- GATT_TRACE_DEBUG0 ("GATTS_DeleteService");
+ GATT_TRACE_DEBUG0 ("GATTS_DeleteService");
if (p_reg == NULL)
{
- GATT_TRACE_ERROR0 ("Applicaiton not foud");
+ GATT_TRACE_ERROR0 ("Applicaiton not foud");
return(FALSE);
}
p_app_uuid128 = &p_reg->app_uuid128;
if ((p_list = gatt_find_hdl_buffer_by_app_id(p_app_uuid128, p_svc_uuid, svc_inst)) == NULL)
{
- GATT_TRACE_ERROR0 ("No Service found");
+ GATT_TRACE_ERROR0 ("No Service found");
return(FALSE);
}
- if ( (p_buf = gatt_sr_is_new_srv_chg(&p_list->asgn_range.app_uuid128,
- &p_list->asgn_range.svc_uuid,
+ if ( (p_buf = gatt_sr_is_new_srv_chg(&p_list->asgn_range.app_uuid128,
+ &p_list->asgn_range.svc_uuid,
p_list->asgn_range.svc_inst)) != NULL)
{
- GATT_TRACE_DEBUG0 ("Delete a new service changed item - the service has not yet started");
+ GATT_TRACE_DEBUG0 ("Delete a new service changed item - the service has not yet started");
GKI_freebuf (GKI_remove_from_queue (&gatt_cb.pending_new_srv_start_q, p_buf));
}
else
@@ -414,17 +427,17 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
gatt_proc_srv_chg();
}
- if ((i_sreg = gatt_sr_find_i_rcb_by_app_id (p_app_uuid128,
- p_svc_uuid,
+ if ((i_sreg = gatt_sr_find_i_rcb_by_app_id (p_app_uuid128,
+ p_svc_uuid,
svc_inst)) != GATT_MAX_SR_PROFILES)
{
GATTS_StopService(gatt_cb.sr_reg[i_sreg].s_hdl);
}
- GATT_TRACE_DEBUG2 ("released handles s_hdl=%u e_hdl=%u",
- p_list->asgn_range.s_handle , p_list->asgn_range.e_handle );
+ GATT_TRACE_DEBUG2 ("released handles s_hdl=%u e_hdl=%u",
+ p_list->asgn_range.s_handle , p_list->asgn_range.e_handle );
- if ( (p_list->asgn_range.s_handle >= gatt_cb.hdl_cfg.app_start_hdl)
+ if ( (p_list->asgn_range.s_handle >= gatt_cb.hdl_cfg.app_start_hdl)
&& gatt_cb.cb_info.p_nv_save_callback)
(*gatt_cb.cb_info.p_nv_save_callback)(FALSE, &p_list->asgn_range);
@@ -447,7 +460,7 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
** return GATT_SUCCESS if sucessfully started; otherwise error code.
**
*******************************************************************************/
-tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
+tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
tGATT_TRANSPORT sup_transport)
{
tGATT_SR_REG *p_sreg;
@@ -458,24 +471,24 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
tGATTS_PENDING_NEW_SRV_START *p_buf;
- GATT_TRACE_API0 ("GATTS_StartService");
+ GATT_TRACE_API0 ("GATTS_StartService");
if (p_reg == NULL)
{
/* Not found */
- GATT_TRACE_ERROR0 ("Applicaiton not found ");
+ GATT_TRACE_ERROR0 ("Applicaiton not found ");
return GATT_NOT_FOUND;
}
if ((p_list = gatt_find_hdl_buffer_by_handle(service_handle)) == NULL)
{
/* Not found */
- GATT_TRACE_ERROR0 ("no service found");
+ GATT_TRACE_ERROR0 ("no service found");
return GATT_NOT_FOUND;
}
- if (gatt_sr_find_i_rcb_by_app_id (&p_list->asgn_range.app_uuid128,
- &p_list->asgn_range.svc_uuid,
+ if (gatt_sr_find_i_rcb_by_app_id (&p_list->asgn_range.app_uuid128,
+ &p_list->asgn_range.svc_uuid,
p_list->asgn_range.svc_inst) != GATT_MAX_SR_PROFILES)
{
GATT_TRACE_ERROR0 ("Duplicate Service start - Service already started");
@@ -485,7 +498,7 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
/*this is a new application servoce start */
if ((i_sreg = gatt_sr_alloc_rcb(p_list)) == GATT_MAX_SR_PROFILES)
{
- GATT_TRACE_ERROR0 ("GATTS_StartService: no free server registration block");
+ GATT_TRACE_ERROR0 ("GATTS_StartService: no free server registration block");
return GATT_NO_RESOURCES;
}
@@ -495,7 +508,7 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
switch (sup_transport)
{
case GATT_TRANSPORT_BR_EDR:
- case GATT_TRANSPORT_LE_BR_EDR:
+ case GATT_TRANSPORT_LE_BR_EDR:
if (p_sreg->type == GATT_UUID_PRI_SERVICE)
{
p_uuid = gatts_get_service_uuid (p_sreg->p_db);
@@ -507,7 +520,7 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
break;
}
- gatts_update_srv_list_elem(i_sreg, p_sreg->s_hdl,
+ gatts_update_srv_list_elem(i_sreg, p_sreg->s_hdl,
p_list->asgn_range.is_primary);
gatt_add_a_srv_to_list(&gatt_cb.srv_list_info, &gatt_cb.srv_list[i_sreg]);
@@ -515,13 +528,13 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
GATT_TRACE_DEBUG1 ("allocated i_sreg=%d ",i_sreg);
GATT_TRACE_DEBUG5 ("s_hdl=%d e_hdl=%d type=0x%x svc_inst=%d sdp_hdl=0x%x",
- p_sreg->s_hdl,p_sreg->e_hdl,
+ p_sreg->s_hdl,p_sreg->e_hdl,
p_sreg->type, p_sreg->service_instance,
p_sreg->sdp_handle);
- if ( (p_buf = gatt_sr_is_new_srv_chg(&p_list->asgn_range.app_uuid128,
- &p_list->asgn_range.svc_uuid,
+ if ( (p_buf = gatt_sr_is_new_srv_chg(&p_list->asgn_range.app_uuid128,
+ &p_list->asgn_range.svc_uuid,
p_list->asgn_range.svc_inst)) != NULL)
{
gatt_proc_srv_chg();
@@ -536,10 +549,10 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
**
** Function GATTS_StopService
**
-** Description This function is called to stop a service
+** Description This function is called to stop a service
+**
+** Parameter service_handle : this is the start handle of a service
**
-** Parameter service_handle : this is the start handle of a service
-**
** Returns None.
**
*******************************************************************************/
@@ -569,7 +582,7 @@ void GATTS_StopService (UINT16 service_handle)
**
** Function GATTs_HandleValueIndication
**
-** Description This function sends a handle value indication to a client.
+** Description This function sends a handle value indication to a client.
**
** Parameter conn_id: connection identifier.
** attr_handle: Attribute handle of this handle value indication.
@@ -592,7 +605,7 @@ tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, U
tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(tcb_idx);
- GATT_TRACE_API0 ("GATTS_HandleValueIndication");
+ GATT_TRACE_API0 ("GATTS_HandleValueIndication");
if ( (p_reg == NULL) || (p_tcb == NULL))
{
GATT_TRACE_ERROR1 ("GATTS_HandleValueIndication Unknown conn_id: %u ", conn_id);
@@ -608,10 +621,10 @@ tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, U
{
if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle))
{
- GATT_TRACE_DEBUG0 ("Add a pending indication");
+ GATT_TRACE_DEBUG0 ("Add a pending indication");
if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) !=NULL)
{
- cmd_status = GATT_SUCCESS;
+ cmd_status = GATT_SUCCESS;
}
else
{
@@ -640,7 +653,7 @@ tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, U
**
** Function GATTS_HandleValueNotification
**
-** Description This function sends a handle value notification to a client.
+** Description This function sends a handle value notification to a client.
**
** Parameter conn_id: connection identifier.
** attr_handle: Attribute handle of this handle value indication.
@@ -696,7 +709,7 @@ tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
**
*******************************************************************************/
-tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
+tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
tGATT_STATUS status, tGATTS_RSP *p_msg)
{
tGATT_STATUS cmd_sent = GATT_ILLEGAL_PARAMETER;
@@ -705,7 +718,7 @@ tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(tcb_idx);
- GATT_TRACE_API3 ("GATTS_SendRsp: conn_id: %u trans_id: %u Status: 0x%04x",
+ GATT_TRACE_API3 ("GATTS_SendRsp: conn_id: %u trans_id: %u Status: 0x%04x",
conn_id, trans_id, status);
if ( (p_reg == NULL) || (p_tcb == NULL))
@@ -722,7 +735,7 @@ tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
return(GATT_WRONG_STATE);
}
/* Process App response */
- cmd_sent = gatt_sr_process_app_rsp (p_tcb, gatt_if, trans_id, p_tcb->sr_cmd.op_code, status, p_msg);
+ cmd_sent = gatt_sr_process_app_rsp (p_tcb, gatt_if, trans_id, p_tcb->sr_cmd.op_code, status, p_msg);
return cmd_sent;
}
@@ -740,14 +753,14 @@ tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
/*******************************************************************************
**
-** Function GATTC_ConfigureMTU
+** Function GATTC_ConfigureMTU
**
** Description This function is called to configure the ATT MTU size.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** mtu - attribute MTU size..
**
-** Returns GATT_SUCCESS if command started successfully.
+** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
@@ -781,7 +794,7 @@ tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
p_clcb->p_tcb->payload_size = mtu;
p_clcb->operation = GATTC_OPTYPE_CONFIG;
- ret = attp_send_cl_msg (p_clcb->p_tcb, p_clcb->clcb_idx, GATT_REQ_MTU, (tGATT_CL_MSG *)&mtu);
+ ret = attp_send_cl_msg (p_clcb->p_tcb, p_clcb->clcb_idx, GATT_REQ_MTU, (tGATT_CL_MSG *)&mtu);
}
return ret;
@@ -789,18 +802,18 @@ tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
/*******************************************************************************
**
-** Function GATTC_Discover
+** Function GATTC_Discover
**
** Description This function is called to do a discovery procedure on ATT server.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** disc_type:discovery type.
** p_param: parameters of discovery requirement.
**
-** Returns GATT_SUCCESS if command received/sent successfully.
+** Returns GATT_SUCCESS if command received/sent successfully.
**
*******************************************************************************/
-tGATT_STATUS GATTC_Discover (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
+tGATT_STATUS GATTC_Discover (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
tGATT_DISC_PARAM *p_param)
{
tGATT_STATUS status = GATT_SUCCESS;
@@ -830,10 +843,10 @@ tGATT_STATUS GATTC_Discover (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
if ((p_clcb = gatt_clcb_alloc(conn_id)) != NULL )
{
- if (!GATT_HANDLE_IS_VALID(p_param->s_handle) ||
+ if (!GATT_HANDLE_IS_VALID(p_param->s_handle) ||
!GATT_HANDLE_IS_VALID(p_param->e_handle) ||
/* search by type does not have a valid UUID param */
- (disc_type == GATT_DISC_SRVC_BY_UUID &&
+ (disc_type == GATT_DISC_SRVC_BY_UUID &&
p_param->service.len == 0))
{
return GATT_ILLEGAL_PARAMETER;
@@ -856,16 +869,16 @@ tGATT_STATUS GATTC_Discover (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
/*******************************************************************************
**
-** Function GATTC_Read
+** Function GATTC_Read
**
** Description This function is called to read the value of an attribute from
** the server.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** type - attribute read type.
** p_read - read operation parameters.
**
-** Returns GATT_SUCCESS if command started successfully.
+** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM *p_read)
@@ -910,7 +923,7 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM
break;
case GATT_READ_MULTIPLE:
p_clcb->s_handle = 0;
- /* copy multiple handles in CB */
+ /* copy multiple handles in CB */
p_read_multi = (tGATT_READ_MULTI *)GKI_getbuf(sizeof(tGATT_READ_MULTI));
p_clcb->p_attr_buf = (UINT8*)p_read_multi;
memcpy (p_read_multi, &p_read->read_multiple, sizeof(tGATT_READ_MULTI));
@@ -944,16 +957,16 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM
/*******************************************************************************
**
-** Function GATTC_Write
+** Function GATTC_Write
**
** Description This function is called to write the value of an attribute to
** the server.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** type - attribute write type.
** p_write - write operation parameters.
**
-** Returns GATT_SUCCESS if command started successfully.
+** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_write)
@@ -1019,15 +1032,15 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_
/*******************************************************************************
**
-** Function GATTC_ExecuteWrite
+** Function GATTC_ExecuteWrite
**
** Description This function is called to send an Execute write request to
** the server.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** is_execute - to execute or cancel the prepare write requet(s)
**
-** Returns GATT_SUCCESS if command started successfully.
+** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
@@ -1058,7 +1071,7 @@ tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
{
p_clcb->operation = GATTC_OPTYPE_EXE_WRITE;
flag = is_execute ? GATT_PREP_WRITE_EXEC : GATT_PREP_WRITE_CANCEL;
- gatt_send_queue_write_cancel (p_clcb->p_tcb, p_clcb, flag);
+ gatt_send_queue_write_cancel (p_clcb->p_tcb, p_clcb, flag);
}
else
{
@@ -1070,21 +1083,21 @@ tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
/*******************************************************************************
**
-** Function GATTC_SendHandleValueConfirm
+** Function GATTC_SendHandleValueConfirm
**
** Description This function is called to send a handle value confirmation
** as response to a handle value notification from server.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
** handle: the handle of the attribute confirmation.
**
-** Returns GATT_SUCCESS if command started successfully.
+** Returns GATT_SUCCESS if command started successfully.
**
*******************************************************************************/
tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle)
{
tGATT_STATUS ret = GATT_ILLEGAL_PARAMETER;
- tGATT_TCB *p_tcb=gatt_get_tcb_by_idx(GATT_GET_TCB_IDX(conn_id));
+ tGATT_TCB *p_tcb=gatt_get_tcb_by_idx(GATT_GET_TCB_IDX(conn_id));
GATT_TRACE_API2 ("GATTC_SendHandleValueConfirm conn_id=%d handle=0x%x", conn_id, handle);
@@ -1124,7 +1137,7 @@ tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle)
**
** Function GATT_SetIdleTimeout
**
-** Description This function (common to both client and server) sets the idle
+** Description This function (common to both client and server) sets the idle
** timeout for a tansport connection
**
** Parameter bd_addr: target device bd address.
@@ -1150,7 +1163,7 @@ void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout)
}
}
- GATT_TRACE_API2 ("GATT_SetIdleTimeout idle_tout=%d status=%d(1-OK 0-not performed)",
+ GATT_TRACE_API2 ("GATT_SetIdleTimeout idle_tout=%d status=%d(1-OK 0-not performed)",
idle_tout, status);
}
@@ -1159,7 +1172,7 @@ void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout)
**
** Function GATT_Register
**
-** Description This function is called to register an application
+** Description This function is called to register an application
** with GATT
**
** Parameter p_app_uuid128: Application UUID
@@ -1210,11 +1223,11 @@ tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info)
**
** Function GATT_Deregister
**
-** Description This function deregistered the application from GATT.
+** Description This function deregistered the application from GATT.
**
** Parameters gatt_if: applicaiton interface.
**
-** Returns None.
+** Returns None.
**
*******************************************************************************/
void GATT_Deregister (tGATT_IF gatt_if)
@@ -1267,7 +1280,7 @@ void GATT_Deregister (tGATT_IF gatt_if)
for (j = 0, p_clcb= &gatt_cb.clcb[j]; j < GATT_CL_MAX_LCB; j++, p_clcb++)
{
- if (p_clcb->in_use &&
+ if (p_clcb->in_use &&
(p_clcb->p_reg->gatt_if == gatt_if) &&
(p_clcb->p_tcb->tcb_idx == p_tcb->tcb_idx))
{
@@ -1315,8 +1328,8 @@ void GATT_StartIf (tGATT_IF gatt_if)
p_tcb = gatt_find_tcb_by_addr(bda);
if (p_reg->app_cb.p_conn_cb)
{
- conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
- (*p_reg->app_cb.p_conn_cb)(gatt_if, bda, conn_id, TRUE, 0);
+ conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
+ (*p_reg->app_cb.p_conn_cb)(gatt_if, bda, conn_id, TRUE, 0);
}
start_idx = ++found_idx;
}
@@ -1330,7 +1343,7 @@ void GATT_StartIf (tGATT_IF gatt_if)
**
** Description This function initiate a connecttion to a ATT server.
**
-** Parameters gatt_if: applicaiton interface
+** Parameters gatt_if: applicaiton interface
** bd_addr: peer device address.
** is_direct: is a direct conenection or a background auto connection
**
@@ -1366,7 +1379,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct){
** Description This function initiate a connecttion to a ATT server.
**
** Parameters gatt_if: client interface. If 0 used as unconditionally disconnect,
-** typically used for direct connection cancellation.
+** typically used for direct connection cancellation.
** bd_addr: peer device address.
**
** Returns TRUE if connection started; FALSE if connection start failure.
@@ -1398,7 +1411,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct
{
while (status && gatt_find_app_hold_link(p_tcb, start_idx, &found_idx, &temp_gatt_if))
{
- status = gatt_cancel_open(temp_gatt_if, bd_addr);
+ status = gatt_cancel_open(temp_gatt_if, bd_addr);
start_idx = ++found_idx;
}
}
@@ -1443,7 +1456,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct
**
** Description This function disconnect a logic channel.
**
-** Parameters conn_id: connection identifier.
+** Parameters conn_id: connection identifier.
**
** Returns GATT_SUCCESS if disconnected.
**
@@ -1480,7 +1493,7 @@ tGATT_STATUS GATT_Disconnect (UINT16 conn_id)
** interface
**
** Parameters conn_id: connection id (input)
-** p_gatt_if: applicaiton interface (output)
+** p_gatt_if: applicaiton interface (output)
** bd_addr: peer device address. (output)
**
** Returns TRUE the ligical link information is found for conn_id
@@ -1499,8 +1512,8 @@ BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, BD_ADDR bd_
if (p_tcb && p_reg )
{
- memcpy(bd_addr, p_tcb->peer_bda, BD_ADDR_LEN);
- *p_gatt_if = gatt_if;
+ memcpy(bd_addr, p_tcb->peer_bda, BD_ADDR_LEN);
+ *p_gatt_if = gatt_if;
status = TRUE;
}
return status;
@@ -1514,11 +1527,11 @@ BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, BD_ADDR bd_
** Description This function find the conn_id if the logical link for BD address
** and applciation interface is connected
**
-** Parameters gatt_if: applicaiton interface (input)
+** Parameters gatt_if: applicaiton interface (input)
** bd_addr: peer device address. (input)
** p_conn_id: connection id (output)
**
-** Returns TRUE the ligical link is connected
+** Returns TRUE the ligical link is connected
**
*******************************************************************************/
BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_conn_id)
diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c
index d8b417f..b7ec2fc 100644
--- a/stack/gatt/gatt_attr.c
+++ b/stack/gatt/gatt_attr.c
@@ -1,13 +1,27 @@
-/*****************************************************************************
-**
-** Name: gatt_attr.c
-**
-** Description: this file contains the main GATT server attributes access
-** request handling functions.
-**
-** Copyright (c) 2008-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2008-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 main GATT server attributes access request
+ * handling functions.
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -28,7 +42,7 @@
static void gatt_profile_request_cback (UINT16 conn_id, UINT32 trans_id, UINT8 op_code, tGATTS_DATA *p_data);
static void gatt_profile_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected, tGATT_DISCONN_REASON reason);
-static tGATT_CBACK gatt_profile_cback =
+static tGATT_CBACK gatt_profile_cback =
{
gatt_profile_connect_cback,
NULL,
@@ -144,14 +158,14 @@ BOOLEAN gatt_profile_clcb_dealloc (UINT16 conn_id)
**
** Function gatt_profile_request_cback
**
-** Description GATT profile attribute access request callback.
+** Description GATT profile attribute access request callback.
**
** Returns void.
**
*******************************************************************************/
-static void gatt_profile_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
+static void gatt_profile_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
tGATTS_DATA *p_data)
-{
+{
UINT8 status = GATT_INVALID_PDU;
tGATTS_RSP rsp_msg ;
BOOLEAN ignore = FALSE;
@@ -165,7 +179,7 @@ static void gatt_profile_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_
break;
case GATTS_REQ_TYPE_WRITE:
- status = GATT_WRITE_NOT_PERMIT;
+ status = GATT_WRITE_NOT_PERMIT;
break;
case GATTS_REQ_TYPE_WRITE_EXEC:
@@ -198,11 +212,11 @@ static void gatt_profile_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_
** Returns void
**
*******************************************************************************/
-static void gatt_profile_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
+static void gatt_profile_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
BOOLEAN connected, tGATT_DISCONN_REASON reason)
{
- GATT_TRACE_EVENT5 ("gatt_profile_connect_cback: from %08x%04x connected:%d conn_id=%d reason = 0x%04x",
- (bda[0]<<24)+(bda[1]<<16)+(bda[2]<<8)+bda[3],
+ GATT_TRACE_EVENT5 ("gatt_profile_connect_cback: from %08x%04x connected:%d conn_id=%d reason = 0x%04x",
+ (bda[0]<<24)+(bda[1]<<16)+(bda[2]<<8)+bda[3],
(bda[4]<<8)+bda[5], connected, conn_id, reason);
if (connected)
@@ -243,21 +257,21 @@ void gatt_profile_db_init (void)
GATT_StartIf(gatt_cb.gatt_if);
service_handle = GATTS_CreateService (gatt_cb.gatt_if , &uuid, 0, GATTP_MAX_ATTR_NUM, TRUE);
- /* add Service Changed characteristic
+ /* add Service Changed characteristic
*/
- uuid.uu.uuid16 = gatt_cb.gattp_attr.uuid = GATT_UUID_GATT_SRV_CHGD;
+ uuid.uu.uuid16 = gatt_cb.gattp_attr.uuid = GATT_UUID_GATT_SRV_CHGD;
gatt_cb.gattp_attr.service_change = 0;
- gatt_cb.gattp_attr.handle =
+ gatt_cb.gattp_attr.handle =
gatt_cb.handle_of_h_r = GATTS_AddCharacteristic(service_handle, &uuid, 0, GATT_CHAR_PROP_BIT_INDICATE);
- GATT_TRACE_DEBUG1 ("gatt_profile_db_init: handle of service changed%d",
+ GATT_TRACE_DEBUG1 ("gatt_profile_db_init: handle of service changed%d",
gatt_cb.handle_of_h_r );
- /* start service
+ /* start service
*/
status = GATTS_StartService (gatt_cb.gatt_if, service_handle, GATT_TRANSPORT_LE_BR_EDR);
- GATT_TRACE_DEBUG2 ("gatt_profile_db_init: gatt_if=%d start status%d",
+ GATT_TRACE_DEBUG2 ("gatt_profile_db_init: gatt_if=%d start status%d",
gatt_cb.gatt_if, status);
}
diff --git a/stack/gatt/gatt_auth.c b/stack/gatt/gatt_auth.c
index b7fa13f..de0c14f 100644
--- a/stack/gatt/gatt_auth.c
+++ b/stack/gatt/gatt_auth.c
@@ -1,13 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatt_auth.c
-**
-** Description: this file contains GATT authentication handling functions
-**
-**
-** Copyright (c) 1999-2011, Broadcom Corp, All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 1999-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 GATT authentication handling functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
#if BLE_INCLUDED == TRUE
@@ -49,13 +62,13 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
p_attr->len = payload_size - GATT_AUTH_SIGN_LEN - 3;
p_signature = p_attr->value + p_attr->len;
- if (BTM_BleDataSignature(p_clcb->p_tcb->peer_bda,
- p_data,
+ if (BTM_BleDataSignature(p_clcb->p_tcb->peer_bda,
+ p_data,
(UINT16)(p_attr->len + 3), /* 3 = 2 byte handle + opcode */
p_signature))
{
- p_attr->len += BTM_BLE_AUTH_SIGN_LEN;
- gatt_set_ch_state(p_clcb->p_tcb, GATT_CH_OPEN);
+ p_attr->len += BTM_BLE_AUTH_SIGN_LEN;
+ gatt_set_ch_state(p_clcb->p_tcb, GATT_CH_OPEN);
gatt_act_write(p_clcb);
}
else
@@ -73,17 +86,17 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
**
** Function gatt_verify_signature
**
-** Description This function start to verify the sign data when receiving
+** Description This function start to verify the sign data when receiving
** the data from peer device.
**
-** Returns
+** Returns
**
*******************************************************************************/
void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
{
UINT16 cmd_len;
UINT8 op_code;
- UINT8 *p, *p_orig = (UINT8 *)(p_buf + 1) + p_buf->offset;
+ UINT8 *p, *p_orig = (UINT8 *)(p_buf + 1) + p_buf->offset;
UINT32 counter;
cmd_len = p_buf->len - GATT_AUTH_SIGN_LEN + 4;
@@ -137,7 +150,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb)
**
** Description link encryption complete callback.
**
-** Returns
+** Returns
**
*******************************************************************************/
void gatt_enc_cmpl_cback(BD_ADDR bd_addr, void *p_ref_data, tBTM_STATUS result)
@@ -149,7 +162,7 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, void *p_ref_data, tBTM_STATUS result)
GATT_TRACE_DEBUG0("gatt_enc_cmpl_cback");
if ((p_tcb = gatt_find_tcb_by_addr(bd_addr)) != NULL)
{
- gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
+ gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
if (result == BTM_SUCCESS)
{
@@ -271,8 +284,8 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
/* now check link needs to be encrypted or not if the link key upgrade is not required */
if (act == GATT_SEC_OK)
{
- if (is_le_link &&
- (p_clcb->operation == GATTC_OPTYPE_WRITE) &&
+ if (is_le_link &&
+ (p_clcb->operation == GATTC_OPTYPE_WRITE) &&
(p_clcb->op_subtype == GATT_WRITE_NO_RSP))
{
/* this is a write command request
@@ -282,7 +295,7 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
btm_ble_get_enc_key_type(p_tcb->peer_bda, &key_type);
if ( (key_type & BTM_LE_KEY_LCSRK) &&
- ((auth_req == GATT_AUTH_REQ_SIGNED_NO_MITM) ||
+ ((auth_req == GATT_AUTH_REQ_SIGNED_NO_MITM) ||
(auth_req == GATT_AUTH_REQ_SIGNED_MITM)))
{
act = GATT_SEC_SIGN_DATA;
@@ -314,7 +327,7 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
** Function gatt_get_link_encrypt_status
**
** Description This routine get the encryption status of the specified link
-**
+**
**
** Returns tGATT_STATUS link encryption status
**
@@ -322,7 +335,7 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb)
{
tGATT_STATUS encrypt_status = GATT_NOT_ENCRYPTED;
- UINT8 sec_flag=0;
+ UINT8 sec_flag=0;
BTM_GetSecurityFlags(p_tcb->peer_bda, &sec_flag);
@@ -400,8 +413,8 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
case GATT_SEC_ENCRYPT_NO_MITM:
case GATT_SEC_ENCRYPT_MITM:
GATT_TRACE_DEBUG0("gatt_security_check_start: Encrypt now or key upgreade first");
- gatt_convert_sec_action(p_tcb->sec_act, &btm_ble_sec_act);
- gatt_set_ch_state(p_tcb, GATT_CH_W4_SEC_COMP);
+ gatt_convert_sec_action(p_tcb->sec_act, &btm_ble_sec_act);
+ gatt_set_ch_state(p_tcb, GATT_CH_W4_SEC_COMP);
p_tcb->p_clcb = p_clcb; /* keep the clcb pointer in CCB */
btm_status = BTM_SetEncryption(p_tcb->peer_bda, gatt_enc_cmpl_cback, &btm_ble_sec_act);
if ( (btm_status != BTM_SUCCESS) && (btm_status != BTM_CMD_STARTED))
@@ -419,7 +432,7 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
if (status == FALSE)
{
gatt_set_sec_act(p_tcb, GATT_SEC_NONE);
- gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
+ gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
}
}
else
diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.c
index 9853694..91fb985 100644
--- a/stack/gatt/gatt_cl.c
+++ b/stack/gatt/gatt_cl.c
@@ -1,12 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatt_cl.c
-**
-** Description: this file contains the main GATT client functions
-**
-** Copyright (c) 1999-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 1999-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 main GATT client functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -25,17 +39,17 @@
*********************************************************************************/
void gatt_send_prepare_write(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb);
-UINT8 disc_type_to_att_opcode[GATT_DISC_MAX] =
+UINT8 disc_type_to_att_opcode[GATT_DISC_MAX] =
{
0,
- GATT_REQ_READ_BY_GRP_TYPE, /* GATT_DISC_SRVC_ALL = 1, */
- GATT_REQ_FIND_TYPE_VALUE, /* GATT_DISC_SRVC_BY_UUID, */
- GATT_REQ_READ_BY_TYPE, /* GATT_DISC_INC_SRVC, */
- GATT_REQ_READ_BY_TYPE, /* GATT_DISC_CHAR, */
- GATT_REQ_FIND_INFO /* GATT_DISC_CHAR_DSCPT, */
+ GATT_REQ_READ_BY_GRP_TYPE, /* GATT_DISC_SRVC_ALL = 1, */
+ GATT_REQ_FIND_TYPE_VALUE, /* GATT_DISC_SRVC_BY_UUID, */
+ GATT_REQ_READ_BY_TYPE, /* GATT_DISC_INC_SRVC, */
+ GATT_REQ_READ_BY_TYPE, /* GATT_DISC_CHAR, */
+ GATT_REQ_FIND_INFO /* GATT_DISC_CHAR_DSCPT, */
};
-UINT16 disc_type_to_uuid[GATT_DISC_MAX] =
+UINT16 disc_type_to_uuid[GATT_DISC_MAX] =
{
0, /* reserved */
GATT_UUID_PRI_SERVICE, /* <service> DISC_SRVC_ALL */
@@ -50,7 +64,7 @@ UINT16 disc_type_to_uuid[GATT_DISC_MAX] =
**
** Function gatt_act_discovery
**
-** Description GATT discovery operation.
+** Description GATT discovery operation.
**
** Returns void.
**
@@ -96,7 +110,7 @@ void gatt_act_discovery(tGATT_CLCB *p_clcb)
**
** Function gatt_act_read
**
-** Description GATT read operation.
+** Description GATT read operation.
**
** Returns void.
**
@@ -165,7 +179,7 @@ void gatt_act_read (tGATT_CLCB *p_clcb, UINT16 offset)
msg.handle = p_clcb->s_handle;
p_clcb->op_subtype &= ~ 0x90;
break;
-
+
default:
GATT_TRACE_ERROR1("Unknown read type: %d", p_clcb->op_subtype);
break;
@@ -174,7 +188,7 @@ void gatt_act_read (tGATT_CLCB *p_clcb, UINT16 offset)
if ( op_code == 0 ||
(rt = attp_send_cl_msg(p_tcb, p_clcb->clcb_idx, op_code, &msg)) != GATT_SUCCESS)
{
- gatt_end_operation(p_clcb, rt, NULL);
+ gatt_end_operation(p_clcb, rt, NULL);
}
}
@@ -182,7 +196,7 @@ void gatt_act_read (tGATT_CLCB *p_clcb, UINT16 offset)
**
** Function gatt_act_write
**
-** Description GATT write operation.
+** Description GATT write operation.
**
** Returns void.
**
@@ -198,14 +212,14 @@ void gatt_act_write (tGATT_CLCB *p_clcb)
switch (p_clcb->op_subtype)
{
case GATT_WRITE_NO_RSP:
- p_clcb->s_handle = p_attr->handle;
+ p_clcb->s_handle = p_attr->handle;
op_code = (p_tcb->sec_act & GATT_SEC_SIGN_DATA) ? GATT_SIGN_CMD_WRITE : GATT_CMD_WRITE;
- rt = gatt_send_write_msg(p_tcb,
- p_clcb->clcb_idx,
- op_code,
- p_attr->handle,
- p_attr->len,
- 0,
+ rt = gatt_send_write_msg(p_tcb,
+ p_clcb->clcb_idx,
+ op_code,
+ p_attr->handle,
+ p_attr->len,
+ 0,
p_attr->value);
break;
@@ -214,12 +228,12 @@ void gatt_act_write (tGATT_CLCB *p_clcb)
{
p_clcb->s_handle = p_attr->handle;
- rt = gatt_send_write_msg(p_tcb,
- p_clcb->clcb_idx,
- GATT_REQ_WRITE,
- p_attr->handle,
- p_attr->len,
- 0,
+ rt = gatt_send_write_msg(p_tcb,
+ p_clcb->clcb_idx,
+ GATT_REQ_WRITE,
+ p_attr->handle,
+ p_attr->len,
+ 0,
p_attr->value);
}
else /* prepare write for long attribute */
@@ -228,8 +242,8 @@ void gatt_act_write (tGATT_CLCB *p_clcb)
}
break;
- case GATT_WRITE_PREPARE:
- gatt_send_prepare_write(p_tcb, p_clcb);
+ case GATT_WRITE_PREPARE:
+ gatt_send_prepare_write(p_tcb, p_clcb);
break;
default:
@@ -241,12 +255,12 @@ void gatt_act_write (tGATT_CLCB *p_clcb)
else
rt = GATT_INTERNAL_ERROR;
- if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED)
+ if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED)
|| (rt != GATT_CMD_STARTED && p_clcb->op_subtype == GATT_WRITE_NO_RSP))
{
if (rt != GATT_SUCCESS)
{
- GATT_TRACE_ERROR1("gatt_act_write() failed op_code=0x%x", op_code);
+ GATT_TRACE_ERROR1("gatt_act_write() failed op_code=0x%x", op_code);
}
gatt_end_operation(p_clcb, rt, NULL);
}
@@ -311,7 +325,7 @@ BOOLEAN gatt_check_write_long_terminate(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, t
}
if (exec)
{
- gatt_send_queue_write_cancel (p_tcb, p_clcb, flag);
+ gatt_send_queue_write_cancel (p_tcb, p_clcb, flag);
return TRUE;
}
return FALSE;
@@ -326,7 +340,7 @@ BOOLEAN gatt_check_write_long_terminate(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, t
**
*******************************************************************************/
void gatt_send_prepare_write(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb)
-{
+{
tGATT_VALUE *p_attr = (tGATT_VALUE *)p_clcb->p_attr_buf;
UINT16 to_send, offset;
UINT8 rt = GATT_SUCCESS;
@@ -343,15 +357,15 @@ void gatt_send_prepare_write(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb)
offset = p_attr->offset;
if (type == GATT_WRITE_PREPARE)
{
- offset += p_clcb->start_offset;
+ offset += p_clcb->start_offset;
}
GATT_TRACE_DEBUG2("offset =0x%x len=%d", offset, to_send );
- rt = gatt_send_write_msg(p_tcb,
- p_clcb->clcb_idx,
- GATT_REQ_PREPARE_WRITE,
- p_attr->handle,
+ rt = gatt_send_write_msg(p_tcb,
+ p_clcb->clcb_idx,
+ GATT_REQ_PREPARE_WRITE,
+ p_attr->handle,
to_send, /* length */
offset, /* used as offset */
p_attr->value + p_attr->offset); /* data */
@@ -377,43 +391,43 @@ void gatt_send_prepare_write(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb)
*******************************************************************************/
void gatt_proc_disc_read_by_type_rsp(tGATT_CLCB *p_clcb, UINT16 len, UINT8 *p_data)
{
- /*
+ /*
tGATT_TCB *p_tcb = p_clcb->p_tcb;
tGATT_DISCOVERY_DB *p_db = p_clcb->p_disc_db;
tGATT_DISC_REC *p_rec;
tGATT_STATUS status = GATT_INTERNAL_ERROR;
-
-
+
+
if ((p_rec = gatt_add_record(p_clcb->p_disc_db)) != NULL)
{
p_rec->handle = handle;
p_rec->type = p_db->uuid_filter;
p_rec->attr_len = len;
-
- // copy the attibute value into DB
+
+ // copy the attibute value into DB
p_rec->p_value = p_db->p_free_mem;
memcpy(p_rec->p_value, p_value, len);
p_db->p_free_mem += len;
p_db->mem_free -= len;
-
+
if (handle < p_clcb->e_handle)
{
// send another request
- if (gatt_act_send_browse(p_tcb, p_clcb->conn_id,
- GATT_REQ_READ_BY_TYPE,
- (UINT16)(handle + 1), // starting handle
- p_clcb->e_handle, // end handle
+ if (gatt_act_send_browse(p_tcb, p_clcb->conn_id,
+ GATT_REQ_READ_BY_TYPE,
+ (UINT16)(handle + 1), // starting handle
+ p_clcb->e_handle, // end handle
p_clcb->p_disc_db->uuid_filter) // uuid filter /
- == GATT_SUCCESS)
+ == GATT_SUCCESS)
{
- status = GATT_SUCCESS;
+ status = GATT_SUCCESS;
}
}
}
else
status = GATT_DB_FULL;
-
- if (status != GATT_SUCCESS) // DB full
+
+ if (status != GATT_SUCCESS) // DB full
{
gatt_end_operation(p_clcb, status, NULL);
}*/
@@ -465,14 +479,14 @@ void gatt_process_find_type_value_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UIN
**
** Function gatt_process_read_info_rsp
**
-** Description This function is called to handle the read information
+** Description This function is called to handle the read information
** response.
**
**
** Returns void
**
*******************************************************************************/
-void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
+void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
tGATT_DISC_RES result;
@@ -482,7 +496,7 @@ void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_c
if (p_clcb->operation != GATTC_OPTYPE_DISCOVERY || p_clcb->op_subtype != GATT_DISC_CHAR_DSCPT)
return;
- STREAM_TO_UINT8(type, p);
+ STREAM_TO_UINT8(type, p);
len -= 1;
if (type == GATT_INFO_TYPE_PAIR_16)
@@ -522,7 +536,7 @@ void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_c
** Returns void.
**
*******************************************************************************/
-void gatt_proc_disc_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 opcode,
+void gatt_proc_disc_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 opcode,
UINT16 handle, UINT8 reason)
{
tGATT_STATUS status = (tGATT_STATUS) reason;
@@ -553,13 +567,13 @@ void gatt_proc_disc_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 opcode
**
** Function gatt_process_error_rsp
**
-** Description This function is called to handle the error response
+** Description This function is called to handle the error response
**
**
** Returns void
**
*******************************************************************************/
-void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
+void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
UINT8 opcode, reason, * p= p_data;
@@ -567,9 +581,9 @@ void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
tGATT_VALUE *p_attr = (tGATT_VALUE *)p_clcb->p_attr_buf;
GATT_TRACE_DEBUG0("gatt_process_error_rsp ");
- STREAM_TO_UINT8(opcode, p);
- STREAM_TO_UINT16(handle, p);
- STREAM_TO_UINT8(reason, p);
+ STREAM_TO_UINT8(opcode, p);
+ STREAM_TO_UINT16(handle, p);
+ STREAM_TO_UINT8(reason, p);
if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY)
{
@@ -603,13 +617,13 @@ void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
**
** Function gatt_process_prep_write_rsp
**
-** Description This function is called to handle the read response
+** Description This function is called to handle the read response
**
**
** Returns void
**
*******************************************************************************/
-void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
+void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
tGATT_VALUE value = {0};
@@ -617,7 +631,7 @@ void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op
GATT_TRACE_ERROR2("value resp op_code = %s len = %d", gatt_dbg_op_name(op_code), len);
- STREAM_TO_UINT16 (value.handle, p);
+ STREAM_TO_UINT16 (value.handle, p);
STREAM_TO_UINT16 (value.offset, p);
value.len = len - 4;
@@ -650,14 +664,14 @@ void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op
** Returns void
**
*******************************************************************************/
-void gatt_process_notification(tGATT_TCB *p_tcb, UINT8 op_code,
+void gatt_process_notification(tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
tGATT_VALUE value = {0};
tGATT_REG *p_reg;
UINT16 conn_id;
tGATT_STATUS encrypt_status;
- UINT8 *p= p_data, i,
+ UINT8 *p= p_data, i,
event = (op_code == GATT_HANDLE_VALUE_NOTIF) ? GATTC_OPTYPE_NOTIFICATION : GATTC_OPTYPE_INDICATION;
GATT_TRACE_DEBUG0("gatt_process_notification ");
@@ -715,7 +729,7 @@ void gatt_process_notification(tGATT_TCB *p_tcb, UINT8 op_code,
encrypt_status = gatt_get_link_encrypt_status(p_tcb);
(*p_reg->app_cb.p_cmpl_cb) (conn_id, event, encrypt_status, (tGATT_CL_COMPLETE *)&value);
}
- }
+ }
}
@@ -748,7 +762,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
{
/* this is an error case that server's response containing a value length which is larger than MTU-2
or value_len > message total length -1 */
- GATT_TRACE_ERROR4("gatt_process_read_by_type_rsp: Discard response op_code=%d vale_len=%d > (MTU-2=%d or msg_len-1=%d)",
+ GATT_TRACE_ERROR4("gatt_process_read_by_type_rsp: Discard response op_code=%d vale_len=%d > (MTU-2=%d or msg_len-1=%d)",
op_code, value_len, (p_tcb->payload_size - 2), (len-1));
gatt_end_operation(p_clcb, GATT_ERROR, NULL);
return;
@@ -773,13 +787,13 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
memset(&result, 0, sizeof(tGATT_DISC_RES));
memset(&record_value, 0, sizeof(tGATT_DISC_VALUE));
- result.handle = handle;
+ result.handle = handle;
result.type.len = 2;
result.type.uu.uuid16 = disc_type_to_uuid[p_clcb->op_subtype];
/* discover all services */
if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY &&
- p_clcb->op_subtype == GATT_DISC_SRVC_ALL &&
+ p_clcb->op_subtype == GATT_DISC_SRVC_ALL &&
op_code == GATT_RSP_READ_BY_GRP_TYPE)
{
STREAM_TO_UINT16(handle, p);
@@ -804,7 +818,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
{
STREAM_TO_UINT16(record_value.incl_service.s_handle, p);
STREAM_TO_UINT16(record_value.incl_service.e_handle, p);
-
+
if (!GATT_HANDLE_IS_VALID(record_value.incl_service.s_handle) ||
!GATT_HANDLE_IS_VALID(record_value.incl_service.e_handle))
{
@@ -822,7 +836,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
p_clcb->s_handle = record_value.incl_service.s_handle;
p_clcb->read_uuid128.wait_for_read_rsp = TRUE;
p_clcb->read_uuid128.next_disc_start_hdl = handle + 1;
- memcpy(&p_clcb->read_uuid128.result, &result, sizeof(result));
+ memcpy(&p_clcb->read_uuid128.result, &result, sizeof(result));
memcpy(&p_clcb->read_uuid128.result.value, &record_value, sizeof (result.value));
p_clcb->op_subtype |= 0x90;
gatt_act_read(p_clcb, 0);
@@ -846,15 +860,15 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
if (!p_clcb->p_attr_buf)
p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf(GATT_MAX_ATTR_LEN);
if (p_clcb->p_attr_buf && p_clcb->counter <= GATT_MAX_ATTR_LEN)
- {
+ {
memcpy(p_clcb->p_attr_buf, p, p_clcb->counter);
- gatt_act_read(p_clcb, p_clcb->counter);
+ gatt_act_read(p_clcb, p_clcb->counter);
}
else
gatt_end_operation(p_clcb, GATT_INTERNAL_ERROR, (void *)p);
}
else
- {
+ {
gatt_end_operation(p_clcb, GATT_SUCCESS, (void *)p);
}
return;
@@ -870,7 +884,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
}
gatt_parse_uuid_from_cmd(&record_value.dclr_value.char_uuid, (UINT16)(value_len - 3), &p);
- /* UUID not matching */
+ /* UUID not matching */
if (!gatt_uuid_compare(record_value.dclr_value.char_uuid, p_clcb->uuid))
{
len -= (value_len + 2);
@@ -879,7 +893,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
else if (p_clcb->operation == GATTC_OPTYPE_READ)
/* UUID match for read characteristic value */
{
- /* only read the first matching UUID characteristic value, and
+ /* only read the first matching UUID characteristic value, and
discard the rest results */
p_clcb->s_handle = record_value.dclr_value.val_handle;
p_clcb->op_subtype |= 0x80;
@@ -914,13 +928,13 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
**
** Function gatt_process_read_rsp
**
-** Description This function is called to handle the read BLOB response
+** Description This function is called to handle the read BLOB response
**
**
** Returns void
**
*******************************************************************************/
-void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
+void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
UINT16 offset = p_clcb->counter;
@@ -948,7 +962,7 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
p_clcb->counter += len;
- memcpy(p_clcb->p_attr_buf + offset, p, len);
+ memcpy(p_clcb->p_attr_buf + offset, p, len);
/* send next request if needed */
@@ -957,7 +971,7 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
{
GATT_TRACE_DEBUG3("full pkt issue read blob for remianing bytes old offset=%d len=%d new offset=%d",
offset, len, p_clcb->counter);
- gatt_act_read(p_clcb, p_clcb->counter);
+ gatt_act_read(p_clcb, p_clcb->counter);
}
else /* end of request, send callback */
{
@@ -981,12 +995,12 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
p_clcb->read_uuid128.wait_for_read_rsp = FALSE;
if (len == LEN_UUID_128)
{
-
- memcpy(p_clcb->read_uuid128.result.value.incl_service.service_type.uu.uuid128, p, len);
+
+ memcpy(p_clcb->read_uuid128.result.value.incl_service.service_type.uu.uuid128, p, len);
p_clcb->read_uuid128.result.value.incl_service.service_type.len = LEN_UUID_128;
if ( p_clcb->p_reg->app_cb.p_disc_res_cb)
(*p_clcb->p_reg->app_cb.p_disc_res_cb)(p_clcb->conn_id, p_clcb->op_subtype, &p_clcb->read_uuid128.result);
- gatt_act_discovery(p_clcb) ;
+ gatt_act_discovery(p_clcb) ;
}
else
{
@@ -1002,7 +1016,7 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
**
** Function gatt_process_handle_rsp
**
-** Description This function is called to handle the write response
+** Description This function is called to handle the write response
**
**
** Returns void
@@ -1013,7 +1027,7 @@ void gatt_process_handle_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code
UINT16 handle;
UINT8 * p= p_data;
- STREAM_TO_UINT16(handle, p);
+ STREAM_TO_UINT16(handle, p);
len -= 2;
if (op_code == GATT_RSP_WRITE)
@@ -1074,7 +1088,7 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
tGATT_CMD_Q *p_cmd = &p_tcb->cl_cmd_q[p_tcb->pending_cl_req];
BOOLEAN sent = FALSE;
- while (!sent &&
+ while (!sent &&
p_tcb->pending_cl_req != p_tcb->next_slot_inq &&
p_cmd->to_send && p_cmd->p_cmd != NULL)
{
@@ -1095,22 +1109,22 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
p_tcb->pending_cl_req ++;
p_cmd = &p_tcb->cl_cmd_q[p_tcb->pending_cl_req];
}
- }
- return sent;
+ }
+ return sent;
}
/*******************************************************************************
**
** Function gatt_client_handle_server_rsp
**
-** Description This function is called to handle the server response to
+** Description This function is called to handle the server response to
** client.
**
**
** Returns void
**
*******************************************************************************/
-void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
+void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
tGATT_CLCB *p_clcb = NULL;
@@ -1180,18 +1194,18 @@ void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
gatt_process_prep_write_rsp(p_tcb, p_clcb, op_code, len, p_data);
break;
- case GATT_RSP_EXEC_WRITE:
+ case GATT_RSP_EXEC_WRITE:
gatt_end_operation(p_clcb, p_clcb->status, NULL);
break;
case GATT_HANDLE_VALUE_NOTIF:
- case GATT_HANDLE_VALUE_IND:
+ case GATT_HANDLE_VALUE_IND:
gatt_process_notification(p_tcb, op_code, len, p_data);
break;
default:
GATT_TRACE_ERROR1("Unknown opcode = %d", op_code);
- break;
+ break;
}
}
diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.c
index 68982bd..bd94e50 100644
--- a/stack/gatt/gatt_db.c
+++ b/stack/gatt/gatt_db.c
@@ -1,13 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatts_db.c
-**
-** Description: this file contains GATT database building and query
-** functions
-**
-** Copyright (c) 2009-2011, Broadcom Corp, All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2009-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 GATT database building and query functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -29,22 +42,22 @@ static BOOLEAN deallocate_attr_in_db(tGATT_SVC_DB *p_db, void *p_attr);
static BOOLEAN copy_extra_byte_in_db(tGATT_SVC_DB *p_db, void **p_dst, UINT16 len);
static void gatts_db_add_service_declaration(tGATT_SVC_DB *p_db, tBT_UUID service, BOOLEAN is_pri);
-static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
+static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 handle, UINT16 offset, UINT32 trans_id);
/*******************************************************************************
**
-** Function gatts_init_service_db
+** Function gatts_init_service_db
**
** Description This function initialize a memory space to be a service database.
**
** Parameter p_db: database pointer.
** len: size of the memory space.
**
-** Returns Status of te operation.
+** Returns Status of te operation.
**
*******************************************************************************/
-BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID service, BOOLEAN is_pri,
+BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID service, BOOLEAN is_pri,
UINT16 s_hdl, UINT16 num_handle)
{
if (!allocate_svc_db_buf(p_db))
@@ -53,7 +66,7 @@ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID service, BOOLEAN is
return FALSE;
}
- GATT_TRACE_DEBUG0("gatts_init_service_db");
+ GATT_TRACE_DEBUG0("gatts_init_service_db");
GATT_TRACE_DEBUG2("s_hdl = %d num_handle = %d", s_hdl, num_handle );
/* update service database information */
@@ -67,14 +80,14 @@ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID service, BOOLEAN is
/*******************************************************************************
**
-** Function gatts_init_service_db
+** Function gatts_init_service_db
**
** Description This function initialize a memory space to be a service database.
**
** Parameter p_db: database pointer.
** len: size of the memory space.
**
-** Returns Status of te operation.
+** Returns Status of te operation.
**
*******************************************************************************/
tBT_UUID * gatts_get_service_uuid (tGATT_SVC_DB *p_db)
@@ -93,15 +106,15 @@ tBT_UUID * gatts_get_service_uuid (tGATT_SVC_DB *p_db)
/*******************************************************************************
**
-** Function gatts_check_attr_readability
+** Function gatts_check_attr_readability
**
** Description check attribute readability
**
-** Returns status of operation.
+** Returns status of operation.
**
*******************************************************************************/
-static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
- UINT16 offset,
+static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
+ UINT16 offset,
BOOLEAN read_long,
tGATT_SEC_FLAG sec_flag,
UINT8 key_size)
@@ -142,7 +155,7 @@ static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
if ( (perm & GATT_READ_ENCRYPTED_REQUIRED) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED) && (key_size < min_key_size))
{
GATT_TRACE_ERROR0( "GATT_INSUF_KEY_SIZE");
- return GATT_INSUF_KEY_SIZE;
+ return GATT_INSUF_KEY_SIZE;
}
@@ -171,7 +184,7 @@ static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
/*******************************************************************************
**
-** Function read_attr_value
+** Function read_attr_value
**
** Description Utility function to read an attribute value.
**
@@ -181,15 +194,15 @@ static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
** p_len: output parameter to carry out the attribute length.
** read_long: this is a read blob request.
** mtu: MTU
-** sec_flag: current link security status.
-** key_size: encryption key size.
+** sec_flag: current link security status.
+** key_size: encryption key size.
**
-** Returns status of operation.
+** Returns status of operation.
**
*******************************************************************************/
-static tGATT_STATUS read_attr_value (void *p_attr,
- UINT16 offset,
- UINT8 **p_data,
+static tGATT_STATUS read_attr_value (void *p_attr,
+ UINT16 offset,
+ UINT8 **p_data,
BOOLEAN read_long,
UINT16 mtu,
UINT16 *p_len,
@@ -204,7 +217,7 @@ static tGATT_STATUS read_attr_value (void *p_attr,
GATT_TRACE_DEBUG5("read_attr_value uuid=0x%04x perm=0x%0x sec_flag=0x%x offset=%d read_long=%d",
p_attr16->uuid,
- p_attr16->permission,
+ p_attr16->permission,
sec_flag,
offset,
read_long);
@@ -282,7 +295,7 @@ static tGATT_STATUS read_attr_value (void *p_attr,
/*******************************************************************************
**
-** Function gatts_db_read_attr_value_by_type
+** Function gatts_db_read_attr_value_by_type
**
** Description Query attribute value by attribute type.
**
@@ -292,20 +305,20 @@ static tGATT_STATUS read_attr_value (void *p_attr,
** e_handle: ending handle of the range we are looking for.
** type: Attribute type.
** mtu: MTU.
-** sec_flag: current link security status.
-** key_size: encryption key size.
+** sec_flag: current link security status.
+** key_size: encryption key size.
**
-** Returns Status of the operation.
+** Returns Status of the operation.
**
*******************************************************************************/
-tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
+tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
tGATT_SVC_DB *p_db,
UINT8 op_code,
- BT_HDR *p_rsp,
- UINT16 s_handle,
- UINT16 e_handle,
- tBT_UUID type,
- UINT16 *p_len,
+ BT_HDR *p_rsp,
+ UINT16 s_handle,
+ UINT16 e_handle,
+ tBT_UUID type,
+ UINT16 *p_len,
tGATT_SEC_FLAG sec_flag,
UINT8 key_size,
UINT32 trans_id,
@@ -344,7 +357,7 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
UINT16_TO_STREAM (p, p_attr->handle);
- status = read_attr_value ((void *)p_attr, 0, &p, FALSE, (UINT16)(*p_len -2), &len, sec_flag, key_size);
+ status = read_attr_value ((void *)p_attr, 0, &p, FALSE, (UINT16)(*p_len -2), &len, sec_flag, key_size);
if (status == GATT_PENDING)
{
@@ -385,22 +398,22 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
/*******************************************************************************
**
-** Function gatts_add_included_service
+** Function gatts_add_included_service
**
** Description This function adds an included service into a database.
**
** Parameter p_db: database pointer.
** inc_srvc_type: included service type.
**
-** Returns Status of the operation.
+** Returns Status of the operation.
**
*******************************************************************************/
-UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e_handle,
+UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e_handle,
tBT_UUID service)
{
tGATT_ATTR16 *p_attr;
- GATT_TRACE_DEBUG3("gatts_add_included_service: s_hdl = 0x%04x e_hdl = 0x%04x uuid = 0x%04x",
+ GATT_TRACE_DEBUG3("gatts_add_included_service: s_hdl = 0x%04x e_hdl = 0x%04x uuid = 0x%04x",
s_handle, e_handle, service.uu.uuid16);
if (service.len == 0 || s_handle == 0 || e_handle == 0)
@@ -430,7 +443,7 @@ UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e
/*******************************************************************************
**
-** Function gatts_add_characteristic
+** Function gatts_add_characteristic
**
** Description This function add a characteristics and its descriptor into
** a servce identified by the service database pointer.
@@ -440,11 +453,11 @@ UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e
** property: property of the characteristic.
** p_char: characteristic value information.
**
-** Returns Status of te operation.
+** Returns Status of te operation.
**
*******************************************************************************/
-UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
- tGATT_CHAR_PROP property,
+UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
+ tGATT_CHAR_PROP property,
tBT_UUID * p_char_uuid)
{
tGATT_ATTR16 *p_char_decl, *p_char_val;
@@ -456,7 +469,7 @@ UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
{
if (!copy_extra_byte_in_db(p_db, (void **)&p_char_decl->p_value, sizeof(tGATT_CHAR_DECL)))
{
- deallocate_attr_in_db(p_db, p_char_decl);
+ deallocate_attr_in_db(p_db, p_char_decl);
return 0;
}
@@ -464,7 +477,7 @@ UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
if (p_char_val == NULL)
{
- deallocate_attr_in_db(p_db, p_char_decl);
+ deallocate_attr_in_db(p_db, p_char_decl);
return 0;
}
@@ -481,11 +494,11 @@ UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
/*******************************************************************************
**
-** Function gatt_convertchar_descr_type
+** Function gatt_convertchar_descr_type
**
** Description This function convert a char descript UUID into descriptor type.
**
-** Returns descriptor type.
+** Returns descriptor type.
**
*******************************************************************************/
UINT8 gatt_convertchar_descr_type(tBT_UUID *p_descr_uuid)
@@ -525,7 +538,7 @@ UINT8 gatt_convertchar_descr_type(tBT_UUID *p_descr_uuid)
/*******************************************************************************
**
-** Function gatts_add_char_descr
+** Function gatts_add_char_descr
**
** Description This function add a characteristics descriptor.
**
@@ -534,10 +547,10 @@ UINT8 gatt_convertchar_descr_type(tBT_UUID *p_descr_uuid)
** char_dscp_tpye: the characteristic descriptor masks.
** p_dscp_params: characteristic descriptors values.
**
-** Returns Status of the operation.
+** Returns Status of the operation.
**
*******************************************************************************/
-UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
+UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
tBT_UUID * p_descr_uuid)
{
tGATT_ATTR16 *p_char_dscptr;
@@ -546,10 +559,10 @@ UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
GATT_TRACE_DEBUG1("gatts_add_char_descr uuid=0x%04x", p_descr_uuid->uu.uuid16);
/* Add characteristic descriptors */
- if ((p_char_dscptr = (tGATT_ATTR16 *)allocate_attr_in_db(p_db,
- uuid16,
- p_descr_uuid->uu.uuid128,
- perm))
+ if ((p_char_dscptr = (tGATT_ATTR16 *)allocate_attr_in_db(p_db,
+ uuid16,
+ p_descr_uuid->uu.uuid128,
+ perm))
== NULL)
{
GATT_TRACE_DEBUG0("gatts_add_char_descr Fail for adding char descriptors.");
@@ -566,7 +579,7 @@ UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
/*******************************************************************************/
/*******************************************************************************
**
-** Function gatts_read_attr_value_by_handle
+** Function gatts_read_attr_value_by_handle
**
** Description Query attribute value by attribute handle.
**
@@ -577,17 +590,17 @@ UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
** p_len: output parameter as attribute length read.
** read_long: this is a read blob request.
** mtu: MTU.
-** sec_flag: current link security status.
-** key_size: encryption key size
+** sec_flag: current link security status.
+** key_size: encryption key size
**
-** Returns Status of operation.
+** Returns Status of operation.
**
*******************************************************************************/
tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,
- tGATT_SVC_DB *p_db,
- UINT8 op_code,
- UINT16 handle, UINT16 offset,
- UINT8 *p_value, UINT16 *p_len,
+ tGATT_SVC_DB *p_db,
+ UINT8 op_code,
+ UINT16 handle, UINT16 offset,
+ UINT8 *p_value, UINT16 *p_len,
UINT16 mtu,
tGATT_SEC_FLAG sec_flag,
UINT8 key_size,
@@ -605,8 +618,8 @@ tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,
{
if (p_attr->handle == handle)
{
- status = read_attr_value (p_attr, offset, &pp,
- (BOOLEAN)(op_code == GATT_REQ_READ_BLOB),
+ status = read_attr_value (p_attr, offset, &pp,
+ (BOOLEAN)(op_code == GATT_REQ_READ_BLOB),
mtu, p_len, sec_flag, key_size);
if (status == GATT_PENDING)
@@ -624,7 +637,7 @@ tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,
/*******************************************************************************
**
-** Function gatts_read_attr_perm_check
+** Function gatts_read_attr_perm_check
**
** Description Check attribute readability.
**
@@ -635,15 +648,15 @@ tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,
** p_len: output parameter as attribute length read.
** read_long: this is a read blob request.
** mtu: MTU.
-** sec_flag: current link security status.
-** key_size: encryption key size
+** sec_flag: current link security status.
+** key_size: encryption key size
**
-** Returns Status of operation.
+** Returns Status of operation.
**
*******************************************************************************/
-tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db,
- BOOLEAN is_long,
- UINT16 handle,
+tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db,
+ BOOLEAN is_long,
+ UINT16 handle,
tGATT_SEC_FLAG sec_flag,
UINT8 key_size)
{
@@ -658,8 +671,8 @@ tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db,
{
if (p_attr->handle == handle)
{
- status = gatts_check_attr_readability (p_attr, 0,
- is_long,
+ status = gatts_check_attr_readability (p_attr, 0,
+ is_long,
sec_flag, key_size);
break;
}
@@ -671,7 +684,7 @@ tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db,
}
/*******************************************************************************
**
-** Function gatts_write_attr_perm_check
+** Function gatts_write_attr_perm_check
**
** Description Write attribute value into database.
**
@@ -681,14 +694,14 @@ tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db,
** offset: Write offset if write op code is write blob.
** p_data: Attribute value to write.
** len: attribute data length.
-** sec_flag: current link security status.
-** key_size: encryption key size
+** sec_flag: current link security status.
+** key_size: encryption key size
**
-** Returns Status of the operation.
+** Returns Status of the operation.
**
*******************************************************************************/
tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
- UINT16 handle, UINT16 offset, UINT8 *p_data,
+ UINT16 handle, UINT16 offset, UINT8 *p_data,
UINT16 len, tGATT_SEC_FLAG sec_flag, UINT8 key_size)
{
tGATT_STATUS status = GATT_NOT_FOUND;
@@ -697,7 +710,7 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
tGATT_PERM perm;
UINT16 min_key_size;
- GATT_TRACE_DEBUG6( "gatts_write_attr_perm_check op_code=0x%0x handle=0x%04x offset=%d len=%d sec_flag=0x%0x key_size=%d",
+ GATT_TRACE_DEBUG6( "gatts_write_attr_perm_check op_code=0x%0x handle=0x%04x offset=%d len=%d sec_flag=0x%0x key_size=%d",
op_code, handle, offset, len, sec_flag, key_size);
if (p_db != NULL)
@@ -714,7 +727,7 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
{
min_key_size +=6;
}
- GATT_TRACE_DEBUG2( "gatts_write_attr_perm_check p_attr->permission =0x%04x min_key_size==0x%04x",
+ GATT_TRACE_DEBUG2( "gatts_write_attr_perm_check p_attr->permission =0x%04x min_key_size==0x%04x",
p_attr->permission,
min_key_size);
@@ -836,9 +849,9 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
/*******************************************************************************
**
-** Function allocate_attr_in_db
+** Function allocate_attr_in_db
**
-** Description Allocate a memory space for a new attribute, and link this
+** Description Allocate a memory space for a new attribute, and link this
** attribute into the database attribute list.
**
**
@@ -865,7 +878,7 @@ static void *allocate_attr_in_db(tGATT_SVC_DB *p_db, UINT16 uuid16, UINT8 *uuid1
if (p_db->end_handle <= p_db->next_handle)
{
GATT_TRACE_DEBUG2("handle space full. handle_max = %d next_handle = %d",
- p_db->end_handle, p_db->next_handle);
+ p_db->end_handle, p_db->next_handle);
return NULL;
}
@@ -878,8 +891,8 @@ static void *allocate_attr_in_db(tGATT_SVC_DB *p_db, UINT16 uuid16, UINT8 *uuid1
}
}
- p_attr16 = (tGATT_ATTR16 *) p_db->p_free_mem;
- p_attr128 = (tGATT_ATTR128 *) p_db->p_free_mem;
+ p_attr16 = (tGATT_ATTR16 *) p_db->p_free_mem;
+ p_attr128 = (tGATT_ATTR128 *) p_db->p_free_mem;
memset(p_attr16, 0, len);
@@ -901,7 +914,7 @@ static void *allocate_attr_in_db(tGATT_SVC_DB *p_db, UINT16 uuid16, UINT8 *uuid1
p_attr16->permission = perm;
p_attr16->p_next = NULL;
- /* link the attribute record into the end of DB */
+ /* link the attribute record into the end of DB */
if (p_db->p_attr_list == NULL)
p_db->p_attr_list = p_attr16;
else
@@ -916,13 +929,13 @@ static void *allocate_attr_in_db(tGATT_SVC_DB *p_db, UINT16 uuid16, UINT8 *uuid1
if (p_attr16->uuid_type == GATT_ATTR_UUID_TYPE_16)
{
- GATT_TRACE_DEBUG3("=====> handle = [0x%04x] uuid = [0x%04x] perm=0x%02x ",
+ GATT_TRACE_DEBUG3("=====> handle = [0x%04x] uuid = [0x%04x] perm=0x%02x ",
p_attr16->handle, p_attr16->uuid, p_attr16->permission);
}
else
{
- GATT_TRACE_DEBUG4("=====> handle = [0x%04x] uuid128 = [0x%02x:0x%02x] perm=0x%02x ",
- p_attr128->handle, p_attr128->uuid[0],p_attr128->uuid[1],
+ GATT_TRACE_DEBUG4("=====> handle = [0x%04x] uuid128 = [0x%02x:0x%02x] perm=0x%02x ",
+ p_attr128->handle, p_attr128->uuid[0],p_attr128->uuid[1],
p_attr128->permission);
}
return(void *)p_attr16;
@@ -930,9 +943,9 @@ static void *allocate_attr_in_db(tGATT_SVC_DB *p_db, UINT16 uuid16, UINT8 *uuid1
/*******************************************************************************
**
-** Function deallocate_attr_in_db
+** Function deallocate_attr_in_db
**
-** Description Free an attribute within the database.
+** Description Free an attribute within the database.
**
** Parameter p_db: database pointer.
** p_attr: pointer to the attribute record to be freed.
@@ -951,7 +964,7 @@ static BOOLEAN deallocate_attr_in_db(tGATT_SVC_DB *p_db, void *p_attr)
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
p_next = (tGATT_ATTR16 *) p_cur->p_next;
- for (; p_cur != NULL && p_next != NULL;
+ for (; p_cur != NULL && p_next != NULL;
p_cur = p_next, p_next = (tGATT_ATTR16 *)p_next->p_next)
{
if (p_next == p_attr)
@@ -974,7 +987,7 @@ static BOOLEAN deallocate_attr_in_db(tGATT_SVC_DB *p_db, void *p_attr)
/*******************************************************************************
**
-** Function copy_extra_byte_in_db
+** Function copy_extra_byte_in_db
**
** Description Utility function to allocate extra bytes memory in DB and copy
** the value from a source place.
@@ -985,7 +998,7 @@ static BOOLEAN deallocate_attr_in_db(tGATT_SVC_DB *p_db, void *p_attr)
** p_src: source data pointer.
** len: data length to be copied.
**
-** Returns None.
+** Returns None.
**
*******************************************************************************/
static BOOLEAN copy_extra_byte_in_db(tGATT_SVC_DB *p_db, void **p_dst, UINT16 len)
@@ -1003,7 +1016,7 @@ static BOOLEAN copy_extra_byte_in_db(tGATT_SVC_DB *p_db, void **p_dst, UINT16 le
p = p_db->p_free_mem;
p_db->p_free_mem += len;
- p_db->mem_free -= len;
+ p_db->mem_free -= len;
memset((void *)p, 0, len);
*p_dst = (void *)p;
@@ -1012,11 +1025,11 @@ static BOOLEAN copy_extra_byte_in_db(tGATT_SVC_DB *p_db, void **p_dst, UINT16 le
/*******************************************************************************
**
-** Function allocate_svc_db_buf
+** Function allocate_svc_db_buf
**
** Description Utility function to allocate extra buffer for service database.
**
-** Returns TRUE if allocation succeed, otherwise FALSE.
+** Returns TRUE if allocation succeed, otherwise FALSE.
**
*******************************************************************************/
static BOOLEAN allocate_svc_db_buf(tGATT_SVC_DB *p_db)
@@ -1043,14 +1056,14 @@ static BOOLEAN allocate_svc_db_buf(tGATT_SVC_DB *p_db)
/*******************************************************************************
**
-** Function gatts_send_app_read_request
+** Function gatts_send_app_read_request
**
** Description Send application read request callback
**
-** Returns status of operation.
+** Returns status of operation.
**
*******************************************************************************/
-static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
+static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 handle, UINT16 offset, UINT32 trans_id)
{
tGATTS_DATA sr_data;
@@ -1064,7 +1077,7 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
if (trans_id == 0)
{
- trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, handle);
+ trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, handle);
gatt_sr_update_cback_cnt(p_tcb, p_sreg->gatt_if, TRUE, TRUE);
}
@@ -1076,7 +1089,7 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
sr_data.read_req.is_long = (BOOLEAN)(op_code == GATT_REQ_READ_BLOB);
sr_data.read_req.offset = offset;
- gatt_sr_send_req_callback(conn_id,
+ gatt_sr_send_req_callback(conn_id,
trans_id, GATTS_REQ_TYPE_READ, &sr_data);
return(tGATT_STATUS) GATT_PENDING;
}
@@ -1087,7 +1100,7 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
/*******************************************************************************
**
-** Function gatts_db_add_service_declaration
+** Function gatts_db_add_service_declaration
**
** Description Update a service database service declaration record.
**
@@ -1102,7 +1115,7 @@ static void gatts_db_add_service_declaration(tGATT_SVC_DB *p_db, tBT_UUID servic
tGATT_ATTR16 *p_attr;
UINT16 service_type = is_pri ? GATT_UUID_PRI_SERVICE: GATT_UUID_SEC_SERVICE;
- GATT_TRACE_DEBUG0( "add_service_declaration");
+ GATT_TRACE_DEBUG0( "add_service_declaration");
/* add service declration record */
if ((p_attr = (tGATT_ATTR16 *)(allocate_attr_in_db(p_db, service_type, NULL, GATT_PERM_READ))) != NULL)
diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h
index 7c7fb89..44a2bc1 100644
--- a/stack/gatt/gatt_int.h
+++ b/stack/gatt/gatt_int.h
@@ -1,13 +1,20 @@
-/****************************************************************************
-**
-** Name: gatt_int.h
-**
-** Function this file contains internally used GATT profile
-**
-** Copyright (c) 1999-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 1999-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.
+ *
+ ******************************************************************************/
#ifndef GATT_INT_H
#define GATT_INT_H
@@ -25,11 +32,11 @@
#include <string.h>
-#define GATT_CREATE_CONN_ID(tcb_idx, gatt_if) ((UINT16) ((((UINT8)(tcb_idx) ) << 8) | ((UINT8) (gatt_if))))
-#define GATT_GET_TCB_IDX(conn_id) ((UINT8) (((UINT16) (conn_id)) >> 8))
-#define GATT_GET_GATT_IF(conn_id) ((tGATT_IF)((UINT8) (conn_id)))
+#define GATT_CREATE_CONN_ID(tcb_idx, gatt_if) ((UINT16) ((((UINT8)(tcb_idx) ) << 8) | ((UINT8) (gatt_if))))
+#define GATT_GET_TCB_IDX(conn_id) ((UINT8) (((UINT16) (conn_id)) >> 8))
+#define GATT_GET_GATT_IF(conn_id) ((tGATT_IF)((UINT8) (conn_id)))
-#define GATT_GET_SR_REG_PTR(index) (&gatt_cb.sr_reg[(UINT8) (index)]);
+#define GATT_GET_SR_REG_PTR(index) (&gatt_cb.sr_reg[(UINT8) (index)]);
#define GATT_TRANS_ID_MAX 0x0fffffff /* 4 MSB is reserved */
/* security action for GATT write and read request */
@@ -37,7 +44,7 @@
#define GATT_SEC_OK 1
#define GATT_SEC_ENCRYPT 2 /* encrypt the link with current key */
#define GATT_SEC_ENCRYPT_NO_MITM 3 /* unauthenticated encryption or better */
-#define GATT_SEC_ENCRYPT_MITM 4 /* authenticated encryption */
+#define GATT_SEC_ENCRYPT_MITM 4 /* authenticated encryption */
#define GATT_SEC_SIGN_DATA 5 /* compute the signature for the write cmd */
typedef UINT8 tGATT_SEC_ACTION;
@@ -86,7 +93,7 @@ typedef UINT8 tGATT_SEC_ACTION;
#define GATT_SEC_FLAG_ENCRYPTED BTM_SEC_FLAG_ENCRYPTED
typedef UINT8 tGATT_SEC_FLAG;
-/* Find Information Response Type
+/* Find Information Response Type
*/
#define GATT_INFO_TYPE_PAIR_16 0x01
#define GATT_INFO_TYPE_PAIR_128 0x02
@@ -101,18 +108,18 @@ typedef struct
UINT8 value[GATT_MAX_MTU_SIZE]; /* pointer to the attribute value to be found */
} tGATT_FIND_TYPE_VALUE;
-/* client request message to ATT protocol
+/* client request message to ATT protocol
*/
typedef union
{
tGATT_READ_BY_TYPE browse; /* read by type request */
tGATT_FIND_TYPE_VALUE find_type_value;/* find by type value */
- tGATT_READ_MULTI read_multi; /* read multiple request */
+ tGATT_READ_MULTI read_multi; /* read multiple request */
tGATT_READ_PARTIAL read_blob; /* read blob */
tGATT_VALUE attr_value; /* write request */
/* prepare write */
/* write blob */
- UINT16 handle; /* read, handle value confirmation */
+ UINT16 handle; /* read, handle value confirmation */
UINT16 mtu;
tGATT_EXEC_FLAG exec_write; /* execute write */
}tGATT_CL_MSG;
@@ -125,7 +132,7 @@ typedef struct
UINT8 reason;
}tGATT_ERROR;
-/* server response message to ATT protocol
+/* server response message to ATT protocol
*/
typedef union
{
@@ -139,15 +146,15 @@ typedef union
/* Characteristic declaration attribute value
*/
-typedef struct
+typedef struct
{
tGATT_CHAR_PROP property;
UINT16 char_val_handle;
} tGATT_CHAR_DECL;
-/* attribute value maintained in the server database
+/* attribute value maintained in the server database
*/
-typedef union
+typedef union
{
tBT_UUID uuid; /* service declaration */
tGATT_CHAR_DECL char_decl; /* characteristic declaration */
@@ -155,7 +162,7 @@ typedef union
} tGATT_ATTR_VALUE;
-/* Attribute UUID type
+/* Attribute UUID type
*/
#define GATT_ATTR_UUID_TYPE_16 0
#define GATT_ATTR_UUID_TYPE_128 1
@@ -165,7 +172,7 @@ typedef UINT8 tGATT_ATTR_UUID_TYPE;
*/
typedef struct
{
- void *p_next; /* pointer to the next attribute,
+ void *p_next; /* pointer to the next attribute,
either tGATT_ATTR16 or tGATT_ATTR128 */
tGATT_ATTR_VALUE *p_value;
tGATT_ATTR_UUID_TYPE uuid_type;
@@ -178,7 +185,7 @@ typedef struct
*/
typedef struct
{
- void *p_next; /* pointer to the next attribute,
+ void *p_next; /* pointer to the next attribute,
either tGATT_ATTR16 or tGATT_ATTR128 */
tGATT_ATTR_VALUE *p_value;
tGATT_ATTR_UUID_TYPE uuid_type;
@@ -191,7 +198,7 @@ typedef struct
*/
typedef struct
{
- void *p_attr_list; /* pointer to the first attribute,
+ void *p_attr_list; /* pointer to the first attribute,
either tGATT_ATTR16 or tGATT_ATTR128 */
UINT8 *p_free_mem; /* Pointer to free memory */
BUFFER_Q svc_buffer; /* buffer queue used for service database */
@@ -203,7 +210,7 @@ typedef struct
/* Data Structure used for GATT server */
/* A GATT registration record consists of a handle, and 1 or more attributes */
/* A service registration information record consists of beginning and ending */
-/* attribute handle, service UUID and a set of GATT server callback. */
+/* attribute handle, service UUID and a set of GATT server callback. */
typedef struct
{
tGATT_SVC_DB *p_db; /* pointer to the service database */
@@ -215,7 +222,7 @@ typedef struct
UINT16 s_hdl; /* service starting handle */
UINT16 e_hdl; /* service ending handle */
tGATT_IF gatt_if; /* this service is belong to which application */
- BOOLEAN in_use;
+ BOOLEAN in_use;
} tGATT_SR_REG;
@@ -227,7 +234,7 @@ typedef struct
typedef struct
{
tBT_UUID app_uuid128;
- tGATT_CBACK app_cb;
+ tGATT_CBACK app_cb;
tGATT_IF gatt_if; /* one based */
BOOLEAN in_use;
} tGATT_REG;
@@ -325,8 +332,8 @@ typedef struct
typedef struct
{
- void *p_clcb; /* which clcb is doing encryption */
- tGATT_SEC_ACTION sec_act;
+ void *p_clcb; /* which clcb is doing encryption */
+ tGATT_SEC_ACTION sec_act;
BD_ADDR peer_bda;
UINT32 trans_id;
@@ -342,14 +349,14 @@ typedef struct
/* server response data */
tGATT_SR_CMD sr_cmd;
UINT16 indicate_handle;
- BUFFER_Q pending_ind_q;
+ BUFFER_Q pending_ind_q;
TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */
UINT8 prep_cnt[GATT_MAX_APPS];
- UINT8 ind_count;
+ UINT8 ind_count;
- tGATT_CMD_Q cl_cmd_q[GATT_CL_MAX_LCB];
+ tGATT_CMD_Q cl_cmd_q[GATT_CL_MAX_LCB];
TIMER_LIST_ENT rsp_timer_ent; /* peer response timer */
TIMER_LIST_ENT ind_ack_timer_ent; /* local app confirm to indication timer */
UINT8 pending_cl_req;
@@ -368,7 +375,7 @@ typedef struct
} tGATT_READ_INC_UUID128;
typedef struct
{
- tGATT_TCB *p_tcb; /* associated TCB of this CLCB */
+ tGATT_TCB *p_tcb; /* associated TCB of this CLCB */
tGATT_REG *p_reg; /* owner of this CLCB */
UINT8 sccb_idx;
UINT8 *p_attr_buf; /* attribute buffer for read multiple, prepare write */
@@ -378,14 +385,14 @@ typedef struct
UINT16 s_handle; /* starting handle of the active request */
UINT16 e_handle; /* ending handle of the active request */
UINT16 counter; /* used as offset, attribute length, num of prepare write */
- UINT16 start_offset;
+ UINT16 start_offset;
tGATT_AUTH_REQ auth_req; /* authentication requirement */
UINT8 operation; /* one logic channel can have one operation active */
UINT8 op_subtype; /* operation subtype */
UINT8 status; /* operation status */
BOOLEAN first_read_blob_after_read;
tGATT_READ_INC_UUID128 read_uuid128;
- BOOLEAN in_use;
+ BOOLEAN in_use;
} tGATT_CLCB;
#define GATT_SIGN_WRITE 1
@@ -409,7 +416,7 @@ typedef struct
typedef struct
{
UINT16 clcb_idx;
- BOOLEAN in_use;
+ BOOLEAN in_use;
} tGATT_SCCB;
typedef struct
@@ -421,7 +428,7 @@ typedef struct
typedef struct
{
- tGATT_IF gatt_if[GATT_MAX_APPS];
+ tGATT_IF gatt_if[GATT_MAX_APPS];
BD_ADDR remote_bda;
BOOLEAN in_use;
}tGATT_BG_CONN_DEV;
@@ -451,7 +458,7 @@ typedef struct
BUFFER_Q srv_chg_clt_q; /* service change clients queue */
BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */
- tGATT_REG cl_rcb[GATT_MAX_APPS];
+ tGATT_REG cl_rcb[GATT_MAX_APPS];
tGATT_CLCB clcb[GATT_CL_MAX_LCB]; /* connection link control block*/
tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
UINT8 trace_level;
@@ -494,7 +501,7 @@ GATT_API extern tGATT_CB *gatt_cb_ptr;
GATT_API extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status);
#endif
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
@@ -587,11 +594,11 @@ extern UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle);
extern UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
extern UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list);
extern tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if, UINT32 trans_id, UINT8 op_code, tGATT_STATUS status, tGATTS_RSP *p_msg);
-extern void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
+extern void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data);
-extern void gatt_sr_send_req_callback(UINT16 conn_id, UINT32 trans_id,
+extern void gatt_sr_send_req_callback(UINT16 conn_id, UINT32 trans_id,
UINT8 op_code, tGATTS_DATA *p_req_data);
-extern UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle);
+extern UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle);
extern BOOLEAN gatt_cancel_open(tGATT_IF gatt_if, BD_ADDR bda);
/* */
@@ -628,11 +635,11 @@ extern void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_
extern void gatt_act_discovery(tGATT_CLCB *p_clcb);
extern void gatt_act_read(tGATT_CLCB *p_clcb, UINT16 offset);
extern void gatt_act_write(tGATT_CLCB *p_clcb);
-extern UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle, UINT16 e_handle,
+extern UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle, UINT16 e_handle,
tBT_UUID uuid);
extern tGATT_CLCB *gatt_cmd_dequeue(tGATT_TCB *p_tcb, UINT8 *p_opcode);
extern BOOLEAN gatt_cmd_enq(tGATT_TCB *p_tcb, UINT16 clcb_idx, BOOLEAN to_send, UINT8 op_code, BT_HDR *p_buf);
-extern void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
+extern void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data);
extern void gatt_send_queue_write_cancel (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, tGATT_EXEC_FLAG flag);
@@ -649,11 +656,11 @@ extern BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID service, BOOL
extern UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e_handle, tBT_UUID service);
extern UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm, tGATT_CHAR_PROP property, tBT_UUID *p_char_uuid);
extern UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm, tBT_UUID *p_dscp_uuid);
-extern tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, tGATT_SVC_DB *p_db, UINT8 op_code, BT_HDR *p_rsp, UINT16 s_handle,
+extern tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, tGATT_SVC_DB *p_db, UINT8 op_code, BT_HDR *p_rsp, UINT16 s_handle,
UINT16 e_handle, tBT_UUID type, UINT16 *p_len, tGATT_SEC_FLAG sec_flag, UINT8 key_size,UINT32 trans_id, UINT16 *p_cur_handle);
-extern tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,tGATT_SVC_DB *p_db, UINT8 op_code, UINT16 handle, UINT16 offset,
+extern tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,tGATT_SVC_DB *p_db, UINT8 op_code, UINT16 handle, UINT16 offset,
UINT8 *p_value, UINT16 *p_len, UINT16 mtu,tGATT_SEC_FLAG sec_flag,UINT8 key_size,UINT32 trans_id);
-extern tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,UINT16 handle, UINT16 offset, UINT8 *p_data,
+extern tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,UINT16 handle, UINT16 offset, UINT8 *p_data,
UINT16 len, tGATT_SEC_FLAG sec_flag, UINT8 key_size);
extern tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db, BOOLEAN is_long, UINT16 handle, tGATT_SEC_FLAG sec_flag,UINT8 key_size);
extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary);
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c
index 396367a..06d87bb 100644
--- a/stack/gatt/gatt_main.c
+++ b/stack/gatt/gatt_main.c
@@ -1,12 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatt_main.c
-**
-** Description: this file contains the main ATT functions
-**
-** Copyright (c) 2008-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2008-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 main ATT functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
@@ -37,7 +51,7 @@ static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
static void gatt_send_conn_cback (BOOLEAN is_bg_conn, tGATT_TCB *p_tcb);
-static const tL2CAP_APPL_INFO dyn_info =
+static const tL2CAP_APPL_INFO dyn_info =
{
gatt_l2cif_connect_ind_cback,
gatt_l2cif_connect_cfm_cback,
@@ -57,7 +71,7 @@ tGATT_CB gatt_cb;
/*******************************************************************************
**
-** Function gatt_init
+** Function gatt_init
**
** Description This function is enable the GATT profile on the device.
** It clears out the control blocks, and registers with L2CAP.
@@ -103,9 +117,9 @@ void gatt_init (void)
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
- gatt_cb.hdl_cfg.gatt_start_hdl = GATT_GATT_START_HANDLE;
- gatt_cb.hdl_cfg.gap_start_hdl = GATT_GAP_START_HANDLE;
- gatt_cb.hdl_cfg.app_start_hdl = GATT_APP_START_HANDLE;
+ gatt_cb.hdl_cfg.gatt_start_hdl = GATT_GATT_START_HANDLE;
+ gatt_cb.hdl_cfg.gap_start_hdl = GATT_GAP_START_HANDLE;
+ gatt_cb.hdl_cfg.app_start_hdl = GATT_APP_START_HANDLE;
gatt_profile_db_init();
}
@@ -118,7 +132,7 @@ void gatt_init (void)
**
** Description This function is called to initiate a connection to a peer device.
**
-** Parameter rem_bda: remote device address to connect to.
+** Parameter rem_bda: remote device address to connect to.
**
** Returns TRUE if connection is started, otherwise return FALSE.
**
@@ -153,9 +167,9 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb)
**
** Description This function is called to disconnect to an ATT device.
**
-** Parameter rem_bda: remote device address to disconnect from.
+** Parameter rem_bda: remote device address to disconnect from.
**
-** Returns TRUE: if connection found and to be disconnected; otherwise
+** Returns TRUE: if connection found and to be disconnected; otherwise
** return FALSE.
**
*******************************************************************************/
@@ -208,7 +222,7 @@ BOOLEAN gatt_disconnect (BD_ADDR rem_bda)
void gatt_update_app_hold_link_status (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add)
{
UINT8 i;
- BOOLEAN found=FALSE;
+ BOOLEAN found=FALSE;
if (p_tcb == NULL)
{
@@ -259,13 +273,13 @@ void gatt_update_app_hold_link_status (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLE
*******************************************************************************/
void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link)
{
- GATT_TRACE_DEBUG2("gatt_update_app_use_link_flag is_add=%d chk_link=%d",
+ GATT_TRACE_DEBUG2("gatt_update_app_use_link_flag is_add=%d chk_link=%d",
is_add, check_acl_link);
gatt_update_app_hold_link_status(gatt_if, p_tcb, is_add);
if (check_acl_link &&
- p_tcb &&
+ p_tcb &&
(BTM_GetHCIConnHandle(p_tcb->peer_bda) != GATT_INVALID_ACL_HANDLE))
{
if (is_add)
@@ -320,7 +334,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr)
if (!gatt_connect(bd_addr, p_tcb))
{
GATT_TRACE_ERROR0("gatt_connect failed");
- memset(p_tcb, 0, sizeof(tGATT_TCB));
+ memset(p_tcb, 0, sizeof(tGATT_TCB));
}
else
ret = TRUE;
@@ -336,7 +350,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr)
{
gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, FALSE);
}
-
+
return ret;
}
@@ -345,7 +359,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr)
** Function gatt_le_connect_cback
**
** Description This callback function is called by L2CAP to indicate that
-** the ATT fixed channel for LE is
+** the ATT fixed channel for LE is
** connected (conn = TRUE)/disconnected (conn = FALSE).
**
*******************************************************************************/
@@ -360,7 +374,7 @@ static void gatt_le_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 re
GATT_TRACE_DEBUG3 ("GATT ATT protocol channel with BDA: %08x%04x is %s",
- (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
+ (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5], (connected) ? "connected" : "disconnected");
@@ -376,7 +390,7 @@ static void gatt_le_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 re
if (connected)
{
- GATT_TRACE_DEBUG1("connected is TRUE reason=%d",reason );
+ GATT_TRACE_DEBUG1("connected is TRUE reason=%d",reason );
/* BR/EDR lik, ignore this callback */
if (reason == 0)
return;
@@ -477,7 +491,7 @@ static void gatt_le_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf)
**
** Description This function handles an inbound connection indication
** from L2CAP. This is the case where we are acting as a
-** server.
+** server.
**
** Returns void
**
@@ -509,7 +523,7 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
}
/* Send L2CAP connect rsp */
- L2CA_ConnectRsp(bd_addr, id, lcid, result, 0);
+ L2CA_ConnectRsp(bd_addr, id, lcid, result, 0);
/* if result ok, proceed with connection */
if (result == L2CAP_CONN_OK)
@@ -531,7 +545,7 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
** Function gatt_l2c_connect_cfm_cback
**
** Description This is the L2CAP connect confirm callback function.
-**
+**
**
** Returns void
**
@@ -583,7 +597,7 @@ void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
** Function gatt_l2cif_config_cfm_cback
**
** Description This is the L2CAP config confirm callback function.
-**
+**
**
** Returns void
**
@@ -639,7 +653,7 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
** Function gatt_l2cif_config_ind_cback
**
** Description This is the L2CAP config indication callback function.
-**
+**
**
** Returns void
**
@@ -694,7 +708,7 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
** Function gatt_l2cif_disconnect_ind_cback
**
** Description This is the L2CAP disconnect indication callback function.
-**
+**
**
** Returns void
**
@@ -728,7 +742,7 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
** Function gatt_l2cif_disconnect_cfm_cback
**
** Description This is the L2CAP disconnect confirm callback function.
-**
+**
**
** Returns void
**
@@ -757,7 +771,7 @@ void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
** Function gatt_l2cif_data_ind_cback
**
** Description This is the L2CAP data indication callback function.
-**
+**
**
** Returns void
**
@@ -782,14 +796,14 @@ void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
** Function gatt_send_conn_cback
**
** Description Callback used to notify layer above about a connection.
-**
+**
**
** Returns void
**
*******************************************************************************/
static void gatt_send_conn_cback(BOOLEAN is_bg_conn, tGATT_TCB *p_tcb)
{
- UINT8 i;
+ UINT8 i;
tGATT_REG *p_reg;
tGATT_BG_CONN_DEV *p_bg_dev=NULL;
UINT16 conn_id;
@@ -807,7 +821,7 @@ static void gatt_send_conn_cback(BOOLEAN is_bg_conn, tGATT_TCB *p_tcb)
if (p_reg->app_cb.p_conn_cb)
{
- conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
+ conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
(*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, TRUE, 0);
}
}
@@ -854,7 +868,7 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
if (pseudo_op_code < GATT_OP_CODE_MAX)
{
if (op_code == GATT_SIGN_CMD_WRITE)
- {
+ {
gatt_verify_signature(p_tcb, p_buf);
return;
}
@@ -870,12 +884,12 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
else
{
GATT_TRACE_ERROR1 ("ATT - Rcvd L2CAP data, unknown cmd: 0x%x", op_code);
- }
+ }
}
else
{
GATT_TRACE_ERROR0 ("invalid data length, ignore");
- }
+ }
GKI_freebuf (p_buf);
}
@@ -885,7 +899,7 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
** Function gatt_add_a_bonded_dev_for_srv_chg
**
** Description Add a bonded dev to the service changed client list
-**
+**
** Returns void
**
*******************************************************************************/
@@ -938,8 +952,8 @@ void gatt_send_srv_chg_ind (BD_ADDR peer_bda)
}
else
{
- GATT_TRACE_ERROR2("Unable to find conn_id for %08x%04x ",
- (peer_bda[0]<<24)+(peer_bda[1]<<16)+(peer_bda[2]<<8)+peer_bda[3],
+ GATT_TRACE_ERROR2("Unable to find conn_id for %08x%04x ",
+ (peer_bda[0]<<24)+(peer_bda[1]<<16)+(peer_bda[2]<<8)+peer_bda[3],
(peer_bda[4]<<8)+peer_bda[5] );
}
}
@@ -957,7 +971,7 @@ void gatt_send_srv_chg_ind (BD_ADDR peer_bda)
*******************************************************************************/
void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt)
{
- GATT_TRACE_DEBUG1("gatt_chk_srv_chg srv_changed=%d", p_srv_chg_clt->srv_changed );
+ GATT_TRACE_DEBUG1("gatt_chk_srv_chg srv_changed=%d", p_srv_chg_clt->srv_changed );
if (p_srv_chg_clt->srv_changed)
{
@@ -997,10 +1011,10 @@ void gatt_init_srv_chg (void)
{
GATT_TRACE_DEBUG1("gatt_init_srv_chg num_srv_chg_clt_clients=%d", rsp.num_clients);
num_clients = rsp.num_clients;
- i = 1; /* use one based index */
+ i = 1; /* use one based index */
while ((i <= num_clients) && status)
{
- req.client_read_index = i;
+ req.client_read_index = i;
if ((status = (*gatt_cb.cb_info.p_srv_chg_callback)(GATTS_SRV_CHG_CMD_READ_CLENT, &req, &rsp)))
{
memcpy(&srv_chg_clt, &rsp.srv_chg ,sizeof(tGATTS_SRV_CHG));
@@ -1036,7 +1050,7 @@ void gatt_proc_srv_chg (void)
BOOLEAN srv_chg_ind_pending=FALSE;
tGATT_TCB *p_tcb;
- GATT_TRACE_DEBUG0 ("gatt_proc_srv_chg");
+ GATT_TRACE_DEBUG0 ("gatt_proc_srv_chg");
if (gatt_cb.cb_info.p_srv_chg_callback && gatt_cb.handle_of_h_r)
{
@@ -1053,7 +1067,7 @@ void gatt_proc_srv_chg (void)
}
else
{
- GATT_TRACE_DEBUG0 ("discard srv chg - already has one in the queue");
+ GATT_TRACE_DEBUG0 ("discard srv chg - already has one in the queue");
}
start_idx = ++found_idx;
}
diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c
index 9da6c34..ddecdb3 100644
--- a/stack/gatt/gatt_sr.c
+++ b/stack/gatt/gatt_sr.c
@@ -1,17 +1,31 @@
-/*****************************************************************************
-**
-** Name: gatt_sr.c
-**
-** Description: this file contains the GATT server functions
-**
-** Copyright (c) 2008-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2008-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 functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
#if BLE_INCLUDED == TRUE
-#include <string.h>
+#include <string.h>
#include "gatt_int.h"
#include "l2c_api.h"
@@ -20,7 +34,7 @@
**
** Function gatt_sr_enqueue_cmd
**
-** Description This function enqueue the request from client which needs a
+** Description This function enqueue the request from client which needs a
** application response, and update the transaction ID.
**
** Returns void
@@ -31,11 +45,11 @@ UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle)
tGATT_SR_CMD *p_cmd = &p_tcb->sr_cmd;
UINT32 trans_id = 0;
- if ( (p_cmd->op_code == 0) ||
+ if ( (p_cmd->op_code == 0) ||
(op_code == GATT_HANDLE_VALUE_CONF)) /* no pending request */
{
- if (op_code == GATT_CMD_WRITE ||
- op_code == GATT_SIGN_CMD_WRITE ||
+ if (op_code == GATT_CMD_WRITE ||
+ op_code == GATT_SIGN_CMD_WRITE ||
op_code == GATT_REQ_MTU ||
op_code == GATT_HANDLE_VALUE_CONF)
{
@@ -43,7 +57,7 @@ UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle)
}
else
{
- p_cmd->trans_id = ++p_tcb->trans_id;
+ p_cmd->trans_id = ++p_tcb->trans_id;
p_cmd->op_code = op_code;
p_cmd->handle = handle;
p_cmd->status = GATT_NOT_FOUND;
@@ -91,7 +105,7 @@ void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb)
while (p_tcb->sr_cmd.multi_rsp_q.p_first)
GKI_freebuf (GKI_dequeue (&p_tcb->sr_cmd.multi_rsp_q));
- memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
+ memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
}
/*******************************************************************************
@@ -127,7 +141,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
p_cmd->status = status;
if (status == GATT_SUCCESS)
{
- GATT_TRACE_DEBUG2 ("Multi read count=%d num_hdls=%d",
+ GATT_TRACE_DEBUG2 ("Multi read count=%d num_hdls=%d",
p_cmd->multi_rsp_q.count, p_cmd->multi_req.num_handles);
/* Wait till we get all the responses */
if (p_cmd->multi_rsp_q.count == p_cmd->multi_req.num_handles)
@@ -168,7 +182,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
{
/* just send the partial response for the overflow case */
len = p_rsp->attr_value.len - (total_len - mtu);
- is_overflow = TRUE;
+ is_overflow = TRUE;
GATT_TRACE_DEBUG2 ("multi read overflow available len=%d val_len=%d", len, p_rsp->attr_value.len );
}
else
@@ -185,7 +199,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
}
else
{
- p_cmd->status = GATT_NOT_FOUND;
+ p_cmd->status = GATT_NOT_FOUND;
break;
}
@@ -195,7 +209,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
}
else
{
- p_cmd->status = GATT_NOT_FOUND;
+ p_cmd->status = GATT_NOT_FOUND;
break;
}
@@ -235,7 +249,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
**
** Function gatt_sr_process_app_rsp
**
-** Description This function checks whether the response message from application
+** Description This function checks whether the response message from application
** match any pending request or not.
**
** Returns void
@@ -267,7 +281,7 @@ tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if,
p_tcb->sr_cmd.status = status;
- if (gatt_sr_is_cback_cnt_zero(p_tcb)
+ if (gatt_sr_is_cback_cnt_zero(p_tcb)
&& status == GATT_SUCCESS)
{
if (p_tcb->sr_cmd.p_rsp_msg == NULL)
@@ -280,7 +294,7 @@ tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if,
}
}
}
- if (gatt_sr_is_cback_cnt_zero(p_tcb))
+ if (gatt_sr_is_cback_cnt_zero(p_tcb))
{
if ( (p_tcb->sr_cmd.status == GATT_SUCCESS) && (p_tcb->sr_cmd.p_rsp_msg) )
{
@@ -289,7 +303,7 @@ tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if,
}
else
{
- ret_code = gatt_send_error_rsp (p_tcb, status, op_code, p_tcb->sr_cmd.handle, FALSE);
+ ret_code = gatt_send_error_rsp (p_tcb, status, op_code, p_tcb->sr_cmd.handle, FALSE);
}
gatt_dequeue_sr_cmd(p_tcb);
@@ -304,7 +318,7 @@ tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if,
**
** Function gatt_process_exec_write_req
**
-** Description This function is called to process the execute write request
+** Description This function is called to process the execute write request
** from client.
**
** Returns void
@@ -322,12 +336,12 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
/* mask the flag */
flag &= GATT_PREP_WRITE_EXEC;
-
+
/* no prep write is queued */
if (!gatt_sr_is_prep_cnt_zero(p_tcb))
{
- trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, 0);
+ trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, 0);
gatt_sr_copy_prep_cnt_to_cback_cnt(p_tcb);
for (i=0; i<GATT_MAX_APPS; i++)
@@ -336,9 +350,9 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
{
gatt_if = (tGATT_IF) (i+1);
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
- gatt_sr_send_req_callback(conn_id,
- trans_id,
- GATTS_REQ_TYPE_WRITE_EXEC,
+ gatt_sr_send_req_callback(conn_id,
+ trans_id,
+ GATTS_REQ_TYPE_WRITE_EXEC,
(tGATTS_DATA *)&flag);
p_tcb->prep_cnt[i]= 0;
}
@@ -360,7 +374,7 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
**
** Function gatt_process_read_multi_req
**
-** Description This function is called to process the read multiple request
+** Description This function is called to process the read multiple request
** from client.
**
** Returns void
@@ -375,12 +389,12 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
UINT8 sec_flag, key_size;
tGATTS_RSP *p_msg;
- GATT_TRACE_DEBUG0("gatt_process_read_multi_req" );
+ GATT_TRACE_DEBUG0("gatt_process_read_multi_req" );
p_tcb->sr_cmd.multi_req.num_handles = 0;
- gatt_sr_get_sec_info(p_tcb->peer_bda,
- (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
- &sec_flag,
+ gatt_sr_get_sec_info(p_tcb->peer_bda,
+ (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
+ &sec_flag,
&key_size);
#if GATT_CONFORMANCE_TESTING == TRUE
@@ -407,9 +421,9 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
/* check read permission */
if ((err = gatts_read_attr_perm_check( gatt_cb.sr_reg[i_rcb].p_db,
FALSE,
- handle,
+ handle,
sec_flag,
- key_size))
+ key_size))
!= GATT_SUCCESS)
{
GATT_TRACE_DEBUG1("read permission denied : 0x%02x", err);
@@ -424,7 +438,7 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
}
ll -= 2;
}
-
+
if (ll != 0)
{
GATT_TRACE_ERROR0("max attribute handle reached in ReadMultiple Request.");
@@ -452,21 +466,21 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
err = gatts_read_attr_value_by_handle(p_tcb,
gatt_cb.sr_reg[i_rcb].p_db,
op_code,
- handle,
- 0,
- p_msg->attr_value.value,
+ handle,
+ 0,
+ p_msg->attr_value.value,
&p_msg->attr_value.len,
- GATT_MAX_ATTR_LEN,
+ GATT_MAX_ATTR_LEN,
sec_flag,
key_size,
- trans_id);
+ trans_id);
if (err == GATT_SUCCESS)
{
gatt_sr_process_app_rsp(p_tcb, gatt_cb.sr_reg[i_rcb].gatt_if ,trans_id, op_code, GATT_SUCCESS, p_msg);
}
/* either not using or done using the buffer, release it now */
- GKI_freebuf(p_msg);
+ GKI_freebuf(p_msg);
}
else
{
@@ -495,8 +509,8 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
** Returns void
**
*******************************************************************************/
-static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_tcb,
- UINT8 op_code, UINT16 s_hdl,
+static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_tcb,
+ UINT8 op_code, UINT16 s_hdl,
UINT16 e_hdl, UINT8 *p_data, tBT_UUID value)
{
tGATT_STATUS status = GATT_NOT_FOUND;
@@ -512,7 +526,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
while (p_srv)
{
- p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
+ p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
if (p_rcb->in_use &&
p_rcb->s_hdl >= s_hdl &&
@@ -561,7 +575,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
gatt_build_uuid_to_stream(&p, *p_uuid);
status = GATT_SUCCESS;
- p_msg->len += p_msg->offset;
+ p_msg->len += p_msg->offset;
}
}
else
@@ -585,7 +599,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
** FALSE: packet full, or format mismatch.
**
*******************************************************************************/
-static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg, UINT16 *p_len,
+static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg, UINT16 *p_len,
UINT16 s_hdl, UINT16 e_hdl)
{
tGATT_STATUS status = GATT_NOT_FOUND;
@@ -621,7 +635,7 @@ static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg,
UINT16_TO_STREAM(p, p_attr->handle);
UINT16_TO_STREAM(p, p_attr->uuid);
}
- else if (p_msg->offset == GATT_INFO_TYPE_PAIR_128 &&
+ else if (p_msg->offset == GATT_INFO_TYPE_PAIR_128 &&
p_attr->uuid_type == GATT_ATTR_UUID_TYPE_128 )
{
UINT16_TO_STREAM(p, p_attr->handle);
@@ -661,7 +675,7 @@ static tGATT_STATUS gatt_build_find_info_rsp(tGATT_SR_REG *p_rcb, BT_HDR *p_msg,
** Returns void
**
*******************************************************************************/
-static tGATT_STATUS gatts_validate_packet_format(UINT8 op_code, UINT16 *p_len,
+static tGATT_STATUS gatts_validate_packet_format(UINT8 op_code, UINT16 *p_len,
UINT8 **p_data, tBT_UUID *p_uuid_filter,
UINT16 *p_s_hdl, UINT16 *p_e_hdl)
{
@@ -682,7 +696,7 @@ static tGATT_STATUS gatts_validate_packet_format(UINT8 op_code, UINT16 *p_len,
reason = GATT_INVALID_HANDLE;
}
/* for these PDUs, uuid filter must present */
- else if (op_code == GATT_REQ_READ_BY_GRP_TYPE ||
+ else if (op_code == GATT_REQ_READ_BY_GRP_TYPE ||
op_code == GATT_REQ_FIND_TYPE_VALUE ||
op_code == GATT_REQ_READ_BY_TYPE)
{
@@ -717,7 +731,7 @@ static tGATT_STATUS gatts_validate_packet_format(UINT8 op_code, UINT16 *p_len,
**
** Function gatts_process_primary_service_req
**
-** Description process ReadByGroupType/ReadByTypeValue request, for discover
+** Description process ReadByGroupType/ReadByTypeValue request, for discover
** all primary services or discover primary service by UUID request.
**
** Returns void
@@ -769,7 +783,7 @@ void gatts_process_primary_service_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 l
/* we do not support ReadByTypeValue with any non-primamry_service type */
reason = GATT_NOT_FOUND;
GATT_TRACE_DEBUG1("unexpected ReadByTypeValue type: 0x%04x", uuid.uu.uuid16);
- }
+ }
}
}
@@ -787,7 +801,7 @@ void gatts_process_primary_service_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 l
**
** Function gatts_process_find_info
**
-** Description process find information request, for discover character
+** Description process find information request, for discover character
** descriptors.
**
** Returns void
@@ -827,7 +841,7 @@ static void gatts_process_find_info(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
while (p_srv)
{
- p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
+ p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
if (p_rcb->in_use &&
!(p_rcb->s_hdl > e_hdl ||
@@ -873,7 +887,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
UINT16 mtu = 0;
UINT8 *p = p_data, i;
BT_HDR *p_buf;
- UINT16 conn_id;
+ UINT16 conn_id;
STREAM_TO_UINT16 (mtu, p);
@@ -902,7 +916,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
if (gatt_cb.cl_rcb[i].in_use )
{
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_cb.cl_rcb[i].gatt_if);
- gatt_sr_send_req_callback(conn_id, 0, GATTS_REQ_TYPE_MTU,
+ gatt_sr_send_req_callback(conn_id, 0, GATTS_REQ_TYPE_MTU,
(tGATTS_DATA *)&p_tcb->payload_size);
}
}
@@ -918,7 +932,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
** Description process Read By type request.
** This PDU can be used to perform:
** - read characteristic value
-** - read characteristic descriptor value
+** - read characteristic descriptor value
** - discover characteristic
** - discover characteristic by UUID
** - relationship discovery
@@ -931,7 +945,7 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
tBT_UUID uuid;
tGATT_SR_REG *p_rcb;
UINT16 msg_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET),
- buf_len,
+ buf_len,
s_hdl, e_hdl, err_hdl = 0;
BT_HDR *p_msg = NULL;
tGATT_STATUS reason, ret;
@@ -977,23 +991,23 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
while (p_srv)
{
- p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
+ p_rcb = GATT_GET_SR_REG_PTR(p_srv->i_sreg);
if (p_rcb->in_use &&
!(p_rcb->s_hdl > e_hdl ||
p_rcb->e_hdl < s_hdl))
{
- gatt_sr_get_sec_info(p_tcb->peer_bda,
- (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
- &sec_flag,
+ gatt_sr_get_sec_info(p_tcb->peer_bda,
+ (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
+ &sec_flag,
&key_size);
- ret = gatts_db_read_attr_value_by_type(p_tcb,
- p_rcb->p_db,
+ ret = gatts_db_read_attr_value_by_type(p_tcb,
+ p_rcb->p_db,
op_code,
- p_msg,
- s_hdl,
- e_hdl,
+ p_msg,
+ s_hdl,
+ e_hdl,
uuid,
&buf_len,
sec_flag,
@@ -1036,7 +1050,7 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
**
** Function gatts_process_write_req
**
-** Description This function is called to process the write request
+** Description This function is called to process the write request
** from client.
**
** Returns void
@@ -1065,7 +1079,7 @@ void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
if (op_code == GATT_SIGN_CMD_WRITE)
{
GATT_TRACE_DEBUG0("Write CMD with data sigining" );
- len -= GATT_AUTH_SIGN_LEN;
+ len -= GATT_AUTH_SIGN_LEN;
}
/* fall through */
case GATT_CMD_WRITE:
@@ -1078,18 +1092,18 @@ void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
break;
}
- gatt_sr_get_sec_info(p_tcb->peer_bda,
- (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
- &sec_flag,
+ gatt_sr_get_sec_info(p_tcb->peer_bda,
+ (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
+ &sec_flag,
&key_size);
status = gatts_write_attr_perm_check (gatt_cb.sr_reg[i_rcb].p_db,
op_code,
- handle,
- sr_data.write_req.offset,
- p,
- len,
- sec_flag,
+ handle,
+ sr_data.write_req.offset,
+ p,
+ len,
+ sec_flag,
key_size);
if (status == GATT_SUCCESS)
@@ -1099,10 +1113,10 @@ void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
p_sreg = &gatt_cb.sr_reg[i_rcb];
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_sreg->gatt_if);
gatt_sr_send_req_callback(conn_id,
- trans_id,
- GATTS_REQ_TYPE_WRITE,
+ trans_id,
+ GATTS_REQ_TYPE_WRITE,
&sr_data);
-
+
status = GATT_PENDING;
}
else
@@ -1125,13 +1139,13 @@ void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
**
** Function gatts_process_read_req
**
-** Description This function is called to process the read request
+** Description This function is called to process the read request
** from client.
**
** Returns void
**
*******************************************************************************/
-static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8 op_code,
+static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8 op_code,
UINT16 handle, UINT16 len, UINT8 *p_data)
{
UINT16 buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
@@ -1157,22 +1171,22 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
p_msg->len = 1;
buf_len = p_tcb->payload_size - 1;
- gatt_sr_get_sec_info(p_tcb->peer_bda,
- (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
- &sec_flag,
+ gatt_sr_get_sec_info(p_tcb->peer_bda,
+ (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
+ &sec_flag,
&key_size);
reason = gatts_read_attr_value_by_handle(p_tcb,
p_rcb->p_db,
op_code,
- handle,
- offset,
- p,
+ handle,
+ offset,
+ p,
&value_len,
- buf_len,
+ buf_len,
sec_flag,
key_size,
- 0);
+ 0);
p_msg->len += value_len;
}
@@ -1194,13 +1208,13 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
**
** Function gatts_process_attribute_req
**
-** Description This function is called to process the per attribute handle request
+** Description This function is called to process the per attribute handle request
** from client.
**
** Returns void
**
*******************************************************************************/
-void gatts_process_attribute_req (tGATT_TCB *p_tcb, UINT8 op_code,
+void gatts_process_attribute_req (tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
UINT16 handle;
@@ -1237,13 +1251,13 @@ void gatts_process_attribute_req (tGATT_TCB *p_tcb, UINT8 op_code,
{
switch (op_code)
{
- case GATT_REQ_READ: /* read char/char descriptor value */
+ case GATT_REQ_READ: /* read char/char descriptor value */
case GATT_REQ_READ_BLOB:
gatts_process_read_req(p_tcb, p_rcb, op_code, handle, len, p);
break;
case GATT_REQ_WRITE: /* write char/char descriptor value */
- case GATT_CMD_WRITE:
+ case GATT_CMD_WRITE:
case GATT_SIGN_CMD_WRITE:
case GATT_REQ_PREPARE_WRITE:
gatts_process_write_req(p_tcb, i, handle, op_code, len, p);
@@ -1269,13 +1283,13 @@ void gatts_process_attribute_req (tGATT_TCB *p_tcb, UINT8 op_code,
**
** Function gatts_proc_srv_chg_ind_ack
**
-** Description This function process the service changed indicaiton ACK
+** Description This function process the service changed indicaiton ACK
**
** Returns void
**
*******************************************************************************/
static void gatts_proc_srv_chg_ind_ack(tGATT_TCB *p_tcb )
-{
+{
tGATTS_SRV_CHG_REQ req;
tGATTS_SRV_CHG *p_buf = NULL;
@@ -1320,7 +1334,7 @@ static void gatts_chk_pending_ind(tGATT_TCB *p_tcb )
**
** Function gatts_proc_ind_ack
**
-** Description This function process the Indication ack
+** Description This function process the Indication ack
**
** Returns TRUE continue to process the indication ack by the aaplication
** if the ACk is not a Service Changed Indication Ack
@@ -1375,7 +1389,7 @@ void gatts_process_value_conf(tGATT_TCB *p_tcb, UINT8 op_code)
{
trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, handle);
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_rcb->gatt_if);
- gatt_sr_send_req_callback(conn_id,
+ gatt_sr_send_req_callback(conn_id,
trans_id, GATTS_REQ_TYPE_CONF, (tGATTS_DATA *)&handle);
}
}
@@ -1391,14 +1405,14 @@ void gatts_process_value_conf(tGATT_TCB *p_tcb, UINT8 op_code)
**
** Function gatt_server_handle_client_req
**
-** Description This function is called to handle the client requests to
+** Description This function is called to handle the client requests to
** server.
**
**
** Returns void
**
*******************************************************************************/
-void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
+void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
UINT16 len, UINT8 *p_data)
{
/* there is pending command, discard this one */
@@ -1411,11 +1425,11 @@ void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
{
GATT_TRACE_ERROR2("server receive invalid PDU size:%d pdu size:%d", len + 1, p_tcb->payload_size );
/* for invalid request expecting response, send it now */
- if (op_code != GATT_CMD_WRITE &&
- op_code != GATT_SIGN_CMD_WRITE &&
+ if (op_code != GATT_CMD_WRITE &&
+ op_code != GATT_SIGN_CMD_WRITE &&
op_code != GATT_HANDLE_VALUE_CONF)
{
- gatt_send_error_rsp (p_tcb, GATT_INVALID_PDU, op_code, 0, FALSE);
+ gatt_send_error_rsp (p_tcb, GATT_INVALID_PDU, op_code, 0, FALSE);
}
/* otherwise, ignore the pkt */
}
@@ -1438,10 +1452,10 @@ void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
break;
- case GATT_REQ_READ: /* read char/char descriptor value */
+ case GATT_REQ_READ: /* read char/char descriptor value */
case GATT_REQ_READ_BLOB:
case GATT_REQ_WRITE: /* write char/char descriptor value */
- case GATT_CMD_WRITE:
+ case GATT_CMD_WRITE:
case GATT_SIGN_CMD_WRITE:
case GATT_REQ_PREPARE_WRITE:
gatts_process_attribute_req (p_tcb, op_code, len, p_data);
@@ -1464,7 +1478,7 @@ void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
break;
default:
- break;
+ break;
}
}
}
diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c
index ca72f9d..bd3aaf6 100644
--- a/stack/gatt/gatt_utils.c
+++ b/stack/gatt/gatt_utils.c
@@ -1,13 +1,26 @@
-/*****************************************************************************
-**
-** Name: gatt_utils.c
-**
-** Description: this file contains GATT utility functions
-**
-**
-** Copyright (c) 2009-2011, Broadcom Corp, All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 2009-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 GATT utility functions
+ *
+ ******************************************************************************/
#include "bt_target.h"
#if BLE_INCLUDED == TRUE
@@ -28,39 +41,39 @@
const char * const op_code_name[] =
{
- "UNKNOWN",
- "ATT_RSP_ERROR",
- "ATT_REQ_MTU",
- "ATT_RSP_MTU",
- "ATT_REQ_READ_INFO",
- "ATT_RSP_READ_INFO",
- "ATT_REQ_FIND_TYPE_VALUE",
- "ATT_RSP_FIND_TYPE_VALUE",
- "ATT_REQ_READ_BY_TYPE",
- "ATT_RSP_READ_BY_TYPE",
- "ATT_REQ_READ",
- "ATT_RSP_READ",
- "ATT_REQ_READ_BLOB",
- "ATT_RSP_READ_BLOB",
- "GATT_REQ_READ_MULTI",
- "GATT_RSP_READ_MULTI",
+ "UNKNOWN",
+ "ATT_RSP_ERROR",
+ "ATT_REQ_MTU",
+ "ATT_RSP_MTU",
+ "ATT_REQ_READ_INFO",
+ "ATT_RSP_READ_INFO",
+ "ATT_REQ_FIND_TYPE_VALUE",
+ "ATT_RSP_FIND_TYPE_VALUE",
+ "ATT_REQ_READ_BY_TYPE",
+ "ATT_RSP_READ_BY_TYPE",
+ "ATT_REQ_READ",
+ "ATT_RSP_READ",
+ "ATT_REQ_READ_BLOB",
+ "ATT_RSP_READ_BLOB",
+ "GATT_REQ_READ_MULTI",
+ "GATT_RSP_READ_MULTI",
"GATT_REQ_READ_BY_GRP_TYPE",
"GATT_RSP_READ_BY_GRP_TYPE",
- "ATT_REQ_WRITE",
- "ATT_RSP_WRITE",
- "ATT_CMD_WRITE",
- "ATT_SIGN_CMD_WRITE",
- "ATT_REQ_PREPARE_WRITE",
- "ATT_RSP_PREPARE_WRITE",
- "ATT_REQ_EXEC_WRITE",
- "ATT_RSP_EXEC_WRITE",
- "Reserved",
- "ATT_HANDLE_VALUE_NOTIF",
- "Reserved",
- "ATT_HANDLE_VALUE_IND",
- "ATT_HANDLE_VALUE_CONF",
- "ATT_OP_CODE_MAX"
-};
+ "ATT_REQ_WRITE",
+ "ATT_RSP_WRITE",
+ "ATT_CMD_WRITE",
+ "ATT_SIGN_CMD_WRITE",
+ "ATT_REQ_PREPARE_WRITE",
+ "ATT_RSP_PREPARE_WRITE",
+ "ATT_REQ_EXEC_WRITE",
+ "ATT_RSP_EXEC_WRITE",
+ "Reserved",
+ "ATT_HANDLE_VALUE_NOTIF",
+ "Reserved",
+ "ATT_HANDLE_VALUE_IND",
+ "ATT_HANDLE_VALUE_CONF",
+ "ATT_OP_CODE_MAX"
+};
static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@@ -70,9 +83,9 @@ static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x0
**
** Function gatt_free_pending_ind
**
-** Description Free all pending indications
+** Description Free all pending indications
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void gatt_free_pending_ind(tGATT_TCB *p_tcb)
@@ -87,9 +100,9 @@ void gatt_free_pending_ind(tGATT_TCB *p_tcb)
**
** Function gatt_delete_dev_from_srv_chg_clt_list
**
-** Description Delete a device from the service changed client lit
+** Description Delete a device from the service changed client lit
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr)
@@ -97,7 +110,7 @@ void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr)
tGATTS_SRV_CHG *p_buf;
tGATTS_SRV_CHG_REQ req;
- GATT_TRACE_DEBUG0 ("gatt_delete_dev_from_srv_chg_clt_list");
+ GATT_TRACE_DEBUG0 ("gatt_delete_dev_from_srv_chg_clt_list");
if ((p_buf = gatt_is_bda_in_the_srv_chg_clt_list(bd_addr)) != NULL)
{
if (gatt_cb.cb_info.p_srv_chg_callback)
@@ -115,9 +128,9 @@ void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr)
**
** Function gatt_set_srv_chg
**
-** Description Set the service changed flag to TRUE
+** Description Set the service changed flag to TRUE
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void gatt_set_srv_chg(void)
@@ -125,13 +138,13 @@ void gatt_set_srv_chg(void)
tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)GKI_getfirst(&gatt_cb.srv_chg_clt_q);
tGATTS_SRV_CHG_REQ req;
- GATT_TRACE_DEBUG0 ("gatt_set_srv_chg");
+ GATT_TRACE_DEBUG0 ("gatt_set_srv_chg");
while (p_buf)
{
- GATT_TRACE_DEBUG0 ("found a srv_chg clt");
+ GATT_TRACE_DEBUG0 ("found a srv_chg clt");
if (!p_buf->srv_changed)
{
- GATT_TRACE_DEBUG0 ("set srv_changed to TRUE");
+ GATT_TRACE_DEBUG0 ("set srv_changed to TRUE");
p_buf->srv_changed= TRUE;
memcpy(&req.srv_chg, p_buf, sizeof(tGATTS_SRV_CHG));
if (gatt_cb.cb_info.p_srv_chg_callback)
@@ -145,9 +158,9 @@ void gatt_set_srv_chg(void)
**
** Function gatt_sr_is_new_srv_chg
**
-** Description Find the app id in on the new service changed list
+** Description Find the app id in on the new service changed list
**
-** Returns Pointer to the found new service changed item othwerwise NULL
+** Returns Pointer to the found new service changed item othwerwise NULL
**
*******************************************************************************/
tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst)
@@ -166,28 +179,28 @@ tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tB
break;
}
p_buf = (tGATTS_PENDING_NEW_SRV_START *)GKI_getnext(p_buf);
- }
+ }
- return p_buf;
+ return p_buf;
}
/*******************************************************************************
**
-** Function gatt_add_pending_ind
+** Function gatt_add_pending_ind
**
** Description Add a pending indication
-**
-** Returns Pointer to the current pending indication buffer, NULL no buffer available
+**
+** Returns Pointer to the current pending indication buffer, NULL no buffer available
**
*******************************************************************************/
tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind)
{
tGATT_VALUE *p_buf;
- GATT_TRACE_DEBUG0 ("gatt_add_pending_ind");
+ GATT_TRACE_DEBUG0 ("gatt_add_pending_ind");
if ((p_buf = (tGATT_VALUE *)GKI_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
{
- GATT_TRACE_DEBUG0 ("enqueue a pending indication");
+ GATT_TRACE_DEBUG0 ("enqueue a pending indication");
memcpy(p_buf, p_ind, sizeof(tGATT_VALUE));
GKI_enqueue (&p_tcb->pending_ind_q, p_buf);
}
@@ -197,22 +210,22 @@ tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind)
/*******************************************************************************
**
-** Function gatt_add_pending_new_srv_start
+** Function gatt_add_pending_new_srv_start
**
** Description Add a pending new srv start to the new service start queue
-**
-** Returns Pointer to the new service start buffer, NULL no buffer available
+**
+** Returns Pointer to the new service start buffer, NULL no buffer available
**
*******************************************************************************/
tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start(tGATTS_HNDL_RANGE *p_new_srv_start)
{
tGATTS_PENDING_NEW_SRV_START *p_buf;
- GATT_TRACE_DEBUG0 ("gatt_add_pending_new_srv_start");
+ GATT_TRACE_DEBUG0 ("gatt_add_pending_new_srv_start");
if ((p_buf = (tGATTS_PENDING_NEW_SRV_START *)GKI_getbuf((UINT16)sizeof(tGATTS_PENDING_NEW_SRV_START))) != NULL)
{
- GATT_TRACE_DEBUG0 ("enqueue a new pending new srv start");
- p_buf->p_new_srv_start = p_new_srv_start;
+ GATT_TRACE_DEBUG0 ("enqueue a new pending new srv start");
+ p_buf->p_new_srv_start = p_new_srv_start;
GKI_enqueue (&gatt_cb.pending_new_srv_start_q, p_buf);
}
return p_buf;
@@ -221,20 +234,20 @@ tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start(tGATTS_HNDL_RANGE *
/*******************************************************************************
**
-** Function gatt_add_srv_chg_clt
+** Function gatt_add_srv_chg_clt
**
** Description Add a service chnage client to the service change client queue
-**
-** Returns Pointer to the service change client buffer; Null no buffer available
+**
+** Returns Pointer to the service change client buffer; Null no buffer available
**
*******************************************************************************/
tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg)
{
tGATTS_SRV_CHG *p_buf;
- GATT_TRACE_DEBUG0 ("gatt_add_srv_chg_clt");
+ GATT_TRACE_DEBUG0 ("gatt_add_srv_chg_clt");
if ((p_buf = (tGATTS_SRV_CHG *)GKI_getbuf((UINT16)sizeof(tGATTS_SRV_CHG))) != NULL)
{
- GATT_TRACE_DEBUG0 ("enqueue a srv chg client");
+ GATT_TRACE_DEBUG0 ("enqueue a srv chg client");
memcpy(p_buf, p_srv_chg, sizeof(tGATTS_SRV_CHG));
GKI_enqueue (&gatt_cb.srv_chg_clt_q, p_buf);
}
@@ -245,11 +258,11 @@ tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg)
/*******************************************************************************
**
-** Function gatt_alloc_hdl_buffer
+** Function gatt_alloc_hdl_buffer
**
** Description Allocate a handle buufer
-**
-** Returns Pointer to the allocated buffer, NULL no buffer available
+**
+** Returns Pointer to the allocated buffer, NULL no buffer available
**
*******************************************************************************/
tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
@@ -273,11 +286,11 @@ tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
/*******************************************************************************
**
-** Function gatt_find_hdl_buffer_by_handle
+** Function gatt_find_hdl_buffer_by_handle
**
** Description Find handle range buffer by service handle.
-**
-** Returns Pointer to the buffer, NULL no buffer available
+**
+** Returns Pointer to the buffer, NULL no buffer available
**
*******************************************************************************/
tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_handle(UINT16 handle)
@@ -299,14 +312,14 @@ tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_handle(UINT16 handle)
}
/*******************************************************************************
**
-** Function gatt_find_hdl_buffer_by_app_id
+** Function gatt_find_hdl_buffer_by_app_id
**
** Description Find handle range buffer by app ID, service and service instance ID.
-**
-** Returns Pointer to the buffer, NULL no buffer available
+**
+** Returns Pointer to the buffer, NULL no buffer available
**
*******************************************************************************/
-tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128,
+tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128,
tBT_UUID *p_svc_uuid,
UINT16 svc_inst)
{
@@ -321,7 +334,7 @@ tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128,
&& gatt_uuid_compare (*p_svc_uuid, p_list->asgn_range.svc_uuid)
&& (svc_inst == p_list->asgn_range.svc_inst) )
{
- GATT_TRACE_DEBUG0 ("Already allocated handles for this service before!!");
+ GATT_TRACE_DEBUG0 ("Already allocated handles for this service before!!");
return(p_list);
}
p_list = p_list->p_next;
@@ -330,11 +343,11 @@ tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128,
}
/*******************************************************************************
**
-** Function gatt_free_hdl_buffer
+** Function gatt_free_hdl_buffer
**
** Description free a handle buffer
-**
-** Returns None
+**
+** Returns None
**
*******************************************************************************/
void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p)
@@ -349,12 +362,12 @@ void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p)
}
/*******************************************************************************
**
-** Function gatt_free_srvc_db_buffer_app_id
+** Function gatt_free_srvc_db_buffer_app_id
**
** Description free the service attribute database buffers by the owner of the
** service app ID.
-**
-** Returns None
+**
+** Returns None
**
*******************************************************************************/
void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id)
@@ -376,11 +389,11 @@ void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id)
}
/*******************************************************************************
**
-** Function gatt_is_last_attribute
+** Function gatt_is_last_attribute
**
** Description Check this is the last attribute of the specified value or not
-**
-** Returns TRUE - yes this is the last attribute
+**
+** Returns TRUE - yes this is the last attribute
**
*******************************************************************************/
BOOLEAN gatt_is_last_attribute(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_start, tBT_UUID value)
@@ -413,11 +426,11 @@ BOOLEAN gatt_is_last_attribute(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM
/*******************************************************************************
**
-** Function gatt_update_last_pri_srv_info
+** Function gatt_update_last_pri_srv_info
**
** Description Update the the last primary info for the service list info
-**
-** Returns None
+**
+** Returns None
**
*******************************************************************************/
void gatt_update_last_pri_srv_info(tGATT_SRV_LIST_INFO *p_list)
@@ -438,11 +451,11 @@ void gatt_update_last_pri_srv_info(tGATT_SRV_LIST_INFO *p_list)
}
/*******************************************************************************
**
-** Function gatts_update_srv_list_elem
+** Function gatts_update_srv_list_elem
**
** Description update an element in the service list.
**
-** Returns None.
+** Returns None.
**
*******************************************************************************/
void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary)
@@ -456,12 +469,12 @@ void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary)
}
/*******************************************************************************
**
-** Function gatt_add_a_srv_to_list
+** Function gatt_add_a_srv_to_list
**
-** Description add an service to the list in ascending
+** Description add an service to the list in ascending
** order of the start handle
**
-** Returns BOOLEAN TRUE-if add is successful
+** Returns BOOLEAN TRUE-if add is successful
**
*******************************************************************************/
BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_new)
@@ -478,7 +491,7 @@ BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM
{
/* this is an empty list */
p_list->p_first =
- p_list->p_last = p_new;
+ p_list->p_last = p_new;
p_new->p_next =
p_new->p_prev = NULL;
}
@@ -507,7 +520,7 @@ BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM
p_new->p_prev = p_old->p_prev;
p_new->p_next = p_old;
- p_old->p_prev = p_new;
+ p_old->p_prev = p_new;
break;
}
}
@@ -523,11 +536,11 @@ BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM
/*******************************************************************************
**
-** Function gatt_remove_a_srv_from_list
+** Function gatt_remove_a_srv_from_list
**
-** Description Remove a service from the list
+** Description Remove a service from the list
**
-** Returns BOOLEAN TRUE-if remove is successful
+** Returns BOOLEAN TRUE-if remove is successful
**
*******************************************************************************/
BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_remove)
@@ -547,7 +560,7 @@ BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_
else if (p_remove->p_next == NULL)
{
p_list->p_last = p_remove->p_prev;
- p_remove->p_prev->p_next = NULL;
+ p_remove->p_prev->p_next = NULL;
}
else
{
@@ -562,12 +575,12 @@ BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_
/*******************************************************************************
**
-** Function gatt_add_an_item_to_list
+** Function gatt_add_an_item_to_list
**
-** Description add an service handle range to the list in decending
+** Description add an service handle range to the list in decending
** order of the start handle
**
-** Returns BOOLEAN TRUE-if add is successful
+** Returns BOOLEAN TRUE-if add is successful
**
*******************************************************************************/
BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_new)
@@ -583,7 +596,7 @@ BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELE
{
/* this is an empty list */
p_list->p_first =
- p_list->p_last = p_new;
+ p_list->p_last = p_new;
p_new->p_next =
p_new->p_prev = NULL;
}
@@ -613,7 +626,7 @@ BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELE
p_new->p_next = p_old;
- p_old->p_prev = p_new;
+ p_old->p_prev = p_new;
break;
}
}
@@ -627,11 +640,11 @@ BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELE
/*******************************************************************************
**
-** Function gatt_remove_an_item_from_list
+** Function gatt_remove_an_item_from_list
**
-** Description Remove an service handle range from the list
+** Description Remove an service handle range from the list
**
-** Returns BOOLEAN TRUE-if remove is successful
+** Returns BOOLEAN TRUE-if remove is successful
**
*******************************************************************************/
BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_remove)
@@ -651,7 +664,7 @@ BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIS
else if (p_remove->p_next == NULL)
{
p_list->p_last = p_remove->p_prev;
- p_remove->p_prev->p_next = NULL;
+ p_remove->p_prev->p_next = NULL;
}
else
{
@@ -667,7 +680,7 @@ BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIS
**
** Function gatt_find_the_connected_bda
**
-** Description This function find the connected bda
+** Description This function find the connected bda
**
** Returns TRUE if found
**
@@ -691,7 +704,7 @@ BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found
}
}
GATT_TRACE_DEBUG2("gatt_find_the_connected_bda found=%d found_idx=%d", found, i);
- return found;
+ return found;
}
@@ -731,7 +744,7 @@ BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb)
}
GATT_TRACE_DEBUG1("srv_chg_ind_pending = %d", srv_chg_ind_pending);
- return srv_chg_ind_pending;
+ return srv_chg_ind_pending;
}
@@ -759,9 +772,9 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
break;
}
p_buf = (tGATTS_SRV_CHG *)GKI_getnext(p_buf);
- }
+ }
- return p_buf;
+ return p_buf;
}
@@ -769,7 +782,7 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
**
** Function gatt_is_bda_connected
**
-** Description
+** Description
**
** Returns GATT_INDEX_INVALID if not found. Otherwise index to the tcb.
**
@@ -788,7 +801,7 @@ BOOLEAN gatt_is_bda_connected(BD_ADDR bda)
break;
}
}
- return connected;
+ return connected;
}
/*******************************************************************************
@@ -812,7 +825,7 @@ UINT8 gatt_find_i_tcb_by_addr(BD_ADDR bda)
break;
}
}
- return j;
+ return j;
}
@@ -832,7 +845,7 @@ tGATT_TCB * gatt_get_tcb_by_idx(UINT8 tcb_idx)
if ( (tcb_idx < GATT_MAX_PHY_CHANNEL) && gatt_cb.tcb[tcb_idx].in_use)
p_tcb = &gatt_cb.tcb[tcb_idx];
- return p_tcb;
+ return p_tcb;
}
/*******************************************************************************
@@ -852,7 +865,7 @@ tGATT_TCB * gatt_find_tcb_by_addr(BD_ADDR bda)
if ((i = gatt_find_i_tcb_by_addr(bda)) != GATT_INDEX_INVALID)
p_tcb = &gatt_cb.tcb[i];
- return p_tcb;
+ return p_tcb;
}
/*******************************************************************************
**
@@ -875,7 +888,7 @@ UINT8 gatt_find_i_tcb_free(void)
break;
}
}
- return j;
+ return j;
}
/*******************************************************************************
**
@@ -888,7 +901,7 @@ UINT8 gatt_find_i_tcb_free(void)
*******************************************************************************/
tGATT_TCB * gatt_allocate_tcb_by_bdaddr(BD_ADDR bda)
{
- UINT8 i = 0;
+ UINT8 i = 0;
BOOLEAN allocated = FALSE;
tGATT_TCB *p_tcb = NULL;
@@ -1087,8 +1100,8 @@ BOOLEAN gatt_parse_uuid_from_cmd(tBT_UUID *p_uuid_rec, UINT16 uuid_size, UINT8 *
void gatt_start_rsp_timer(tGATT_TCB *p_tcb)
{
p_tcb->rsp_timer_ent.param = (TIMER_PARAM_TYPE)p_tcb;
- btu_start_timer (&p_tcb->rsp_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
- GATT_WAIT_FOR_RSP_TOUT);
+ btu_start_timer (&p_tcb->rsp_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
+ GATT_WAIT_FOR_RSP_TOUT);
}
/*******************************************************************************
**
@@ -1102,8 +1115,8 @@ void gatt_start_rsp_timer(tGATT_TCB *p_tcb)
void gatt_start_conf_timer(tGATT_TCB *p_tcb)
{
p_tcb->conf_timer_ent.param = (TIMER_PARAM_TYPE)p_tcb;
- btu_start_timer (&p_tcb->conf_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
- GATT_WAIT_FOR_RSP_TOUT);
+ btu_start_timer (&p_tcb->conf_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
+ GATT_WAIT_FOR_RSP_TOUT);
}
/*******************************************************************************
**
@@ -1118,7 +1131,7 @@ void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb)
{
p_tcb->ind_ack_timer_ent.param = (TIMER_PARAM_TYPE)p_tcb;
/* start notification cache timer */
- btu_start_timer (&p_tcb->ind_ack_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_IND_ACK,
+ btu_start_timer (&p_tcb->ind_ack_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_IND_ACK,
GATT_WAIT_FOR_RSP_TOUT);
}
@@ -1204,12 +1217,12 @@ UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid
p_this_uuid = gatts_get_service_uuid (p_sreg->p_db);
if (p_this_uuid &&
- gatt_uuid_compare (*p_app_uuid128, p_sreg->app_uuid ) &&
- gatt_uuid_compare (*p_svc_uuid, *p_this_uuid) &&
+ gatt_uuid_compare (*p_app_uuid128, p_sreg->app_uuid ) &&
+ gatt_uuid_compare (*p_svc_uuid, *p_this_uuid) &&
(svc_inst == p_sreg->service_instance))
{
GATT_TRACE_ERROR0 ("Active Service Found ");
- gatt_dbg_display_uuid(*p_svc_uuid);
+ gatt_dbg_display_uuid(*p_svc_uuid);
break;
}
@@ -1242,7 +1255,7 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list )
memcpy (&p_sreg->app_uuid, &p_list->asgn_range.app_uuid128, sizeof(tBT_UUID));
p_sreg->service_instance = p_list->asgn_range.svc_inst;
- p_sreg->type = p_list->asgn_range.is_primary ? GATT_UUID_PRI_SERVICE: GATT_UUID_SEC_SERVICE;
+ p_sreg->type = p_list->asgn_range.is_primary ? GATT_UUID_PRI_SERVICE: GATT_UUID_SEC_SERVICE;
p_sreg->s_hdl = p_list->asgn_range.s_handle;
p_sreg->e_hdl = p_list->asgn_range.e_handle;
//p_sreg->sr_cb = *p_cback;
@@ -1261,7 +1274,7 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list )
**
** Description Get the security flag and key size information for the peer
** device.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -1280,14 +1293,14 @@ void gatt_sr_get_sec_info(BD_ADDR rem_bda, BOOLEAN le_conn, UINT8 *p_sec_flag, U
**
** Function gatt_sr_send_req_callback
**
-** Description
-**
+** Description
+**
**
** Returns void
**
*******************************************************************************/
-void gatt_sr_send_req_callback(UINT16 conn_id,
- UINT32 trans_id,
+void gatt_sr_send_req_callback(UINT16 conn_id,
+ UINT32 trans_id,
tGATTS_REQ_TYPE type, tGATTS_DATA *p_data)
{
tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id);
@@ -1299,10 +1312,10 @@ void gatt_sr_send_req_callback(UINT16 conn_id,
return;
}
- if ( p_reg->in_use &&
+ if ( p_reg->in_use &&
p_reg->app_cb.p_req_cb)
{
- (*p_reg->app_cb.p_req_cb)(conn_id, trans_id, type, p_data);
+ (*p_reg->app_cb.p_req_cb)(conn_id, trans_id, type, p_data);
}
else
{
@@ -1320,14 +1333,14 @@ void gatt_sr_send_req_callback(UINT16 conn_id,
** Returns void
**
*******************************************************************************/
-tGATT_STATUS gatt_send_error_rsp (tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_code,
+tGATT_STATUS gatt_send_error_rsp (tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_code,
UINT16 handle, BOOLEAN deq)
{
tGATT_ERROR error;
tGATT_STATUS status;
BT_HDR *p_buf;
- error.cmd_code = op_code;
+ error.cmd_code = op_code;
error.reason = err_code;
error.handle =handle;
@@ -1390,7 +1403,7 @@ UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl)
proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
proto_elem_list[0].num_params = 1;
proto_elem_list[0].params[0] = BT_PSM_ATT;
- proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_ATT;
+ proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_ATT;
proto_elem_list[1].num_params = 2;
proto_elem_list[1].params[0] = start_hdl;
proto_elem_list[1].params[1] = end_hdl;
@@ -1455,7 +1468,7 @@ tGATT_REG *gatt_get_regcb (tGATT_IF gatt_if)
**
** Function gatt_is_clcb_allocated
**
-** Description The function check clcb for conn_id is allocated or not
+** Description The function check clcb for conn_id is allocated or not
**
** Returns True already allocated
**
@@ -1471,7 +1484,7 @@ BOOLEAN gatt_is_clcb_allocated (UINT16 conn_id)
if (gatt_cb.clcb[i].in_use && (gatt_cb.clcb[i].conn_id == conn_id))
{
is_allocated = TRUE;
- break;
+ break;
}
}
@@ -1536,7 +1549,7 @@ void gatt_clcb_dealloc (tGATT_CLCB *p_clcb)
**
** Function gatt_find_tcb_by_cid
**
-** Description The function searches for an empty entry
+** Description The function searches for an empty entry
** in registration info table for GATT client
**
** Returns NULL if not found. Otherwise pointer to the rcb.
@@ -1743,7 +1756,7 @@ void gatt_sr_reset_prep_cnt(tGATT_TCB *p_tcb )
**
** Function gatt_sr_update_cback_cnt
**
-** Description Update the teh applicaiton callback count
+** Description Update the teh applicaiton callback count
**
** Returns None
**
@@ -1778,9 +1791,9 @@ void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc
**
** Function gatt_sr_update_prep_cnt
**
-** Description Update the teh prepare write request count
+** Description Update the teh prepare write request count
**
-** Returns None
+** Returns None
**
*******************************************************************************/
void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first)
@@ -1788,7 +1801,7 @@ void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc,
UINT8 idx = ((UINT8) gatt_if) - 1 ;
GATT_TRACE_DEBUG4("gatt_sr_update_prep_cnt tcb idx=%d gatt_if=%d is_inc=%d is_reset_first=%d",
- p_tcb->tcb_idx, gatt_if, is_inc, is_reset_first);
+ p_tcb->tcb_idx, gatt_if, is_inc, is_reset_first);
if (p_tcb)
{
@@ -1936,8 +1949,8 @@ tGATT_CLCB * gatt_cmd_dequeue(tGATT_TCB *p_tcb, UINT8 *p_op_code)
** Returns status code
**
*******************************************************************************/
-UINT8 gatt_send_write_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
- UINT16 handle, UINT16 len,
+UINT8 gatt_send_write_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
+ UINT16 handle, UINT16 len,
UINT16 offset, UINT8 *p_data)
{
tGATT_CL_MSG msg;
@@ -1962,7 +1975,7 @@ UINT8 gatt_send_write_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
** Returns status code
**
*******************************************************************************/
-UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle,
+UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle,
UINT16 e_handle, tBT_UUID uuid)
{
tGATT_CL_MSG msg;
@@ -1994,7 +2007,7 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
UINT16 conn_id;
UINT8 operation;
- GATT_TRACE_DEBUG3 ("gatt_end_operation status=%d op=%d subtype=%d",
+ GATT_TRACE_DEBUG3 ("gatt_end_operation status=%d op=%d subtype=%d",
status, p_clcb->operation, p_clcb->op_subtype);
if (p_cmpl_cb != NULL && p_clcb->operation != 0)
@@ -2050,7 +2063,7 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
else if (p_cmpl_cb && op)
(*p_cmpl_cb)(conn_id, op, status, &cb_data);
else
- GATT_TRACE_WARNING3 ("gatt_end_operation not sent out op=%d p_disc_cmpl_cb:%p p_cmpl_cb:%p",
+ GATT_TRACE_WARNING3 ("gatt_end_operation not sent out op=%d p_disc_cmpl_cb:%p p_cmpl_cb:%p",
operation, p_disc_cmpl_cb, p_cmpl_cb);
}
@@ -2102,7 +2115,7 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason)
p_reg = &gatt_cb.cl_rcb[i];
if (p_reg->in_use && p_reg->app_cb.p_conn_cb)
{
- conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
+ conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
GATT_TRACE_DEBUG3 ("found p_reg tcb_idx=%d gatt_if=%d conn_id=0x%x", p_tcb->tcb_idx, p_reg->gatt_if, conn_id);
(*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, bda, conn_id, FALSE, reason);
}
@@ -2162,12 +2175,12 @@ void gatt_dbg_display_uuid(tBT_UUID bt_uuid)
}
else if (bt_uuid.len == LEN_UUID_128)
{
- x += sprintf(&str_buf[x], "0x%02x%02x%02x%02x%02x%02x%02x%02x",
+ x += sprintf(&str_buf[x], "0x%02x%02x%02x%02x%02x%02x%02x%02x",
bt_uuid.uu.uuid128[15], bt_uuid.uu.uuid128[14],
bt_uuid.uu.uuid128[13], bt_uuid.uu.uuid128[12],
bt_uuid.uu.uuid128[11], bt_uuid.uu.uuid128[10],
bt_uuid.uu.uuid128[9], bt_uuid.uu.uuid128[8]);
- sprintf(&str_buf[x], "%02x%02x%02x%02x%02x%02x%02x%02x",
+ sprintf(&str_buf[x], "%02x%02x%02x%02x%02x%02x%02x%02x",
bt_uuid.uu.uuid128[7], bt_uuid.uu.uuid128[6],
bt_uuid.uu.uuid128[5], bt_uuid.uu.uuid128[4],
bt_uuid.uu.uuid128[3], bt_uuid.uu.uuid128[2],
@@ -2403,8 +2416,8 @@ BOOLEAN gatt_remove_bg_dev_from_list(tGATT_IF gatt_if, BD_ADDR bd_addr)
p_dev->gatt_if[i] = 0;
for (j = i + 1; j < GATT_MAX_APPS; j ++)
- p_dev->gatt_if[j - 1] = p_dev->gatt_if[j];
-
+ p_dev->gatt_if[j - 1] = p_dev->gatt_if[j];
+
if (p_dev->gatt_if[0] == 0)
{
ret = BTM_BleUpdateBgConnDev(FALSE, p_dev->remote_bda);
@@ -2444,7 +2457,7 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if)
else if (p_dev_list->gatt_if[j] == gatt_if)
{
for (k = j + 1; k < GATT_MAX_APPS; k ++)
- p_dev_list->gatt_if[k - 1] = p_dev_list->gatt_if[k];
+ p_dev_list->gatt_if[k - 1] = p_dev_list->gatt_if[k];
if (p_dev_list->gatt_if[0] == 0)
{
@@ -2477,7 +2490,7 @@ void gatt_reset_bgdev_list(void)
**
** Function gatt_update_auto_connect_dev
**
-** Description This function add or remove a device for background connection
+** Description This function add or remove a device for background connection
** procedure.
**
** Parameters gatt_if: Application ID.