1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-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 SRVC_DIS_API_H
20 #define SRVC_DIS_API_H
21 
22 #include "common/bt_target.h"
23 #include "stack/gatt_api.h"
24 #include "stack/gattdefs.h"
25 
26 #define DIS_SUCCESS             GATT_SUCCESS
27 #define DIS_ILLEGAL_PARAM       GATT_ILLEGAL_PARAMETER
28 #define DIS_NO_RESOURCES        GATT_NO_RESOURCES
29 typedef UINT8 tDIS_STATUS;
30 
31 
32 /*****************************************************************************
33 **  Data structure for DIS
34 *****************************************************************************/
35 
36 #define DIS_ATTR_SYS_ID_BIT         0x0001
37 #define DIS_ATTR_MODEL_NUM_BIT      0x0002
38 #define DIS_ATTR_SERIAL_NUM_BIT     0x0004
39 #define DIS_ATTR_FW_NUM_BIT         0x0008
40 #define DIS_ATTR_HW_NUM_BIT         0x0010
41 #define DIS_ATTR_SW_NUM_BIT         0x0020
42 #define DIS_ATTR_MANU_NAME_BIT      0x0040
43 #define DIS_ATTR_IEEE_DATA_BIT      0x0080
44 #define DIS_ATTR_PNP_ID_BIT         0x0100
45 typedef UINT16  tDIS_ATTR_MASK;
46 
47 #define DIS_ATTR_ALL_MASK           0xffff
48 
49 typedef tDIS_ATTR_MASK tDIS_ATTR_BIT ;
50 
51 typedef struct {
52     UINT16      len;
53     UINT8       *p_data;
54 } tDIS_STRING;
55 
56 typedef struct {
57     UINT16       vendor_id;
58     UINT16       product_id;
59     UINT16       product_version;
60     UINT8        vendor_id_src;
61 
62 } tDIS_PNP_ID;
63 
64 typedef union {
65     UINT64              system_id;
66     tDIS_PNP_ID         pnp_id;
67     tDIS_STRING         data_str;
68 } tDIS_ATTR;
69 
70 #define DIS_MAX_STRING_DATA     7
71 
72 typedef struct {
73     UINT16                  attr_mask;
74     UINT64                  system_id;
75     tDIS_PNP_ID             pnp_id;
76     UINT8                   *data_string[DIS_MAX_STRING_DATA];
77 } tDIS_VALUE;
78 
79 
80 typedef void (tDIS_READ_CBACK)(BD_ADDR addr, tDIS_VALUE *p_dis_value);
81 
82 /*****************************************************************************
83 **  Data structure used by Battery Service
84 *****************************************************************************/
85 typedef struct {
86     BD_ADDR remote_bda;
87     BOOLEAN need_rsp;
88     UINT16  clt_cfg;
89 } tBA_WRITE_DATA;
90 
91 #define BA_READ_CLT_CFG_REQ     1
92 #define BA_READ_PRE_FMT_REQ     2
93 #define BA_READ_RPT_REF_REQ     3
94 #define BA_READ_LEVEL_REQ       4
95 #define BA_WRITE_CLT_CFG_REQ    5
96 
97 typedef void (tBA_CBACK)(UINT8 app_id, UINT8 event, tBA_WRITE_DATA *p_data);
98 
99 #define BA_LEVEL_NOTIFY         0x01
100 #define BA_LEVEL_PRE_FMT        0x02
101 #define BA_LEVEL_RPT_REF        0x04
102 typedef UINT8   tBA_LEVEL_DESCR;
103 
104 typedef struct {
105     BOOLEAN         is_pri;
106     tBA_LEVEL_DESCR     ba_level_descr;
107     tGATT_TRANSPORT transport;
108     tBA_CBACK       *p_cback;
109 
110 } tBA_REG_INFO;
111 
112 typedef union {
113     UINT8       ba_level;
114     UINT16      clt_cfg;
115     tGATT_CHAR_RPT_REF  rpt_ref;
116     tGATT_CHAR_PRES     pres_fmt;
117 } tBA_RSP_DATA;
118 
119 /*****************************************************************************
120 **  External Function Declarations
121 *****************************************************************************/
122 #ifdef __cplusplus
123 extern "C"
124 {
125 #endif
126 /*****************************************************************************
127 **  Service Engine API
128 *****************************************************************************/
129 /*******************************************************************************
130 **
131 ** Function         srvc_eng_init
132 **
133 ** Description      Initializa the GATT Service engine, register a GATT application
134 **                  as for a central service management.
135 **
136 *******************************************************************************/
137 extern tGATT_STATUS srvc_eng_init (void);
138 
139 
140 /*****************************************************************************
141 **  DIS Server Function
142 *****************************************************************************/
143 
144 /*******************************************************************************
145 **
146 ** Function         DIS_SrInit
147 **
148 ** Description      Initializa the Device Information Service Server.
149 **
150 *******************************************************************************/
151 extern tDIS_STATUS DIS_SrInit (tDIS_ATTR_MASK dis_attr_mask);
152 /*******************************************************************************
153 **
154 ** Function         DIS_SrUpdate
155 **
156 ** Description      Update the DIS server attribute values
157 **
158 *******************************************************************************/
159 extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info);
160 /*****************************************************************************
161 **  DIS Client Function
162 *****************************************************************************/
163 /*******************************************************************************
164 **
165 ** Function         DIS_ReadDISInfo
166 **
167 ** Description      Read remote device DIS information.
168 **
169 ** Returns          void
170 **
171 *******************************************************************************/
172 extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback,
173                                tDIS_ATTR_MASK mask);
174 
175 /*******************************************************************************
176 **      BATTERY SERVICE API
177 *******************************************************************************/
178 /*******************************************************************************
179 **
180 ** Function         Battery_Instantiate
181 **
182 ** Description      Instantiate a Battery service
183 **
184 *******************************************************************************/
185 extern UINT16 Battery_Instantiate (UINT8 app_id, tBA_REG_INFO *p_reg_info);
186 
187 /*******************************************************************************
188 **
189 ** Function         Battery_Rsp
190 **
191 ** Description      Respond to a battery service request
192 **
193 *******************************************************************************/
194 extern void Battery_Rsp (UINT8 app_id, tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp);
195 /*******************************************************************************
196 **
197 ** Function         Battery_Notify
198 **
199 ** Description      Send battery level notification
200 **
201 *******************************************************************************/
202 extern void Battery_Notify (UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level);
203 
204 
205 #ifdef __cplusplus
206 
207 }
208 #endif
209 
210 #endif
211