1 /**
2  ****************************************************************************************
3  *
4  * @file prf_types.h
5  *
6  * @brief Header file - Profile Types
7  *
8  * Copyright (C) RivieraWaves 2009-2016
9  *
10  *
11  ****************************************************************************************
12  */
13 
14 
15 #ifndef _PRF_TYPES_H_
16 #define _PRF_TYPES_H_
17 
18 /**
19  ****************************************************************************************
20  * @addtogroup PRF_TYPES
21  * @ingroup PROFILE
22  * @brief Definitions of shared profiles types
23  *
24  * @{
25  ****************************************************************************************
26  */
27 
28 /*
29  * INCLUDE FILES
30  ****************************************************************************************
31  */
32 #include "att.h"
33 //#include "compiler.h"
34 #include "ble_arch.h"
35 
36 /*
37  * DEFINES
38  ****************************************************************************************
39  */
40 
41 /// Attribute is mandatory
42 #define ATT_MANDATORY   (0xFF)
43 /// Attribute is optional
44 #define ATT_OPTIONAL    (0x00)
45 
46 /// Characteristic Presentation Format Descriptor Size
47 #define PRF_CHAR_PRES_FMT_SIZE  (7)
48 
49 
50 /// Possible values for setting client configuration characteristics
51 enum prf_cli_conf
52 {
53     /// Stop notification/indication
54     PRF_CLI_STOP_NTFIND = 0x0000,
55     /// Start notification
56     PRF_CLI_START_NTF,
57     /// Start indication
58     PRF_CLI_START_IND,
59 };
60 
61 /// Possible values for setting server configuration characteristics
62 enum prf_srv_conf
63 {
64     /// Stop Broadcast
65     PRF_SRV_STOP_BCST = 0x0000,
66     /// Start Broadcast
67     PRF_SRV_START_BCST,
68 };
69 
70 /// Connection type
71 enum prf_con_type
72 {
73     ///Discovery type connection
74     PRF_CON_DISCOVERY = 0x00,
75     /// Normal type connection
76     PRF_CON_NORMAL    = 0x01,
77 };
78 
79 enum prf_svc_type
80 {
81     PRF_PRIMARY_SERVICE = 0x00,
82     PRF_SECONDARY_SERVICE = 0x01
83 };
84 
85 /*
86  * TYPE DEFINITIONS
87  ****************************************************************************************
88  */
89 
90 /**
91  * Characteristic Presentation Format Descriptor structure
92  * Packed size is PRF_CHAR_PRES_FMT_SIZE
93  */
94 /// characteristic presentation information
95 struct prf_char_pres_fmt
96 {
97     /// Unit (The Unit is a UUID)
98     uint16_t unit;
99     /// Description
100     uint16_t description;
101     /// Format
102     uint8_t format;
103     /// Exponent
104     uint8_t exponent;
105     /// Name space
106     uint8_t name_space;
107 };
108 
109 /**
110  * date and time structure
111  * size = 7 bytes
112  */
113 /// Time profile information
114 struct prf_date_time
115 {
116     /// year time element
117     uint16_t year;
118     /// month time element
119     uint8_t month;
120     /// day time element
121     uint8_t day;
122     /// hour time element
123     uint8_t hour;
124     /// minute time element
125     uint8_t min;
126     /// second time element
127     uint8_t sec;
128 };
129 
130 /**
131  *  SFLOAT: Short Floating Point Type
132  *
133  *        +----------+----------+---------+
134  *        | Exponent | Mantissa |  Total  |
135  * +------+----------+----------+---------+
136  * | size |  4 bits  | 12 bits  | 16 bits |
137  * +------+----------+----------+---------+
138  */
139 typedef uint16_t prf_sfloat;
140 
141 
142 
143 /// Attribute information
144 struct prf_att_info
145 {
146     /// Attribute Handle
147     uint16_t handle;
148     /// Attribute length
149     uint16_t length;
150     /// Status of request
151     uint8_t  status;
152     /// Attribute value
153     uint8_t value[__ARRAY_EMPTY];
154 };
155 
156 
157 
158 
159 /// service handles
160 struct prf_svc
161 {
162     /// start handle
163     uint16_t shdl;
164     /// end handle
165     uint16_t ehdl;
166 };
167 
168 /// service handles
169 struct prf_incl_svc
170 {
171     /// attribute handle
172     uint16_t handle;
173     /// included service start handle
174     uint16_t start_hdl;
175     /// included service  end handle
176     uint16_t end_hdl;
177     /// UUID length
178     uint8_t uuid_len;
179     /// UUID
180     uint8_t uuid[ATT_UUID_128_LEN];
181 };
182 
183 /// characteristic info
184 struct prf_char_inf
185 {
186     /// Characteristic handle
187     uint16_t char_hdl;
188     /// Value handle
189     uint16_t val_hdl;
190     /// Characteristic properties
191     uint8_t prop;
192     /// End of characteristic offset
193     uint8_t char_ehdl_off;
194 };
195 
196 /// characteristic description
197 struct prf_char_desc_inf
198 {
199     /// Descriptor handle
200     uint16_t desc_hdl;
201 };
202 
203 
204 /// Characteristic definition
205 struct prf_char_def
206 {
207     /// Characteristic UUID
208     uint16_t uuid;
209     /// Requirement Attribute Flag
210     uint8_t req_flag;
211     /// Mandatory Properties
212     uint8_t prop_mand;
213 };
214 
215 /// Characteristic definition uuid128
216 struct prf_char_uuid128_def
217 {
218     /// Service UUID Length
219     uint8_t  uuid_len;
220     /// 128 bits UUID LSB First
221     uint8_t uuid[ATT_UUID_128_LEN];
222     /// Requirement Attribute Flag
223     uint8_t req_flag;
224     /// Mandatory Properties
225     uint8_t prop_mand;
226 };
227 
228 /// Characteristic Descriptor definition
229 struct prf_char_desc_def
230 {
231     /// Characteristic Descriptor uuid
232     uint16_t uuid;
233     /// requirement attribute flag
234     uint8_t req_flag;
235     /// Corresponding characteristic code
236     uint8_t char_code;
237 };
238 
239 /// Characteristic Descriptor definition uuid128
240 struct prf_char_desc_uuid128_def
241 {
242     /// Service UUID Length
243     uint8_t  uuid_len;
244     /// 128 bits UUID LSB First
245     uint8_t uuid[ATT_UUID_128_LEN];
246     /// requirement attribute flag
247     uint8_t req_flag;
248     /// Corresponding characteristic code
249     uint8_t char_code;
250 };
251 
252 /// Message structure used to inform APP that a profile client role has been disabled
253 struct prf_client_disable_ind
254 {
255     /// Status
256     uint8_t status;
257 };
258 
259 
260 
261 /// Message structure used to inform APP that an error has occured in the profile server role task
262 struct prf_server_error_ind
263 {
264     /// Message ID
265     uint16_t msg_id;
266     /// Status
267     uint8_t status;
268 };
269 
270 
271 /// @} PRF_TYPES
272 
273 #endif /* _PRF_TYPES_H_ */
274