forked from tato123/nrf8001_arm_support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aci_evts.h
executable file
·397 lines (356 loc) · 12 KB
/
aci_evts.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/* Copyright (c) 2014, Nordic Semiconductor ASA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* @file
*
* @ingroup aci
*
* @brief Definitions for the ACI (Application Control Interface) events
*/
#ifndef ACI_EVTS_H__
#define ACI_EVTS_H__
#include "aci.h"
/**
* @enum aci_evt_opcode_t
* @brief ACI event opcodes
*/
typedef enum
{
/**
* Invalid event code
*/
ACI_EVT_INVALID = 0x00,
/**
* Sent every time the device starts
*/
ACI_EVT_DEVICE_STARTED = 0x81,
/**
* Mirrors the ACI_CMD_ECHO
*/
ACI_EVT_ECHO = 0x82,
/**
* Asynchronous hardware error event
*/
ACI_EVT_HW_ERROR = 0x83,
/**
* Event opcode used as a event response for all commands
*/
ACI_EVT_CMD_RSP = 0x84,
/**
* Link connected
*/
ACI_EVT_CONNECTED = 0x85,
/**
* Link disconnected
*/
ACI_EVT_DISCONNECTED = 0x86,
/**
* Bond completion result
*/
ACI_EVT_BOND_STATUS = 0x87,
/**
* Pipe bitmap for available pipes
*/
ACI_EVT_PIPE_STATUS = 0x88,
/**
* Sent to the application when the radio enters a connected state
* or when the timing of the radio connection changes
*/
ACI_EVT_TIMING = 0x89,
/**
* Notification to the application that transmit credits are
* available
*/
ACI_EVT_DATA_CREDIT = 0x8A,
/**
* Data acknowledgement event
*/
ACI_EVT_DATA_ACK = 0x8B,
/**
* Data received notification event
*/
ACI_EVT_DATA_RECEIVED = 0x8C,
/**
* Error notification event
*/
ACI_EVT_PIPE_ERROR = 0x8D,
/**
* Display Passkey Event
*/
ACI_EVT_DISPLAY_PASSKEY = 0x8E,
/**
* Security Key request
*/
ACI_EVT_KEY_REQUEST = 0x8F
} _aci_packed_ aci_evt_opcode_t;
ACI_ASSERT_SIZE(aci_evt_opcode_t, 1);
/**
* @struct aci_evt_params_device_started_t
* @brief Structure for the ACI_EVT_DEVICE_STARTED event return parameters
*/
typedef struct
{
aci_device_operation_mode_t device_mode; /**< Mode in which the device is being started */
aci_hw_error_t hw_error; /**< Hardware Error if available for the start */
uint8_t credit_available; /**< Flow control credit available for this specific FW build */
} _aci_packed_ aci_evt_params_device_started_t;
ACI_ASSERT_SIZE(aci_evt_params_device_started_t, 3);
/**
* @struct aci_evt_params_hw_error_t
* @brief Structure for the ACI_EVT_HW_ERROR event return parameters
*/
typedef struct
{
uint16_t line_num;
uint8_t file_name[20];
} _aci_packed_ aci_evt_params_hw_error_t;
ACI_ASSERT_SIZE(aci_evt_params_hw_error_t, 22);
/**
* @struct aci_evt_cmd_rsp_params_dtm_cmd_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_DTM_CMD event return parameters
*/
typedef struct
{
uint8_t evt_msb;
uint8_t evt_lsb;
} _aci_packed_ aci_evt_cmd_rsp_params_dtm_cmd_t;
/**
* @struct aci_evt_cmd_rsp_read_dynamic_data_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_READ_DYNAMIC_DATA event return parameters
* @note Dynamic data chunk size in this event is defined to go up to ACI_PACKET_MAX_LEN - 5
*/
typedef struct
{
uint8_t seq_no;
uint8_t dynamic_data[1];
} _aci_packed_ aci_evt_cmd_rsp_read_dynamic_data_t;
/**
* @struct aci_evt_cmd_rsp_params_get_device_version_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_VERSION event return parameters
*/
typedef struct
{
uint16_t configuration_id;
uint8_t aci_version;
uint8_t setup_format;
uint32_t setup_id;
uint8_t setup_status;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_version_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_version_t, 9);
/**
* @struct aci_evt_cmd_rsp_params_get_device_address_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_ADDRESS event return parameters
*/
typedef struct
{
uint8_t bd_addr_own[BTLE_DEVICE_ADDRESS_SIZE];
aci_bd_addr_type_t bd_addr_type;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_address_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_address_t, BTLE_DEVICE_ADDRESS_SIZE + 1);
/**
* @struct aci_evt_cmd_rsp_params_get_battery_level_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_BATTERY_LEVEL event return parameters
*/
typedef struct
{
uint16_t battery_level;
} _aci_packed_ aci_evt_cmd_rsp_params_get_battery_level_t;
/**
* @struct aci_evt_cmd_rsp_params_get_temperature_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_TEMPERATURE event return parameters
*/
typedef struct
{
int16_t temperature_value;
} _aci_packed_ aci_evt_cmd_rsp_params_get_temperature_t;
/**
* @struct aci_evt_params_cmd_rsp_t
* @brief Structure for the ACI_EVT_CMD_RSP event return parameters
*/
typedef struct
{
aci_cmd_opcode_t cmd_opcode; /**< Command opcode for which the event response is being sent */
aci_status_code_t cmd_status; /**< Status of the command that was sent. Used in the context of the command. */
union
{
aci_evt_cmd_rsp_params_dtm_cmd_t dtm_cmd;
aci_evt_cmd_rsp_read_dynamic_data_t read_dynamic_data;
aci_evt_cmd_rsp_params_get_device_version_t get_device_version;
aci_evt_cmd_rsp_params_get_device_address_t get_device_address;
aci_evt_cmd_rsp_params_get_battery_level_t get_battery_level;
aci_evt_cmd_rsp_params_get_temperature_t get_temperature;
uint8_t padding[29];
} params;
} _aci_packed_ aci_evt_params_cmd_rsp_t;
ACI_ASSERT_SIZE(aci_evt_params_cmd_rsp_t, 31);
/**
* @struct aci_evt_params_connected_t
* @brief Structure for the ACI_EVT_CONNECTED event return parameters
*/
typedef struct
{
aci_bd_addr_type_t dev_addr_type;
uint8_t dev_addr[BTLE_DEVICE_ADDRESS_SIZE];
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
aci_clock_accuracy_t master_clock_accuracy; /**< Clock accuracy of Bluetooth master: Enumerated list of values from 500 ppm to 20 ppm */
} _aci_packed_ aci_evt_params_connected_t;
ACI_ASSERT_SIZE(aci_evt_params_connected_t, 14);
/**
* @struct aci_evt_params_disconnected_t
* @brief Structure for the ACI_EVT_DISCONNECTED event return parameters
*/
typedef struct
{
aci_status_code_t aci_status;
uint8_t btle_status;
} _aci_packed_ aci_evt_params_disconnected_t;
ACI_ASSERT_SIZE(aci_evt_params_disconnected_t, 2);
/**
* @struct aci_evt_params_bond_status_t
* @brief Structure for the ACI_EVT_BOND_STATUS event return parameters
*/
typedef struct
{
aci_bond_status_code_t status_code;
aci_bond_status_source_t status_source;
uint8_t secmode1_bitmap;
uint8_t secmode2_bitmap;
uint8_t keys_exchanged_slave;
uint8_t keys_exchanged_master;
} _aci_packed_ aci_evt_params_bond_status_t;
ACI_ASSERT_SIZE(aci_evt_params_bond_status_t, 6);
/**
* @struct aci_evt_params_pipe_status_t
* @brief Structure for the ACI_EVT_PIPE_STATUS event return parameters
*/
typedef struct
{
uint8_t pipes_open_bitmap[8];
uint8_t pipes_closed_bitmap[8];
} _aci_packed_ aci_evt_params_pipe_status_t;
ACI_ASSERT_SIZE(aci_evt_params_pipe_status_t, 16);
/**
* @struct aci_evt_params_timing_t
* @brief Structure for the ACI_EVT_TIMING event return parameters
*/
typedef struct
{
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
} _aci_packed_ aci_evt_params_timing_t;
ACI_ASSERT_SIZE(aci_evt_params_timing_t, 6);
/**
* @struct aci_evt_params_data_credit_t
* @brief Structure for the ACI_EVT_DATA_CREDIT event return parameters
*/
typedef struct
{
uint8_t credit;
} _aci_packed_ aci_evt_params_data_credit_t;
/**
* @struct aci_evt_params_data_ack_t
* @brief Structure for the ACI_EVT_DATA_ACK event return parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_evt_params_data_ack_t;
/**
* @struct aci_evt_params_data_received_t
* @brief Structure for the ACI_EVT_DATA_RECEIVED event return parameters
*/
typedef struct
{
aci_rx_data_t rx_data;
} _aci_packed_ aci_evt_params_data_received_t;
typedef struct
{
uint8_t content[1];
} _aci_packed_ error_data_t;
/**
* @struct aci_evt_params_pipe_error_t
* @brief Structure for the ACI_EVT_PIPE_ERROR event return parameters
*/
typedef struct
{
uint8_t pipe_number;
uint8_t error_code;
union
{
error_data_t error_data;
} params;
} _aci_packed_ aci_evt_params_pipe_error_t;
/**
* @struct aci_evt_params_display_passkey_t
* @brief Structure for the ACI_EVT_DISPLAY_PASSKEY event return parameters
*/
typedef struct
{
uint8_t passkey[6];
} _aci_packed_ aci_evt_params_display_passkey_t;
/**
* @struct aci_evt_params_key_request_t
* @brief Structure for the ACI_EVT_KEY_REQUEST event return parameters
*/
typedef struct
{
aci_key_type_t key_type;
} _aci_packed_ aci_evt_params_key_request_t;
/**
* @struct aci_event_params_echo_t
* @brief Structure for the ACI_EVT_ECHO ACI event parameters
*/
typedef struct
{
uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
} _aci_packed_ aci_evt_params_echo_t;
/**
* @struct aci_evt_t
* @brief Encapsulates a generic ACI event
*/
typedef struct
{
uint8_t len;
aci_evt_opcode_t evt_opcode;
union
{
aci_evt_params_device_started_t device_started;
aci_evt_params_echo_t echo;
aci_evt_params_hw_error_t hw_error;
aci_evt_params_cmd_rsp_t cmd_rsp;
aci_evt_params_connected_t connected;
aci_evt_params_disconnected_t disconnected;
aci_evt_params_bond_status_t bond_status;
aci_evt_params_pipe_status_t pipe_status;
aci_evt_params_timing_t timing;
aci_evt_params_data_credit_t data_credit;
aci_evt_params_data_ack_t data_ack;
aci_evt_params_data_received_t data_received;
aci_evt_params_pipe_error_t pipe_error;
aci_evt_params_display_passkey_t display_passkey;
aci_evt_params_key_request_t key_request;
} params;
} _aci_packed_ aci_evt_t;
ACI_ASSERT_SIZE(aci_evt_t, 33);
#endif // ACI_EVTS_H__