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