#define GAP_INCLUDED TRUE
#endif
-/* This is set to enable use of GAP L2CAP connections. */
-#ifndef GAP_CONN_INCLUDED
-#define GAP_CONN_INCLUDED TRUE
-#endif
-
-/* This is set to enable posting event for data write */
-#ifndef GAP_CONN_POST_EVT_INCLUDED
-#define GAP_CONN_POST_EVT_INCLUDED FALSE
-#endif
-
-/* The maximum number of simultaneous GAP L2CAP connections. */
-#ifndef GAP_MAX_CONNECTIONS
-#define GAP_MAX_CONNECTIONS 8
-#endif
-
/******************************************************************************
**
** CTP
./l2cap/l2c_ble.c \
./gap/gap_api.c \
./gap/gap_ble.c \
- ./gap/gap_conn.c \
- ./gap/gap_utils.c \
../vnd/ble/vendor_ble.c
LOCAL_MODULE := libbt-brcm_stack
GKI_freebuf (p_msg);
break;
#endif /* SAP */
-#if (defined(GAP_CONN_INCLUDED) && GAP_CONN_INCLUDED == TRUE && GAP_CONN_POST_EVT_INCLUDED == TRUE)
- case BT_EVT_TO_GAP_MSG :
- gap_proc_btu_event(p_msg);
- GKI_freebuf (p_msg);
- break;
-#endif
// NOTE: The timer calls below may not be sent by HCI.
case BT_EVT_TO_START_TIMER :
/* Start free running 1 second timer for list management */
#include "bt_target.h"
#include "bt_utils.h"
#include "gap_int.h"
-#include "btm_int.h"
-#include "gki.h"
-#include "btu.h"
-
-/*******************************************************************************
-**
-** Function GAP_SetDiscoverableMode
-**
-** Description This function is called to allow or disallow a service to
-** discovered (Inquiry Scans).
-**
-** Parameters: mode - GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE,
-** or GAP_GENERAL_DISCOVERABLE
-**
-** duration - Amount of time for the duration of an inquiry scan.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-** If a value of '0' is entered the default of
-** 0x0012 (11.25 msecs) will be used.
-** Note: The duration must be less than or equal to
-** the interval.
-**
-** interval - Amount of time between the start of two inquiry scans.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-** If a value of '0' is entered the default of
-** 0x800 (1.28 secs) will be used.
-**
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_PARM if a bad parameter is detected,
-** GAP_DEVICE_NOT_UP if the device is not active,
-** GAP_ERR_PROCESSING if not enough resources to carry out request
-**
-*******************************************************************************/
-UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration, UINT16 interval)
-{
- tBTM_STATUS status;
-
- status = BTM_SetDiscoverability(mode, duration, interval);
-
- return (gap_convert_btm_status (status));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ReadDiscoverableMode
-**
-** Description This function is called to retrieve the current discoverable mode
-** for the local device.
-**
-** Parameters: duration - pointer to the amount of time of an inquiry scan.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-** interval - pointer to the amount of time between the start of
-** two inquiry scans.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-**
-** Returns GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or
-** GAP_GENERAL_DISCOVERABLE
-**
-*******************************************************************************/
-UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval)
-{
- return (BTM_ReadDiscoverability(duration, interval));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_SetConnectableMode
-**
-** Description This function is called to allow or disallow a
-** connections on the local device.
-**
-** Parameters: mode - GAP_NON_CONNECTABLE, GAP_CONNECTABLE,
-**
-** duration - Amount of time for the duration of a page scan.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-** If a value of '0' is entered the default of
-** 0x0012 (11.25 msecs) will be used.
-** Note: The duration must be less than or equal to
-** the interval.
-**
-** interval - Amount of time between the start of two page scans.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-** If a value of '0' is entered the default of
-** 0x800 (1.28 secs) will be used.
-**
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_PARM if a bad parameter is detected,
-** GAP_DEVICE_NOT_UP if the device is not active,
-** GAP_ERR_PROCESSING if not enough resources to carry out request
-**
-*******************************************************************************/
-UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration, UINT16 interval)
-{
- tBTM_STATUS status;
-
- status = BTM_SetConnectability(mode, duration, interval);
-
- return (gap_convert_btm_status (status));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_FindAddrByName
-**
-** Description This function is called to retrieve a device address given
-** a device name. It first looks in the current local inquiry
-** database for the device with the specified name. If not found
-** it initiates a general inquiry. Upon completion, it retrieves
-** the name for each device until a match is found or all devices
-** have been checked. Note: This process can take a while to
-** complete.
-**
-** Parameters: devname -
-**
-** inqparms - pointer to the inquiry information
-** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry
-** duration - length in 1.28 sec intervals
-** max_resps - maximum amount of devices to search for before ending the inquiry
-** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or
-** GAP_FILTER_COND_BD_ADDR
-** filter_cond - value for the filter (based on filter_cond_type)
-**
-**
-** Returns BT_PASS if the name was immediately available. (BD_ADDR is returned)
-** GAP_CMD_INITIATED if an inquiry has been initiated
-**
-*******************************************************************************/
-UINT16 GAP_FindAddrByName (BD_NAME devname, tGAP_INQ_PARMS *p_inq_parms, tGAP_CALLBACK *p_addr_cb,
- BD_ADDR bd_addr)
-{
- UINT16 status;
- tBTM_STATUS btm_status;
-
-
- /* If the remote name is retrieved automatically during an inquiry search the local db first */
- if ((status = gap_find_local_addr_by_name (devname, bd_addr)) != BT_PASS)
- {
- /* If this code is used, the name wasn't in the current inquiry database */
- /* A general inquiry must now be initiated */
- if (gap_cb.findaddr_cb.in_use == FALSE)
- {
- gap_cb.findaddr_cb.p_cback = p_addr_cb;
- gap_cb.findaddr_cb.p_cur_inq = (tBTM_INQ_INFO *) NULL; /* Reset to the beginning of the database */
- BCM_STRNCPY_S ((char *)gap_cb.findaddr_cb.results.devname, sizeof(gap_cb.findaddr_cb.results.devname), (char *)devname, BTM_MAX_REM_BD_NAME_LEN);
-
- /* make sure we have an end of string char */
- gap_cb.findaddr_cb.results.devname[BTM_MAX_REM_BD_NAME_LEN] = 0;
-
- btm_status = BTM_StartInquiry (p_inq_parms, (tBTM_INQ_RESULTS_CB *) NULL,
- (tBTM_CMPL_CB *) gap_find_addr_inq_cb);
- gap_cb.findaddr_cb.in_use = TRUE;
-
- /* convert the error code into a GAP code and check the results for any errors */
- if ((status = gap_convert_btm_status (btm_status)) == GAP_CMD_INITIATED)
- gap_cb.findaddr_cb.in_use = TRUE;
- }
- else
- status = GAP_ERR_BUSY;
- }
-
- return (status);
-}
-
-/*******************************************************************************
-**
-** Function GAP_ReadConnectableMode
-**
-** Description This function is called to retrieve the current connectability
-** mode for the local device.
-**
-** Parameters: duration - pointer to the amount of time of an page scan.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-** interval - pointer to the amount of time between the start of
-** two page scans.
-** The step size is in 0.625 msec intervals.
-** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs)
-**
-**
-** Returns GAP_NON_CONNECTABLE, GAP_CONNECTABLE
-**
-*******************************************************************************/
-
-UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval)
-{
- return (BTM_ReadConnectability(duration, interval));
-}
-
-/*******************************************************************************
-**
-** Function GAP_Bond
-**
-** Description This function is called to perform bonding with peer device
-**
-** Parameters: bd_addr - Address of the device to bond
-** pin_len - length in bytes of the PIN Code
-** p_pin - pointer to array with the PIN Code
-** trusted_mask - bitwise OR of trusted services (array of UINT32)
-**
-*******************************************************************************/
-UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
-{
- return ((UINT8) BTM_SecBond (bd_addr, pin_len, p_pin, trusted_mask));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_SecRegister
-**
-** Description Application manager calls this function to register for
-** security services. There can be one and only one application
-** saving link keys. BTM allows only first registration.
-**
-** Returns TRUE if registered OK, else FALSE
-**
-*******************************************************************************/
-BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info)
-{
- return (BTM_SecRegister (p_cb_info));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_PinRsp
-**
-** Description This function is called from UI after Security Manager submitted
-** PIN code request.
-**
-** Parameters: bd_addr - Address of the device for which PIN was requested
-** res - result of the operation BTM_SUCCESS if success
-** pin_len - length in bytes of the PIN Code
-** p_pin - pointer to array with the PIN Code
-** trusted_mask - bitwise OR of trusted services (array of UINT32)
-**
-*******************************************************************************/
-void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
-{
- BTM_PINCodeReply (bd_addr, res, pin_len, p_pin, trusted_mask);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_AuthorizeRsp
-**
-** Description This function is called from UI after Security Manager submitted
-** authorization request
-**
-** Parameters: bd_addr - Address of the device for which PIN was requested
-** res - result of the operation BTM_SUCCESS if success
-** trusted_mask - bitwise OR of trusted services (array of UINT32)
-**
-*******************************************************************************/
-void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res, UINT32 trusted_mask[])
-{
- BTM_DeviceAuthorized (bd_addr, res, trusted_mask);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_SetPairableMode
-**
-** Description This function is called to allow or disallow pairing
-** on the local device.
-**
-** Parameters: mode - GAP_ALLOW_PAIRING, GAP_DISALLOW_PAIRING
-** connect_only_pairable - TRUE or FALSE connect only to paired devices
-**
-** callback - The callback is called when a pin number is requested.
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-**
-*******************************************************************************/
-
-UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired)
-{
- tBTM_STATUS btm_status;
- UINT16 status = BT_PASS;
-
- if (mode == GAP_ALLOW_PAIRING)
- {
- btm_status = BTM_SetConnectability(BTM_CONNECTABLE, 0, 0);
-
- if ((status = gap_convert_btm_status (btm_status)) == BT_PASS)
- BTM_SetPairableMode (TRUE, connect_only_paired);
- }
- else if (mode == GAP_DISALLOW_PAIRING)
- {
- BTM_SetPairableMode (FALSE, connect_only_paired);
- }
- else
- {
- GAP_TRACE_ERROR ("GAP_SetPairableMode: illegal mode %d", mode);
- status = GAP_ERR_ILL_MODE;
- }
- return (status);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_StartInquiry
-**
-** Description This function initiates a single inquiry.
-**
-** Parameters: p_inqparms - pointer to the inquiry information
-** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry
-** duration - length in 1.28 sec intervals
-** max_resps - maximum amount of devices to search for before ending the inquiry
-** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or
-** GAP_FILTER_COND_BD_ADDR
-** filter_cond - value for the filter (based on filter_cond_type)
-**
-** p_results_cb - Pointer to the callback routine which gets called
-** upon receipt of an inquiry result. If this field is
-** NULL, the application is not notified.
-**
-** p_cmpl_cb - Pointer to the callback routine which gets called
-** upon completion. If this field is NULL, the
-** application is not notified when completed.
-**
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_MODE if a bad mode parameter was passed
-** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
-** GAP_ERR_NO_CTRL_BLK if out of control blocks
-** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
-** GAP_ERR_BUSY if the device already has an iquiry active
-** GAP_DEVICE_NOT_UP if the device is not initialized yet
-** GAP_ERR_PROCESSING if any other BTM error was returned
-**
-*******************************************************************************/
-UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms, tGAP_CALLBACK *p_results_cb, tGAP_CALLBACK *p_cmpl_cb)
-{
- tGAP_INFO *p_cb;
- tBTM_STATUS btm_status;
- UINT16 retval;
-
- /*** Make sure the parameters are valid before continuing ***/
- if (p_inq_parms->mode != GAP_GENERAL_INQUIRY && p_inq_parms->mode != GAP_LIMITED_INQUIRY)
- return (GAP_ERR_ILL_MODE);
-
- if (p_inq_parms->duration < GAP_MIN_INQUIRY_LEN ||
- p_inq_parms->duration > GAP_MAX_INQUIRY_LENGTH)
- return (GAP_ERR_ILL_INQ_TIME);
-
- /*** get a control block for this operation ***/
- if ((p_cb = gap_allocate_cb()) != NULL)
- {
- p_cb->gap_cback = p_cmpl_cb;
- p_cb->gap_inq_rslt_cback = p_results_cb;
- p_cb->event = GAP_EVT_INQUIRY_COMPLETE; /* Return event expected */
-
- btm_status = BTM_StartInquiry(p_inq_parms, gap_inq_results_cb,
- (tBTM_CMPL_CB *) gap_cb.btm_cback[p_cb->index]);
-
- /* convert the error code into a GAP code and check the results for any errors */
- if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED)
- gap_free_cb(p_cb); /* Error starting the inquiry */
- }
- else
- retval = GAP_ERR_NO_CTRL_BLK;
-
- return (retval);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_StartPeriodicInquiry
-**
-** Description This function initiates a periodic inquiry.
-**
-** Parameters: p_inqparms - pointer to the inquiry information
-** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry
-** duration - length in 1.28 sec intervals
-** max_resps - maximum amount of devices to search for before ending the inquiry
-** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or
-** GAP_FILTER_COND_BD_ADDR
-** filter_cond - value for the filter (based on filter_cond_type)
-**
-** min_time - Minimum amount of time between consecutive inquiries.
-** The value is in 1.28 second intervals.
-** Range: 0x0002 - 0xFFFE (2.56 - 83883.52 seconds)
-**
-** max_time - Maximum amount of time between consecutive inquiries.
-** The value is in 1.28 sec intervals.
-** Range: 0x0003 - 0xFFFF (3.84 - 83884.8 seconds)
-**
-** p_results_cb - Pointer to the callback routine which gets called
-** upon receipt of an inquiry result. If this field is
-** NULL, the application is not notified.
-**
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_MODE if a bad mode parameter was passed
-** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
-** GAP_ERR_NO_CTRL_BLK if out of control blocks
-** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
-** GAP_ERR_BUSY if the device already has an iquiry active
-** GAP_DEVICE_NOT_UP if the device is not initialized yet
-** GAP_ERR_PROCESSING if any other BTM error was returned
-**
-*******************************************************************************/
-
-UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms, UINT16 min_time,
- UINT16 max_time, tGAP_CALLBACK *p_results_cb)
-{
- tGAP_INFO *p_cb;
- tBTM_STATUS btm_status;
- UINT16 retval = BT_PASS;
-
- /*** Make sure the parameters are valid before continuing ***/
- if (p_inq_parms->mode != GAP_GENERAL_INQUIRY && p_inq_parms->mode != GAP_LIMITED_INQUIRY)
- return (GAP_ERR_ILL_MODE);
-
- if (p_inq_parms->duration < GAP_MIN_INQUIRY_LEN ||
- p_inq_parms->duration > GAP_MAX_INQUIRY_LENGTH ||
- min_time <= p_inq_parms->duration ||
- min_time < GAP_PER_INQ_MIN_MIN_PERIOD ||
- min_time > GAP_PER_INQ_MAX_MIN_PERIOD ||
- max_time <= min_time ||
- max_time < GAP_PER_INQ_MIN_MAX_PERIOD)
- {
- return (GAP_ERR_ILL_INQ_TIME);
- }
-
- /*** get a control block for this operation ***/
- if ((p_cb = gap_allocate_cb()) != NULL)
- {
- p_cb->gap_inq_rslt_cback = p_results_cb;
- p_cb->event = GAP_EVT_INQUIRY_COMPLETE; /* mark the inquiry event active */
-
- btm_status = BTM_SetPeriodicInquiryMode(p_inq_parms, max_time, min_time,
- gap_inq_results_cb);
-
- /* convert the error code into a GAP code and check the results for any errors */
- if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED)
- gap_free_cb(p_cb); /* Error starting the inquiry */
- }
- else
- retval = GAP_ERR_NO_CTRL_BLK;
-
- return (retval);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_CancelInquiry
-**
-** Description This function cancels a single inquiry (if in progress)
-**
-** Parameters: None
-**
-** Returns BOOLEAN (TRUE if successful, otherwise FALSE)
-**
-*******************************************************************************/
-UINT16 GAP_CancelInquiry(void)
-{
- tGAP_INFO *p_cb = &gap_cb.blk[0];
- UINT8 x;
- tBTM_STATUS btm_status;
- UINT16 status;
-
- btm_status = BTM_CancelInquiry();
- if ((status = gap_convert_btm_status (btm_status)) == BT_PASS)
- {
- /* Free the control block that is waiting for the inquiry complete event */
- for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++)
- {
- if (p_cb->in_use && p_cb->event == GAP_EVT_INQUIRY_COMPLETE)
- {
- gap_free_cb(p_cb);
- return (BT_PASS);
- }
- }
-
- /* If here the control block was not found */
- status = GAP_ERR_NO_CTRL_BLK;
- }
-
- return (status);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_CancelPeriodicInquiry
-**
-** Description This function cancels a periodic inquiry (if in progress)
-**
-** Parameters: None
-**
-** Returns BOOLEAN: (TRUE if successful, otherwise FALSE)
-**
-*******************************************************************************/
-UINT16 GAP_CancelPeriodicInquiry(void)
-{
- tGAP_INFO *p_cb = &gap_cb.blk[0];
- UINT8 x;
- tBTM_STATUS btm_status;
- UINT16 status;
-
- btm_status = BTM_CancelPeriodicInquiry();
- if ((status = gap_convert_btm_status (btm_status)) == BT_PASS)
- {
- /* Free the control block that is waiting for the inquiry complete event */
- for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++)
- {
- if (p_cb->in_use && p_cb->event == GAP_EVT_INQUIRY_COMPLETE)
- {
- gap_free_cb(p_cb);
- return (BT_PASS);
- }
- }
-
- /* If here the control block was not found */
- status = GAP_ERR_NO_CTRL_BLK;
- }
-
- return (status);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_GetFirstInquiryResult
-**
-** Description This function retrieves the first valid inquiry result.
-**
-** Parameters: p_results - pointer to the inquiry results
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-** GAP_EOINQDB if no more entries in the database.
-**
-*******************************************************************************/
-UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results)
-{
- UINT8 *ptr;
-
- gap_cb.cur_inqptr = BTM_InqFirstResult();
-
- if (gap_cb.cur_inqptr != NULL)
- {
- memcpy(p_results, &gap_cb.cur_inqptr->results, sizeof(tBTM_INQ_RESULTS));
-
- ptr = (UINT8 *)gap_cb.cur_inqptr->results.remote_bd_addr;
- GAP_TRACE_EVENT("GAP_GetFirstInqResult %02x%02x%02x%02x%02x%02x",
- ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5]);
- return(BT_PASS);
- }
- else
- {
- GAP_TRACE_EVENT("GAP_FirstInqResults: No BD_ADDRs Found");
- memset(p_results, 0, sizeof(tBTM_INQ_RESULTS));
- return(GAP_EOINQDB);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_GetNextInquiryResult
-**
-** Description This function retrieves the next valid inquiry result.
-**
-** Parameters: p_results - pointer to the inquiry results
-**
-** Returns BT_PASS (0) if successful, or a non-zero status code
-** GAP_EOINQDB if no more entries in the database.
-**
-*******************************************************************************/
-UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results)
-{
- UINT8 *ptr;
-
- /*** if the current inquiry db pointer is NULL then call the first entry ***/
- if (gap_cb.cur_inqptr)
- {
- gap_cb.cur_inqptr = BTM_InqNextResult(gap_cb.cur_inqptr);
- if (gap_cb.cur_inqptr != NULL)
- {
- memcpy(p_results, &gap_cb.cur_inqptr->results,
- sizeof(tGAP_INQ_RESULTS));
-
- ptr = (UINT8 *)gap_cb.cur_inqptr->results.remote_bd_addr;
- GAP_TRACE_EVENT("GAP_GetNextInqResult %02x%02x%02x%02x%02x%02x",
- ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5]);
-
- return(BT_PASS);
- }
- else
- {
- GAP_TRACE_EVENT("GAP_NextInqResults: No BD_ADDRs Found");
- memset(p_results, 0, sizeof(tBTM_INQ_RESULTS));
- return(GAP_EOINQDB);
- }
- }
- else
- return (GAP_GetFirstInquiryResult(p_results));
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ReadLocalDeviceInfo
-**
-** Description This function retrieves local device information to the caller.
-**
-** Parameters: name - (output) pointer to the UTF-8 encoded string representing
-** the device name.
-**
-** addr - (output) pointer to the Bluetooth device address (BD_ADDR).
-**
-** verinfo - (output) pointer to the LMP version information.
-**
-** features - (output) pointer to the LMP features for the device.
-**
-** NOTE: Return parameters that are set to NULL are not retrieved.
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-**
-*******************************************************************************/
-
-UINT16 GAP_ReadLocalDeviceInfo(UINT8 *name, BD_ADDR *addr, tGAP_LMP_VERSION *verinfo,
- tGAP_LMP_FEATURES *features)
-{
- UNUSED(name);
- UNUSED(addr);
- UNUSED(verinfo);
- UNUSED(features);
- return (GAP_UNSUPPORTED);
-}
-
-
-
-/*******************************************************************************
-**
-** Function GAP_GetRemoteDeviceName
-**
-** Description The remote name is retrieved from the specified remote device. If
-** GAP_CMD_INITIATED is returned by the function, the command was
-** successfully sent to the controller. The GAP_EVT_NAME_RESP event
-** is passed in the callback when the remote device name has been retrieved.
-**
-** Parameters: addr - The Bluetooth device address (BD_ADDR) of the remote
-** device.
-**
-** callback - pointer to the callback which is called after the
-** remote device has been retrieved.
-** p_data in the callback points to the structure containing the
-** status, device name length, and the UTF-8 encoded
-** device name. (type tBTM_REMOTE_DEV_NAME)
-** The event field in the callback is set to GAP_EVT_REM_NAME_COMPLETE.
-** The callback is not called unless (GAP_CMD_INITIATED) is returned.
-**
-**
-** Returns
-** GAP_CMD_INITIATED if remote search successfully initiated
-** GAP_ERR_BUSY if a remote name request is already in progress,
-** GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending)
-** GAP_BAD_BD_ADDR if the device address is bad,
-** GAP_DEVICE_NOT_UP if the device has not been initialized yet
-** GAP_ERR_PROCESSING if any other BTM error has been returned
-**
-*******************************************************************************/
-UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback)
-{
- tGAP_INFO *p_cb;
- UINT16 retval;
- tBTM_STATUS btm_status;
-
- if ((p_cb = gap_allocate_cb()) != NULL)
- {
- p_cb->gap_cback = callback;
- p_cb->event = GAP_EVT_REM_NAME_COMPLETE; /* Return event expected */
-
- btm_status = BTM_ReadRemoteDeviceName (addr, gap_cb.btm_cback[p_cb->index], BT_TRANSPORT_BR_EDR);
-
- /* If the name was not returned immediately, or if an error occurred, release the control block */
- if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED)
- gap_free_cb (p_cb);
- }
- else
- retval = GAP_ERR_NO_CTRL_BLK;
-
- return (retval);
-}
-
-/*******************************************************************************
-**
-** Function GAP_SetDeviceClass
-**
-** Description This function updates the local Device Class.
-**
-** Parameters:
-** p_cod - Pointer to the device class to set to
-**
-** cmd - the fields of the device class to update.
-** GAP_SET_COD_MAJOR_MINOR, - overwrite major, minor class
-** GAP_SET_COD_SERVICE_CLASS - set the bits in the input
-** GAP_CLR_COD_SERVICE_CLASS - clear the bits in the input
-** GAP_SET_COD_ALL - overwrite major, minor, set the bits in service class
-** GAP_INIT_COD - overwrite major, minor, and service class
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_BUSY if a discovery is already in progress
-** GAP_ERR_ILL_PARM if an illegal parameter was detected
-** GAP_ERR_PROCESSING if any other BTM error has been returned
-**
-*******************************************************************************/
-UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd)
-{
- tBTM_STATUS btm_status;
- UINT8 *dev;
- UINT16 service;
- UINT8 minor, major;
- DEV_CLASS dev_class;
-
- dev = BTM_ReadDeviceClass();
- BTM_COD_SERVICE_CLASS( service, dev );
- BTM_COD_MINOR_CLASS(minor, dev );
- BTM_COD_MAJOR_CLASS(major, dev );
-
- switch(cmd)
- {
- case GAP_SET_COD_MAJOR_MINOR:
- minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
- major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
- break;
-
- case GAP_SET_COD_SERVICE_CLASS:
- /* clear out the bits that is not SERVICE_CLASS bits */
- p_cod->service &= BTM_COD_SERVICE_CLASS_MASK;
- service = service | p_cod->service;
- break;
-
- case GAP_CLR_COD_SERVICE_CLASS:
- p_cod->service &= BTM_COD_SERVICE_CLASS_MASK;
- service = service & (~p_cod->service);
- break;
-
- case GAP_SET_COD_ALL:
- minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
- major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
- p_cod->service &= BTM_COD_SERVICE_CLASS_MASK;
- service = service | p_cod->service;
- break;
-
- case GAP_INIT_COD:
- minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
- major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
- service = p_cod->service & BTM_COD_SERVICE_CLASS_MASK;
- break;
-
- default:
- return GAP_ERR_ILL_PARM;
- }
-
- /* convert the fields into the device class type */
- FIELDS_TO_COD(dev_class, minor, major, service);
-
- btm_status = BTM_SetDeviceClass(dev_class);
- return (gap_convert_btm_status (btm_status));
-}
-
-/*******************************************************************************
-**
-** Function GAP_ReadDeviceClass
-**
-** Description This function reads the local Device Class.
-**
-** Parameters:
-**
-** Returns PASS
-**
-*******************************************************************************/
-UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod)
-{
- UINT8 *dev;
-
- dev = BTM_ReadDeviceClass();
-
- BTM_COD_SERVICE_CLASS( p_cod->service, dev );
- BTM_COD_MINOR_CLASS( p_cod->minor, dev );
- BTM_COD_MAJOR_CLASS( p_cod->major, dev );
-
- return (BT_PASS);
-}
+tGAP_CB gap_cb;
/*******************************************************************************
**
{
memset (&gap_cb, 0, sizeof (tGAP_CB));
- /*** Initialize the callbacks for BTM; Needs to be one per GAP_MAX_BLOCKS ***/
- gap_cb.btm_cback[0] = gap_btm_cback0;
-#if GAP_MAX_BLOCKS > 1
- gap_cb.btm_cback[1] = gap_btm_cback1;
-#endif
-#if GAP_MAX_BLOCKS > 2
- gap_cb.btm_cback[2] = gap_btm_cback2;
-#endif
-
#if defined(GAP_INITIAL_TRACE_LEVEL)
gap_cb.trace_level = GAP_INITIAL_TRACE_LEVEL;
#else
gap_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
#endif
- /* Initialize the connection control block if included in build */
-#if GAP_CONN_INCLUDED == TRUE
- gap_conn_init();
-#endif /* GAP_CONN_INCLUDED */
-
#if BLE_INCLUDED == TRUE
gap_attr_db_init();
#endif
+++ /dev/null
-/******************************************************************************
- *
- * Copyright (C) 2009-2013 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.
- *
- ******************************************************************************/
-
-
-#include "bt_target.h"
-#include "bt_utils.h"
-#include "btu.h"
-#include "fixed_queue.h"
-#include "gap_int.h"
-#include "l2cdefs.h"
-#include "l2c_int.h"
-#include <string.h>
-#if GAP_CONN_INCLUDED == TRUE
-#include "btm_int.h"
-
-extern fixed_queue_t *btu_hci_msg_queue;
-/********************************************************************************/
-/* L O C A L F U N C T I O N P R O T O T Y P E S */
-/********************************************************************************/
-static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id);
-static void gap_connect_cfm (UINT16 l2cap_cid, UINT16 result);
-static void gap_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg);
-static void gap_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg);
-static void gap_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed);
-static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg);
-static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested);
-
-static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid);
-static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle);
-static tGAP_CCB *gap_allocate_ccb (void);
-static void gap_release_ccb (tGAP_CCB *p_ccb);
-
-/*******************************************************************************
-**
-** Function gap_conn_init
-**
-** Description This function is called to initialize GAP connection management
-**
-** Returns void
-**
-*******************************************************************************/
-void gap_conn_init (void)
-{
-#if AMP_INCLUDED == TRUE
- gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = gap_connect_ind;
- gap_cb.conn.reg_info.pAMP_ConnectCfm_Cb = gap_connect_cfm;
- gap_cb.conn.reg_info.pAMP_ConnectPnd_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_ConfigInd_Cb = gap_config_ind;
- gap_cb.conn.reg_info.pAMP_ConfigCfm_Cb = gap_config_cfm;
- gap_cb.conn.reg_info.pAMP_DisconnectInd_Cb = gap_disconnect_ind;
- gap_cb.conn.reg_info.pAMP_DisconnectCfm_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_QoSViolationInd_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_DataInd_Cb = gap_data_ind;
- gap_cb.conn.reg_info.pAMP_CongestionStatus_Cb = gap_congestion_ind;
- gap_cb.conn.reg_info.pAMP_TxComplete_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_MoveInd_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_MoveRsp_Cb = NULL;
- gap_cb.conn.reg_info.pAMP_MoveCfm_Cb = NULL; //gap_move_cfm
- gap_cb.conn.reg_info.pAMP_MoveCfmRsp_Cb = NULL; //gap_move_cfm_rsp
-
-#else
- gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = gap_connect_ind;
- gap_cb.conn.reg_info.pL2CA_ConnectCfm_Cb = gap_connect_cfm;
- gap_cb.conn.reg_info.pL2CA_ConnectPnd_Cb = NULL;
- gap_cb.conn.reg_info.pL2CA_ConfigInd_Cb = gap_config_ind;
- gap_cb.conn.reg_info.pL2CA_ConfigCfm_Cb = gap_config_cfm;
- gap_cb.conn.reg_info.pL2CA_DisconnectInd_Cb = gap_disconnect_ind;
- gap_cb.conn.reg_info.pL2CA_DisconnectCfm_Cb = NULL;
- gap_cb.conn.reg_info.pL2CA_QoSViolationInd_Cb = NULL;
- gap_cb.conn.reg_info.pL2CA_DataInd_Cb = gap_data_ind;
- gap_cb.conn.reg_info.pL2CA_CongestionStatus_Cb = gap_congestion_ind;
- gap_cb.conn.reg_info.pL2CA_TxComplete_Cb = NULL;
-#endif
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnOpen
-**
-** Description This function is called to open an L2CAP connection.
-**
-** Parameters: is_server - If TRUE, the connection is not created
-** but put into a "listen" mode waiting for
-** the remote side to connect.
-**
-** service_id - Unique service ID from
-** BTM_SEC_SERVICE_FIRST_EMPTY (6)
-** to BTM_SEC_MAX_SERVICE_RECORDS (32)
-**
-** p_rem_bda - Pointer to remote BD Address.
-** If a server, and we don't care about the
-** remote BD Address, then NULL should be passed.
-**
-** psm - the PSM used for the connection
-**
-** p_config - Optional pointer to configuration structure.
-** If NULL, the default GAP configuration will
-** be used.
-**
-** security - security flags
-** chan_mode_mask - (GAP_FCR_CHAN_OPT_BASIC, GAP_FCR_CHAN_OPT_ERTM, GAP_FCR_CHAN_OPT_STREAM)
-**
-** p_cb - Pointer to callback function for events.
-**
-** Returns handle of the connection if successful, else GAP_INVALID_HANDLE
-**
-*******************************************************************************/
-UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
- BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
- UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb)
-{
- tGAP_CCB *p_ccb;
- UINT16 cid;
- tBT_UUID bt_uuid = {2, {GAP_PROTOCOL_ID}};
-
- GAP_TRACE_EVENT ("GAP_CONN - Open Request");
-
- /* Allocate a new CCB. Return if none available. */
- if ((p_ccb = gap_allocate_ccb()) == NULL)
- return (GAP_INVALID_HANDLE);
-
- /* If caller specified a BD address, save it */
- if (p_rem_bda)
- {
- /* the bd addr is not BT_BD_ANY, then a bd address was specified */
- if (memcmp (p_rem_bda, BT_BD_ANY, BD_ADDR_LEN))
- p_ccb->rem_addr_specified = TRUE;
-
- memcpy (&p_ccb->rem_dev_address[0], p_rem_bda, BD_ADDR_LEN);
- }
- else if (!is_server)
- {
- /* remore addr is not specified and is not a server -> bad */
- return (GAP_INVALID_HANDLE);
- }
-
- /* A client MUST have specified a bd addr to connect with */
- if (!p_ccb->rem_addr_specified && !is_server)
- {
- gap_release_ccb (p_ccb);
- GAP_TRACE_ERROR ("GAP ERROR: Client must specify a remote BD ADDR to connect to!");
- return (GAP_INVALID_HANDLE);
- }
-
- /* Check if configuration was specified */
- if (p_cfg)
- p_ccb->cfg = *p_cfg;
-
- p_ccb->p_callback = p_cb;
-
- /* If originator, use a dynamic PSM */
-#if AMP_INCLUDED == TRUE
- if (!is_server)
- gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = NULL;
- else
- gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = gap_connect_ind;
-#else
- if (!is_server)
- gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = NULL;
- else
- gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = gap_connect_ind;
-#endif
-
- /* Register the PSM with L2CAP */
- if ((p_ccb->psm = L2CA_REGISTER (psm, &gap_cb.conn.reg_info, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE)) == 0)
- {
- GAP_TRACE_ERROR ("GAP_ConnOpen: Failure registering PSM 0x%04x", psm);
- gap_release_ccb (p_ccb);
- return (GAP_INVALID_HANDLE);
- }
-
- /* Register with Security Manager for the specific security level */
- p_ccb->service_id = service_id;
- if (!BTM_SetSecurityLevel ((UINT8)!is_server, p_serv_name, p_ccb->service_id, security, p_ccb->psm, 0, 0))
- {
- GAP_TRACE_ERROR ("GAP_CONN - Security Error");
- gap_release_ccb (p_ccb);
- return (GAP_INVALID_HANDLE);
- }
-
- /* Fill in eL2CAP parameter data */
- if( p_ccb->cfg.fcr_present )
- {
- p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode;
- p_ccb->ertm_info.user_rx_pool_id = GAP_DATA_POOL_ID;
- p_ccb->ertm_info.user_tx_pool_id = GAP_DATA_POOL_ID;
- p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
- p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
- }
-
- /* optional FCR channel modes */
- p_ccb->ertm_info.allowed_modes = (chan_mode_mask) ? chan_mode_mask : (UINT8)L2CAP_FCR_CHAN_OPT_BASIC;
-
- if (is_server)
- {
- p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; /* assume btm/l2cap would handle it */
- p_ccb->con_state = GAP_CCB_STATE_LISTENING;
- return (p_ccb->gap_handle);
- }
- else
- {
- /* We are the originator of this connection */
- p_ccb->con_flags = GAP_CCB_FLAGS_IS_ORIG;
-
- /* Transition to the next appropriate state, waiting for connection confirm. */
- p_ccb->con_state = GAP_CCB_STATE_CONN_SETUP;
-
- /* mark security done flag, when security is not required */
- if ((security & (BTM_SEC_OUT_AUTHORIZE | BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT) ) == 0)
- p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
-
- /* Check if L2CAP started the connection process */
- if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info, &bt_uuid)) != 0))
- {
- p_ccb->connection_id = cid;
- return (p_ccb->gap_handle);
- }
- else
- {
- gap_release_ccb (p_ccb);
- return (GAP_INVALID_HANDLE);
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnClose
-**
-** Description This function is called to close a connection.
-**
-** Parameters: handle - Handle of the connection returned by GAP_ConnOpen
-**
-** Returns BT_PASS - closed OK
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-UINT16 GAP_ConnClose (UINT16 gap_handle)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
-
- GAP_TRACE_EVENT ("GAP_CONN - close handle: 0x%x", gap_handle);
-
- if (p_ccb)
- {
- /* Check if we have a connection ID */
- if (p_ccb->con_state != GAP_CCB_STATE_LISTENING)
- L2CA_DISCONNECT_REQ (p_ccb->connection_id);
-
- gap_release_ccb (p_ccb);
-
- return (BT_PASS);
- }
-
- return (GAP_ERR_BAD_HANDLE);
-}
-
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnReadData
-**
-** Description Normally not GKI aware application will call this function
-** after receiving GAP_EVT_RXDATA event.
-**
-** Parameters: handle - Handle of the connection returned in the Open
-** p_data - Data area
-** max_len - Byte count requested
-** p_len - Byte count received
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_NO_DATA_AVAIL - no data available
-**
-*******************************************************************************/
-UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT16 *p_len)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
- BT_HDR *p_buf;
- UINT16 copy_len;
-
- if (!p_ccb)
- return (GAP_ERR_BAD_HANDLE);
-
- *p_len = 0;
-
- p_buf = (BT_HDR *)GKI_getfirst (&p_ccb->rx_queue);
- if (!p_buf)
- return (GAP_NO_DATA_AVAIL);
-
- GKI_disable();
-
- while (max_len && p_buf)
- {
- copy_len = (p_buf->len > max_len)?max_len:p_buf->len;
- max_len -= copy_len;
- *p_len += copy_len;
- if (p_data)
- {
- memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, copy_len);
- p_data += copy_len;
- }
-
- if (p_buf->len > copy_len)
- {
- p_buf->offset += copy_len;
- p_buf->len -= copy_len;
- break;
- }
- else
- {
- if (max_len)
- {
- p_buf = (BT_HDR *)GKI_getnext (p_buf);
- }
- GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
- }
- }
-
- p_ccb->rx_queue_size -= *p_len;
-
- GKI_enable();
-
- GAP_TRACE_EVENT ("GAP_ConnReadData - rx_queue_size left=%d, *p_len=%d",
- p_ccb->rx_queue_size, *p_len);
-
- return (BT_PASS);
-}
-
-/*******************************************************************************
-**
-** Function GAP_GetRxQueueCnt
-**
-** Description This function return number of bytes on the rx queue.
-**
-** Parameters: handle - Handle returned in the GAP_ConnOpen
-** p_rx_queue_count - Pointer to return queue count in.
-**
-**
-*******************************************************************************/
-int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count)
-{
- tGAP_CCB *p_ccb;
- int rc = BT_PASS;
-
- /* Check that handle is valid */
- if (handle < GAP_MAX_CONNECTIONS)
- {
- p_ccb = &gap_cb.conn.ccb_pool[handle];
-
- if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
- {
- *p_rx_queue_count = p_ccb->rx_queue_size;
- }
- else
- rc = GAP_INVALID_HANDLE;
- }
- else
- rc = GAP_INVALID_HANDLE;
-
- GAP_TRACE_EVENT ("GAP_GetRxQueueCnt - rc = 0x%04x, rx_queue_count=%d",
- rc , *p_rx_queue_count);
-
- return (rc);
-}
-
-/*******************************************************************************
-**
-** Function GAP_ConnBTRead
-**
-** Description Bluetooth aware applications will call this function after receiving
-** GAP_EVT_RXDATA event.
-**
-** Parameters: handle - Handle of the connection returned in the Open
-** pp_buf - pointer to address of buffer with data,
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_NO_DATA_AVAIL - no data available
-**
-*******************************************************************************/
-UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
- BT_HDR *p_buf;
-
- if (!p_ccb)
- return (GAP_ERR_BAD_HANDLE);
-
- p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->rx_queue);
-
- if (p_buf)
- {
- *pp_buf = p_buf;
-
- p_ccb->rx_queue_size -= p_buf->len;
- return (BT_PASS);
- }
- else
- {
- *pp_buf = NULL;
- return (GAP_NO_DATA_AVAIL);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnBTWrite
-**
-** Description Bluetooth Aware applications can call this function to write data.
-**
-** Parameters: handle - Handle of the connection returned in the Open
-** p_buf - pointer to address of buffer with data,
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_ERR_BAD_STATE - connection not established
-** GAP_INVALID_BUF_OFFSET - buffer offset is invalid
-*******************************************************************************/
-UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
-
- if (!p_ccb)
- {
- GKI_freebuf (p_buf);
- return (GAP_ERR_BAD_HANDLE);
- }
-
- if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
- {
- GKI_freebuf (p_buf);
- return (GAP_ERR_BAD_STATE);
- }
-
- if (p_buf->offset < L2CAP_MIN_OFFSET)
- {
- GKI_freebuf (p_buf);
- return (GAP_ERR_BUF_OFFSET);
- }
-
- GKI_enqueue (&p_ccb->tx_queue, p_buf);
-
- if (p_ccb->is_congested)
- {
- return (BT_PASS);
- }
-
- /* Send the buffer through L2CAP */
-#if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
- gap_send_event (gap_handle);
-#else
- while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
- {
- UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
-
- if (status == L2CAP_DW_CONGESTED)
- {
- p_ccb->is_congested = TRUE;
- break;
- }
- else if (status != L2CAP_DW_SUCCESS)
- return (GAP_ERR_BAD_STATE);
- }
-#endif
- return (BT_PASS);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnWriteData
-**
-** Description Normally not GKI aware application will call this function
-** to send data to the connection.
-**
-** Parameters: handle - Handle of the connection returned in the Open
-** p_data - Data area
-** max_len - Byte count requested
-** p_len - Byte count received
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_ERR_BAD_STATE - connection not established
-** GAP_CONGESTION - system is congested
-**
-*******************************************************************************/
-UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT16 *p_len)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
- BT_HDR *p_buf;
-
- *p_len = 0;
-
- if (!p_ccb)
- return (GAP_ERR_BAD_HANDLE);
-
- if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
- return (GAP_ERR_BAD_STATE);
-
- while (max_len)
- {
- if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
- {
- if ((p_buf = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_tx_pool_id)) == NULL)
- return (GAP_ERR_CONGESTED);
- }
- else
- {
- if ((p_buf = (BT_HDR *)GKI_getpoolbuf (GAP_DATA_POOL_ID)) == NULL)
- return (GAP_ERR_CONGESTED);
- }
-
- p_buf->offset = L2CAP_MIN_OFFSET;
- p_buf->len = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len;
- p_buf->event = BT_EVT_TO_BTU_SP_DATA;
-
- memcpy ((UINT8 *)(p_buf + 1) + p_buf->offset, p_data, p_buf->len);
-
- *p_len += p_buf->len;
- max_len -= p_buf->len;
- p_data += p_buf->len;
-
- GAP_TRACE_EVENT ("GAP_WriteData %d bytes", p_buf->len);
-
- GKI_enqueue (&p_ccb->tx_queue, p_buf);
- }
-
- if (p_ccb->is_congested)
- {
- return (BT_PASS);
- }
-
- /* Send the buffer through L2CAP */
-#if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
- gap_send_event (gap_handle);
-#else
- while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
- {
- UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
-
- if (status == L2CAP_DW_CONGESTED)
- {
- p_ccb->is_congested = TRUE;
- break;
- }
- else if (status != L2CAP_DW_SUCCESS)
- return (GAP_ERR_BAD_STATE);
- }
-#endif
- return (BT_PASS);
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnReconfig
-**
-** Description Applications can call this function to reconfigure the connection.
-**
-** Parameters: handle - Handle of the connection
-** p_cfg - Pointer to new configuration
-**
-** Returns BT_PASS - config process started
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
-
- if (!p_ccb)
- return (GAP_ERR_BAD_HANDLE);
-
- p_ccb->cfg = *p_cfg;
-
- if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
- L2CA_CONFIG_REQ (p_ccb->connection_id, p_cfg);
-
- return (BT_PASS);
-}
-
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnSetIdleTimeout
-**
-** Description Higher layers call this function to set the idle timeout for
-** a connection, or for all future connections. The "idle timeout"
-** is the amount of time that a connection can remain up with
-** no L2CAP channels on it. A timeout of zero means that the
-** connection will be torn down immediately when the last channel
-** is removed. A timeout of 0xFFFF means no timeout. Values are
-** in seconds.
-**
-** Parameters: handle - Handle of the connection
-** timeout - in secs
-** 0 = immediate disconnect when last channel is removed
-** 0xFFFF = no idle timeout
-**
-** Returns BT_PASS - config process started
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout)
-{
- tGAP_CCB *p_ccb;
-
- if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
- return (GAP_ERR_BAD_HANDLE);
-
- if (L2CA_SetIdleTimeout (p_ccb->connection_id, timeout, FALSE))
- return (BT_PASS);
- else
- return (GAP_ERR_BAD_HANDLE);
-}
-
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetRemoteAddr
-**
-** Description This function is called to get the remote BD address
-** of a connection.
-**
-** Parameters: handle - Handle of the connection returned by GAP_ConnOpen
-**
-** Returns BT_PASS - closed OK
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
-
- GAP_TRACE_EVENT ("GAP_ConnGetRemoteAddr gap_handle = %d", gap_handle);
-
- if ((p_ccb) && (p_ccb->con_state > GAP_CCB_STATE_LISTENING))
- {
- GAP_TRACE_EVENT("GAP_ConnGetRemoteAddr bda :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", \
- p_ccb->rem_dev_address[0],p_ccb->rem_dev_address[1],p_ccb->rem_dev_address[2],
- p_ccb->rem_dev_address[3],p_ccb->rem_dev_address[4],p_ccb->rem_dev_address[5]);
- return (p_ccb->rem_dev_address);
- }
- else
- {
- GAP_TRACE_EVENT ("GAP_ConnGetRemoteAddr return Error ");
- return (NULL);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetRemMtuSize
-**
-** Description Returns the remote device's MTU size
-**
-** Parameters: handle - Handle of the connection
-**
-** Returns UINT16 - maximum size buffer that can be transmitted to the peer
-**
-*******************************************************************************/
-UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle)
-{
- tGAP_CCB *p_ccb;
-
- if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
- return (0);
-
- return (p_ccb->rem_mtu_size);
-}
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetL2CAPCid
-**
-** Description Returns the L2CAP channel id
-**
-** Parameters: handle - Handle of the connection
-**
-** Returns UINT16 - The L2CAP channel id
-** 0, if error
-**
-*******************************************************************************/
-UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle)
-{
- tGAP_CCB *p_ccb;
-
- if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
- return (0);
-
- return (p_ccb->connection_id);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_connect_ind
-**
-** Description This function handles an inbound connection indication
-** from L2CAP. This is the case where we are acting as a
-** server.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id)
-{
- UINT16 xx;
- tGAP_CCB *p_ccb;
- tBT_UUID bt_uuid = {2, {GAP_PROTOCOL_ID}};
-
- /* See if we have a CCB listening for the connection */
- for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
- {
- if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING)
- && (p_ccb->psm == psm)
- && ((p_ccb->rem_addr_specified == FALSE)
- || (!memcmp (bd_addr, p_ccb->rem_dev_address, BD_ADDR_LEN))))
- break;
- }
-
- if (xx == GAP_MAX_CONNECTIONS)
- {
- GAP_TRACE_WARNING("*******");
- GAP_TRACE_WARNING("WARNING: GAP Conn Indication for Unexpected Bd Addr...Disconnecting");
- GAP_TRACE_WARNING("*******");
-
- /* Disconnect because it is an unexpected connection */
- L2CA_DISCONNECT_REQ (l2cap_cid);
- return;
- }
-
- /* Transition to the next appropriate state, waiting for config setup. */
- p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
-
- /* Save the BD Address and Channel ID. */
- memcpy (&p_ccb->rem_dev_address[0], bd_addr, BD_ADDR_LEN);
- p_ccb->connection_id = l2cap_cid;
-
- /* Send response to the L2CAP layer. */
- L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info, &bt_uuid);
-
- GAP_TRACE_EVENT("GAP_CONN - Rcvd L2CAP conn ind, CID: 0x%x", p_ccb->connection_id);
-
- /* Send a Configuration Request. */
- L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
-}
-
-/*******************************************************************************
-**
-** Function gap_checks_con_flags
-**
-** Description This function processes the L2CAP configuration indication
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_checks_con_flags (tGAP_CCB *p_ccb)
-{
- GAP_TRACE_EVENT ("gap_checks_con_flags conn_flags:0x%x, ", p_ccb->con_flags);
- /* if all the required con_flags are set, report the OPEN event now */
- if ((p_ccb->con_flags & GAP_CCB_FLAGS_CONN_DONE) == GAP_CCB_FLAGS_CONN_DONE)
- {
- p_ccb->con_state = GAP_CCB_STATE_CONNECTED;
-
- p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_OPENED);
- }
-}
-
-/*******************************************************************************
-**
-** Function gap_sec_check_complete
-**
-** Description The function called when Security Manager finishes
-** verification of the service side connection
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_data, UINT8 res)
-{
- tGAP_CCB *p_ccb = (tGAP_CCB *)p_ref_data;
- UNUSED(bd_addr);
- UNUSED (transport);
-
- GAP_TRACE_EVENT ("gap_sec_check_complete conn_state:%d, conn_flags:0x%x, status:%d",
- p_ccb->con_state, p_ccb->con_flags, res);
- if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
- return;
-
- if (res == BTM_SUCCESS)
- {
- p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
- gap_checks_con_flags (p_ccb);
- }
- else
- {
- /* security failed - disconnect the channel */
- L2CA_DISCONNECT_REQ (p_ccb->connection_id);
- }
-}
-
-/*******************************************************************************
-**
-** Function gap_connect_cfm
-**
-** Description This function handles the connect confirm events
-** from L2CAP. This is the case when we are acting as a
-** client and have sent a connect request.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_connect_cfm (UINT16 l2cap_cid, UINT16 result)
-{
- tGAP_CCB *p_ccb;
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
- return;
-
- /* initiate security process, if needed */
- if ( (p_ccb->con_flags & GAP_CCB_FLAGS_SEC_DONE) == 0)
- {
- btm_sec_mx_access_request (p_ccb->rem_dev_address, p_ccb->psm, TRUE,
- 0, 0, &gap_sec_check_complete, p_ccb);
- }
-
- /* If the connection response contains success status, then */
- /* Transition to the next state and startup the timer. */
- if ((result == L2CAP_CONN_OK) && (p_ccb->con_state == GAP_CCB_STATE_CONN_SETUP))
- {
- p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
-
- /* Send a Configuration Request. */
- L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
- }
- else
- {
- /* Tell the user if he has a callback */
- if (p_ccb->p_callback)
- (*p_ccb->p_callback) (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
-
- gap_release_ccb (p_ccb);
- }
-}
-
-/*******************************************************************************
-**
-** Function gap_config_ind
-**
-** Description This function processes the L2CAP configuration indication
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
-{
- tGAP_CCB *p_ccb;
- UINT16 local_mtu_size;
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
- return;
-
- /* Remember the remote MTU size */
-
- if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
- {
- local_mtu_size = GKI_get_pool_bufsize (p_ccb->ertm_info.user_tx_pool_id)
- - sizeof(BT_HDR) - L2CAP_MIN_OFFSET;
- }
- else
- local_mtu_size = L2CAP_MTU_SIZE;
-
- if ((!p_cfg->mtu_present)||(p_cfg->mtu > local_mtu_size))
- {
- p_ccb->rem_mtu_size = local_mtu_size;
- }
- else
- p_ccb->rem_mtu_size = p_cfg->mtu;
-
- /* For now, always accept configuration from the other side */
- p_cfg->flush_to_present = FALSE;
- p_cfg->mtu_present = FALSE;
- p_cfg->result = L2CAP_CFG_OK;
- p_cfg->fcs_present = FALSE;
-
- L2CA_CONFIG_RSP (l2cap_cid, p_cfg);
-
- p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE;
-
- gap_checks_con_flags (p_ccb);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_config_cfm
-**
-** Description This function processes the L2CAP configuration confirmation
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
-{
- tGAP_CCB *p_ccb;
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
- return;
-
- if (p_cfg->result == L2CAP_CFG_OK)
- {
- p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE;
-
-
- if (p_ccb->cfg.fcr_present)
- p_ccb->cfg.fcr.mode = p_cfg->fcr.mode;
- else
- p_ccb->cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
-
- gap_checks_con_flags (p_ccb);
- }
- else
- {
- p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
- gap_release_ccb (p_ccb);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function gap_disconnect_ind
-**
-** Description This function handles a disconnect event from L2CAP. If
-** requested to, we ack the disconnect before dropping the CCB
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed)
-{
- tGAP_CCB *p_ccb;
-
- GAP_TRACE_EVENT ("GAP_CONN - Rcvd L2CAP disc, CID: 0x%x", l2cap_cid);
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
- return;
-
- if (ack_needed)
- L2CA_DISCONNECT_RSP (l2cap_cid);
-
- p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
- gap_release_ccb (p_ccb);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_data_ind
-**
-** Description This function is called when data is received from L2CAP.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
-{
- tGAP_CCB *p_ccb;
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
- {
- GKI_freebuf (p_msg);
- return;
- }
-
- if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
- {
- GKI_enqueue (&p_ccb->rx_queue, p_msg);
-
- p_ccb->rx_queue_size += p_msg->len;
- /*
- GAP_TRACE_EVENT ("gap_data_ind - rx_queue_size=%d, msg len=%d",
- p_ccb->rx_queue_size, p_msg->len);
- */
-
- p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL);
- }
- else
- {
- GKI_freebuf (p_msg);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function gap_congestion_ind
-**
-** Description This is a callback function called by L2CAP when
-** data L2CAP congestion status changes
-**
-*******************************************************************************/
-static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested)
-{
- tGAP_CCB *p_ccb;
- UINT16 event;
- BT_HDR *p_buf;
- UINT8 status;
-
- GAP_TRACE_EVENT ("GAP_CONN - Rcvd L2CAP Is Congested (%d), CID: 0x%x",
- is_congested, lcid);
-
- /* Find CCB based on CID */
- if ((p_ccb = gap_find_ccb_by_cid (lcid)) == NULL)
- return;
-
- p_ccb->is_congested = is_congested;
-
- event = (is_congested) ? GAP_EVT_CONN_CONGESTED : GAP_EVT_CONN_UNCONGESTED;
- p_ccb->p_callback (p_ccb->gap_handle, event);
-
- if (!is_congested)
- {
- while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
- {
- status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
-
- if (status == L2CAP_DW_CONGESTED)
- {
- p_ccb->is_congested = TRUE;
- break;
- }
- else if (status != L2CAP_DW_SUCCESS)
- break;
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function gap_find_ccb_by_cid
-**
-** Description This function searches the CCB table for an entry with the
-** passed CID.
-**
-** Returns the CCB address, or NULL if not found.
-**
-*******************************************************************************/
-static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid)
-{
- UINT16 xx;
- tGAP_CCB *p_ccb;
-
- /* Look through each connection control block */
- for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
- {
- if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->connection_id == cid))
- return (p_ccb);
- }
-
- /* If here, not found */
- return (NULL);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_find_ccb_by_handle
-**
-** Description This function searches the CCB table for an entry with the
-** passed handle.
-**
-** Returns the CCB address, or NULL if not found.
-**
-*******************************************************************************/
-static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle)
-{
- tGAP_CCB *p_ccb;
-
- /* Check that handle is valid */
- if (handle < GAP_MAX_CONNECTIONS)
- {
- p_ccb = &gap_cb.conn.ccb_pool[handle];
-
- if (p_ccb->con_state != GAP_CCB_STATE_IDLE)
- return (p_ccb);
- }
-
- /* If here, handle points to invalid connection */
- return (NULL);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_allocate_ccb
-**
-** Description This function allocates a new CCB.
-**
-** Returns CCB address, or NULL if none available.
-**
-*******************************************************************************/
-static tGAP_CCB *gap_allocate_ccb (void)
-{
- UINT16 xx;
- tGAP_CCB *p_ccb;
-
- /* Look through each connection control block for a free one */
- for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
- {
- if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
- {
- memset (p_ccb, 0, sizeof (tGAP_CCB));
-
- p_ccb->gap_handle = xx;
- p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
-
- return (p_ccb);
- }
- }
-
- /* If here, no free CCB found */
- return (NULL);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_release_ccb
-**
-** Description This function releases a CCB.
-**
-** Returns void
-**
-*******************************************************************************/
-static void gap_release_ccb (tGAP_CCB *p_ccb)
-{
- UINT16 xx;
- UINT16 psm = p_ccb->psm;
- UINT8 service_id = p_ccb->service_id;
-
- /* Drop any buffers we may be holding */
- p_ccb->rx_queue_size = 0;
-
- while (!GKI_queue_is_empty(&p_ccb->rx_queue))
- GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
-
- while (!GKI_queue_is_empty(&p_ccb->tx_queue))
- GKI_freebuf (GKI_dequeue (&p_ccb->tx_queue));
-
- p_ccb->con_state = GAP_CCB_STATE_IDLE;
-
- /* If no-one else is using the PSM, deregister from L2CAP */
- for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
- {
- if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->psm == psm))
- return;
- }
-
- /* Free the security record for this PSM */
- BTM_SecClrService(service_id);
- L2CA_DEREGISTER (psm);
-}
-
-#if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function gap_send_event
-**
-** Description Send BT_EVT_TO_GAP_MSG event to BTU task
-**
-** Returns None
-**
-*******************************************************************************/
-void gap_send_event (UINT16 gap_handle)
-{
- BT_HDR *p_msg;
-
- if ((p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE)) != NULL)
- {
- p_msg->event = BT_EVT_TO_GAP_MSG;
- p_msg->len = 0;
- p_msg->offset = 0;
- p_msg->layer_specific = gap_handle;
-
- fixed_queue_enqueue(btu_hci_msg_queue, p_msg);
- // Signal the target thread work is ready.
- GKI_send_event(BTU_TASK, (UINT16)EVENT_MASK(BTU_HCI_RCV_MBOX));
-
- }
- else
- {
- GAP_TRACE_ERROR("Unable to allocate message buffer for event.");
- }
-}
-
-/*******************************************************************************
-**
-** Function gap_proc_btu_event
-**
-** Description Event handler for BT_EVT_TO_GAP_MSG event from BTU task
-**
-** Returns None
-**
-*******************************************************************************/
-void gap_proc_btu_event(BT_HDR *p_msg)
-{
- tGAP_CCB *p_ccb = gap_find_ccb_by_handle (p_msg->layer_specific);
- UINT8 status;
- BT_HDR *p_buf;
-
- if (!p_ccb)
- {
- return;
- }
-
- if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
- {
- return;
- }
-
- if (p_ccb->is_congested)
- {
- return;
- }
-
- /* Send the buffer through L2CAP */
-
- while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
- {
- status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
-
- if (status == L2CAP_DW_CONGESTED)
- {
- p_ccb->is_congested = TRUE;
- break;
- }
- else if (status != L2CAP_DW_SUCCESS)
- break;
- }
-
-}
-#endif /* (GAP_CONN_POST_EVT_INCLUDED == TRUE) */
-#endif /* GAP_CONN_INCLUDED */
#include "bt_target.h"
#include "gap_api.h"
-#include "btm_api.h"
#include "gki.h"
#include "gatt_api.h"
-#if AMP_INCLUDED == TRUE
- #include "amp_api.h"
-#endif
-
-#if defined BLE_INCLUDED && BLE_INCLUDED == TRUE
- #include "gatt_api.h"
-#endif
-
-#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
-/* There must be a different btm callback for*/
-/* each control block.*/
-
-
-/* Definitions of limits for inquiries */
-#define GAP_PER_INQ_MIN_MAX_PERIOD BTM_PER_INQ_MIN_MAX_PERIOD
-#define GAP_PER_INQ_MAX_MAX_PERIOD BTM_PER_INQ_MAX_MAX_PERIOD
-#define GAP_PER_INQ_MIN_MIN_PERIOD BTM_PER_INQ_MIN_MIN_PERIOD
-#define GAP_PER_INQ_MAX_MIN_PERIOD BTM_PER_INQ_MAX_MIN_PERIOD
-#define GAP_MAX_INQUIRY_LENGTH BTM_MAX_INQUIRY_LENGTH
-#define GAP_MIN_INQUIRY_LEN BTM_MIN_INQUIRY_LEN
-
-/* Define the Generic Access Profile control structure */
-typedef struct
-{
- void *p_data; /* Pointer to any data returned in callback */
- tGAP_CALLBACK *gap_cback; /* Pointer to users callback function */
- tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */
- UINT16 event; /* Passed back in the callback */
- UINT8 index; /* Index of this control block and callback */
- BOOLEAN in_use; /* True when structure is allocated */
-} tGAP_INFO;
-
-/* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
-typedef struct
-{
- tGAP_CALLBACK *p_cback;
- tBTM_INQ_INFO *p_cur_inq; /* Pointer to the current inquiry database entry */
- tGAP_FINDADDR_RESULTS results;
- BOOLEAN in_use;
-} tGAP_FINDADDR_CB;
-
-
-/* Define the GAP Connection Control Block.
-*/
-typedef struct
-{
-#define GAP_CCB_STATE_IDLE 0
-#define GAP_CCB_STATE_LISTENING 1
-#define GAP_CCB_STATE_CONN_SETUP 2
-#define GAP_CCB_STATE_CFG_SETUP 3
-#define GAP_CCB_STATE_WAIT_SEC 4
-#define GAP_CCB_STATE_CONNECTED 5
- UINT8 con_state;
-
-#define GAP_CCB_FLAGS_IS_ORIG 0x01
-#define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02
-#define GAP_CCB_FLAGS_MY_CFG_DONE 0x04
-#define GAP_CCB_FLAGS_SEC_DONE 0x08
-#define GAP_CCB_FLAGS_CONN_DONE 0x0E
- UINT8 con_flags;
-
- UINT8 service_id; /* Used by BTM */
- UINT16 gap_handle; /* GAP handle */
- UINT16 connection_id; /* L2CAP CID */
- BOOLEAN rem_addr_specified;
- UINT8 chan_mode_mask; /* Supported channel modes (FCR) */
- BD_ADDR rem_dev_address;
- UINT16 psm;
- UINT16 rem_mtu_size;
-
- BOOLEAN is_congested;
- BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */
- BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */
-
- UINT32 rx_queue_size; /* Total data count in rx_queue */
-
- tGAP_CONN_CALLBACK *p_callback; /* Users callback function */
-
- tL2CAP_CFG_INFO cfg; /* Configuration */
- tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */
-} tGAP_CCB;
-
-typedef struct
-{
-#if AMP_INCLUDED == TRUE
- tAMP_APPL_INFO reg_info;
-#else
- tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */
-#endif
- tGAP_CCB ccb_pool[GAP_MAX_CONNECTIONS];
-} tGAP_CONN;
-
#if BLE_INCLUDED == TRUE
- #define GAP_MAX_CHAR_NUM 5
+#define GAP_MAX_CHAR_NUM 5
typedef struct
{
typedef struct
{
- tGAP_INFO blk[GAP_MAX_BLOCKS];
- tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS];
UINT8 trace_level;
- tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
- tBTM_INQ_INFO *cur_inqptr;
-
-#if GAP_CONN_INCLUDED == TRUE
- tGAP_CONN conn;
-#endif
/* LE GAP attribute database */
#if BLE_INCLUDED == TRUE
} tGAP_CB;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if GAP_DYNAMIC_MEMORY == FALSE
- extern tGAP_CB gap_cb;
-#else
- extern tGAP_CB *gap_cb_ptr;
-#define gap_cb (*gap_cb_ptr)
-#endif
-
- extern tGAP_INFO *gap_allocate_cb(void);
- extern void gap_free_cb(tGAP_INFO *p_cb);
-
- /* GAP inquiry functions */
- extern void gap_inq_results_cb(tGAP_INQ_RESULTS *p_results, UINT8 *p_eir);
- extern UINT16 gap_find_local_addr_by_name (const BD_NAME devname, BD_ADDR bd_addr);
- extern void gap_find_addr_inq_cb (tBTM_INQUIRY_CMPL *p);
-
- extern BOOLEAN gap_is_service_busy (UINT16 request);
- extern UINT16 gap_convert_btm_status (tBTM_STATUS btm_status);
-
- extern void gap_btm_cback0(void *p1);
-#if GAP_MAX_BLOCKS > 1
- extern void gap_btm_cback1(void *p1);
-#endif
-#if GAP_MAX_BLOCKS > 2
- extern void gap_btm_cback2(void *p1);
-#endif
-
-#if (GAP_CONN_INCLUDED == TRUE)
- extern void gap_conn_init(void);
-#if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
- void gap_send_event (UINT16 gap_handle);
- void gap_proc_btu_event(BT_HDR *p_msg);
-#endif
-#endif
+extern tGAP_CB gap_cb;
#if (BLE_INCLUDED == TRUE)
extern void gap_attr_db_init(void);
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif
+++ /dev/null
-/******************************************************************************
- *
- * Copyright (C) 2009-2013 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.
- *
- ******************************************************************************/
-
-#include <string.h>
-#include "bt_target.h"
-#include "bt_utils.h"
-#include "gap_int.h"
-
-/*****************************************************************************/
-/* G L O B A L GAP D A T A */
-/*****************************************************************************/
-#if GAP_DYNAMIC_MEMORY == FALSE
-tGAP_CB gap_cb;
-#endif
-
-/*****************************************************************************
-** 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)
-{
- UNUSED(devname);
- UNUSED(bd_addr);
- /* No data available because we are not automatically saving the data */
- return (GAP_NO_DATA_AVAIL);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_allocate_cb
-**
-** Description Look through the GAP Control Blocks for a free one.
-**
-** Returns Pointer to the control block or NULL if not found
-**
-*******************************************************************************/
-tGAP_INFO *gap_allocate_cb (void)
-{
- tGAP_INFO *p_cb = &gap_cb.blk[0];
- UINT8 x;
-
- for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++)
- {
- if (!p_cb->in_use)
- {
- memset (p_cb, 0, sizeof (tGAP_INFO));
-
- p_cb->in_use = TRUE;
- p_cb->index = x;
- p_cb->p_data = (void *)NULL;
- return (p_cb);
- }
- }
-
- /* If here, no free control blocks found */
- return (NULL);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_free_cb
-**
-** Description Release GAP control block.
-**
-** Returns Pointer to the control block or NULL if not found
-**
-*******************************************************************************/
-void gap_free_cb (tGAP_INFO *p_cb)
-{
- if (p_cb)
- {
- p_cb->gap_cback = NULL;
- p_cb->in_use = FALSE;
- }
-}
-
-
-/*******************************************************************************
-**
-** Function gap_is_service_busy
-**
-** Description Look through the GAP Control Blocks that are in use
-** and check to see if the event waiting for is the command
-** requested.
-**
-** Returns TRUE if already in use
-** FALSE if not busy
-**
-*******************************************************************************/
-BOOLEAN gap_is_service_busy (UINT16 request)
-{
- tGAP_INFO *p_cb = &gap_cb.blk[0];
- UINT8 x;
-
- for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++)
- {
- if (p_cb->in_use && p_cb->event == request)
- return (TRUE);
- }
-
- /* If here, service is not busy */
- return (FALSE);
-}
-
-
-/*******************************************************************************
-**
-** Function gap_convert_btm_status
-**
-** Description Converts a BTM error status into a GAP error status
-**
-**
-** Returns GAP_UNKNOWN_BTM_STATUS is returned if not recognized
-**
-*******************************************************************************/
-UINT16 gap_convert_btm_status (tBTM_STATUS btm_status)
-{
- switch (btm_status)
- {
- case BTM_SUCCESS:
- return (BT_PASS);
-
- case BTM_CMD_STARTED:
- return (GAP_CMD_INITIATED);
-
- case BTM_BUSY:
- return (GAP_ERR_BUSY);
-
- case BTM_MODE_UNSUPPORTED:
- case BTM_ILLEGAL_VALUE:
- return (GAP_ERR_ILL_PARM);
-
- case BTM_WRONG_MODE:
- return (GAP_DEVICE_NOT_UP);
-
- case BTM_UNKNOWN_ADDR:
- return (GAP_BAD_BD_ADDR);
-
- case BTM_DEVICE_TIMEOUT:
- return (GAP_ERR_TIMEOUT);
-
- default:
- return (GAP_ERR_PROCESSING);
- }
-}
#define FTP_DYNAMIC_MEMORY FALSE
#endif
-#ifndef GAP_DYNAMIC_MEMORY
-#define GAP_DYNAMIC_MEMORY FALSE
-#endif
-
#ifndef GOEP_DYNAMIC_MEMORY
#define GOEP_DYNAMIC_MEMORY FALSE
#endif
#ifndef GAP_API_H
#define GAP_API_H
-#include "profiles_api.h"
-#include "btm_api.h"
-#include "l2c_api.h"
-
/*****************************************************************************
** Constants
*****************************************************************************/
-/*** GAP Error and Status Codes ***/
-#define GAP_UNSUPPORTED (GAP_ERR_GRP + 0x01) /* Unsupported call */
-#define GAP_EOINQDB (GAP_ERR_GRP + 0x02) /* End of inquiry database marker */
-#define GAP_ERR_BUSY (GAP_ERR_GRP + 0x03) /* The requested function was busy */
-#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04) /* No control blocks available */
-#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05) /* Error occurred while initiating the command */
-#define GAP_NO_BDADDR_REC (GAP_ERR_GRP + 0x06) /* No Inquiry DB record for BD_ADDR */
-#define GAP_ERR_ILL_MODE (GAP_ERR_GRP + 0x07) /* An illegal mode parameter was detected */
-#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08) /* An illegal time parameter was detected */
-#define GAP_ERR_ILL_PARM (GAP_ERR_GRP + 0x09) /* An illegal parameter was detected */
-#define GAP_ERR_REM_NAME (GAP_ERR_GRP + 0x0a) /* Error starting the remote device name request */
-#define GAP_CMD_INITIATED (GAP_ERR_GRP + 0x0b) /* The GAP command was started (result pending) */
-#define GAP_DEVICE_NOT_UP (GAP_ERR_GRP + 0x0c) /* The device was not up; the request was not executed */
-#define GAP_BAD_BD_ADDR (GAP_ERR_GRP + 0x0d) /* The bd addr passed in was not found or invalid */
-
-#define GAP_ERR_BAD_HANDLE (GAP_ERR_GRP + 0x0e) /* Bad GAP handle */
-#define GAP_ERR_BUF_OFFSET (GAP_ERR_GRP + 0x0f) /* Buffer offset invalid */
-#define GAP_ERR_BAD_STATE (GAP_ERR_GRP + 0x10) /* Connection is in invalid state */
-#define GAP_NO_DATA_AVAIL (GAP_ERR_GRP + 0x11) /* No data available */
-#define GAP_ERR_CONGESTED (GAP_ERR_GRP + 0x12) /* BT stack is congested */
-#define GAP_ERR_SECURITY (GAP_ERR_GRP + 0x13) /* Security failed */
-
-#define GAP_ERR_PROCESSING (GAP_ERR_GRP + 0x14) /* General error processing BTM request */
-#define GAP_ERR_TIMEOUT (GAP_ERR_GRP + 0x15) /* Timeout occurred while processing cmd */
-
-/** GAP Events - definitions of GAP return events ***/
-#define GAP_EVT_INQUIRY_RESULTS 0x0001
-#define GAP_EVT_INQUIRY_COMPLETE 0x0002
-#define GAP_EVT_DISCOVERY_COMPLETE 0x0003
-#define GAP_EVT_REM_NAME_COMPLETE 0x0004
-#define GAP_EVT_FIND_ADDR_COMPLETE 0x0005
-
-#define GAP_EVT_CONN_OPENED 0x0100
-#define GAP_EVT_CONN_CLOSED 0x0101
-#define GAP_EVT_CONN_DATA_AVAIL 0x0102
-#define GAP_EVT_CONN_CONGESTED 0x0103
-#define GAP_EVT_CONN_UNCONGESTED 0x0104
-
-/* Values for 'chan_mode_mask' field */
-/* GAP_ConnOpen() - optional channels to negotiate */
-#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC
-#define GAP_FCR_CHAN_OPT_ERTM L2CAP_FCR_CHAN_OPT_ERTM
-#define GAP_FCR_CHAN_OPT_STREAM L2CAP_FCR_CHAN_OPT_STREAM
-
-/*** discovery of devices ***/
-#define GAP_INQUIRY_NONE BTM_INQUIRY_NONE
-#define GAP_GENERAL_INQUIRY BTM_GENERAL_INQUIRY
-#define GAP_LIMITED_INQUIRY BTM_LIMITED_INQUIRY
-
-#if BLE_INCLUDED == TRUE
-#define GAP_BLE_INQUIRY_NONE BTM_BLE_INQUIRY_NONE
-#define GAP_BLE_GENERAL_INQUIRY BTM_BLE_GENERAL_INQUIRY
-#define GAP_BLE_LIMITED_INQUIRY BTM_BLE_LIMITED_INQUIRY
-#endif
-
-/*** discoverable modes ***/
-#define GAP_NON_DISCOVERABLE BTM_NON_DISCOVERABLE
-#define GAP_LIMITED_DISCOVERABLE BTM_LIMITED_DISCOVERABLE
-#define GAP_GENERAL_DISCOVERABLE BTM_GENERAL_DISCOVERABLE
-
-/*** Inquiry Filter Condition types (The values are defined in btm_api.h) ***/
-#define GAP_CLR_INQUIRY_FILTER BTM_CLR_INQUIRY_FILTER /* Inquiry Filtering is turned off */
-#define GAP_FILTER_COND_DEVICE_CLASS BTM_FILTER_COND_DEVICE_CLASS /* Filter on device class */
-#define GAP_FILTER_COND_BD_ADDR BTM_FILTER_COND_BD_ADDR /* Filter on device addr */
-
-/*** connectability ***/
-#define GAP_NON_CONNECTABLE BTM_NON_CONNECTABLE
-#define GAP_CONNECTABLE BTM_CONNECTABLE
-
-/*** security features ***/
-#define GAP_DISALLOW_PAIRING 0
-#define GAP_ALLOW_PAIRING 1
-
-/*** class of device settings ***/
-#define GAP_SET_COD_MAJOR_MINOR 0x01
-#define GAP_SET_COD_SERVICE_CLASS 0x02 /* only set the bits in the input */
-#define GAP_CLR_COD_SERVICE_CLASS 0x04
-#define GAP_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */
-#define GAP_INIT_COD 0x0a
-
-/*** used in connection variables and functions ***/
-#define GAP_INVALID_HANDLE 0xFFFF
-
-/* This is used to change the criteria for AMP */
-#define GAP_PROTOCOL_ID (UUID_PROTOCOL_UDP)
-
-/* slave preferred parameter, minimum connection interval */
-#ifndef GAP_SL_CONN_INT_MIN
-#define GAP_SL_CONN_INT_MIN 6
-#endif
-/* slave preferred parameter, maximum connection interval */
-#ifndef GAP_SL_CONN_INT_MAX
-#define GAP_SL_CONN_INT_MAX 20
-#endif
-/* slave preferred parameter */
-#ifndef GAP_SL_LATENCY
-#define GAP_SL_LATENCY 2
-#endif
-
-#ifndef GAP_BLE_PRIVACY_RECONN_ADDR_PERM
-#define GAP_BLE_PRIVACY_RECONN_ADDR_PERM (GATT_PERM_READ|GATT_PERM_WRITE)
-#endif
-
#ifndef GAP_PREFER_CONN_INT_MAX
#define GAP_PREFER_CONN_INT_MAX BTM_BLE_CONN_INT_MIN
#endif
/*****************************************************************************
** Type Definitions
*****************************************************************************/
-/*
-** Callback function for connection services
-*/
-typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
-
-/*
-** Define the callback function prototypes. Parameters are specific
-** to each event and are described below
-*/
-typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
-
-typedef tBTM_REMOTE_DEV_NAME tGAP_REMOTE_DEV_NAME; /* see btm_api.h */
-typedef tBTM_INQ_PARMS tGAP_INQ_PARMS; /* see btm_api.h */
-typedef tBTM_INQ_RESULTS tGAP_INQ_RESULTS; /* see btm_api.h */
-
-/* Inquiry results structure */
-typedef struct
-{
- UINT16 status;
- UINT8 num_results;
-} tGAP_INQ_CMPL;
-
-/* Definition of the GAP_FindAddrByName results structure */
-typedef struct
-{
- UINT16 status;
- BD_ADDR bd_addr;
- tBTM_BD_NAME devname;
-} tGAP_FINDADDR_RESULTS;
-
-/** for GAP_SetDeviceClass() **/
-/* Define Class of Device related values
- *
- * >>> changes to this type need to also be made to tHSP_COD in hsp2_int.h
- */
-typedef struct
-{
- UINT8 minor;
- UINT8 major;
- UINT16 service;
-} tGAP_COD;
-
-/*** Constants and functions for device features ***/
-typedef struct
-{
- UINT8 lmp_version;
- UINT16 mfc_name;
- UINT16 lmp_subversion;
-} tGAP_LMP_VERSION;
-
-typedef struct
-{
- UINT8 lmp_features[8];
-} tGAP_LMP_FEATURES;
typedef struct
{
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function GAP_SetDiscoverableMode
-**
-** Description This function is called to allow or disallow a service to
-** discovered (Inquiry Scans).
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_PARM if a bad parameter is detected,
-** GAP_DEVICE_NOT_UP if the device is not active,
-** GAP_ERR_PROCESSING if not enough resources to carry out request
-**
-*******************************************************************************/
-extern UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration,
- UINT16 interval);
-
-/*******************************************************************************
-**
-** Function GAP_ReadDiscoverableMode
-**
-** Description This function is called to retrieve the current discoverable
-** mode for the local device.
-**
-** Returns GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or
-** GAP_GENERAL_DISCOVERABLE
-**
-*******************************************************************************/
-extern UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval);
-
-/*******************************************************************************
-**
-** Function GAP_StartInquiry
-**
-** Description This function initiates a single inquiry.
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_MODE if a bad mode parameter was passed
-** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
-** GAP_ERR_NO_CTRL_BLK if out of control blocks
-** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
-** GAP_ERR_BUSY if the device already has an iquiry active
-** GAP_DEVICE_NOT_UP if the device is not initialized yet
-** GAP_ERR_PROCESSING if any other BTM error was returned
-**
-*******************************************************************************/
-extern UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms,
- tGAP_CALLBACK *p_results_cb,
- tGAP_CALLBACK *p_cmpl_cb);
-
-/*******************************************************************************
-**
-** Function GAP_StartPeriodicInquiry
-**
-** Description This function initiates a periodic inquiry.
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_MODE if a bad mode parameter was passed
-** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
-** GAP_ERR_NO_CTRL_BLK if out of control blocks
-** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
-** GAP_ERR_BUSY if the device already has an iquiry active
-** GAP_DEVICE_NOT_UP if the device is not initialized yet
-** GAP_ERR_PROCESSING if any other BTM error was returned
-**
-*******************************************************************************/
-extern UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms,
- UINT16 min_time,
- UINT16 max_time,
- tGAP_CALLBACK *p_results_cb);
-
-/*******************************************************************************
-**
-** Function GAP_CancelInquiry
-**
-** Description This function cancels a single inquiry (if in progress)
-**
-** Returns BOOLEAN (TRUE if successful, otherwise FALSE)
-**
-*******************************************************************************/
-extern UINT16 GAP_CancelInquiry(void);
-
-/*******************************************************************************
-**
-** Function GAP_CancelPeriodicInquiry
-**
-** Description This function cancels a periodic inquiry (if in progress)
-**
-** Returns BOOLEAN: (TRUE if successful, otherwise FALSE)
-**
-*******************************************************************************/
-extern UINT16 GAP_CancelPeriodicInquiry(void);
-
-/*******************************************************************************
-**
-** Function GAP_GetFirstInquiryResult
-**
-** Description This function retrieves the first valid inquiry result.
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-** GAP_EOINQDB if no more entries in the database.
-**
-*******************************************************************************/
-extern UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results);
-
-/*******************************************************************************
-**
-** Function GAP_GetNextInquiryResult
-**
-** Description This function retrieves the next valid inquiry result.
-**
-** Returns BT_PASS (0) if successful, or a non-zero status code
-** GAP_EOINQDB if no more entries in the database.
-**
-*******************************************************************************/
-extern UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results);
-
-/*******************************************************************************
-**
-** Function GAP_FindAddrByName
-**
-** Description This function is called to retrieve a device address given
-** a device name. It first looks in the current local inquiry
-** database for the device with the specified name. If not found
-** it initiates a general inquiry. Upon completion, it retrieves
-** the name for each device until a match is found or all devices
-** have been checked. Note: This process can take a while to
-** complete.
-**
-** Returns BT_PASS if the name was immediately available. (BD_ADDR is returned)
-** GAP_CMD_INITIATED if an inquiry has been initiated
-**
-*******************************************************************************/
-extern UINT16 GAP_FindAddrByName (BD_NAME devname,
- tGAP_INQ_PARMS *p_inq_parms,
- tGAP_CALLBACK *p_addr_cb,
- BD_ADDR bd_addr);
-
-/*******************************************************************************
-**
-** Function GAP_SetConnectableMode
-**
-** Description This function is called to allow or disallow a
-** connections on the local device.
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_ILL_PARM if a bad parameter is detected,
-** GAP_DEVICE_NOT_UP if the device is not active,
-** GAP_ERR_PROCESSING if not enough resources to carry out request
-**
-*******************************************************************************/
-extern UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration,
- UINT16 interval);
-
-/*******************************************************************************
-**
-** Function GAP_ReadConnectableMode
-**
-** Description This function is called to retrieve the current connectability
-** mode for the local device.
-**
-** Returns GAP_NON_CONNECTABLE, GAP_CONNECTABLE
-**
-*******************************************************************************/
-extern UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval);
-
-/*******************************************************************************
-**
-** Function GAP_SecRegister
-**
-** Description Application calls this function to register for
-** security services.
-**
-** Returns TRUE if registered OK, else FALSE
-**
-*******************************************************************************/
-extern BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info);
-
-/*******************************************************************************
-**
-** Function GAP_SetPairableMode
-**
-** Description This function is called to allow or disallow pairing
-** on the local device.
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-**
-*******************************************************************************/
-extern UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired);
-
-/*******************************************************************************
-**
-** Function GAP_Bond
-**
-** Description This function is called to initiate bonding with peer device
-**
-** Parameters: bd_addr - Address of the device to bond
-** pin_len - length in bytes of the PIN Code
-** p_pin - pointer to array with the PIN Code
-** trusted_mask - bitwise OR of trusted services (array of UINT32)
-**
-** Returns tBTM_STATUS - BTM_CMD_STARTED of successfully initiated
-**
-*******************************************************************************/
-extern UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len,
- UINT8 *p_pin, UINT32 trusted_mask[]);
-
-/*******************************************************************************
-**
-** Function GAP_PinRsp
-**
-** Description This function is called from UI after Security Manager submitted
-** PIN code request.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
- UINT8 *p_pin, UINT32 trusted_mask[]);
-
-/*******************************************************************************
-**
-** Function GAP_AuthorizeRsp
-**
-** Description This function is called from UI after Security Manager submitted
-** an authorization request.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res,
- UINT32 trusted_mask[]);
-
-/*******************************************************************************
-**
-** Function GAP_SetDeviceClass
-**
-** Description This function updates the local Device Class.
-**
-** Returns BT_PASS (0) if successful,
-** GAP_ERR_BUSY if a discovery is already in progress
-** GAP_ERR_ILL_PARM if an illegal parameter was detected
-** GAP_ERR_PROCESSING if any other BTM error has been returned
-**
-*******************************************************************************/
-extern UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd);
-
-/*******************************************************************************
-**
-** Function GAP_ReadDeviceClass
-**
-** Description This function reads the current local Device Class setting.
-**
-** Returns BT_PASS
-**
-*******************************************************************************/
-extern UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod);
-
-/*******************************************************************************
-**
-** Function GAP_ReadLocalDeviceInfo
-**
-** Description This function retrieves local device information to the caller.
-** NOTE: Return parameters that are set to NULL are not retrieved.
-**
-** Returns BT_PASS (0) if successful, or a non-zero error code
-**
-*******************************************************************************/
-extern UINT16 GAP_ReadLocalDeviceInfo( UINT8 *name, BD_ADDR *addr,
- tGAP_LMP_VERSION *verinfo,
- tGAP_LMP_FEATURES *features);
-
-
-/*******************************************************************************
-**
-** Function GAP_GetRemoteDeviceName
-**
-** Description The remote name is retrieved from the specified remote device. If
-** GAP_CMD_INITIATED is returned by the function, the command was
-** successfully sent to the controller. The GAP_EVT_NAME_RESP event
-** is passed in the callback when the remote device name has been retrieved.
-**
-** Returns
-** GAP_CMD_INITIATED if remote search successfully initiated
-** GAP_ERR_BUSY if a remote name request is already in progress,
-** GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending)
-** GAP_BAD_BD_ADDR if the device address is bad,
-** GAP_DEVICE_NOT_UP if the device has not been initialized yet
-** GAP_ERR_PROCESSING if any other BTM error has been returned
-**
-*******************************************************************************/
-extern UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback);
-
-/*** Functions for L2CAP connection interface ***/
-/*******************************************************************************
-**
-** Function GAP_ConnOpen
-**
-** Description This function is called to open a generic L2CAP connection.
-**
-** Returns handle of the connection if successful, else GAP_INVALID_HANDLE
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
- BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
- UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
-
-/*******************************************************************************
-**
-** Function GAP_ConnClose
-**
-** Description This function is called to close a connection.
-**
-** Returns BT_PASS - closed OK
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnClose (UINT16 gap_handle);
-
-/*******************************************************************************
-**
-** Function GAP_ConnReadData
-**
-** Description GKI buffer unaware application will call this function
-** after receiving GAP_EVT_RXDATA event. A data copy is made
-** into the receive buffer parameter.
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_NO_DATA_AVAIL - no data available
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
- UINT16 max_len, UINT16 *p_len);
-
-/*******************************************************************************
-**
-** Function GAP_GetRxQueueCnt
-**
-** Description This function return number of bytes on the rx queue.
-**
-** Parameters: handle - Handle returned in the GAP_ConnOpen
-** p_rx_queue_count - Pointer to return queue count in.
-**
-**
-*******************************************************************************/
-extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
-
-/*******************************************************************************
-**
-** Function GAP_ConnBTRead
-**
-** Description GKI buffer aware applications will call this function after
-** receiving an GAP_EVT_RXDATA event to process the incoming
-** data buffer.
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_NO_DATA_AVAIL - no data available
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
-
-/*******************************************************************************
-**
-** Function GAP_ConnBTWrite
-**
-** Description GKI buffer aware applications can call this function to write data
-** by passing a pointer to the GKI buffer of data.
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_ERR_BAD_STATE - connection not established
-** GAP_INVALID_BUF_OFFSET - buffer offset is invalid
-*******************************************************************************/
-extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
-
-/*******************************************************************************
-**
-** Function GAP_ConnWriteData
-**
-** Description GKI buffer unaware application will call this function
-** to send data to the connection. A data copy is made into a GKI
-** buffer.
-**
-** Returns BT_PASS - data read
-** GAP_ERR_BAD_HANDLE - invalid handle
-** GAP_ERR_BAD_STATE - connection not established
-** GAP_CONGESTION - system is congested
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
- UINT16 max_len, UINT16 *p_len);
-
-/*******************************************************************************
-**
-** Function GAP_ConnReconfig
-**
-** Description Applications can call this function to reconfigure the connection.
-**
-** Returns BT_PASS - config process started
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
-
-/*******************************************************************************
-**
-** Function GAP_ConnSetIdleTimeout
-**
-** Description Higher layers call this function to set the idle timeout for
-** a connection, or for all future connections. The "idle timeout"
-** is the amount of time that a connection can remain up with
-** no L2CAP channels on it. A timeout of zero means that the
-** connection will be torn down immediately when the last channel
-** is removed. A timeout of 0xFFFF means no timeout. Values are
-** in seconds.
-**
-** Returns BT_PASS - config process started
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetRemoteAddr
-**
-** Description This function is called to get the remote BD address
-** of a connection.
-**
-** Returns BT_PASS - closed OK
-** GAP_ERR_BAD_HANDLE - invalid handle
-**
-*******************************************************************************/
-extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetRemMtuSize
-**
-** Description Returns the remote device's MTU size.
-**
-** Returns UINT16 - maximum size buffer that can be transmitted to the peer
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
-
-/*******************************************************************************
-**
-** Function GAP_ConnGetL2CAPCid
-**
-** Description Returns the L2CAP channel id
-**
-** Parameters: handle - Handle of the connection
-**
-** Returns UINT16 - The L2CAP channel id
-** 0, if error
-**
-*******************************************************************************/
-extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
/*******************************************************************************
**
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GAP_API_H */