Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2004-2012 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 /******************************************************************************
     20  *
     21  *  This is the public interface file for the Personal Area Networking (PAN)
     22  *  subsystem of BTA, Broadcom's Bluetooth application layer for mobile
     23  *  phones.
     24  *
     25  ******************************************************************************/
     26 #ifndef BTA_PAN_API_H
     27 #define BTA_PAN_API_H
     28 
     29 #include "bta_api.h"
     30 #include "pan_api.h"
     31 
     32 /*****************************************************************************
     33 **  Constants and data types
     34 *****************************************************************************/
     35 #define BTA_PAN_SUCCESS          0
     36 #define BTA_PAN_FAIL             1
     37 
     38 typedef UINT8 tBTA_PAN_STATUS;
     39 
     40 
     41 /* PAN Callback events */
     42 #define BTA_PAN_ENABLE_EVT       0       /* PAN service is enabled. */
     43 #define BTA_PAN_SET_ROLE_EVT     1       /* PAN roles registered */
     44 #define BTA_PAN_OPENING_EVT      2       /* Connection is being opened. */
     45 #define BTA_PAN_OPEN_EVT         3       /* Connection has been opened. */
     46 #define BTA_PAN_CLOSE_EVT        4       /* Connection has been closed. */
     47 
     48 typedef UINT8 tBTA_PAN_EVT;
     49 
     50 
     51 /* pan roles */
     52 #define BTA_PAN_ROLE_PANU        PAN_ROLE_CLIENT
     53 #define BTA_PAN_ROLE_GN          PAN_ROLE_GN_SERVER
     54 #define BTA_PAN_ROLE_NAP         PAN_ROLE_NAP_SERVER
     55 
     56 
     57 typedef UINT8   tBTA_PAN_ROLE;
     58 
     59 /*  information regarding PAN roles */
     60 typedef struct
     61 {
     62     char *p_srv_name;  /* service name for the PAN role */
     63     UINT8 app_id;      /* application id */
     64     tBTA_SEC sec_mask; /* security setting for the role */
     65 
     66 } tBTA_PAN_ROLE_INFO;
     67 
     68 
     69 /* Event associated with BTA_PAN_SET_ROLE_EVT */
     70 typedef struct
     71 {
     72     tBTA_PAN_STATUS status;     /* status of set role event */
     73     tBTA_PAN_ROLE   role;       /* PAN roles successfully registered */
     74 } tBTA_PAN_SET_ROLE;
     75 
     76 /* Event associated with BTA_PAN_OPENING_EVT */
     77 typedef struct
     78 {
     79     BD_ADDR         bd_addr;    /* BD address of peer device. */
     80     UINT16          handle;     /* Handle associated with this connection. */
     81 
     82 } tBTA_PAN_OPENING;
     83 
     84 
     85 /* Event associated with BTA_PAN_OPEN_EVT */
     86 typedef struct
     87 {
     88     BD_ADDR         bd_addr;    /* BD address of peer device. */
     89     UINT16          handle;     /* Handle associated with this connection. */
     90     tBTA_PAN_STATUS status;     /* status of open event */
     91     tBTA_PAN_ROLE   local_role; /* Local device PAN role for the connection */
     92     tBTA_PAN_ROLE   peer_role;  /* Peer device PAN role for the connection */
     93 
     94 } tBTA_PAN_OPEN;
     95 
     96 /* Event associated with BTA_PAN_CLOSE_EVT */
     97 typedef struct
     98 {
     99     UINT16          handle;     /* Handle associated with the connection. */
    100 } tBTA_PAN_CLOSE;
    101 
    102 /* Union of all PAN callback structures */
    103 typedef union
    104 {
    105     tBTA_PAN_SET_ROLE   set_role;   /* set_role event */
    106     tBTA_PAN_OPEN       open;       /* Connection has been opened. */
    107     tBTA_PAN_OPENING    opening;    /* Connection being opened */
    108     tBTA_PAN_CLOSE      close;      /* Connection has been closed. */
    109 } tBTA_PAN;
    110 
    111 /* Number of PAN connections */
    112 #ifndef BTA_PAN_NUM_CONN
    113 #define BTA_PAN_NUM_CONN         4
    114 #endif
    115 
    116 /* PAN callback */
    117 typedef void (tBTA_PAN_CBACK)(tBTA_PAN_EVT event, tBTA_PAN *p_data);
    118 
    119 /*****************************************************************************
    120 **  External Function Declarations
    121 *****************************************************************************/
    122 #ifdef __cplusplus
    123 extern "C"
    124 {
    125 #endif
    126 
    127 /*******************************************************************************
    128 **
    129 ** Function         BTA_PanEnable
    130 **
    131 ** Description      Enable PAN service.  This function must be
    132 **                  called before any other functions in the PAN API are called.
    133 **                  When the enable operation is complete the callback function
    134 **                  will be called with a BTA_PAN_ENABLE_EVT.
    135 **
    136 ** Returns          void
    137 **
    138 *******************************************************************************/
    139 extern void BTA_PanEnable(tBTA_PAN_CBACK p_cback);
    140 
    141 /*******************************************************************************
    142 **
    143 ** Function         BTA_PanDisable
    144 **
    145 ** Description      Disable PAN service.
    146 **
    147 ** Returns          void
    148 **
    149 *******************************************************************************/
    150 extern void BTA_PanDisable(void);
    151 
    152 
    153 /*******************************************************************************
    154 **
    155 ** Function         BTA_PanSetRole
    156 **
    157 ** Description      Sets PAN roles. When the enable operation is complete
    158 **                  the callback function will be called with a BTA_PAN_SET_ROLE_EVT.
    159 **
    160 ** Returns          void
    161 **
    162 *******************************************************************************/
    163 void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO *p_user_info, tBTA_PAN_ROLE_INFO *p_gn_info,
    164                     tBTA_PAN_ROLE_INFO *p_nap_info);
    165 
    166 
    167 /*******************************************************************************
    168 **
    169 ** Function         BTA_PanOpen
    170 **
    171 ** Description      Opens a connection to a peer device.
    172 **                  When connection is open callback function is called
    173 **                  with a BTA_PAN_OPEN_EVT.
    174 **
    175 **
    176 ** Returns          void
    177 **
    178 *******************************************************************************/
    179 void BTA_PanOpen(BD_ADDR bd_addr, tBTA_PAN_ROLE    local_role, tBTA_PAN_ROLE  peer_role);
    180 
    181 
    182 
    183 /*******************************************************************************
    184 **
    185 ** Function         BTA_PanClose
    186 **
    187 ** Description      Close a PAN  connection to a peer device.
    188 **
    189 **
    190 ** Returns          void
    191 **
    192 *******************************************************************************/
    193 extern void BTA_PanClose(UINT16 handle);
    194 
    195 
    196 #ifdef __cplusplus
    197 }
    198 #endif
    199 
    200 #endif /* BTA_PAN_API_H */
    201