1 /** 2 **************************************************************************************** 3 * 4 * @file gapc_task.h 5 * 6 * @brief Generic Access Profile Controller Task Header. 7 * 8 * Copyright (C) RivieraWaves 2009-2016 9 * 10 **************************************************************************************** 11 */ 12 #ifndef _GAPC_TASK_H_ 13 #define _GAPC_TASK_H_ 14 15 /** 16 **************************************************************************************** 17 * @addtogroup GAPC_TASK Generic Access Profile Controller Task 18 * @ingroup GAPC 19 * @brief Handles ALL messages to/from GAP Controller block. 20 * 21 * It handles messages from lower and higher layers related to an ongoing connection. 22 * 23 * @{ 24 **************************************************************************************** 25 */ 26 27 /* 28 * INCLUDE FILES 29 **************************************************************************************** 30 */ 31 #include "rwip_task.h" // Task definitions 32 #include "gap.h" 33 #include <stdbool.h> 34 35 36 /* 37 * MACROS 38 **************************************************************************************** 39 */ 40 41 /* 42 * DEFINES 43 **************************************************************************************** 44 */ 45 46 47 /// GAP Controller Task messages 48 enum gapc_msg_id 49 { 50 /* Default event */ 51 /// Command Complete event 52 GAPC_CMP_EVT = TASK_FIRST_MSG(TASK_ID_GAPC), 53 54 /* Connection state information */ 55 /// Indicate that a connection has been established 56 GAPC_CONNECTION_REQ_IND, 57 /// Set specific link data configuration. 58 GAPC_CONNECTION_CFM, 59 60 /// Indicate that a link has been disconnected 61 GAPC_DISCONNECT_IND, 62 63 /* Link management command */ 64 /// Request disconnection of current link command. 65 GAPC_DISCONNECT_CMD, 66 67 /* Peer device info */ 68 /// Retrieve information command 69 GAPC_GET_INFO_CMD, 70 /// Peer device attribute DB info such as Device Name, Appearance or Slave Preferred Parameters 71 GAPC_PEER_ATT_INFO_IND, 72 /// Indication of peer version info 73 GAPC_PEER_VERSION_IND, 74 /// Indication of peer features info 75 GAPC_PEER_FEATURES_IND, 76 /// Indication of ongoing connection RSSI 77 GAPC_CON_RSSI_IND, 78 79 /* Device Name Management */ 80 /// Peer device request local device info such as name, appearance or slave preferred parameters 81 GAPC_GET_DEV_INFO_REQ_IND, 82 /// Send requested info to peer device 83 GAPC_GET_DEV_INFO_CFM, 84 /// Peer device request to modify local device info such as name or appearance 85 GAPC_SET_DEV_INFO_REQ_IND, 86 /// Local device accept or reject device info modification 87 GAPC_SET_DEV_INFO_CFM, 88 89 /* Connection parameters update */ 90 /// Perform update of connection parameters command 91 GAPC_PARAM_UPDATE_CMD, 92 /// Request of updating connection parameters indication 93 GAPC_PARAM_UPDATE_REQ_IND, 94 /// Master confirm or not that parameters proposed by slave are accepted or not 95 GAPC_PARAM_UPDATE_CFM, 96 /// Connection parameters updated indication 97 GAPC_PARAM_UPDATED_IND, 98 99 /* Bonding procedure */ 100 /// Start Bonding command procedure 101 GAPC_BOND_CMD, 102 /// Bonding requested by peer device indication message. 103 GAPC_BOND_REQ_IND, 104 /// Confirm requested bond information. 105 GAPC_BOND_CFM, 106 /// Bonding information indication message 107 GAPC_BOND_IND, 108 109 /* Encryption procedure */ 110 /// Start Encryption command procedure 111 GAPC_ENCRYPT_CMD, 112 /// Encryption requested by peer device indication message. 113 GAPC_ENCRYPT_REQ_IND, 114 /// Confirm requested Encryption information. 115 GAPC_ENCRYPT_CFM, 116 /// Encryption information indication message 117 GAPC_ENCRYPT_IND, 118 119 /* Security request procedure */ 120 /// Start Security Request command procedure 121 GAPC_SECURITY_CMD, 122 /// Security requested by peer device indication message 123 GAPC_SECURITY_IND, 124 125 /* Signature procedure */ 126 /// Indicate the current sign counters to the application 127 GAPC_SIGN_COUNTER_IND, 128 129 /* Device information */ 130 /// Indication of ongoing connection Channel Map 131 GAPC_CON_CHANNEL_MAP_IND, 132 133 134 /* Deprecated */ 135 /// Deprecated messages 136 GAPC_DEPRECATED_0, 137 GAPC_DEPRECATED_1, 138 GAPC_DEPRECATED_2, 139 GAPC_DEPRECATED_3, 140 GAPC_DEPRECATED_4, 141 GAPC_DEPRECATED_5, 142 GAPC_DEPRECATED_6, 143 GAPC_DEPRECATED_7, 144 GAPC_DEPRECATED_8, 145 GAPC_DEPRECATED_9, 146 147 /* LE Ping */ 148 /// Update LE Ping timeout value 149 GAPC_SET_LE_PING_TO_CMD, 150 /// LE Ping timeout indication 151 GAPC_LE_PING_TO_VAL_IND, 152 /// LE Ping timeout expires indication 153 GAPC_LE_PING_TO_IND, 154 155 /* LE Data Length extension*/ 156 /// LE Set Data Length Command 157 GAPC_SET_LE_PKT_SIZE_CMD, 158 /// LE Set Data Length Indication 159 GAPC_LE_PKT_SIZE_IND, 160 161 /* Secure Connections */ 162 /// Request to inform the remote device when keys have been entered or erased 163 GAPC_KEY_PRESS_NOTIFICATION_CMD, 164 /// Indication that a KeyPress has been performed on the peer device. 165 GAPC_KEY_PRESS_NOTIFICATION_IND, 166 167 // ---------------------- INTERNAL API ------------------------ 168 /* Internal messages for timer events, not part of API*/ 169 /// Signature procedure 170 GAPC_SIGN_CMD, 171 /// Signature result 172 GAPC_SIGN_IND, 173 174 /// Parameter update procedure timeout indication 175 GAPC_PARAM_UPDATE_TO_IND, 176 /// Pairing procedure timeout indication 177 GAPC_SMP_TIMEOUT_TIMER_IND, 178 /// Pairing repeated attempts procedure timeout indication 179 GAPC_SMP_REP_ATTEMPTS_TIMER_IND, 180 }; 181 182 183 184 185 /// request operation type - application interface 186 enum gapc_operation 187 { 188 /* Operation Flags */ 189 /* No Operation (if nothing has been requested) */ 190 /* ************************************************ */ 191 /// No operation 192 GAPC_NO_OP = 0x00, 193 194 /* Connection management */ 195 /// Disconnect link 196 GAPC_DISCONNECT, 197 198 /* Connection information */ 199 /// Retrieve name of peer device. 200 GAPC_GET_PEER_NAME, 201 /// Retrieve peer device version info. 202 GAPC_GET_PEER_VERSION, 203 /// Retrieve peer device features. 204 GAPC_GET_PEER_FEATURES, 205 /// Get Peer device appearance 206 GAPC_GET_PEER_APPEARANCE, 207 /// Get Peer device Slaved Preferred Parameters 208 GAPC_GET_PEER_SLV_PREF_PARAMS, 209 /// Retrieve connection RSSI. 210 GAPC_GET_CON_RSSI, 211 /// Retrieve Connection Channel MAP. 212 GAPC_GET_CON_CHANNEL_MAP, 213 214 /* Connection parameters update */ 215 /// Perform update of connection parameters. 216 GAPC_UPDATE_PARAMS, 217 218 /* Security procedures */ 219 /// Start bonding procedure. 220 GAPC_BOND, 221 /// Start encryption procedure. 222 GAPC_ENCRYPT, 223 /// Start security request procedure 224 GAPC_SECURITY_REQ, 225 226 /* Deprecated */ 227 /// Deprecated operation 228 GAPC_OP_DEPRECATED_0, 229 GAPC_OP_DEPRECATED_1, 230 GAPC_OP_DEPRECATED_2, 231 GAPC_OP_DEPRECATED_3, 232 GAPC_OP_DEPRECATED_4, 233 234 /* LE Ping*/ 235 /// get timer timeout value 236 GAPC_GET_LE_PING_TO, 237 /// set timer timeout value 238 GAPC_SET_LE_PING_TO, 239 240 /* LE Data Length extension*/ 241 /// LE Set Data Length 242 GAPC_SET_LE_PKT_SIZE, 243 244 /* Central Address resolution supported*/ 245 GAPC_GET_ADDR_RESOL_SUPP, 246 247 /* Secure Connections */ 248 /// Request to inform the remote device when keys have been entered or erased 249 GAPC_KEY_PRESS_NOTIFICATION, 250 251 // ---------------------- INTERNAL API ------------------------ 252 /* Packet signature */ 253 /// sign an attribute packet 254 GAPC_SIGN_PACKET, 255 /// Verify signature or an attribute packet 256 GAPC_SIGN_CHECK, 257 }; 258 259 /// Bond event type. 260 enum gapc_bond 261 { 262 /// Bond Pairing request 263 GAPC_PAIRING_REQ, 264 /// Respond to Pairing request 265 GAPC_PAIRING_RSP, 266 267 /// Pairing Finished information 268 GAPC_PAIRING_SUCCEED, 269 /// Pairing Failed information 270 GAPC_PAIRING_FAILED, 271 272 /// Used to retrieve pairing Temporary Key 273 GAPC_TK_EXCH, 274 /// Used for Identity Resolving Key exchange 275 GAPC_IRK_EXCH, 276 /// Used for Connection Signature Resolving Key exchange 277 GAPC_CSRK_EXCH, 278 /// Used for Long Term Key exchange 279 GAPC_LTK_EXCH, 280 281 /// Bond Pairing request issue, Repeated attempt 282 GAPC_REPEATED_ATTEMPT, 283 284 /// Out of Band - exchange of confirm and rand. 285 GAPC_OOB_EXCH, 286 287 /// Numeric Comparison - Exchange of Numeric Value - 288 GAPC_NC_EXCH 289 }; 290 291 /// List of device info that should be provided by application 292 enum gapc_dev_info 293 { 294 /// Device Name 295 GAPC_DEV_NAME, 296 /// Device Appearance Icon 297 GAPC_DEV_APPEARANCE, 298 /// Device Slave preferred parameters 299 GAPC_DEV_SLV_PREF_PARAMS, 300 /// Device Central address resolution 301 GAPC_DEV_CTL_ADDR_RESOL, 302 /// maximum device info parameter 303 GAPC_DEV_INFO_MAX, 304 }; 305 306 /// List of features available on a device 307 enum gapc_features_list 308 { 309 /// LE encryption 310 GAPC_ENCRYPT_FEAT_MASK = (1 << 0), 311 /// Connection Parameters Request Procedure 312 GAPC_CONN_PARAM_REQ_FEAT_MASK = (1 << 1), 313 /// Extended Reject Indication 314 GAPC_EXT_REJECT_IND_FEAT_MASK = (1 << 2), 315 /// Slave-initiated Features Exchange 316 GAPC_SLAVE_FEAT_EXCH_FEAT_MASK = (1 << 3), 317 /// LE ping 318 GAPC_LE_PING_FEAT_MASK = (1 << 4) 319 }; 320 321 /* 322 * TYPE DEFINITIONS 323 **************************************************************************************** 324 */ 325 326 /// Operation command structure in order to keep requested operation. 327 struct gapc_operation_cmd 328 { 329 /// GAP request type 330 uint8_t operation; 331 }; 332 333 334 /// Command complete event data structure 335 struct gapc_cmp_evt 336 { 337 /// GAP request type 338 uint8_t operation; 339 /// Status of the request 340 uint8_t status; 341 }; 342 343 /// Indicate that a connection has been established 344 struct gapc_connection_req_ind 345 { 346 /// Connection handle 347 uint16_t conhdl; 348 /// Connection interval 349 uint16_t con_interval; 350 /// Connection latency 351 uint16_t con_latency; 352 /// Link supervision timeout 353 uint16_t sup_to; 354 /// Clock accuracy 355 uint8_t clk_accuracy; 356 /// Peer address type 357 uint8_t peer_addr_type; 358 /// Peer BT address 359 bd_addr_t peer_addr; 360 }; 361 362 363 /// Set specific link data configuration. 364 struct gapc_connection_cfm 365 { 366 /// Local CSRK value 367 struct gap_sec_key lcsrk; 368 /// Local signature counter value 369 uint32_t lsign_counter; 370 371 /// Remote CSRK value 372 struct gap_sec_key rcsrk; 373 /// Remote signature counter value 374 uint32_t rsign_counter; 375 376 /// Authentication (@see gap_auth) 377 uint8_t auth; 378 /// Service Changed Indication enabled 379 uint8_t svc_changed_ind_enable; 380 /// LTK exchanged during pairing. 381 bool ltk_present; 382 }; 383 384 385 /// Request disconnection of current link command. 386 struct gapc_disconnect_cmd 387 { 388 /// GAP request type: 389 /// - GAPC_DISCONNECT: Disconnect link. 390 uint8_t operation; 391 392 /// Reason of disconnection 393 uint8_t reason; 394 }; 395 396 397 /// Indicate that a link has been disconnected 398 struct gapc_disconnect_ind 399 { 400 /// Connection handle 401 uint16_t conhdl; 402 /// Reason of disconnection 403 uint8_t reason; 404 }; 405 406 407 /// Retrieve information command 408 struct gapc_get_info_cmd 409 { 410 /// GAP request type: 411 /// - GAPC_GET_PEER_NAME: Retrieve name of peer device. 412 /// - GAPC_GET_PEER_VERSION: Retrieve peer device version info. 413 /// - GAPC_GET_PEER_FEATURES: Retrieve peer device features. 414 /// - GAPC_GET_CON_RSSI: Retrieve connection RSSI. 415 /// - GAPC_GET_CON_CHANNEL_MAP: Retrieve Connection Channel MAP. 416 /// - GAPC_GET_PEER_APPEARANCE: Get Peer device appearance 417 /// - GAPC_GET_PEER_SLV_PREF_PARAMS: Get Peer device Slaved Preferred Parameters 418 /// - GAPC_GET_ADDR_RESOL_SUPP: Address Resolution Supported 419 /// - GAPC_GET_LE_PING_TIMEOUT: Retrieve LE Ping Timeout Value 420 uint8_t operation; 421 }; 422 423 /// device information data 424 union gapc_dev_info_val 425 { 426 /// Device name 427 struct gap_dev_name name; 428 /// Appearance Icon 429 uint16_t appearance; 430 /// Slave preferred parameters 431 struct gap_slv_pref slv_params; 432 /// Central address resolution 433 uint8_t cnt_addr_resol; 434 }; 435 436 /// Peer device attribute DB info such as Device Name, Appearance or Slave Preferred Parameters 437 struct gapc_peer_att_info_ind 438 { 439 /// Requested information 440 /// - GAPC_DEV_NAME: Device Name 441 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 442 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 443 /// - GAPC_GET_ADDR_RESOL_SUPP: Address resolution supported 444 uint8_t req; 445 /// Attribute handle 446 uint16_t handle; 447 448 /// device information data 449 union gapc_dev_info_val info; 450 }; 451 452 /// Indication of peer version info 453 struct gapc_peer_version_ind 454 { 455 /// Manufacturer name 456 uint16_t compid; 457 /// LMP subversion 458 uint16_t lmp_subvers; 459 /// LMP version 460 uint8_t lmp_vers; 461 }; 462 463 /// Indication of peer features info 464 struct gapc_peer_features_ind 465 { 466 /// 8-byte array for LE features 467 uint8_t features[GAP_LE_FEATS_LEN]; 468 }; 469 470 /// Indication of ongoing connection RSSI 471 struct gapc_con_rssi_ind 472 { 473 /// RSSI value 474 int8_t rssi; 475 }; 476 /// Indication of ongoing connection Channel Map 477 struct gapc_con_channel_map_ind 478 { 479 /// channel map value 480 le_chnl_map_t ch_map; 481 }; 482 483 /// Sign counter value changed due to packet signing or signature verification. 484 struct gapc_sign_counter_updated_ind 485 { 486 /// New Local signature counter value 487 uint32_t lsign_counter; 488 /// New Remote signature counter value 489 uint32_t rsign_counter; 490 }; 491 492 /// Indication of LE Ping 493 struct gapc_le_ping_to_val_ind 494 { 495 ///Authenticated payload timeout 496 uint16_t timeout; 497 }; 498 499 500 /// Peer device request local device info such as name, appearance or slave preferred parameters 501 struct gapc_get_dev_info_req_ind 502 { 503 /// Requested information 504 /// - GAPC_DEV_NAME: Device Name 505 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 506 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 507 uint8_t req; 508 }; 509 510 511 512 /// Send requested info to peer device 513 struct gapc_get_dev_info_cfm 514 { 515 /// Requested information 516 /// - GAPC_DEV_NAME: Device Name 517 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 518 /// - GAPC_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 519 uint8_t req; 520 521 /// Peer device information data 522 union gapc_dev_info_val info; 523 }; 524 525 /// Peer device request to modify local device info such as name or appearance 526 struct gapc_set_dev_info_req_ind 527 { 528 /// Requested information 529 /// - GAPC_DEV_NAME: Device Name 530 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 531 uint8_t req; 532 533 /// device information data 534 union gapc_set_dev_info 535 { 536 /// Device name 537 struct gap_dev_name name; 538 /// Appearance Icon 539 uint16_t appearance; 540 } info; 541 }; 542 543 /// Local device accept or reject device info modification 544 struct gapc_set_dev_info_cfm 545 { 546 /// Requested information 547 /// - GAPC_DEV_NAME: Device Name 548 /// - GAPC_DEV_APPEARANCE: Device Appearance Icon 549 uint8_t req; 550 551 /// Status code used to know if requested has been accepted or not 552 uint8_t status; 553 }; 554 555 /// Connection Parameter used to update connection parameters 556 struct gapc_conn_param 557 { 558 /// Connection interval minimum 559 uint16_t intv_min; 560 /// Connection interval maximum 561 uint16_t intv_max; 562 /// Latency 563 uint16_t latency; 564 /// Supervision timeout 565 uint16_t time_out; 566 }; 567 568 /// Perform update of connection parameters command 569 struct gapc_param_update_cmd 570 { 571 /// GAP request type: 572 /// - GAPC_UPDATE_PARAMS: Perform update of connection parameters. 573 uint8_t operation; 574 /// Internal parameter used to manage internally l2cap packet identifier for signaling 575 uint8_t pkt_id; 576 /// Connection interval minimum 577 uint16_t intv_min; 578 /// Connection interval maximum 579 uint16_t intv_max; 580 /// Latency 581 uint16_t latency; 582 /// Supervision timeout 583 uint16_t time_out; 584 /// Minimum Connection Event Duration 585 uint16_t ce_len_min; 586 /// Maximum Connection Event Duration 587 uint16_t ce_len_max; 588 }; 589 590 /// Request of updating connection parameters indication 591 struct gapc_param_update_req_ind 592 { 593 /// Connection interval minimum 594 uint16_t intv_min; 595 /// Connection interval maximum 596 uint16_t intv_max; 597 /// Latency 598 uint16_t latency; 599 /// Supervision timeout 600 uint16_t time_out; 601 }; 602 603 /// Connection parameters updated indication 604 struct gapc_param_updated_ind 605 { 606 ///Connection interval value 607 uint16_t con_interval; 608 ///Connection latency value 609 uint16_t con_latency; 610 ///Supervision timeout 611 uint16_t sup_to; 612 }; 613 614 /// Master confirm or not that parameters proposed by slave are accepted or not 615 struct gapc_param_update_cfm 616 { 617 /// True to accept slave connection parameters, False else. 618 bool accept; 619 /// Minimum Connection Event Duration 620 uint16_t ce_len_min; 621 /// Maximum Connection Event Duration 622 uint16_t ce_len_max; 623 }; 624 625 /// Pairing parameters 626 struct gapc_pairing 627 { 628 /// IO capabilities (@see gap_io_cap) 629 uint8_t iocap; 630 /// OOB information (@see gap_oob) 631 uint8_t oob; 632 /// Authentication (@see gap_auth) 633 /// Note in BT 4.1 the Auth Field is extended to include 'Key Notification' and 634 /// and 'Secure Connections'. 635 uint8_t auth; 636 /// Encryption key size (7 to 16) 637 uint8_t key_size; 638 ///Initiator key distribution (@see gap_kdist) 639 uint8_t ikey_dist; 640 ///Responder key distribution (@see gap_kdist) 641 uint8_t rkey_dist; 642 643 /// Device security requirements (minimum security level). (@see gap_sec_req) 644 uint8_t sec_req; 645 }; 646 647 /// Long Term Key information 648 struct gapc_ltk 649 { 650 /// Long Term Key 651 struct gap_sec_key ltk; 652 /// Encryption Diversifier 653 uint16_t ediv; 654 /// Random Number 655 rand_nb_t randnb; 656 /// Encryption key size (7 to 16) 657 uint8_t key_size; 658 659 uint8_t key_num; 660 }; 661 /// Out of Band Information 662 struct gapc_oob 663 { 664 /// Confirm Value 665 uint8_t conf[GAP_KEY_LEN]; 666 /// Random Number 667 uint8_t rand[GAP_KEY_LEN]; 668 }; 669 670 struct gapc_nc 671 { 672 uint8_t value[4]; 673 }; 674 675 /// Identity Resolving Key information 676 struct gapc_irk 677 { 678 /// Identity Resolving Key 679 struct gap_sec_key irk; 680 /// Device BD Identity Address 681 struct gap_bdaddr addr; 682 }; 683 684 685 /// Start Bonding command procedure 686 struct gapc_bond_cmd 687 { 688 /// GAP request type: 689 /// - GAPC_BOND: Start bonding procedure. 690 uint8_t operation; 691 /// Pairing information 692 struct gapc_pairing pairing; 693 }; 694 695 /// Bonding requested by peer device indication message. 696 struct gapc_bond_req_ind 697 { 698 /// Bond request type (@see gapc_bond) 699 uint8_t request; 700 701 /// Bond procedure requested information data 702 union gapc_bond_req_data 703 { 704 /// Authentication level (@see gap_auth) (if request = GAPC_PAIRING_REQ) 705 uint8_t auth_req; 706 /// LTK Key Size (if request = GAPC_LTK_EXCH) 707 uint8_t key_size; 708 /// Device IO used to get TK: (if request = GAPC_TK_EXCH) 709 /// - GAP_TK_OOB: TK get from out of band method 710 /// - GAP_TK_DISPLAY: TK generated and shall be displayed by local device 711 /// - GAP_TK_KEY_ENTRY: TK shall be entered by user using device keyboard 712 uint8_t tk_type; 713 714 /// Addition OOB Data for the OOB Conf and Rand values 715 struct gapc_oob oob_data; 716 /// Numeric Comparison Data 717 struct gapc_nc nc_data; 718 } data; 719 }; 720 721 /// Confirm requested bond information. 722 struct gapc_bond_cfm 723 { 724 /// Bond request type (@see gapc_bond) 725 uint8_t request; 726 /// Request accepted 727 uint8_t accept; 728 729 /// Bond procedure information data 730 union gapc_bond_cfm_data 731 { 732 /// Pairing Features (request = GAPC_PAIRING_RSP) 733 struct gapc_pairing pairing_feat; 734 /// LTK (request = GAPC_LTK_EXCH) 735 struct gapc_ltk ltk; 736 /// CSRK (request = GAPC_CSRK_EXCH) 737 struct gap_sec_key csrk; 738 /// TK (request = GAPC_TK_EXCH) 739 struct gap_sec_key tk; 740 /// IRK (request = GAPC_IRK_EXCH) 741 struct gapc_irk irk; 742 /// OOB Confirm and Random from the peer (request = GAPC_OOB_EXCH) 743 struct gapc_oob oob; 744 } data; 745 }; 746 747 /** 748 * Authentication information 749 */ 750 struct gapc_bond_auth 751 { 752 /// Authentication information (@see gap_auth) 753 uint8_t info; 754 755 /// LTK exchanged during pairing. 756 bool ltk_present; 757 }; 758 759 760 761 /// Bonding information indication message 762 struct gapc_bond_ind 763 { 764 /// Bond information type (@see gapc_bond) 765 uint8_t info; 766 767 /// Bond procedure information data 768 union gapc_bond_data 769 { 770 /// Authentication information (@see gap_auth) 771 /// (if info = GAPC_PAIRING_SUCCEED) 772 struct gapc_bond_auth auth; 773 /// Pairing failed reason (if info = GAPC_PAIRING_FAILED) 774 uint8_t reason; 775 /// Long Term Key information (if info = GAPC_LTK_EXCH) 776 struct gapc_ltk ltk; 777 /// Identity Resolving Key information (if info = GAPC_IRK_EXCH) 778 struct gapc_irk irk; 779 /// Connection Signature Resolving Key information (if info = GAPC_CSRK_EXCH) 780 struct gap_sec_key csrk; 781 } data; 782 }; 783 784 /// Start Encryption command procedure 785 struct gapc_encrypt_cmd 786 { 787 /// GAP request type: 788 /// - GAPC_ENCRYPT: Start encryption procedure. 789 uint8_t operation; 790 /// Long Term Key information 791 struct gapc_ltk ltk; 792 }; 793 794 /// Encryption requested by peer device indication message. 795 struct gapc_encrypt_req_ind 796 { 797 /// Encryption Diversifier 798 uint16_t ediv; 799 /// Random Number 800 rand_nb_t rand_nb; 801 }; 802 803 /// Confirm requested Encryption information. 804 struct gapc_encrypt_cfm 805 { 806 /// Indicate if a LTK has been found for the peer device 807 uint8_t found; 808 /// Long Term Key 809 struct gap_sec_key ltk; 810 /// LTK Key Size 811 uint8_t key_size; 812 }; 813 814 /// Encryption information indication message 815 struct gapc_encrypt_ind 816 { 817 /// Authentication level (@see gap_auth) 818 uint8_t auth; 819 }; 820 821 /// Start Security Request command procedure 822 struct gapc_security_cmd 823 { 824 /// GAP request type: 825 /// - GAPC_SECURITY_REQ: Start security request procedure 826 uint8_t operation; 827 /// Authentication level (@see gap_auth) 828 uint8_t auth; 829 }; 830 /// Security requested by peer device indication message 831 struct gapc_security_ind 832 { 833 /// Authentication level (@see gap_auth) 834 uint8_t auth; 835 }; 836 837 /// Parameters of the @ref GAPC_SIGN_COUNTER_IND message 838 struct gapc_sign_counter_ind 839 { 840 /// Local SignCounter value 841 uint32_t local_sign_counter; 842 /// Peer SignCounter value 843 uint32_t peer_sign_counter; 844 }; 845 846 847 /// Parameters of the @ref GAPC_SET_LE_PING_TO_CMD message 848 struct gapc_set_le_ping_to_cmd 849 { 850 /// GAP request type: 851 /// - GAPC_SET_LE_PING_TO : Set the LE Ping timeout value 852 uint8_t operation; 853 /// Authenticated payload timeout 854 uint16_t timeout; 855 }; 856 857 /// Parameters of the @ref GAPC_SET_LE_PKT_SIZE_CMD message 858 struct gapc_set_le_pkt_size_cmd 859 { 860 /// GAP request type: 861 /// - GAPC_SET_LE_PKT_SIZE : Set the LE Data length value 862 uint8_t operation; 863 ///Preferred maximum number of payload octets that the local Controller should include 864 ///in a single Link Layer Data Channel PDU. 865 uint16_t tx_octets; 866 ///Preferred maximum number of microseconds that the local Controller should use to transmit 867 ///a single Link Layer Data Channel PDU 868 uint16_t tx_time; 869 }; 870 871 /// Parameters of the @ref GAPC_LE_PKT_SIZE_IND message 872 struct gapc_le_pkt_size_ind 873 { 874 ///The maximum number of payload octets in TX 875 uint16_t max_tx_octets; 876 ///The maximum time that the local Controller will take to TX 877 uint16_t max_tx_time; 878 ///The maximum number of payload octets in RX 879 uint16_t max_rx_octets; 880 ///The maximum time that the local Controller will take to RX 881 uint16_t max_rx_time; 882 }; 883 884 /// Parameters of the @ref GAPC_KEY_PRESS_NOTIFICATION_CMD message 885 struct gapc_key_press_notif_cmd 886 { 887 /// GAP request type: 888 /// - GAPC_KEY_PRESS_NOTIFICATION_CMD : Inform the remote device when keys have been entered or erased 889 uint8_t operation; 890 /// notification type 891 uint8_t notification_type; 892 }; 893 894 /// Parameters of the @ref GAPC_KEY_PRESS_NOTIFICATION_IND message 895 struct gapc_key_press_notif_ind 896 { 897 /// notification type 898 uint8_t notification_type; 899 }; 900 901 902 /// Parameters of the @ref GAPC_SIGN_CMD message 903 struct gapc_sign_cmd 904 { 905 /// GAP request type: 906 /// - GAPC_SIGN_PACKET: Sign an attribute packet 907 /// - GAPC_SIGN_CHECK: Verify signature or an attribute packet 908 uint8_t operation; 909 /// Data PDU length (Bytes) 910 uint16_t byte_len; 911 /// Data PDU + SignCounter if generation, Data PDU + SignCounter + MAC if verification 912 uint8_t msg[__ARRAY_EMPTY]; 913 }; 914 915 /// Parameters of the @ref GAPC_SIGN_IND message 916 struct gapc_sign_ind 917 { 918 /// GAP request type: 919 /// - GAPC_SIGN_PACKET: Sign an attribute packet 920 /// - GAPC_SIGN_CHECK: Verify signature or an attribute packet 921 uint8_t operation; 922 /// Data PDU length (Bytes) 923 uint16_t byte_len; 924 /// Data PDU + SignCounter + MAC 925 uint8_t signed_msg[__ARRAY_EMPTY]; 926 }; 927 928 929 /// @} GAPC_TASK 930 931 #endif /* _GAPC_TASK_H_ */ 932