1/******************************************************************************
2 *
3 *  Copyright (C) 2009-2013 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#ifndef GAP_API_H
20#define GAP_API_H
21
22#include "profiles_api.h"
23#include "btm_api.h"
24#include "l2c_api.h"
25
26/*****************************************************************************
27**  Constants
28*****************************************************************************/
29
30/*** GAP Error and Status Codes ***/
31#define GAP_UNSUPPORTED     (GAP_ERR_GRP + 0x01)    /* Unsupported call */
32#define GAP_EOINQDB         (GAP_ERR_GRP + 0x02)    /* End of inquiry database marker */
33#define GAP_ERR_BUSY        (GAP_ERR_GRP + 0x03)    /* The requested function was busy */
34#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04)    /* No control blocks available */
35#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05)   /* Error occurred while initiating the command */
36#define GAP_NO_BDADDR_REC   (GAP_ERR_GRP + 0x06)    /* No Inquiry DB record for BD_ADDR */
37#define GAP_ERR_ILL_MODE    (GAP_ERR_GRP + 0x07)    /* An illegal mode parameter was detected */
38#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08)   /* An illegal time parameter was detected */
39#define GAP_ERR_ILL_PARM     (GAP_ERR_GRP + 0x09)   /* An illegal parameter was detected */
40#define GAP_ERR_REM_NAME    (GAP_ERR_GRP + 0x0a)    /* Error starting the remote device name request */
41#define GAP_CMD_INITIATED   (GAP_ERR_GRP + 0x0b)    /* The GAP command was started (result pending) */
42#define GAP_DEVICE_NOT_UP   (GAP_ERR_GRP + 0x0c)    /* The device was not up; the request was not executed */
43#define GAP_BAD_BD_ADDR     (GAP_ERR_GRP + 0x0d)    /* The bd addr passed in was not found or invalid */
44
45#define GAP_ERR_BAD_HANDLE  (GAP_ERR_GRP + 0x0e)    /* Bad GAP handle                       */
46#define GAP_ERR_BUF_OFFSET  (GAP_ERR_GRP + 0x0f)    /* Buffer offset invalid                */
47#define GAP_ERR_BAD_STATE   (GAP_ERR_GRP + 0x10)    /* Connection is in invalid state       */
48#define GAP_NO_DATA_AVAIL   (GAP_ERR_GRP + 0x11)    /* No data available                    */
49#define GAP_ERR_CONGESTED   (GAP_ERR_GRP + 0x12)    /* BT stack is congested                */
50#define GAP_ERR_SECURITY    (GAP_ERR_GRP + 0x13)    /* Security failed                      */
51
52#define GAP_ERR_PROCESSING  (GAP_ERR_GRP + 0x14)    /* General error processing BTM request */
53#define GAP_ERR_TIMEOUT     (GAP_ERR_GRP + 0x15)    /* Timeout occurred while processing cmd */
54
55/** GAP Events - definitions of GAP return events ***/
56#define GAP_EVT_INQUIRY_RESULTS     0x0001
57#define GAP_EVT_INQUIRY_COMPLETE    0x0002
58#define GAP_EVT_DISCOVERY_COMPLETE  0x0003
59#define GAP_EVT_REM_NAME_COMPLETE   0x0004
60#define GAP_EVT_FIND_ADDR_COMPLETE  0x0005
61
62#define GAP_EVT_CONN_OPENED         0x0100
63#define GAP_EVT_CONN_CLOSED         0x0101
64#define GAP_EVT_CONN_DATA_AVAIL     0x0102
65#define GAP_EVT_CONN_CONGESTED      0x0103
66#define GAP_EVT_CONN_UNCONGESTED    0x0104
67
68/* Values for 'chan_mode_mask' field */
69/* GAP_ConnOpen() - optional channels to negotiate */
70#define GAP_FCR_CHAN_OPT_BASIC      L2CAP_FCR_CHAN_OPT_BASIC
71#define GAP_FCR_CHAN_OPT_ERTM       L2CAP_FCR_CHAN_OPT_ERTM
72#define GAP_FCR_CHAN_OPT_STREAM     L2CAP_FCR_CHAN_OPT_STREAM
73
74/*** discovery of devices ***/
75#define GAP_INQUIRY_NONE            BTM_INQUIRY_NONE
76#define GAP_GENERAL_INQUIRY         BTM_GENERAL_INQUIRY
77#define GAP_LIMITED_INQUIRY         BTM_LIMITED_INQUIRY
78
79#if BLE_INCLUDED == TRUE
80#define GAP_BLE_INQUIRY_NONE        BTM_BLE_INQUIRY_NONE
81#define GAP_BLE_GENERAL_INQUIRY     BTM_BLE_GENERAL_INQUIRY
82#define GAP_BLE_LIMITED_INQUIRY     BTM_BLE_LIMITED_INQUIRY
83#endif
84
85/*** discoverable modes ***/
86#define GAP_NON_DISCOVERABLE        BTM_NON_DISCOVERABLE
87#define GAP_LIMITED_DISCOVERABLE    BTM_LIMITED_DISCOVERABLE
88#define GAP_GENERAL_DISCOVERABLE    BTM_GENERAL_DISCOVERABLE
89
90/*** Inquiry Filter Condition types  (The values are defined in btm_api.h) ***/
91#define GAP_CLR_INQUIRY_FILTER      BTM_CLR_INQUIRY_FILTER          /* Inquiry Filtering is turned off */
92#define GAP_FILTER_COND_DEVICE_CLASS BTM_FILTER_COND_DEVICE_CLASS    /* Filter on device class */
93#define GAP_FILTER_COND_BD_ADDR     BTM_FILTER_COND_BD_ADDR         /* Filter on device addr */
94
95/*** connectability ***/
96#define GAP_NON_CONNECTABLE         BTM_NON_CONNECTABLE
97#define GAP_CONNECTABLE             BTM_CONNECTABLE
98
99/*** security features ***/
100#define GAP_DISALLOW_PAIRING        0
101#define GAP_ALLOW_PAIRING           1
102
103/*** class of device settings ***/
104#define GAP_SET_COD_MAJOR_MINOR     0x01
105#define GAP_SET_COD_SERVICE_CLASS   0x02 /* only set the bits in the input */
106#define GAP_CLR_COD_SERVICE_CLASS   0x04
107#define GAP_SET_COD_ALL             0x08 /* take service class as the input (may clear some set bits!!) */
108#define GAP_INIT_COD                0x0a
109
110/*** used in connection variables and functions ***/
111#define GAP_INVALID_HANDLE      0xFFFF
112
113/* This is used to change the criteria for AMP  */
114#define GAP_PROTOCOL_ID         (UUID_PROTOCOL_UDP)
115
116/* slave preferred parameter, minimum connection interval */
117#ifndef GAP_SL_CONN_INT_MIN
118#define GAP_SL_CONN_INT_MIN     6
119#endif
120/* slave preferred parameter, maximum connection interval */
121#ifndef GAP_SL_CONN_INT_MAX
122#define GAP_SL_CONN_INT_MAX     20
123#endif
124/* slave preferred parameter */
125#ifndef GAP_SL_LATENCY
126#define GAP_SL_LATENCY     2
127#endif
128
129#ifndef GAP_BLE_PRIVACY_RECONN_ADDR_PERM
130#define GAP_BLE_PRIVACY_RECONN_ADDR_PERM        (GATT_PERM_READ|GATT_PERM_WRITE)
131#endif
132
133#ifndef  GAP_PREFER_CONN_INT_MAX
134#define  GAP_PREFER_CONN_INT_MAX         BTM_BLE_CONN_INT_MIN
135#endif
136
137#ifndef  GAP_PREFER_CONN_INT_MIN
138#define  GAP_PREFER_CONN_INT_MIN         BTM_BLE_CONN_INT_MIN
139#endif
140
141#ifndef  GAP_PREFER_CONN_LATENCY
142#define  GAP_PREFER_CONN_LATENCY         0
143#endif
144
145#ifndef  GAP_PREFER_CONN_SP_TOUT
146#define  GAP_PREFER_CONN_SP_TOUT         2000
147#endif
148
149/*****************************************************************************
150**  Type Definitions
151*****************************************************************************/
152/*
153** Callback function for connection services
154*/
155typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
156
157/*
158** Define the callback function prototypes.  Parameters are specific
159** to each event and are described below
160*/
161typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
162
163typedef tBTM_REMOTE_DEV_NAME    tGAP_REMOTE_DEV_NAME;   /* see btm_api.h */
164typedef tBTM_INQ_PARMS          tGAP_INQ_PARMS;         /* see btm_api.h */
165typedef tBTM_INQ_RESULTS        tGAP_INQ_RESULTS;       /* see btm_api.h */
166
167/* Inquiry results structure */
168typedef struct
169{
170    UINT16  status;
171    UINT8   num_results;
172} tGAP_INQ_CMPL;
173
174/* Definition of the GAP_FindAddrByName results structure */
175typedef struct
176{
177    UINT16       status;
178    BD_ADDR      bd_addr;
179    tBTM_BD_NAME devname;
180} tGAP_FINDADDR_RESULTS;
181
182/** for GAP_SetDeviceClass() **/
183/* Define Class of Device related values
184 *
185 * >>> changes to this type need to also be made to tHSP_COD in hsp2_int.h
186 */
187typedef struct
188{
189    UINT8       minor;
190    UINT8       major;
191    UINT16      service;
192} tGAP_COD;
193
194/*** Constants and functions for device features ***/
195typedef struct
196{
197    UINT8   lmp_version;
198    UINT16  mfc_name;
199    UINT16  lmp_subversion;
200} tGAP_LMP_VERSION;
201
202typedef struct
203{
204    UINT8   lmp_features[8];
205} tGAP_LMP_FEATURES;
206
207typedef struct
208{
209    UINT16      int_min;
210    UINT16      int_max;
211    UINT16      latency;
212    UINT16      sp_tout;
213}tGAP_BLE_PREF_PARAM;
214
215typedef union
216{
217    tGAP_BLE_PREF_PARAM     conn_param;
218    BD_ADDR                 reconn_bda;
219    UINT16                  icon;
220    UINT8                   *p_dev_name;
221    UINT8                   privacy;
222
223}tGAP_BLE_ATTR_VALUE;
224
225typedef void (tGAP_BLE_DEV_NAME_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name);
226
227typedef void (tGAP_BLE_RECONN_ADDR_CBACK)(BOOLEAN status, BD_ADDR addr, BD_ADDR reconn_bda);
228
229/*****************************************************************************
230**  External Function Declarations
231*****************************************************************************/
232#ifdef __cplusplus
233extern "C"
234{
235#endif
236
237/*******************************************************************************
238**
239** Function         GAP_SetDiscoverableMode
240**
241** Description      This function is called to allow or disallow a service to
242**                  discovered (Inquiry Scans).
243**
244** Returns          BT_PASS (0) if successful,
245**                  GAP_ERR_ILL_PARM if a bad parameter is detected,
246**                  GAP_DEVICE_NOT_UP if the device is not active,
247**                  GAP_ERR_PROCESSING if not enough resources to carry out request
248**
249*******************************************************************************/
250GAP_API extern UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration,
251                                               UINT16 interval);
252
253/*******************************************************************************
254**
255** Function         GAP_ReadDiscoverableMode
256**
257** Description      This function is called to retrieve the current discoverable
258**                  mode for the local device.
259**
260** Returns          GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or
261**                  GAP_GENERAL_DISCOVERABLE
262**
263*******************************************************************************/
264GAP_API extern UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval);
265
266/*******************************************************************************
267**
268** Function         GAP_StartInquiry
269**
270** Description      This function initiates a single inquiry.
271**
272** Returns          BT_PASS (0) if successful,
273**                  GAP_ERR_ILL_MODE if a bad mode parameter was passed
274**                  GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
275**                  GAP_ERR_NO_CTRL_BLK if out of control blocks
276**                  GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
277**                  GAP_ERR_BUSY if the device already has an iquiry active
278**                  GAP_DEVICE_NOT_UP if the device is not initialized yet
279**                  GAP_ERR_PROCESSING if any other BTM error was returned
280**
281*******************************************************************************/
282GAP_API extern UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms,
283                                        tGAP_CALLBACK *p_results_cb,
284                                        tGAP_CALLBACK *p_cmpl_cb);
285
286/*******************************************************************************
287**
288** Function         GAP_StartPeriodicInquiry
289**
290** Description      This function initiates a periodic inquiry.
291**
292** Returns          BT_PASS (0) if successful,
293**                  GAP_ERR_ILL_MODE if a bad mode parameter was passed
294**                  GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
295**                  GAP_ERR_NO_CTRL_BLK if out of control blocks
296**                  GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
297**                  GAP_ERR_BUSY if the device already has an iquiry active
298**                  GAP_DEVICE_NOT_UP if the device is not initialized yet
299**                  GAP_ERR_PROCESSING if any other BTM error was returned
300**
301*******************************************************************************/
302GAP_API extern UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms,
303                                                UINT16 min_time,
304                                                UINT16 max_time,
305                                                tGAP_CALLBACK *p_results_cb);
306
307/*******************************************************************************
308**
309** Function         GAP_CancelInquiry
310**
311** Description      This function cancels a single inquiry (if in progress)
312**
313** Returns          BOOLEAN (TRUE if successful, otherwise FALSE)
314**
315*******************************************************************************/
316GAP_API extern UINT16 GAP_CancelInquiry(void);
317
318/*******************************************************************************
319**
320** Function         GAP_CancelPeriodicInquiry
321**
322** Description      This function cancels a periodic inquiry (if in progress)
323**
324** Returns          BOOLEAN: (TRUE if successful, otherwise FALSE)
325**
326*******************************************************************************/
327GAP_API extern UINT16 GAP_CancelPeriodicInquiry(void);
328
329/*******************************************************************************
330**
331** Function         GAP_GetFirstInquiryResult
332**
333** Description      This function retrieves the first valid inquiry result.
334**
335** Returns          BT_PASS (0) if successful, or a non-zero error code
336**                  GAP_EOINQDB if no more entries in the database.
337**
338*******************************************************************************/
339GAP_API extern UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results);
340
341/*******************************************************************************
342**
343** Function         GAP_GetNextInquiryResult
344**
345** Description      This function retrieves the next valid inquiry result.
346**
347** Returns          BT_PASS (0) if successful, or a non-zero status code
348**                  GAP_EOINQDB if no more entries in the database.
349**
350*******************************************************************************/
351GAP_API extern UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results);
352
353/*******************************************************************************
354**
355** Function         GAP_FindAddrByName
356**
357** Description      This function is called to retrieve a device address given
358**                  a device name.  It first looks in the current local inquiry
359**                  database for the device with the specified name.  If not found
360**                  it initiates a general inquiry.  Upon completion, it retrieves
361**                  the name for each device until a match is found or all devices
362**                  have been checked.  Note:  This process can take a while to
363**                  complete.
364**
365** Returns          BT_PASS if the name was immediately available. (BD_ADDR is returned)
366**                  GAP_CMD_INITIATED if an inquiry has been initiated
367**
368*******************************************************************************/
369GAP_API extern UINT16 GAP_FindAddrByName (BD_NAME devname,
370                                          tGAP_INQ_PARMS *p_inq_parms,
371                                          tGAP_CALLBACK *p_addr_cb,
372                                          BD_ADDR bd_addr);
373
374/*******************************************************************************
375**
376** Function         GAP_SetConnectableMode
377**
378** Description      This function is called to allow or disallow a
379**                  connections on the local device.
380**
381** Returns          BT_PASS (0) if successful,
382**                  GAP_ERR_ILL_PARM if a bad parameter is detected,
383**                  GAP_DEVICE_NOT_UP if the device is not active,
384**                  GAP_ERR_PROCESSING if not enough resources to carry out request
385**
386*******************************************************************************/
387GAP_API extern UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration,
388                                              UINT16 interval);
389
390/*******************************************************************************
391**
392** Function         GAP_ReadConnectableMode
393**
394** Description      This function is called to retrieve the current connectability
395**                  mode for the local device.
396**
397** Returns          GAP_NON_CONNECTABLE, GAP_CONNECTABLE
398**
399*******************************************************************************/
400GAP_API extern UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval);
401
402/*******************************************************************************
403**
404** Function         GAP_SetSecurityMode
405**
406** Description      Set security mode for the device (Service or Link level)
407**
408** Returns          void
409**
410*******************************************************************************/
411GAP_API extern void GAP_SetSecurityMode (UINT8 sec_mode);
412
413/*******************************************************************************
414**
415** Function         GAP_SecRegister
416**
417** Description      Application calls this function to register for
418**                  security services.
419**
420** Returns          TRUE if registered OK, else FALSE
421**
422*******************************************************************************/
423GAP_API extern BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info);
424
425/*******************************************************************************
426**
427** Function         GAP_SetPairableMode
428**
429** Description      This function is called to allow or disallow pairing
430**                  on the local device.
431**
432** Returns          BT_PASS (0) if successful, or a non-zero error code
433**
434*******************************************************************************/
435GAP_API extern UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired);
436
437/*******************************************************************************
438**
439** Function         GAP_Bond
440**
441** Description      This function is called to initiate bonding with peer device
442**
443** Parameters:      bd_addr      - Address of the device to bond
444**                  pin_len      - length in bytes of the PIN Code
445**                  p_pin        - pointer to array with the PIN Code
446**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
447**
448** Returns          tBTM_STATUS - BTM_CMD_STARTED of successfully initiated
449**
450*******************************************************************************/
451GAP_API extern UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len,
452                               UINT8 *p_pin, UINT32 trusted_mask[]);
453
454/*******************************************************************************
455**
456** Function         GAP_PinRsp
457**
458** Description      This function is called from UI after Security Manager submitted
459**                  PIN code request.
460**
461** Returns          void
462**
463*******************************************************************************/
464GAP_API extern void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
465                                UINT8 *p_pin, UINT32 trusted_mask[]);
466
467/*******************************************************************************
468**
469** Function         GAP_AuthorizeRsp
470**
471** Description      This function is called from UI after Security Manager submitted
472**                  an authorization request.
473**
474** Returns          void
475**
476*******************************************************************************/
477GAP_API extern void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res,
478                                      UINT32 trusted_mask[]);
479
480/*******************************************************************************
481**
482** Function         GAP_SetDeviceClass
483**
484** Description      This function updates the local Device Class.
485**
486** Returns          BT_PASS (0) if successful,
487**                  GAP_ERR_BUSY if a discovery is already in progress
488**                  GAP_ERR_ILL_PARM if an illegal parameter was detected
489**                  GAP_ERR_PROCESSING if any other BTM error has been returned
490**
491*******************************************************************************/
492GAP_API extern UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd);
493
494/*******************************************************************************
495**
496** Function         GAP_ReadDeviceClass
497**
498** Description      This function reads the current local Device Class setting.
499**
500** Returns          BT_PASS
501**
502*******************************************************************************/
503GAP_API extern UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod);
504
505/*******************************************************************************
506**
507** Function         GAP_ReadLocalDeviceInfo
508**
509** Description      This function retrieves local device information to the caller.
510**                  NOTE:  Return parameters that are set to NULL are not retrieved.
511**
512** Returns          BT_PASS (0) if successful, or a non-zero error code
513**
514*******************************************************************************/
515GAP_API extern UINT16 GAP_ReadLocalDeviceInfo(  UINT8 *name, BD_ADDR *addr,
516                                                tGAP_LMP_VERSION *verinfo,
517                                                tGAP_LMP_FEATURES *features);
518
519
520/*******************************************************************************
521**
522** Function         GAP_GetRemoteDeviceName
523**
524** Description      The remote name is retrieved from the specified remote device.  If
525**                  GAP_CMD_INITIATED is returned by the function, the command was
526**                  successfully sent to the controller.  The GAP_EVT_NAME_RESP event
527**                  is passed in the callback when the remote device name has been retrieved.
528**
529** Returns
530**                  GAP_CMD_INITIATED if remote search successfully initiated
531**                  GAP_ERR_BUSY if a remote name request is already in progress,
532**                  GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending)
533**                  GAP_BAD_BD_ADDR if the device address is bad,
534**                  GAP_DEVICE_NOT_UP if the device has not been initialized yet
535**                  GAP_ERR_PROCESSING if any other BTM error has been returned
536**
537*******************************************************************************/
538GAP_API extern UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback);
539
540/*** Functions for L2CAP connection interface ***/
541/*******************************************************************************
542**
543** Function         GAP_ConnOpen
544**
545** Description      This function is called to open a generic L2CAP connection.
546**
547** Returns          handle of the connection if successful, else GAP_INVALID_HANDLE
548**
549*******************************************************************************/
550GAP_API extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
551                                    BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
552                                    UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
553
554/*******************************************************************************
555**
556** Function         GAP_ConnClose
557**
558** Description      This function is called to close a connection.
559**
560** Returns          BT_PASS             - closed OK
561**                  GAP_ERR_BAD_HANDLE  - invalid handle
562**
563*******************************************************************************/
564GAP_API extern UINT16 GAP_ConnClose (UINT16 gap_handle);
565
566/*******************************************************************************
567**
568** Function         GAP_ConnReadData
569**
570** Description      GKI buffer unaware application will call this function
571**                  after receiving GAP_EVT_RXDATA event. A data copy is made
572**                  into the receive buffer parameter.
573**
574** Returns          BT_PASS             - data read
575**                  GAP_ERR_BAD_HANDLE  - invalid handle
576**                  GAP_NO_DATA_AVAIL   - no data available
577**
578*******************************************************************************/
579GAP_API extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
580                                        UINT16 max_len, UINT16 *p_len);
581
582/*******************************************************************************
583**
584** Function         GAP_GetRxQueueCnt
585**
586** Description      This function return number of bytes on the rx queue.
587**
588** Parameters:      handle     - Handle returned in the GAP_ConnOpen
589**                  p_rx_queue_count - Pointer to return queue count in.
590**
591**
592*******************************************************************************/
593GAP_API extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
594
595/*******************************************************************************
596**
597** Function         GAP_ConnBTRead
598**
599** Description      GKI buffer aware applications will call this function after
600**                  receiving an GAP_EVT_RXDATA event to process the incoming
601**                  data buffer.
602**
603** Returns          BT_PASS             - data read
604**                  GAP_ERR_BAD_HANDLE  - invalid handle
605**                  GAP_NO_DATA_AVAIL   - no data available
606**
607*******************************************************************************/
608GAP_API extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
609
610/*******************************************************************************
611**
612** Function         GAP_ConnBTWrite
613**
614** Description      GKI buffer aware applications can call this function to write data
615**                  by passing a pointer to the GKI buffer of data.
616**
617** Returns          BT_PASS                 - data read
618**                  GAP_ERR_BAD_HANDLE      - invalid handle
619**                  GAP_ERR_BAD_STATE       - connection not established
620**                  GAP_INVALID_BUF_OFFSET  - buffer offset is invalid
621*******************************************************************************/
622GAP_API extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
623
624/*******************************************************************************
625**
626** Function         GAP_ConnWriteData
627**
628** Description      GKI buffer unaware application will call this function
629**                  to send data to the connection. A data copy is made into a GKI
630**                  buffer.
631**
632** Returns          BT_PASS                 - data read
633**                  GAP_ERR_BAD_HANDLE      - invalid handle
634**                  GAP_ERR_BAD_STATE       - connection not established
635**                  GAP_CONGESTION          - system is congested
636**
637*******************************************************************************/
638GAP_API extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
639                                         UINT16 max_len, UINT16 *p_len);
640
641/*******************************************************************************
642**
643** Function         GAP_ConnReconfig
644**
645** Description      Applications can call this function to reconfigure the connection.
646**
647** Returns          BT_PASS                 - config process started
648**                  GAP_ERR_BAD_HANDLE      - invalid handle
649**
650*******************************************************************************/
651GAP_API extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
652
653/*******************************************************************************
654**
655** Function         GAP_ConnSetIdleTimeout
656**
657** Description      Higher layers call this function to set the idle timeout for
658**                  a connection, or for all future connections. The "idle timeout"
659**                  is the amount of time that a connection can remain up with
660**                  no L2CAP channels on it. A timeout of zero means that the
661**                  connection will be torn down immediately when the last channel
662**                  is removed. A timeout of 0xFFFF means no timeout. Values are
663**                  in seconds.
664**
665** Returns          BT_PASS                 - config process started
666**                  GAP_ERR_BAD_HANDLE      - invalid handle
667**
668*******************************************************************************/
669GAP_API extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
670
671/*******************************************************************************
672**
673** Function         GAP_ConnGetRemoteAddr
674**
675** Description      This function is called to get the remote BD address
676**                  of a connection.
677**
678** Returns          BT_PASS             - closed OK
679**                  GAP_ERR_BAD_HANDLE  - invalid handle
680**
681*******************************************************************************/
682GAP_API extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
683
684/*******************************************************************************
685**
686** Function         GAP_ConnGetRemMtuSize
687**
688** Description      Returns the remote device's MTU size.
689**
690** Returns          UINT16 - maximum size buffer that can be transmitted to the peer
691**
692*******************************************************************************/
693GAP_API extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
694
695/*******************************************************************************
696**
697** Function         GAP_ConnGetL2CAPCid
698**
699** Description      Returns the L2CAP channel id
700**
701** Parameters:      handle      - Handle of the connection
702**
703** Returns          UINT16      - The L2CAP channel id
704**                  0, if error
705**
706*******************************************************************************/
707GAP_API extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
708
709/*******************************************************************************
710**
711** Function         GAP_SetTraceLevel
712**
713** Description      This function sets the trace level for GAP.  If called with
714**                  a value of 0xFF, it simply returns the current trace level.
715**
716** Returns          The new or current trace level
717**
718*******************************************************************************/
719GAP_API extern UINT8 GAP_SetTraceLevel (UINT8 new_level);
720
721/*******************************************************************************
722**
723** Function         GAP_Init
724**
725** Description      Initializes the control blocks used by GAP.
726**                  This routine should not be called except once per
727**                      stack invocation.
728**
729** Returns          Nothing
730**
731*******************************************************************************/
732GAP_API extern void GAP_Init(void);
733
734#if (BLE_INCLUDED == TRUE)
735/*******************************************************************************
736**
737** Function         GAP_BleAttrDBUpdate
738**
739** Description      update GAP local BLE attribute database.
740**
741** Returns          Nothing
742**
743*******************************************************************************/
744GAP_API extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value);
745
746
747/*******************************************************************************
748**
749** Function         GAP_BleReadPeerPrefConnParams
750**
751** Description      Start a process to read a connected peripheral's preferred
752**                  connection parameters
753**
754** Returns          TRUE if read started, else FALSE if GAP is busy
755**
756*******************************************************************************/
757GAP_API extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda);
758
759/*******************************************************************************
760**
761** Function         GAP_BleReadPeerDevName
762**
763** Description      Start a process to read a connected peripheral's device name.
764**
765** Returns          TRUE if request accepted
766**
767*******************************************************************************/
768GAP_API extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NAME_CBACK *p_cback);
769
770
771/*******************************************************************************
772**
773** Function         GAP_BleCancelReadPeerDevName
774**
775** Description      Cancel reading a peripheral's device name.
776**
777** Returns          TRUE if request accepted
778**
779*******************************************************************************/
780GAP_API extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda);
781
782/*******************************************************************************
783**
784** Function         GAP_BleUpdateReconnectAddr
785**
786** Description      Start a process to udpate the reconnect address if remote devive
787**                  has privacy enabled.
788**
789** Returns          TRUE if read started, else FALSE if GAP is busy
790**
791*******************************************************************************/
792GAP_API extern BOOLEAN GAP_BleUpdateReconnectAddr (BD_ADDR peer_bda,
793                                                   BD_ADDR reconn_addr,
794                                                   tGAP_BLE_RECONN_ADDR_CBACK *p_cback);
795
796#endif
797
798#ifdef __cplusplus
799}
800#endif
801
802#endif  /* GAP_API_H */
803
804