• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _HAL_PRF_TYPES_H
17 #define _HAL_PRF_TYPES_H
18 
19 #include "hal_att.h"
20 #include "compiler.h"
21 
22 /// Attribute is mandatory
23 #define ATT_MANDATORY   (0xFF)
24 /// Attribute is optional
25 #define ATT_OPTIONAL    (0x00)
26 
27 /// Characteristic Presentation Format Descriptor Size
28 #define PRF_CHAR_PRES_FMT_SIZE  (7)
29 
30 
31 /// Possible values for setting client configuration characteristics
32 enum prf_cli_conf
33 {
34     /// Stop notification/indication
35     PRF_CLI_STOP_NTFIND = 0x0000,
36     /// Start notification
37     PRF_CLI_START_NTF,
38     /// Start indication
39     PRF_CLI_START_IND,
40 };
41 
42 /// Possible values for setting server configuration characteristics
43 enum prf_srv_conf
44 {
45     /// Stop Broadcast
46     PRF_SRV_STOP_BCST = 0x0000,
47     /// Start Broadcast
48     PRF_SRV_START_BCST,
49 };
50 
51 /// Connection type
52 enum prf_con_type
53 {
54     ///Discovery type connection
55     PRF_CON_DISCOVERY = 0x00,
56     /// Normal type connection
57     PRF_CON_NORMAL    = 0x01,
58 };
59 
60 enum prf_svc_type
61 {
62     PRF_PRIMARY_SERVICE = 0x00,
63     PRF_SECONDARY_SERVICE = 0x01
64 };
65 
66 /*
67  * TYPE DEFINITIONS
68  ****************************************************************************************
69  */
70 
71 /**
72  * Characteristic Presentation Format Descriptor structure
73  * Packed size is PRF_CHAR_PRES_FMT_SIZE
74  */
75 /// characteristic presentation information
76 struct prf_char_pres_fmt
77 {
78     /// Unit (The Unit is a UUID)
79     uint16_t unit;
80     /// Description
81     uint16_t description;
82     /// Format
83     uint8_t format;
84     /// Exponent
85     uint8_t exponent;
86     /// Name space
87     uint8_t name_space;
88 };
89 
90 /**
91  * date and time structure
92  * size = 7 bytes
93  */
94 /// Time profile information
95 struct prf_date_time
96 {
97     /// year time element
98     uint16_t year;
99     /// month time element
100     uint8_t month;
101     /// day time element
102     uint8_t day;
103     /// hour time element
104     uint8_t hour;
105     /// minute time element
106     uint8_t min;
107     /// second time element
108     uint8_t sec;
109 };
110 
111 /**
112  *  SFLOAT: Short Floating Point Type
113  *
114  *        +----------+----------+---------+
115  *        | Exponent | Mantissa |  Total  |
116  * +------+----------+----------+---------+
117  * | size |  4 bits  | 12 bits  | 16 bits |
118  * +------+----------+----------+---------+
119  */
120 typedef uint16_t prf_sfloat;
121 
122 
123 
124 /// Attribute information
125 struct prf_att_info
126 {
127     /// Attribute Handle
128     uint16_t handle;
129     /// Attribute length
130     uint16_t length;
131     /// Status of request
132     uint8_t  status;
133     /// Attribute value
134     uint8_t value[__ARRAY_EMPTY];
135 };
136 
137 
138 
139 
140 /// service handles
141 struct prf_svc
142 {
143     /// start handle
144     uint16_t shdl;
145     /// end handle
146     uint16_t ehdl;
147 };
148 
149 /// service handles
150 struct prf_incl_svc
151 {
152     /// attribute handle
153     uint16_t handle;
154     /// included service start handle
155     uint16_t start_hdl;
156     /// included service  end handle
157     uint16_t end_hdl;
158     /// UUID length
159     uint8_t uuid_len;
160     /// UUID
161     uint8_t uuid[ATT_UUID_128_LEN];
162 };
163 
164 /// characteristic info
165 struct prf_char_inf
166 {
167     /// Characteristic handle
168     uint16_t char_hdl;
169     /// Value handle
170     uint16_t val_hdl;
171     /// Characteristic properties
172     uint8_t prop;
173     /// End of characteristic offset
174     uint8_t char_ehdl_off;
175 };
176 
177 /// characteristic description
178 struct prf_char_desc_inf
179 {
180     /// Descriptor handle
181     uint16_t desc_hdl;
182 };
183 
184 
185 /// Characteristic definition
186 struct prf_char_def
187 {
188     /// Characteristic UUID
189     uint16_t uuid;
190     /// Requirement Attribute Flag
191     uint8_t req_flag;
192     /// Mandatory Properties
193     uint8_t prop_mand;
194 };
195 
196 /// Characteristic Descriptor definition
197 struct prf_char_desc_def
198 {
199     /// Characteristic Descriptor uuid
200     uint16_t uuid;
201     /// requirement attribute flag
202     uint8_t req_flag;
203     /// Corresponding characteristic code
204     uint8_t char_code;
205 };
206 
207 /// Message structure used to inform APP that a profile client role has been disabled
208 struct prf_client_disable_ind
209 {
210     /// Status
211     uint8_t status;
212 };
213 
214 
215 
216 /// Message structure used to inform APP that an error has occured in the profile server role task
217 struct prf_server_error_ind
218 {
219     /// Message ID
220     uint16_t msg_id;
221     /// Status
222     uint8_t status;
223 };
224 
225 #endif // _HAL_PRF_TYPES_H
226