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 #ifndef _HAL_GAPC_TASK_H 16 #define _HAL_GAPC_TASK_H 17 18 #include "ble_ip_task.h" // Task definitions 19 #include "hal_gap.h" 20 #include <stdbool.h> 21 #include "ble_ke_msg_type.h" 22 23 /// GAP Controller Task messages 24 /*@TRACE*/ 25 enum gapc_msg_id 26 { 27 /* Default event */ 28 /// Command Complete event 29 GAPC_CMP_EVT = TASK_FIRST_MSG(TASK_ID_GAPC),//!< GAPC_CMP_EVT 30 31 /* Connection state information */ 32 /// Indicate that a connection has been established 33 GAPC_CONNECTION_REQ_IND, //!< GAPC_CONNECTION_REQ_IND 34 /// Set specific link data configuration. 35 GAPC_CONNECTION_CFM, //!< GAPC_CONNECTION_CFM 36 37 /// Indicate that a link has been disconnected 38 GAPC_DISCONNECT_IND, //!< GAPC_DISCONNECT_IND 39 40 /* Link management command */ 41 /// Request disconnection of current link command. 42 GAPC_DISCONNECT_CMD, //!< GAPC_DISCONNECT_CMD 43 44 /* Peer device info */ 45 /// Retrieve information command 46 GAPC_GET_INFO_CMD, //!< GAPC_GET_INFO_CMD 47 /// Peer device attribute DB info such as Device Name, Appearance or Slave Preferred Parameters 48 GAPC_PEER_ATT_INFO_IND, //!< GAPC_PEER_ATT_INFO_IND 49 /// Indication of peer version info 50 GAPC_PEER_VERSION_IND, //!< GAPC_PEER_VERSION_IND 51 /// Indication of peer features info 52 GAPC_PEER_FEATURES_IND, //!< GAPC_PEER_FEATURES_IND 53 /// Indication of ongoing connection RSSI 54 GAPC_CON_RSSI_IND, //!< GAPC_CON_RSSI_IND 55 56 /* Device Name Management */ 57 /// Peer device request local device info such as name, appearance or slave preferred parameters 58 GAPC_GET_DEV_INFO_REQ_IND, //!< GAPC_GET_DEV_INFO_REQ_IND 59 /// Send requested info to peer device 60 GAPC_GET_DEV_INFO_CFM, //!< GAPC_GET_DEV_INFO_CFM 61 /// Peer device request to modify local device info such as name or appearance 62 GAPC_SET_DEV_INFO_REQ_IND, //!< GAPC_SET_DEV_INFO_REQ_IND 63 /// Local device accept or reject device info modification 64 GAPC_SET_DEV_INFO_CFM, //!< GAPC_SET_DEV_INFO_CFM 65 66 /* Connection parameters update */ 67 /// Perform update of connection parameters command 68 GAPC_PARAM_UPDATE_CMD, //!< GAPC_PARAM_UPDATE_CMD 69 /// Request of updating connection parameters indication 70 GAPC_PARAM_UPDATE_REQ_IND, //!< GAPC_PARAM_UPDATE_REQ_IND 71 /// Master confirm or not that parameters proposed by slave are accepted or not 72 GAPC_PARAM_UPDATE_CFM, //!< GAPC_PARAM_UPDATE_CFM 73 /// Connection parameters updated indication 74 GAPC_PARAM_UPDATED_IND, //!< GAPC_PARAM_UPDATED_IND 75 76 /* Bonding procedure */ 77 /// Start Bonding command procedure 78 GAPC_BOND_CMD, //!< GAPC_BOND_CMD 79 /// Bonding requested by peer device indication message. 80 GAPC_BOND_REQ_IND, //!< GAPC_BOND_REQ_IND 81 /// Confirm requested bond information. 82 GAPC_BOND_CFM, //!< GAPC_BOND_CFM 83 /// Bonding information indication message 84 GAPC_BOND_IND, //!< GAPC_BOND_IND 85 86 /* Encryption procedure */ 87 /// Start Encryption command procedure 88 GAPC_ENCRYPT_CMD, //!< GAPC_ENCRYPT_CMD 89 /// Encryption requested by peer device indication message. 90 GAPC_ENCRYPT_REQ_IND, //!< GAPC_ENCRYPT_REQ_IND 91 /// Confirm requested Encryption information. 92 GAPC_ENCRYPT_CFM, //!< GAPC_ENCRYPT_CFM 93 /// Encryption information indication message 94 GAPC_ENCRYPT_IND, //!< GAPC_ENCRYPT_IND 95 96 /* Security request procedure */ 97 /// Start Security Request command procedure 98 GAPC_SECURITY_CMD, //!< GAPC_SECURITY_CMD 99 /// Security requested by peer device indication message 100 GAPC_SECURITY_IND, //!< GAPC_SECURITY_IND 101 102 /* Signature procedure */ 103 /// Indicate the current sign counters to the application 104 GAPC_SIGN_COUNTER_IND, //!< GAPC_SIGN_COUNTER_IND 105 106 /* Device information */ 107 /// Indication of ongoing connection Channel Map 108 GAPC_CON_CHANNEL_MAP_IND, //!< GAPC_CON_CHANNEL_MAP_IND 109 110 /* Deprecated */ 111 /// Deprecated messages 112 GAPC_DEPRECATED_0, //!< GAPC_DEPRECATED_0 113 GAPC_DEPRECATED_1, //!< GAPC_DEPRECATED_1 114 GAPC_DEPRECATED_2, //!< GAPC_DEPRECATED_2 115 GAPC_DEPRECATED_3, //!< GAPC_DEPRECATED_3 116 GAPC_DEPRECATED_4, //!< GAPC_DEPRECATED_4 117 GAPC_DEPRECATED_5, //!< GAPC_DEPRECATED_5 118 GAPC_DEPRECATED_6, //!< GAPC_DEPRECATED_6 119 GAPC_DEPRECATED_7, //!< GAPC_DEPRECATED_7 120 GAPC_DEPRECATED_8, //!< GAPC_DEPRECATED_8 121 GAPC_DEPRECATED_9, //!< GAPC_DEPRECATED_9 122 123 /* LE Ping */ 124 /// Update LE Ping timeout value 125 GAPC_SET_LE_PING_TO_CMD, //!< GAPC_SET_LE_PING_TO_CMD 126 /// LE Ping timeout indication 127 GAPC_LE_PING_TO_VAL_IND, //!< GAPC_LE_PING_TO_VAL_IND 128 /// LE Ping timeout expires indication 129 GAPC_LE_PING_TO_IND, //!< GAPC_LE_PING_TO_IND 130 131 /* LE Data Length extension*/ 132 /// LE Set Data Length Command 133 GAPC_SET_LE_PKT_SIZE_CMD, //!< GAPC_SET_LE_PKT_SIZE_CMD 134 /// LE Set Data Length Indication 135 GAPC_LE_PKT_SIZE_IND, //!< GAPC_LE_PKT_SIZE_IND 136 137 /* Secure Connections */ 138 /// Request to inform the remote device when keys have been entered or erased 139 GAPC_KEY_PRESS_NOTIFICATION_CMD, //!< GAPC_KEY_PRESS_NOTIFICATION_CMD 140 /// Indication that a KeyPress has been performed on the peer device. 141 GAPC_KEY_PRESS_NOTIFICATION_IND, //!< GAPC_KEY_PRESS_NOTIFICATION_IND 142 143 /* PHY Management */ 144 /// Set the PHY configuration for current active link 145 GAPC_SET_PHY_CMD, //!< GAPC_SET_PHY_CMD 146 /// Active link PHY configuration. Triggered when configuration is read or during an update. 147 GAPC_LE_PHY_IND, //!< GAPC_LE_PHY_IND 148 149 /* Channel Selection Algorithm */ 150 /// Indication of currently used channel selection algorithm 151 /// @see struct gapc_chan_sel_algo_ind 152 GAPC_CHAN_SEL_ALGO_IND, //!< GAPC_CHAN_SEL_ALGO_IND 153 154 /* Preferred Slave Latency */ 155 /// Set the preferred slave latency (for slave only, with RW controller) 156 GAPC_SET_PREF_SLAVE_LATENCY_CMD, //!< GAPC_SET_PREF_SLAVE_LATENCY_CMD 157 /// Set the preferred slave event duration (for slave only, with RW controller) 158 GAPC_SET_PREF_SLAVE_EVT_DUR_CMD, //!< GAPC_SET_PREF_SLAVE_EVT_DUR_CMD 159 160 /// Indication to the task that sends the unknown message 161 GAPC_UNKNOWN_MSG_IND, //!< GAPC_UNKNOWN_MSG_IND 162 163 // ---------------------- INTERNAL API ------------------------ 164 /* Internal messages for timer events, not part of API*/ 165 /// Signature procedure 166 GAPC_SIGN_CMD, //!< GAPC_SIGN_CMD 167 /// Signature result 168 GAPC_SIGN_IND, //!< GAPC_SIGN_IND 169 170 /// Parameter update procedure timeout indication 171 GAPC_PARAM_UPDATE_TO_IND, //!< GAPC_PARAM_UPDATE_TO_IND 172 /// Pairing procedure timeout indication 173 GAPC_SMP_TIMEOUT_TIMER_IND, //!< GAPC_SMP_TIMEOUT_TIMER_IND 174 /// Pairing repeated attempts procedure timeout indication 175 GAPC_SMP_REP_ATTEMPTS_TIMER_IND, //!< GAPC_SMP_REP_ATTEMPTS_TIMER_IND 176 }; 177 178 179 180 181 /// request operation type - application interface 182 /*@TRACE*/ 183 enum gapc_operation 184 { 185 /* Operation Flags */ 186 /* No Operation (if nothing has been requested) */ 187 /* ************************************************ */ 188 /// No operation 189 GAPC_NO_OP = 0x00, 190 191 /* Connection management */ 192 /// Disconnect link 193 GAPC_DISCONNECT, 194 195 /* Connection information */ 196 /// Retrieve name of peer device. 197 GAPC_GET_PEER_NAME, 198 /// Retrieve peer device version info. 199 GAPC_GET_PEER_VERSION, 200 /// Retrieve peer device features. 201 GAPC_GET_PEER_FEATURES, 202 /// Get Peer device appearance 203 GAPC_GET_PEER_APPEARANCE, 204 /// Get Peer device Slaved Preferred Parameters 205 GAPC_GET_PEER_SLV_PREF_PARAMS, 206 /// Retrieve connection RSSI. 207 GAPC_GET_CON_RSSI, 208 /// Retrieve Connection Channel MAP. 209 GAPC_GET_CON_CHANNEL_MAP, 210 211 /* Connection parameters update */ 212 /// Perform update of connection parameters. 213 GAPC_UPDATE_PARAMS, 214 215 /* Security procedures */ 216 /// Start bonding procedure. 217 GAPC_BOND, 218 /// Start encryption procedure. 219 GAPC_ENCRYPT, 220 /// Start security request procedure 221 GAPC_SECURITY_REQ, 222 223 /* Deprecated */ 224 /// Deprecated operation 225 GAPC_OP_DEPRECATED_0, 226 GAPC_OP_DEPRECATED_1, 227 GAPC_OP_DEPRECATED_2, 228 GAPC_OP_DEPRECATED_3, 229 GAPC_OP_DEPRECATED_4, 230 231 /* LE Ping*/ 232 /// get timer timeout value 233 GAPC_GET_LE_PING_TO, 234 /// set timer timeout value 235 GAPC_SET_LE_PING_TO, 236 237 /* LE Data Length extension*/ 238 /// LE Set Data Length 239 GAPC_SET_LE_PKT_SIZE, 240 241 /* Central Address resolution supported*/ 242 GAPC_GET_ADDR_RESOL_SUPP, 243 244 /* Secure Connections */ 245 /// Request to inform the remote device when keys have been entered or erased 246 GAPC_KEY_PRESS_NOTIFICATION, 247 248 /* PHY Management */ 249 /// Set the PHY configuration for current active link 250 GAPC_SET_PHY, 251 /// Retrieve PHY configuration of active link 252 GAPC_GET_PHY, 253 254 /* Channel Selection Algorithm */ 255 /// Retrieve Channel Selection Algorithm 256 GAPC_GET_CHAN_SEL_ALGO, 257 258 /* Preferred slave latency */ 259 /// Set the preferred slave latency (for slave only, with RW controller) 260 GAPC_SET_PREF_SLAVE_LATENCY, 261 /// Set the preferred slave event duration (for slave only, with RW controller) 262 GAPC_SET_PREF_SLAVE_EVT_DUR, 263 264 // ---------------------- INTERNAL API ------------------------ 265 /* Packet signature */ 266 /// sign an attribute packet 267 GAPC_SIGN_PACKET, 268 /// Verify signature or an attribute packet 269 GAPC_SIGN_CHECK, 270 }; 271 272 /// Bond event type. 273 /*@TRACE*/ 274 enum gapc_bond 275 { 276 /// Bond Pairing request 277 GAPC_PAIRING_REQ, 278 /// Respond to Pairing request 279 GAPC_PAIRING_RSP, 280 281 /// Pairing Finished information 282 GAPC_PAIRING_SUCCEED, 283 /// Pairing Failed information 284 GAPC_PAIRING_FAILED, 285 286 /// Used to retrieve pairing Temporary Key 287 GAPC_TK_EXCH, 288 /// Used for Identity Resolving Key exchange 289 GAPC_IRK_EXCH, 290 /// Used for Connection Signature Resolving Key exchange 291 GAPC_CSRK_EXCH, 292 /// Used for Long Term Key exchange 293 GAPC_LTK_EXCH, 294 295 /// Bond Pairing request issue, Repeated attempt 296 GAPC_REPEATED_ATTEMPT, 297 298 /// Out of Band - exchange of confirm and rand. 299 GAPC_OOB_EXCH, 300 301 /// Numeric Comparison - Exchange of Numeric Value - 302 GAPC_NC_EXCH 303 }; 304 305 /// List of device info that should be provided by application 306 /*@TRACE*/ 307 enum gapc_dev_info 308 { 309 /// Device Name 310 GAPC_DEV_NAME, 311 /// Device Appearance Icon 312 GAPC_DEV_APPEARANCE, 313 /// Device Slave preferred parameters 314 GAPC_DEV_SLV_PREF_PARAMS, 315 /// Device Central address resolution 316 GAPC_DEV_CTL_ADDR_RESOL, 317 /// maximum device info parameter 318 GAPC_DEV_INFO_MAX, 319 }; 320 321 /// List of features available on a device 322 enum gapc_features_list 323 { 324 /// LE encryption 325 GAPC_ENCRYPT_FEAT_MASK = (1 << 0), 326 /// Connection Parameters Request Procedure 327 GAPC_CONN_PARAM_REQ_FEAT_MASK = (1 << 1), 328 /// Extended Reject Indication 329 GAPC_EXT_REJECT_IND_FEAT_MASK = (1 << 2), 330 /// Slave-initiated Features Exchange 331 GAPC_SLAVE_FEAT_EXCH_FEAT_MASK = (1 << 3), 332 /// LE ping 333 GAPC_LE_PING_FEAT_MASK = (1 << 4) 334 }; 335 336 /// Option for PHY configuration 337 enum gapc_phy_option 338 { 339 /// No preference for rate used when transmitting on the LE Coded PHY 340 GAPC_PHY_OPT_LE_CODED_ALL_RATES = (1 << 0), 341 /// 500kbps rate preferred when transmitting on the LE Coded PHY 342 GAPC_PHY_OPT_LE_CODED_500K_RATE = (1 << 1), 343 /// 125kbps when transmitting on the LE Coded PHY 344 GAPC_PHY_OPT_LE_CODED_125K_RATE = (1 << 2), 345 }; 346 347 /** GAP device external appearance */ 348 enum gapc_appearance{ 349 GAPC_APPEARANCE_UNKNOWN = 0, 350 GAPC_APPEARANCE_GENERIC_PHONE = 64, 351 GAPC_APPEARANCE_GENERIC_COMPUTER = 128, 352 GAPC_APPEARANCE_GENERIC_WATCH = 192, 353 GAPC_APPEARANCE_WATCH_SPORTS_WATCH = 193, 354 GAPC_APPEARANCE_GENERIC_CLOCK = 256, 355 GAPC_APPEARANCE_GENERIC_DISPLAY = 320, 356 GAPC_APPEARANCE_GENERIC_REMOTE_CONTROL = 384, 357 GAPC_APPEARANCE_GENERIC_EYE_GLASSES = 448, 358 GAPC_APPEARANCE_GENERIC_TAG = 512, 359 GAPC_APPEARANCE_GENERIC_KEYRING = 576, 360 GAPC_APPEARANCE_GENERIC_MEDIA_PLAYER = 640, 361 GAPC_APPEARANCE_GENERIC_BARCODE_SCANNER = 704, 362 GAPC_APPEARANCE_GENERIC_THERMOMETER = 768, 363 GAPC_APPEARANCE_THERMOMETER_EAR = 769, 364 GAPC_APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832, 365 GAPC_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT = 833, 366 GAPC_APPEARANCE_GENERIC_BLOOD_PRESSURE = 896, 367 GAPC_APPEARANCE_BLOOD_PRESSURE_ARM = 897, 368 GAPC_APPEARANCE_BLOOD_PRESSURE_WRIST = 898, 369 GAPC_APPEARANCE_GENERIC_HID = 960, 370 GAPC_APPEARANCE_HID_KEYBOARD = 961, 371 GAPC_APPEARANCE_HID_MOUSE = 962, 372 GAPC_APPEARANCE_HID_JOYSTICK = 963, 373 GAPC_APPEARANCE_HID_GAMEPAD = 964, 374 GAPC_APPEARANCE_HID_DIGITIZER_TABLET = 965, 375 GAPC_APPEARANCE_HID_CARD_READER = 966, 376 GAPC_APPEARANCE_HID_DIGITAL_PEN = 967, 377 GAPC_APPEARANCE_HID_BARCODE_SCANNER = 968, 378 GAPC_APPEARANCE_GENERIC_GLUCOSE_METER = 1024, 379 GAPC_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088, 380 GAPC_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089, 381 GAPC_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090, 382 GAPC_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091, 383 GAPC_APPEARANCE_GENERIC_CYCLING = 1152, 384 GAPC_APPEARANCE_CYCLING_CYCLING_COMPUTER = 1153, 385 GAPC_APPEARANCE_CYCLING_SPEED_SENSOR = 1154, 386 GAPC_APPEARANCE_CYCLING_CADENCE_SENSOR = 1155, 387 GAPC_APPEARANCE_CYCLING_POWER_SENSOR = 1156, 388 GAPC_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, 389 GAPC_APPEARANCE_GENERIC_PULSE_OXIMETER = 3136, 390 GAPC_APPEARANCE_PULSE_OXIMETER_FINGERTIP = 3137, 391 GAPC_APPEARANCE_PULSE_OXIMETER_WRIST_WORN = 3138, 392 GAPC_APPEARANCE_GENERIC_WEIGHT_SCALE = 3200, 393 GAPC_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACTIVITY = 5184, 394 GAPC_APPEARANCE_OUTDOOR_SPORTS_ACT_LOCATION_DISPLAY = 5185, 395 GAPC_APPEARANCE_OUTDOOR_SPORTS_ACT_LOCATION_AND_NAVIGATION_DISPLAY = 5186, 396 GAPC_APPEARANCE_OUTDOOR_SPORTS_ACT_LOCATION_POD = 5187, 397 GAPC_APPEARANCE_OUTDOOR_SPORTS_ACT_LOCATION_AND_NAVIGATION_POD = 5188, 398 // dummy appearance ID 399 GAPC_APPEARANCE_LAST, 400 }; 401 402 /* 403 * TYPE DEFINITIONS 404 **************************************************************************************** 405 */ 406 407 /// Operation command structure in order to keep requested operation. 408 struct gapc_operation_cmd 409 { 410 /// GAP request type 411 uint8_t operation; 412 }; 413 414 415 /// Command complete event data structure 416 /*@TRACE*/ 417 struct gapc_cmp_evt 418 { 419 /// GAP request type 420 uint8_t operation; 421 /// Status of the request 422 uint8_t status; 423 }; 424 425 /// Indicate that an unknown message has been received 426 /*@TRACE*/ 427 struct gapc_unknown_msg_ind 428 { 429 /// Unknown message id 430 ke_msg_id_t unknown_msg_id; 431 }; 432 433 /// Indicate that a connection has been established 434 /*@TRACE*/ 435 struct gapc_connection_req_ind 436 { 437 /// Connection handle 438 uint16_t conhdl; 439 /// Connection interval 440 uint16_t con_interval; 441 /// Connection latency 442 uint16_t con_latency; 443 /// Link supervision timeout 444 uint16_t sup_to; 445 /// Clock accuracy 446 uint8_t clk_accuracy; 447 /// Peer address type 448 uint8_t peer_addr_type; 449 /// Peer BT address 450 bd_addr_t peer_addr; 451 /// Role of device in connection (0 = Master / 1 = Slave) 452 uint8_t role; 453 }; 454 455 456 /// Set specific link data configuration. 457 /*@TRACE*/ 458 struct gapc_connection_cfm 459 { 460 /// Local CSRK value 461 struct gap_sec_key lcsrk; 462 /// Local signature counter value 463 uint32_t lsign_counter; 464 465 /// Remote CSRK value 466 struct gap_sec_key rcsrk; 467 /// Remote signature counter value 468 uint32_t rsign_counter; 469 470 /// Authentication (@see gap_auth) 471 uint8_t auth; 472 /// Service Changed Indication enabled 473 uint8_t svc_changed_ind_enable; 474 /// LTK exchanged during pairing. 475 bool ltk_present; 476 }; 477 478 479 /// Request disconnection of current link command. 480 /*@TRACE*/ 481 struct gapc_disconnect_cmd 482 { 483 /// GAP request type: 484 /// - GAPC_DISCONNECT: Disconnect link. 485 uint8_t operation; 486 487 /// Reason of disconnection 488 uint8_t reason; 489 }; 490 491 492 /// Indicate that a link has been disconnected 493 /*@TRACE*/ 494 struct gapc_disconnect_ind 495 { 496 /// Connection handle 497 uint16_t conhdl; 498 /// Reason of disconnection 499 uint8_t reason; 500 }; 501 502 503 /// Retrieve information command 504 /*@TRACE*/ 505 struct gapc_get_info_cmd 506 { 507 /// GAP request type: 508 /// - GAPC_GET_PEER_NAME: Retrieve name of peer device. 509 /// - GAPC_GET_PEER_VERSION: Retrieve peer device version info. 510 /// - GAPC_GET_PEER_FEATURES: Retrieve peer device features. 511 /// - GAPC_GET_CON_RSSI: Retrieve connection RSSI. 512 /// - GAPC_GET_CON_CHANNEL_MAP: Retrieve Connection Channel MAP. 513 /// - GAPC_GET_PEER_APPEARANCE: Get Peer device appearance 514 /// - GAPC_GET_PEER_SLV_PREF_PARAMS: Get Peer device Slaved Preferred Parameters 515 /// - GAPC_GET_ADDR_RESOL_SUPP: Address Resolution Supported 516 /// - GAPC_GET_LE_PING_TIMEOUT: Retrieve LE Ping Timeout Value 517 uint8_t operation; 518 }; 519 520 /// device information data 521 /*@TRACE 522 @trc_ref gapc_dev_info*/ 523 union gapc_dev_info_val 524 { 525 /// Device name 526 //@trc_union parent.req == GAPC_DEV_NAME 527 struct gap_dev_name name; 528 /// Appearance Icon 529 //@trc_union parent.req == GAPC_DEV_APPEARANCE 530 uint16_t appearance; 531 /// Slave preferred parameters 532 //@trc_union parent.req == GAPC_DEV_SLV_PREF_PARAMS 533 struct gap_slv_pref slv_pref_params; 534 /// Central address resolution 535 //@trc_union parent.req == GAPC_DEV_CTL_ADDR_RESOL 536 uint8_t ctl_addr_resol; 537 }; 538 539 /// Peer device attribute DB info such as Device Name, Appearance or Slave Preferred Parameters 540 /*@TRACE*/ 541 struct gapc_peer_att_info_ind 542 { 543 /// Requested information 544 /// - GAPC_DEV_NAME: Device Name 545 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 546 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 547 /// - GAPC_GET_ADDR_RESOL_SUPP: Address resolution supported 548 uint8_t req; 549 /// Attribute handle 550 uint16_t handle; 551 552 /// device information data 553 union gapc_dev_info_val info; 554 }; 555 556 /// Indication of peer version info 557 /*@TRACE*/ 558 struct gapc_peer_version_ind 559 { 560 /// Manufacturer name 561 uint16_t compid; 562 /// LMP subversion 563 uint16_t lmp_subvers; 564 /// LMP version 565 uint8_t lmp_vers; 566 }; 567 568 /// Indication of peer features info 569 /*@TRACE*/ 570 struct gapc_peer_features_ind 571 { 572 /// 8-byte array for LE features 573 uint8_t features[GAP_LE_FEATS_LEN]; 574 }; 575 576 /// Indication of ongoing connection RSSI 577 /*@TRACE*/ 578 struct gapc_con_rssi_ind 579 { 580 /// RSSI value 581 int8_t rssi; 582 }; 583 584 /// Indication of ongoing connection Channel Map 585 /*@TRACE*/ 586 struct gapc_con_channel_map_ind 587 { 588 /// channel map value 589 le_chnl_map_t ch_map; 590 }; 591 592 /// Sign counter value changed due to packet signing or signature verification. 593 struct gapc_sign_counter_updated_ind 594 { 595 /// New Local signature counter value 596 uint32_t lsign_counter; 597 /// New Remote signature counter value 598 uint32_t rsign_counter; 599 }; 600 601 /// Indication of LE Ping 602 /*@TRACE*/ 603 struct gapc_le_ping_to_val_ind 604 { 605 ///Authenticated payload timeout 606 uint16_t timeout; 607 }; 608 609 610 /// Peer device request local device info such as name, appearance or slave preferred parameters 611 /*@TRACE*/ 612 struct gapc_get_dev_info_req_ind 613 { 614 /// Requested information 615 /// - GAPC_DEV_NAME: Device Name 616 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 617 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 618 uint8_t req; 619 }; 620 621 622 623 /// Send requested info to peer device 624 /*@TRACE*/ 625 struct gapc_get_dev_info_cfm 626 { 627 /// Requested information 628 /// - GAPC_DEV_NAME: Device Name 629 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 630 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 631 uint8_t req; 632 633 /// Peer device information data 634 union gapc_dev_info_val info; 635 }; 636 637 /// device information data 638 /*@TRACE 639 @trc_ref gapc_dev_info*/ 640 union gapc_set_dev_info 641 { 642 /// Device name 643 //@trc_union parent.req == GAPC_DEV_NAME 644 struct gap_dev_name name; 645 /// Appearance Icon 646 //@trc_union parent.req == GAPC_DEV_APPEARANCE 647 uint16_t appearance; 648 }; 649 650 /// Peer device request to modify local device info such as name or appearance 651 /*@TRACE*/ 652 struct gapc_set_dev_info_req_ind 653 { 654 /// Requested information 655 /// - GAPC_DEV_NAME: Device Name 656 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 657 uint8_t req; 658 659 /// device information data 660 union gapc_set_dev_info info; 661 }; 662 663 /// Local device accept or reject device info modification 664 /*@TRACE*/ 665 struct gapc_set_dev_info_cfm 666 { 667 /// Requested information 668 /// - GAPC_DEV_NAME: Device Name 669 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 670 uint8_t req; 671 672 /// Status code used to know if requested has been accepted or not 673 uint8_t status; 674 }; 675 676 /// Connection Parameter used to update connection parameters 677 struct gapc_conn_param 678 { 679 /// Connection interval minimum 680 uint16_t intv_min; 681 /// Connection interval maximum 682 uint16_t intv_max; 683 /// Latency 684 uint16_t latency; 685 /// Supervision timeout 686 uint16_t time_out; 687 }; 688 689 /// Perform update of connection parameters command 690 /*@TRACE*/ 691 struct gapc_param_update_cmd 692 { 693 /// GAP request type: 694 /// - GAPC_UPDATE_PARAMS: Perform update of connection parameters. 695 uint8_t operation; 696 /// Internal parameter used to manage internally l2cap packet identifier for signaling 697 uint8_t pkt_id; 698 /// Connection interval minimum 699 uint16_t intv_min; 700 /// Connection interval maximum 701 uint16_t intv_max; 702 /// Latency 703 uint16_t latency; 704 /// Supervision timeout 705 uint16_t time_out; 706 /// Minimum Connection Event Duration 707 uint16_t ce_len_min; 708 /// Maximum Connection Event Duration 709 uint16_t ce_len_max; 710 }; 711 712 /// Request of updating connection parameters indication 713 /*@TRACE*/ 714 struct gapc_param_update_req_ind 715 { 716 /// Connection interval minimum 717 uint16_t intv_min; 718 /// Connection interval maximum 719 uint16_t intv_max; 720 /// Latency 721 uint16_t latency; 722 /// Supervision timeout 723 uint16_t time_out; 724 }; 725 726 /// Connection parameters updated indication 727 /*@TRACE*/ 728 struct gapc_param_updated_ind 729 { 730 ///Connection interval value 731 uint16_t con_interval; 732 ///Connection latency value 733 uint16_t con_latency; 734 ///Supervision timeout 735 uint16_t sup_to; 736 }; 737 738 /// Master confirm or not that parameters proposed by slave are accepted or not 739 /*@TRACE*/ 740 struct gapc_param_update_cfm 741 { 742 /// True to accept slave connection parameters, False else. 743 bool accept; 744 /// Minimum Connection Event Duration 745 uint16_t ce_len_min; 746 /// Maximum Connection Event Duration 747 uint16_t ce_len_max; 748 }; 749 750 /// Parameters of the @ref GAPC_SET_PREF_SLAVE_LATENCY_CMD message 751 /*@TRACE*/ 752 struct gapc_set_pref_slave_latency_cmd 753 { 754 /// GAP request type: 755 /// - GAPC_SET_PREF_SLAVE_LATENCY_CMD : Set preferred slave latency 756 uint8_t operation; 757 /// Preferred latency that the controller should use on a connection (in number of connection events) 758 uint16_t latency; 759 }; 760 761 /// Parameters of the @ref GAPC_SET_PREF_SLAVE_EVT_DUR_CMD message 762 /*@TRACE*/ 763 struct gapc_set_pref_slave_evt_dur_cmd 764 { 765 /// GAP request type: 766 /// - GAPC_SET_PREF_SLAVE_EVT_DUR_CMD : Set preferred slave event duration 767 uint8_t operation; 768 /// Preferred event duration that the controller should use on a connection (N * 0.625 ms) 769 uint16_t duration; 770 /// Slave transmits a single packet per connection event (False/True) 771 uint8_t single_tx; 772 }; 773 774 /// Pairing parameters 775 /*@TRACE*/ 776 struct gapc_pairing 777 { 778 /// IO capabilities (@see gap_io_cap) 779 uint8_t iocap; 780 /// OOB information (@see gap_oob) 781 uint8_t oob; 782 /// Authentication (@see gap_auth) 783 /// Note in BT 4.1 the Auth Field is extended to include 'Key Notification' and 784 /// and 'Secure Connections'. 785 uint8_t auth; 786 /// Encryption key size (7 to 16) 787 uint8_t key_size; 788 ///Initiator key distribution (@see gap_kdist) 789 uint8_t ikey_dist; 790 ///Responder key distribution (@see gap_kdist) 791 uint8_t rkey_dist; 792 793 /// Device security requirements (minimum security level). (@see gap_sec_req) 794 uint8_t sec_req; 795 }; 796 797 /// Long Term Key information 798 /*@TRACE*/ 799 struct gapc_ltk 800 { 801 /// Long Term Key 802 struct gap_sec_key ltk; 803 /// Encryption Diversifier 804 uint16_t ediv; 805 /// Random Number 806 rand_nb_t randnb; 807 /// Encryption key size (7 to 16) 808 uint8_t key_size; 809 }; 810 /// Out of Band Information 811 /*@TRACE*/ 812 struct gapc_oob 813 { 814 /// Confirm Value 815 uint8_t conf[GAP_KEY_LEN]; 816 /// Random Number 817 uint8_t rand[GAP_KEY_LEN]; 818 }; 819 820 /*@TRACE*/ 821 struct gapc_nc 822 { 823 uint8_t value[4]; 824 }; 825 826 /// Identity Resolving Key information 827 /*@TRACE*/ 828 struct gapc_irk 829 { 830 /// Identity Resolving Key 831 struct gap_sec_key irk; 832 /// Device BD Identity Address 833 struct gap_bdaddr addr; 834 }; 835 836 837 /// Start Bonding command procedure 838 /*@TRACE*/ 839 struct gapc_bond_cmd 840 { 841 /// GAP request type: 842 /// - GAPC_BOND: Start bonding procedure. 843 uint8_t operation; 844 /// Pairing information 845 struct gapc_pairing pairing; 846 }; 847 848 /// Bond procedure requested information data 849 /*@TRACE 850 @trc_ref gapc_bond*/ 851 union gapc_bond_req_data 852 { 853 /// Authentication level (@see gap_auth) (if request = GAPC_PAIRING_REQ) 854 //@trc_union parent.request == GAPC_PAIRING_REQ 855 uint8_t auth_req; 856 /// LTK Key Size (if request = GAPC_LTK_EXCH) 857 //@trc_union parent.request == GAPC_LTK_EXCH 858 uint8_t key_size; 859 /// Device IO used to get TK: (if request = GAPC_TK_EXCH) 860 /// - GAP_TK_OOB: TK get from out of band method 861 /// - GAP_TK_DISPLAY: TK generated and shall be displayed by local device 862 /// - GAP_TK_KEY_ENTRY: TK shall be entered by user using device keyboard 863 //@trc_union parent.request == GAPC_TK_EXCH 864 uint8_t tk_type; 865 866 /// Addition OOB Data for the OOB Conf and Rand values 867 //@trc_union parent.request == GAPC_OOB_EXCH 868 struct gapc_oob oob_data; 869 /// Numeric Comparison Data 870 //@trc_union parent.request == GAPC_NC_EXCH 871 struct gapc_nc nc_data; 872 }; 873 874 /// Bonding requested by peer device indication message. 875 /*@TRACE*/ 876 struct gapc_bond_req_ind 877 { 878 /// Bond request type (@see gapc_bond) 879 uint8_t request; 880 881 /// Bond procedure requested information data 882 union gapc_bond_req_data data; 883 }; 884 885 /*@TRACE 886 @trc_ref gapc_bond 887 */ 888 union gapc_bond_cfm_data 889 { 890 /// Pairing Features (request = GAPC_PAIRING_RSP) 891 //@trc_union parent.request == GAPC_PAIRING_RSP 892 struct gapc_pairing pairing_feat; 893 /// LTK (request = GAPC_LTK_EXCH) 894 //@trc_union parent.request == GAPC_LTK_EXCH 895 struct gapc_ltk ltk; 896 /// CSRK (request = GAPC_CSRK_EXCH) 897 //@trc_union parent.request == GAPC_CSRK_EXCH 898 struct gap_sec_key csrk; 899 /// TK (request = GAPC_TK_EXCH) 900 //@trc_union parent.request == GAPC_TK_EXCH 901 struct gap_sec_key tk; 902 /// IRK (request = GAPC_IRK_EXCH) 903 //@trc_union parent.request == GAPC_IRK_EXCH 904 struct gapc_irk irk; 905 /// OOB Confirm and Random from the peer (request = GAPC_OOB_EXCH) 906 //@trc_union parent.request == GAPC_OOB_EXCH 907 struct gapc_oob oob; 908 }; 909 910 /// Confirm requested bond information. 911 /*@TRACE*/ 912 struct gapc_bond_cfm 913 { 914 /// Bond request type (@see gapc_bond) 915 uint8_t request; 916 /// Request accepted 917 uint8_t accept; 918 919 /// Bond procedure information data 920 union gapc_bond_cfm_data data; 921 }; 922 923 /** 924 * Authentication information 925 */ 926 /*@TRACE*/ 927 struct gapc_bond_auth 928 { 929 /// Authentication information (@see gap_auth) 930 uint8_t info; 931 932 /// LTK exchanged during pairing. 933 bool ltk_present; 934 }; 935 936 /// Bond procedure information data 937 /*@TRACE 938 @trc_ref gapc_bond*/ 939 union gapc_bond_data 940 { 941 /// Authentication information (@see gap_auth) 942 /// (if info = GAPC_PAIRING_SUCCEED) 943 //@trc_union parent.info == GAPC_PAIRING_SUCCEED 944 struct gapc_bond_auth auth; 945 /// Pairing failed reason (if info = GAPC_PAIRING_FAILED) 946 //@trc_union parent.info == GAPC_PAIRING_FAILED 947 uint8_t reason; 948 /// Long Term Key information (if info = GAPC_LTK_EXCH) 949 //@trc_union parent.info == GAPC_LTK_EXCH 950 struct gapc_ltk ltk; 951 /// Identity Resolving Key information (if info = GAPC_IRK_EXCH) 952 //@trc_union parent.info == GAPC_IRK_EXCH 953 struct gapc_irk irk; 954 /// Connection Signature Resolving Key information (if info = GAPC_CSRK_EXCH) 955 //@trc_union parent.info == GAPC_CSRK_EXCH 956 struct gap_sec_key csrk; 957 }; 958 959 /// Bonding information indication message 960 /*@TRACE*/ 961 struct gapc_bond_ind 962 { 963 /// Bond information type (@see gapc_bond) 964 uint8_t info; 965 966 /// Bond procedure information data 967 union gapc_bond_data data; 968 }; 969 970 /// Start Encryption command procedure 971 /*@TRACE*/ 972 struct gapc_encrypt_cmd 973 { 974 /// GAP request type: 975 /// - GAPC_ENCRYPT: Start encryption procedure. 976 uint8_t operation; 977 /// Long Term Key information 978 struct gapc_ltk ltk; 979 }; 980 981 /// Encryption requested by peer device indication message. 982 /*@TRACE*/ 983 struct gapc_encrypt_req_ind 984 { 985 /// Encryption Diversifier 986 uint16_t ediv; 987 /// Random Number 988 rand_nb_t rand_nb; 989 }; 990 991 /// Confirm requested Encryption information. 992 /*@TRACE*/ 993 struct gapc_encrypt_cfm 994 { 995 /// Indicate if a LTK has been found for the peer device 996 uint8_t found; 997 /// Long Term Key 998 struct gap_sec_key ltk; 999 /// LTK Key Size 1000 uint8_t key_size; 1001 }; 1002 1003 /// Encryption information indication message 1004 /*@TRACE*/ 1005 struct gapc_encrypt_ind 1006 { 1007 /// Authentication level (@see gap_auth) 1008 uint8_t auth; 1009 }; 1010 1011 /// Start Security Request command procedure 1012 /*@TRACE*/ 1013 struct gapc_security_cmd 1014 { 1015 /// GAP request type: 1016 /// - GAPC_SECURITY_REQ: Start security request procedure 1017 uint8_t operation; 1018 /// Authentication level (@see gap_auth) 1019 uint8_t auth; 1020 }; 1021 /// Security requested by peer device indication message 1022 /*@TRACE*/ 1023 struct gapc_security_ind 1024 { 1025 /// Authentication level (@see gap_auth) 1026 uint8_t auth; 1027 }; 1028 1029 /// Parameters of the @ref GAPC_SIGN_COUNTER_IND message 1030 /*@TRACE*/ 1031 struct gapc_sign_counter_ind 1032 { 1033 /// Local SignCounter value 1034 uint32_t local_sign_counter; 1035 /// Peer SignCounter value 1036 uint32_t peer_sign_counter; 1037 }; 1038 1039 1040 /// Parameters of the @ref GAPC_SET_LE_PING_TO_CMD message 1041 /*@TRACE*/ 1042 struct gapc_set_le_ping_to_cmd 1043 { 1044 /// GAP request type: 1045 /// - GAPC_SET_LE_PING_TO : Set the LE Ping timeout value 1046 uint8_t operation; 1047 /// Authenticated payload timeout 1048 uint16_t timeout; 1049 }; 1050 1051 /// Parameters of the @ref GAPC_SET_LE_PKT_SIZE_CMD message 1052 /*@TRACE*/ 1053 struct gapc_set_le_pkt_size_cmd 1054 { 1055 /// GAP request type: 1056 /// - GAPC_SET_LE_PKT_SIZE : Set the LE Data length value 1057 uint8_t operation; 1058 ///Preferred maximum number of payload octets that the local Controller should include 1059 ///in a single Link Layer Data Channel PDU. 1060 uint16_t tx_octets; 1061 ///Preferred maximum number of microseconds that the local Controller should use to transmit 1062 ///a single Link Layer Data Channel PDU 1063 uint16_t tx_time; 1064 }; 1065 1066 /// Parameters of the @ref GAPC_LE_PKT_SIZE_IND message 1067 /*@TRACE*/ 1068 struct gapc_le_pkt_size_ind 1069 { 1070 ///The maximum number of payload octets in TX 1071 uint16_t max_tx_octets; 1072 ///The maximum time that the local Controller will take to TX 1073 uint16_t max_tx_time; 1074 ///The maximum number of payload octets in RX 1075 uint16_t max_rx_octets; 1076 ///The maximum time that the local Controller will take to RX 1077 uint16_t max_rx_time; 1078 }; 1079 1080 /// Parameters of the @ref GAPC_KEY_PRESS_NOTIFICATION_CMD message 1081 /*@TRACE*/ 1082 struct gapc_key_press_notif_cmd 1083 { 1084 /// GAP request type: 1085 /// - GAPC_KEY_PRESS_NOTIFICATION_CMD : Inform the remote device when keys have been entered or erased 1086 uint8_t operation; 1087 /// notification type 1088 uint8_t notification_type; 1089 }; 1090 1091 /// Parameters of the @ref GAPC_KEY_PRESS_NOTIFICATION_IND message 1092 /*@TRACE*/ 1093 struct gapc_key_press_notif_ind 1094 { 1095 /// notification type 1096 uint8_t notification_type; 1097 }; 1098 1099 /// Set the PHY configuration for current active link 1100 /*@TRACE*/ 1101 struct gapc_set_phy_cmd 1102 { 1103 /// GAP request type: 1104 /// - GAPC_SET_PHY : Set the PHY configuration for current active link 1105 uint8_t operation; 1106 /// Supported LE PHY for data transmission (@see enum gap_phy) 1107 uint8_t tx_phy; 1108 /// Supported LE PHY for data reception (@see enum gap_phy) 1109 uint8_t rx_phy; 1110 /// PHY options (@see enum gapc_phy_option) 1111 uint8_t phy_opt; 1112 }; 1113 1114 /// Active link PHY configuration. Triggered when configuration is read or during an update. 1115 /*@TRACE*/ 1116 struct gapc_le_phy_ind 1117 { 1118 /// LE PHY for data transmission (@see enum gap_phy) 1119 uint8_t tx_phy; 1120 /// LE PHY for data reception (@see enum gap_phy) 1121 uint8_t rx_phy; 1122 }; 1123 1124 /// Parameters of the @ref GAPC_SIGN_CMD message 1125 /*@TRACE*/ 1126 struct gapc_sign_cmd 1127 { 1128 /// GAP request type: 1129 /// - GAPC_SIGN_PACKET: Sign an attribute packet 1130 /// - GAPC_SIGN_CHECK: Verify signature or an attribute packet 1131 uint8_t operation; 1132 /// Data PDU length (Bytes) 1133 uint16_t byte_len; 1134 /// Data PDU + SignCounter if generation, Data PDU + SignCounter + MAC if verification 1135 uint8_t msg[__ARRAY_EMPTY]; 1136 }; 1137 1138 /// Parameters of the @ref GAPC_SIGN_IND message 1139 /*@TRACE*/ 1140 struct gapc_sign_ind 1141 { 1142 /// GAP request type: 1143 /// - GAPC_SIGN_PACKET: Sign an attribute packet 1144 /// - GAPC_SIGN_CHECK: Verify signature or an attribute packet 1145 uint8_t operation; 1146 /// Data PDU length (Bytes) 1147 uint16_t byte_len; 1148 /// Data PDU + SignCounter + MAC 1149 uint8_t signed_msg[__ARRAY_EMPTY]; 1150 }; 1151 1152 /// Parameters of the @ref GAPC_CHAN_SEL_ALGO_IND 1153 /*@TRACE*/ 1154 struct gapc_chan_sel_algo_ind 1155 { 1156 /// Used channel selection algorithm 1157 uint8_t chan_sel_algo; 1158 }; 1159 1160 #endif // _HAL_GAPC_TASK_H 1161