diff options
author | Casper Bonde <c.bonde@samsung.com> | 2015-04-13 21:58:56 +0200 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2015-04-13 14:23:29 -0700 |
commit | d232721ae5e5b6949a5249f0d116408b8a3c5f1d (patch) | |
tree | 20a26dd135f491116375b4a3a0446c5c226d9552 | |
parent | 899b77140675a157dba034e98527ab546bc9ac35 (diff) | |
download | bt-d232721ae5e5b6949a5249f0d116408b8a3c5f1d.tar.gz |
L2CAP socket - fix merge errors
This fixes a few changes that was reverted by mistake,
causing uninitialized data to be used as instance data
in GAP and no buffers allocated to the L2CAP sockets.
Change-Id: I060c5faf602c1dedcc34b4acd1417949820a4da4
-rw-r--r-- | include/bt_target.h | 11 | ||||
-rw-r--r-- | include/gki_target.h | 6 | ||||
-rw-r--r-- | stack/gap/gap_api.c | 4 | ||||
-rw-r--r-- | stack/gap/gap_int.h | 4 | ||||
-rw-r--r-- | stack/gap/gap_utils.c | 294 |
5 files changed, 21 insertions, 298 deletions
diff --git a/include/bt_target.h b/include/bt_target.h index b2550739c..4fb2a0f4c 100644 --- a/include/bt_target.h +++ b/include/bt_target.h @@ -1101,6 +1101,17 @@ ** ******************************************************************************/ #define OBX_14_INCLUDED FALSE + +/* The maximum number of registered servers. */ +#ifndef OBX_NUM_SERVERS +#define OBX_NUM_SERVERS 12 +#endif + +/* The maximum number of active clients. */ +#ifndef OBX_NUM_CLIENTS +#define OBX_NUM_CLIENTS 8 +#endif + /* This option is application when OBX_14_INCLUDED=TRUE Pool ID where to reassemble the SDU. This Pool will allow buffers to be used that are larger than diff --git a/include/gki_target.h b/include/gki_target.h index 1d35c25d1..45f639798 100644 --- a/include/gki_target.h +++ b/include/gki_target.h @@ -94,7 +94,7 @@ #define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3 #endif -/* Pool 4 is unused */ +/* Pool 4 is used for BluetoothSocket L2CAP connections */ /* The size of the buffers in pool 4. */ #ifndef GKI_BUF4_SIZE #define GKI_BUF4_SIZE (8080+26) @@ -102,7 +102,7 @@ /* The number of buffers in buffer pool 4. */ #ifndef GKI_BUF4_MAX -#define GKI_BUF4_MAX 0 +#define GKI_BUF4_MAX (OBX_NUM_SERVERS + OBX_NUM_CLIENTS) #endif /* The ID of buffer pool 4. */ @@ -142,7 +142,7 @@ of order */ #endif /* The size of the buffers in pool 5 -** Special pool used by l2cap retransmissions only. This size based on segment +** Special pool used by L2CAP retransmissions only. This size based on segment ** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI ** header. 13 bytes of max headers allows us a 339 payload max. (in btui_app.txt) ** Note: 748 used for insight scriptwrapper with CAT-2 scripts. diff --git a/stack/gap/gap_api.c b/stack/gap/gap_api.c index a81efdca5..5518efd1c 100644 --- a/stack/gap/gap_api.c +++ b/stack/gap/gap_api.c @@ -64,6 +64,10 @@ void GAP_Init(void) gap_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */ #endif +#if GAP_CONN_INCLUDED == TRUE + gap_conn_init(); +#endif + #if BLE_INCLUDED == TRUE gap_attr_db_init(); #endif diff --git a/stack/gap/gap_int.h b/stack/gap/gap_int.h index 937db64dc..dc58e876f 100644 --- a/stack/gap/gap_int.h +++ b/stack/gap/gap_int.h @@ -152,7 +152,9 @@ typedef struct extern tGAP_CB gap_cb; - +#if (GAP_CONN_INCLUDED == TRUE) + extern void gap_conn_init(void); +#endif #if (BLE_INCLUDED == TRUE) extern void gap_attr_db_init(void); #endif diff --git a/stack/gap/gap_utils.c b/stack/gap/gap_utils.c index e7dfb200c..6c8a05ada 100644 --- a/stack/gap/gap_utils.c +++ b/stack/gap/gap_utils.c @@ -21,300 +21,6 @@ #include "bt_utils.h" #include "gap_int.h" -/*****************************************************************************/ -/* G L O B A L GAP D A T A */ -/*****************************************************************************/ -tGAP_CB gap_cb; - -#if 0 -/***************************************************************************** -** Callbacks passed to BTM - -** There are different callbacks based on the control block index so that -** more than one command can be pending at a time. -** NOTE: There must be 1 callback for each control block defined -** GAP_MAX_BLOCKS -** -** Also, the inquiry results event has its own callback; Not handled here! -******************************************************************************/ -static void btm_cback(UINT16 index, void *p_data) -{ - tGAP_INFO *p_cb; - tGAP_INQ_CMPL inq_cmpl; - - /* Make sure that the index is valid AND it is in use */ - if (index < GAP_MAX_BLOCKS && gap_cb.blk[index].in_use) - { - p_cb = &gap_cb.blk[index]; - - /* If the callback is non-NULL, call it with the specified event */ - switch (p_cb->event) - { - - case GAP_EVT_INQUIRY_COMPLETE: - /* pass the number of results to caller */ - inq_cmpl.num_results = ((tBTM_INQUIRY_CMPL *)p_data)->num_resp; - - inq_cmpl.status = (((tBTM_INQUIRY_CMPL *)p_data)->status == BTM_SUCCESS) ? BT_PASS : GAP_ERR_PROCESSING; - - p_data = &inq_cmpl; - - GAP_TRACE_EVENT(" GAP Inquiry Complete Event (Status 0x%04x, Result(s) %d)", - inq_cmpl.status, inq_cmpl.num_results); - break; - - case GAP_EVT_DISCOVERY_COMPLETE: - if (*((UINT16 *) p_data)) - { - GAP_TRACE_EVENT(" GAP Discovery Complete Event(SDP Result: 0x%04x)", *((UINT16 *) p_data)); - } - else - { - GAP_TRACE_EVENT(" GAP Discovery Successfully Completed"); - } - - break; - - case GAP_EVT_REM_NAME_COMPLETE: - /* override the BTM error code with a GAP error code */ - ((tGAP_REMOTE_DEV_NAME *)p_data)->status = - gap_convert_btm_status ((tBTM_STATUS)((tBTM_REMOTE_DEV_NAME *)p_data)->status); - - GAP_TRACE_EVENT(" GAP Remote Name Complete Event (status 0x%04x)", ((tGAP_REMOTE_DEV_NAME *)p_data)->status); - - break; - }; - - if (p_cb->gap_cback) - p_cb->gap_cback(p_cb->event, p_data); - - /* Deallocate the control block */ - gap_free_cb(p_cb); - } -} - - -/*** Callback functions for BTM_CMPL_CB ***/ -void gap_btm_cback0(void *p1) -{ - btm_cback(0, p1); -} - -#if GAP_MAX_BLOCKS > 1 -void gap_btm_cback1(void *p1) -{ - btm_cback(1, p1); -} -#endif -#if GAP_MAX_BLOCKS > 2 -void gap_btm_cback2(void *p1) -{ - btm_cback(2, p1); -} -#endif - -/* There is only one instance of this because only 1 inquiry can be active at a time */ -void gap_inq_results_cb(tBTM_INQ_RESULTS *p_results, UINT8 *p_eir) -{ - tGAP_INFO *p_cb; - UINT8 index; - UNUSED(p_eir); - - GAP_TRACE_EVENT ("GAP Inquiry Results Callback (bdaddr [%02x%02x%02x%02x%02x%02x])", - p_results->remote_bd_addr[0], p_results->remote_bd_addr[1], - p_results->remote_bd_addr[2], p_results->remote_bd_addr[3], - p_results->remote_bd_addr[4], p_results->remote_bd_addr[5]); - GAP_TRACE_EVENT (" (COD [%02x%02x%02x], clkoff 0x%04x)", - p_results->dev_class[0], p_results->dev_class[1], p_results->dev_class[2], - p_results->clock_offset); - - /* Find the control block which has an Inquiry Active and call its results callback */ - for (index = 0, p_cb = &gap_cb.blk[0]; index < GAP_MAX_BLOCKS; index++, p_cb++) - { - /* Look for the control block that is using inquiry */ - if (p_cb->in_use && (p_cb->event == GAP_EVT_INQUIRY_COMPLETE)) - { - /* Notify the higher layer if they care */ - if (p_cb->gap_inq_rslt_cback) - p_cb->gap_inq_rslt_cback (GAP_EVT_INQUIRY_RESULTS, (tGAP_INQ_RESULTS *)p_results); - } - } -} - - -/******************************************************************************* -** -** Function gap_find_addr_name_cb -** -** Description Processes the remote name request event when the Find Addr by Name -** request is active. The following procedure takes place: -** 1. Check the resulting name (If return status is ok) -** 2. If name matches requested name, we're done, call the appl's callback -** with the BD ADDR. -** 3. Otherwise get the next BD ADDR out of the inquiry database and intiate -** another remote name request. -** 4. If there are no more BD ADDRs, then call the appl's callback with a FAIL -** status. -** -** Returns void -** -*******************************************************************************/ -void gap_find_addr_name_cb (tBTM_REMOTE_DEV_NAME *p) -{ - tGAP_FINDADDR_CB *p_cb = &gap_cb.findaddr_cb; - tGAP_FINDADDR_RESULTS *p_result = &p_cb->results; - - if (p_cb->in_use) - { - if (p->status == BTM_SUCCESS) - { - GAP_TRACE_EVENT(" GAP: FindAddrByName Rem Name Cmpl Evt (Status 0x%04x, Name [%s])", - p->status, p->remote_bd_name); - - /* See if the returned name matches the desired name; if not initiate another search */ - if (!strncmp ((char *)p_result->devname, (char *) p->remote_bd_name, strlen ((char *) p_result->devname))) - { - /* We found the device! Copy it into the return structure */ - memcpy (p_result->bd_addr, p_cb->p_cur_inq->results.remote_bd_addr, BD_ADDR_LEN); - p_result->status = BT_PASS; - } - else /* The name doesn't match so initiate another search */ - { - /* Get the device address of the next database entry */ - if ((p_cb->p_cur_inq = BTM_InqDbNext(p_cb->p_cur_inq)) != NULL) - { - if ((BTM_ReadRemoteDeviceName (p_cb->p_cur_inq->results.remote_bd_addr, - (tBTM_CMPL_CB *) gap_find_addr_name_cb, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) - return; /* This routine will get called again with the next results */ - else - p_result->status = gap_convert_btm_status ((tBTM_STATUS) p->status); - } - else - p_result->status = GAP_EOINQDB; /* No inquiry results; we're done! */ - } - } - else - { - GAP_TRACE_EVENT(" GAP: FindAddrByName Rem Name Cmpl Evt (Status 0x%04x)", p->status); - p_result->status = gap_convert_btm_status ((tBTM_STATUS) p->status); - } - - /* If this code is reached, the process has completed so call the appl's callback with results */ - if (p_cb->p_cback) - p_cb->p_cback (GAP_EVT_FIND_ADDR_COMPLETE, (tGAP_FINDADDR_RESULTS *) p_result); - - /* Clear out the control block */ - p_cb->in_use = FALSE; - p_cb->p_cback = (tGAP_CALLBACK *) NULL; - } -} - -/******************************************************************************* -** -** Function gap_find_addr_inq_cb -** -** Description Processes the inquiry complete event when the Find Addr by Name -** request is active. This callback performs one of the two following -** steps: -** 1. If the remote name is retrieved automatically, the DB is searched -** immediately, and the results are returned in the appls callback. -** -** 2. If remote name is not automatic, retrieve the first BTM INQ -** database entry and initiate a remote name request. -** -** Returns void -** -*******************************************************************************/ -void gap_find_addr_inq_cb (tBTM_INQUIRY_CMPL *p) -{ - tGAP_FINDADDR_CB *p_cb = &gap_cb.findaddr_cb; - tGAP_FINDADDR_RESULTS *p_result = &p_cb->results; - - if (p_cb->in_use) - { - - GAP_TRACE_EVENT(" GAP: FindAddrByName Inq Cmpl Evt (Status 0x%04x, Result(s) %d)", - p->status, p->num_resp); - - if (p->status == BTM_SUCCESS) - { - /* Step 1: If automatically retrieving remote names then search the local database */ - if ((p_result->status = gap_find_local_addr_by_name (p_result->devname, p_result->bd_addr)) == GAP_NO_DATA_AVAIL) - { - /* Step 2: The name is not stored automatically, so a search of all devices needs to - * be initiated. - */ - if ((p_cb->p_cur_inq = BTM_InqDbFirst()) != NULL) - { - if ((BTM_ReadRemoteDeviceName (p_cb->p_cur_inq->results.remote_bd_addr, - (tBTM_CMPL_CB *) gap_find_addr_name_cb, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) - return; /* Wait for the response in gap_find_addr_name_cb() */ - else - p_result->status = gap_convert_btm_status (p->status); - } - else - p_result->status = GAP_EOINQDB; /* No inquiry results; we're done! */ - } - } - else - p_result->status = gap_convert_btm_status (p->status); - - /* If this code is reached, the process has completed so call the appl's callback with results */ - if (p_cb->p_cback) - p_cb->p_cback (GAP_EVT_FIND_ADDR_COMPLETE, (tGAP_FINDADDR_RESULTS *) p_result); - - /* Clear out the control block */ - p_cb->in_use = FALSE; - p_cb->p_cback = (tGAP_CALLBACK *) NULL; - } -} - -/******************************************************************************* -** -** Function gap_find_local_addr_by_name -** -** Description Searches through the internal inquiry database for a device -** that has the same name as the one passed in. If found, the -** device address is filled in. -** -** NOTE: It only searches up to the first BTM_MAX_REM_BD_NAME_LEN -** bytes because the inquiry database uses tBTM_BD_NAME. -** -** Returns BT_PASS if the name was found and the device address is filled in -** GAP_EOINQDB if the name was not found in the database -** GAP_NO_DATA_AVAIL if the name is not saved with the inquiry -** -*******************************************************************************/ -UINT16 gap_find_local_addr_by_name (const tBTM_BD_NAME devname, BD_ADDR bd_addr) -{ - -/* If the remote name is retrieved automatically during an inquiry search the local db */ -#if (BTM_INQ_GET_REMOTE_NAME == TRUE) - tBTM_INQ_INFO *p_result; - - p_result = BTM_InqDbFirst(); - - while (p_result) - { - /* Check the entry for a device name match */ - if (!strncmp ((char *)devname, (char *)p_result->remote_name, BTM_MAX_REM_BD_NAME_LEN)) - { - memcpy (bd_addr, p_result->results.remote_bd_addr, BD_ADDR_LEN); - return (BT_PASS); - } - else - p_result = BTM_InqDbNext(p_result); - }; - - return (GAP_EOINQDB); -#else - UNUSED(devname); - UNUSED(bd_addr); - /* No data available because we are not automatically saving the data */ - return (GAP_NO_DATA_AVAIL); -#endif -} -#endif - /******************************************************************************* ** ** Function gap_allocate_cb |