bluetooth-llapi  2.0.1
bluetooth-llapi
LLBLUETOOTH_defines.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2018-2020 MicroEJ Corp. All rights reserved.
5  * This library is provided in source code for use, modification and test, subject to license terms.
6  * Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
7  */
8 
17 #ifndef _LLBLUETOOTH_DEFINES
18 #define _LLBLUETOOTH_DEFINES
19 
20 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27 #define ATTRIBUTE_TYPE_CHARACTERISTIC (0)
28 #define ATTRIBUTE_TYPE_DESCRIPTOR (1)
29 
31 #define ATTRIBUTE_PERMISSION_NONE (0x00)
32 #define ATTRIBUTE_PERMISSION_READ (0x01)
33 #define ATTRIBUTE_PERMISSION_READ_ENCRYPT (0x02)
34 #define ATTRIBUTE_PERMISSION_READ_AUTH (0x04)
35 #define ATTRIBUTE_PERMISSION_WRITE (0x08)
36 #define ATTRIBUTE_PERMISSION_WRITE_ENCRYPT (0x10)
37 #define ATTRIBUTE_PERMISSION_WRITE_AUTH (0x20)
38 
40 #define ADDRESS_TYPE_PUBLIC (0)
41 #define ADDRESS_TYPE_PRIVATE (1)
42 
44 #define SCAN_FILTER_ACTION_NONE (0)
45 #define SCAN_FILTER_ACTION_FIELD_EXISTS (1)
46 #define SCAN_FILTER_ACTION_FIELD_EQUALS (2)
47 #define SCAN_FILTER_ACTION_FIELD_STARTS_WITH (3)
48 
50 #define EVENT_GAP_SCAN_RESULT (1)
51 #define EVENT_GAP_SCAN_COMPLETED (2)
52 #define EVENT_GAP_ADVERTISEMENT_COMPLETED (3)
53 #define EVENT_GAP_CONNECT_FAILED (4)
54 #define EVENT_GAP_CONNECTED (5)
55 #define EVENT_GAP_DISCONNECTED (6)
56 #define EVENT_GAP_PAIR_REQUEST (7)
57 #define EVENT_GAP_PAIR_COMPLETED (8)
58 #define EVENT_GAP_PASSKEY_REQUEST (9)
59 #define EVENT_GAP_PASSKEY_GENERATED (10)
60 #define EVENT_GATTC_DISCOVERY_RESULT (11)
61 #define EVENT_GATTC_DISCOVERY_COMPLETED (12)
62 #define EVENT_GATTC_READ_COMPLETED (13)
63 #define EVENT_GATTC_WRITE_COMPLETED (14)
64 #define EVENT_GATTC_NOTIFICATION_RECEIVED (15)
65 #define EVENT_GATTS_READ_REQUEST (16)
66 #define EVENT_GATTS_WRITE_REQUEST (17)
67 #define EVENT_GATTS_NOTIFICATION_SENT (18)
68 
70 typedef struct {
71  uint8_t type; // one of ADDRESS_TYPE_* values
72  uint8_t addr[6]; // in big-endian
74 
76 typedef struct {
77  uint8_t uuid[16]; // in big-endian
79 
81 typedef struct {
82  uint8_t type; // one of ATTRIBUTE_TYPE_* values
83  uint8_t _padding;
84  union {
85  struct {
86  LLBLUETOOTH_uuid_t uuid;
87  uint8_t permissions; // combined ATTRIBUTE_PERMISSION_* values
88  uint8_t properties;
89  } characteristic;
90  struct {
91  LLBLUETOOTH_uuid_t uuid;
92  uint8_t permissions; // combined ATTRIBUTE_PERMISSION_* values
93  } descriptor;
94  };
96 
98 typedef struct {
99  LLBLUETOOTH_uuid_t uuid;
100  uint8_t num_characteristics;
101  uint8_t num_descriptors;
102  // followed by: LLBLUETOOTH_gatts_attribute_t attributes[num_char+num_desc];
104 
106 typedef struct {
107  uint8_t type; // one of ATTRIBUTE_TYPE_* values
108  uint8_t _padding;
109  LLBLUETOOTH_uuid_t uuid;
110  union {
111  struct {
112  uint16_t value_handle;
113  uint8_t properties;
114  uint8_t _padding;
115  } characteristic;
116  struct {
117  uint16_t handle;
118  } descriptor;
119  };
121 
123 typedef struct {
124  uint8_t event_type; // one of EVENT_* values
126 
128 typedef struct {
129  uint8_t event_type;
131  uint8_t rssi;
132  uint8_t adv_data_size;
133  // followed by: uint8_t adv_data[adv_data_size];
135 
137 typedef struct {
138  uint8_t event_type;
140 
142 typedef struct {
143  uint8_t event_type;
145 
147 typedef struct {
148  uint8_t event_type;
151 
153 typedef struct {
154  uint8_t event_type;
156  uint16_t conn_handle;
158 
160 typedef struct {
161  uint8_t event_type;
162  uint8_t _padding;
163  uint16_t conn_handle;
165 
167 typedef struct {
168  uint8_t event_type;
169  uint8_t _padding;
170  uint16_t conn_handle;
172 
174 typedef struct {
175  uint8_t event_type;
176  uint8_t success;
177  uint16_t conn_handle;
179 
181 typedef struct {
182  uint8_t event_type;
183  uint8_t _padding;
184  uint16_t conn_handle;
186 
188 typedef struct {
189  uint8_t event_type;
190  uint8_t _padding;
191  uint16_t conn_handle;
192  uint32_t passkey;
194 
196 typedef struct {
197  uint8_t event_type;
198  uint8_t num_attributes;
199  uint16_t conn_handle;
200  uint16_t service_handle;
201  LLBLUETOOTH_uuid_t service_uuid;
202  // followed by: LLBLUETOOTH_gattc_attribute_t attributes[num_attributes];
204 
206 typedef struct {
207  uint8_t event_type;
208  uint8_t _padding;
209  uint16_t conn_handle;
211 
213 typedef struct {
214  uint8_t event_type;
215  uint8_t status;
216  uint16_t conn_handle;
217  uint16_t attr_handle;
218  uint16_t value_size;
219  // followed by: uint8_t value[value_size];
221 
223 typedef struct {
224  uint8_t event_type;
225  uint8_t status;
226  uint16_t conn_handle;
227  uint16_t attr_handle;
229 
231 typedef struct {
232  uint8_t event_type;
233  uint8_t _padding;
234  uint16_t conn_handle;
235  uint16_t attr_handle;
236  uint16_t value_size;
237  // followed by: uint8_t value[value_size];
239 
241 typedef struct {
242  uint8_t event_type;
243  uint8_t _padding;
244  uint16_t conn_handle;
245  uint16_t attr_handle;
247 
249 typedef struct {
250  uint8_t event_type;
251  uint8_t _padding;
252  uint16_t conn_handle;
253  uint16_t attr_handle;
254  uint16_t value_size;
255  // followed by: uint8_t value[value_size];
257 
259 typedef struct {
260  uint8_t event_type;
261  uint8_t success;
262  uint16_t conn_handle;
263  uint16_t attr_handle;
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif // _LLBLUETOOTH_DEFINES