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