1 /** 2 **************************************************************************************** 3 * 4 * @file gapm_task.h 5 * 6 * @brief Generic Access Profile Manager Task Header. 7 * 8 * Copyright (C) RivieraWaves 2009-2016 9 * 10 **************************************************************************************** 11 */ 12 13 14 #ifndef _GAPM_TASK_H_ 15 #define _GAPM_TASK_H_ 16 17 /** 18 **************************************************************************************** 19 * @addtogroup GAPM_TASK Generic Access Profile Manager Task 20 * @ingroup GAPM 21 * @brief Handles ALL messages to/from GAP Manager block. 22 * 23 * It handles messages from lower and higher layers not related to an ongoing connection. 24 * 25 * @{ 26 **************************************************************************************** 27 */ 28 29 /* 30 * INCLUDE FILES 31 **************************************************************************************** 32 */ 33 #include "rwip_task.h" // Task definitions 34 #include "gap.h" 35 36 37 /* 38 * DEFINES 39 **************************************************************************************** 40 */ 41 42 /// GAP Manager Message Interface 43 enum gapm_msg_id 44 { 45 /* Default event */ 46 /// Command Complete event 47 GAPM_CMP_EVT = TASK_FIRST_MSG(TASK_ID_GAPM), 48 /// Event triggered to inform that lower layers are ready 49 GAPM_DEVICE_READY_IND, 50 51 /* Default commands */ 52 /// Reset link layer and the host command 53 GAPM_RESET_CMD, 54 /// Cancel ongoing operation 55 GAPM_CANCEL_CMD, 56 /* Device Configuration */ 57 /// Set device configuration command 58 GAPM_SET_DEV_CONFIG_CMD, 59 /// Set device channel map 60 GAPM_SET_CHANNEL_MAP_CMD, 61 /* Local device information */ 62 /// Get local device info command 63 GAPM_GET_DEV_INFO_CMD, 64 /// Local device version indication event 65 GAPM_DEV_VERSION_IND, 66 /// Local device BD Address indication event 67 GAPM_DEV_BDADDR_IND, 68 /// Advertising channel Tx power level 69 GAPM_DEV_ADV_TX_POWER_IND, 70 /// Indication containing information about memory usage. 71 GAPM_DBG_MEM_INFO_IND, 72 73 /* White List */ 74 /// White List Management Command 75 GAPM_WHITE_LIST_MGT_CMD, 76 /// White List Size indication event 77 GAPM_WHITE_LIST_SIZE_IND, 78 79 /* Air Operations */ 80 /// Set advertising mode Command 81 GAPM_START_ADVERTISE_CMD, 82 /// Update Advertising Data Command - On fly update when device is advertising 83 GAPM_UPDATE_ADVERTISE_DATA_CMD, 84 85 /// Set Scan mode Command 86 GAPM_START_SCAN_CMD, 87 /// Advertising or scanning report information event 88 GAPM_ADV_REPORT_IND, 89 90 /// Set connection initialization Command 91 GAPM_START_CONNECTION_CMD, 92 /// Name of peer device indication 93 GAPM_PEER_NAME_IND, 94 /// Confirm connection to a specific device (Connection Operation in Selective mode) 95 GAPM_CONNECTION_CFM, 96 97 /* Security / Encryption Toolbox */ 98 /// Resolve address command 99 GAPM_RESOLV_ADDR_CMD, 100 /// Indicate that resolvable random address has been solved 101 GAPM_ADDR_SOLVED_IND, 102 /// Generate a random address. 103 GAPM_GEN_RAND_ADDR_CMD, 104 /// Use the AES-128 block in the controller 105 GAPM_USE_ENC_BLOCK_CMD, 106 /// AES-128 block result indication 107 GAPM_USE_ENC_BLOCK_IND, 108 /// Generate a 8-byte random number 109 GAPM_GEN_RAND_NB_CMD, 110 /// Random Number Indication 111 GAPM_GEN_RAND_NB_IND, 112 113 /* Profile Management */ 114 /// Create new task for specific profile 115 GAPM_PROFILE_TASK_ADD_CMD, 116 /// Inform that profile task has been added. 117 GAPM_PROFILE_ADDED_IND, 118 119 /// Indicate that a message has been received on an unknown task 120 GAPM_UNKNOWN_TASK_IND, 121 122 /* Data Length Extension */ 123 /// Suggested Default Data Length indication 124 GAPM_SUGG_DFLT_DATA_LEN_IND, 125 /// Maximum Data Length indication 126 GAPM_MAX_DATA_LEN_IND, 127 128 /* Resolving list for controller-based privacy*/ 129 /// Resolving address list management 130 GAPM_RAL_MGT_CMD, 131 /// Resolving address list size indication 132 GAPM_RAL_SIZE_IND, 133 /// Resolving address list address indication 134 GAPM_RAL_ADDR_IND, 135 136 /* Set new IRK */ 137 /// Modify current IRK 138 GAPM_SET_IRK_CMD, 139 140 /* LE Protocol/Service Multiplexer Management */ 141 /// Register a LE Protocol/Service Multiplexer command 142 GAPM_LEPSM_REGISTER_CMD, 143 /// Unregister a LE Protocol/Service Multiplexer command 144 GAPM_LEPSM_UNREGISTER_CMD, 145 146 /* ************************************************ */ 147 /* -------------- Internal usage only ------------- */ 148 /* ************************************************ */ 149 /// Message received to unknown task received 150 GAPM_UNKNOWN_TASK_MSG, 151 152 /* Secure Connections */ 153 /// Request to provide DH Key 154 GAPM_GEN_DH_KEY_CMD, 155 /// Indicates the DH Key computation is complete and available 156 GAPM_GEN_DH_KEY_IND, 157 158 /* Internal messages for timer events, not part of API*/ 159 /// Limited discoverable timeout indication 160 GAPM_LIM_DISC_TO_IND, 161 /// Scan timeout indication 162 GAPM_SCAN_TO_IND, 163 /// Address renewal timeout indication 164 GAPM_ADDR_RENEW_TO_IND, 165 }; 166 167 168 /// GAP Manager operation type - application interface 169 enum gapm_operation 170 { 171 /* No Operation (if nothing has been requested) */ 172 /* ************************************************ */ 173 /// No operation. 174 GAPM_NO_OP = 0x00, 175 176 /* Default operations */ 177 /* ************************************************ */ 178 /// Reset BLE subsystem: LL and HL. 179 GAPM_RESET, 180 /// Cancel currently executed operation. 181 GAPM_CANCEL, 182 183 /* Configuration operations */ 184 /* ************************************************ */ 185 /// Set device configuration 186 GAPM_SET_DEV_CONFIG, 187 /// Set device channel map 188 GAPM_SET_CHANNEL_MAP, //0x04 189 190 /* Retrieve device information */ 191 /* ************************************************ */ 192 /// Get Local device version 193 GAPM_GET_DEV_VERSION, 194 /// Get Local device BD Address 195 GAPM_GET_DEV_BDADDR, 196 /// Get device advertising power level 197 GAPM_GET_DEV_ADV_TX_POWER, 198 199 /* Operation on White list */ 200 /* ************************************************ */ 201 /// Get White List Size. 202 GAPM_GET_WLIST_SIZE, //0x08 203 /// Add devices in white list. 204 GAPM_ADD_DEV_IN_WLIST, 205 /// Remove devices form white list. 206 GAPM_RMV_DEV_FRM_WLIST, //0x0a 207 /// Clear all devices from white list. 208 GAPM_CLEAR_WLIST, 209 210 /* Advertise mode operations */ 211 /* ************************************************ */ 212 /// Start non connectable advertising 213 GAPM_ADV_NON_CONN, //0x0c 214 /// Start undirected connectable advertising 215 GAPM_ADV_UNDIRECT, 216 /// Start directed connectable advertising 217 GAPM_ADV_DIRECT, 218 /// Start directed connectable advertising using Low Duty Cycle 219 GAPM_ADV_DIRECT_LDC, 220 /// Update on the fly advertising data 221 GAPM_UPDATE_ADVERTISE_DATA, //0x10 222 223 /* Scan mode operations */ 224 /* ************************************************ */ 225 /// Start active scan operation 226 GAPM_SCAN_ACTIVE, 227 /// Start passive scan operation 228 GAPM_SCAN_PASSIVE, 229 230 /* Connection mode operations */ 231 /* ************************************************ */ 232 /// Direct connection operation 233 GAPM_CONNECTION_DIRECT, 234 /// Automatic connection operation 235 GAPM_CONNECTION_AUTO, //0x014 236 /// Selective connection operation 237 GAPM_CONNECTION_SELECTIVE, 238 /// Name Request operation (requires to start a direct connection) 239 GAPM_CONNECTION_NAME_REQUEST, 240 241 /* Security / Encryption Toolbox */ 242 /* ************************************************ */ 243 /// Resolve device address 244 GAPM_RESOLV_ADDR, 245 /// Generate a random address 246 GAPM_GEN_RAND_ADDR, //0x18 247 /// Use the controller's AES-128 block 248 GAPM_USE_ENC_BLOCK, 249 /// Generate a 8-byte random number 250 GAPM_GEN_RAND_NB, 251 252 /* Profile Management */ 253 /* ************************************************ */ 254 /// Create new task for specific profile 255 GAPM_PROFILE_TASK_ADD, 256 257 258 /* DEBUG */ 259 /* ************************************************ */ 260 /// Get memory usage 261 GAPM_DBG_GET_MEM_INFO, //0x1c 262 /// Perform a platform reset 263 GAPM_PLF_RESET, 264 265 /* Data Length Extension */ 266 /* ************************************************ */ 267 /// Set Suggested Default LE Data Length 268 GAPM_SET_SUGGESTED_DFLT_LE_DATA_LEN, 269 /// Get Suggested Default LE Data Length 270 GAPM_GET_SUGGESTED_DFLT_LE_DATA_LEN, 271 /// Get Maximum LE Data Length 272 GAPM_GET_MAX_LE_DATA_LEN, // 0x20 273 274 /* Operation on Resolving List */ 275 /* ************************************************ */ 276 /// Get resolving address list size 277 GAPM_GET_RAL_SIZE, 278 /// Get resolving local address 279 GAPM_GET_RAL_LOC_ADDR, 280 /// Get resolving peer address 281 GAPM_GET_RAL_PEER_ADDR, 282 /// Add device in resolving address list 283 GAPM_ADD_DEV_IN_RAL, // 0x024 284 /// Remove device from resolving address list 285 GAPM_RMV_DEV_FRM_RAL, 286 /// Clear resolving address list 287 GAPM_CLEAR_RAL, 288 289 /* Connection mode operations - cont */ 290 /* ************************************************ */ 291 /// General connection operation 292 GAPM_CONNECTION_GENERAL, 293 294 /* Change current IRK */ 295 /* ************************************************ */ 296 /// Set IRK 297 GAPM_SET_IRK, //0x028 298 299 /* LE Protocol/Service Multiplexer management */ 300 /* ************************************************ */ 301 /// Register a LE Protocol/Service Multiplexer 302 GAPM_LEPSM_REG, 303 /// Unregister a LE Protocol/Service Multiplexer 304 GAPM_LEPSM_UNREG, 305 306 /* Secure Connection - Internal API */ 307 /* ************************************************ */ 308 /// Generate DH_Key 309 GAPM_GEN_DH_KEY, //0x2b 310 }; 311 312 313 /// Device Address type Configuration 314 enum gapm_addr_type 315 { 316 /// Device Address is a Public Static address 317 GAPM_CFG_ADDR_PUBLIC = 0, 318 /// Device Address is a Private Static address 319 GAPM_CFG_ADDR_PRIVATE = 1, 320 /// Device Address generated using host-based Privacy feature 321 GAPM_CFG_ADDR_HOST_PRIVACY = 2, 322 /// Device Address generated using controller-based Privacy feature 323 GAPM_CFG_ADDR_CTNL_PRIVACY = 4, 324 }; 325 326 327 /// Own BD address source of the device 328 enum gapm_own_addr 329 { 330 /// Public or Private Static Address according to device address configuration 331 GAPM_STATIC_ADDR, 332 /// Generated resolvable private random address 333 GAPM_GEN_RSLV_ADDR, 334 /// Generated non-resolvable private random address 335 GAPM_GEN_NON_RSLV_ADDR, 336 }; 337 338 /// Device Attribute write permission requirement 339 enum gapm_write_att_perm 340 { 341 /// Disable write access 342 GAPM_WRITE_DISABLE = 0, 343 /// Enable write access - no authentication required 344 GAPM_WRITE_NO_AUTH = 1, 345 /// Write access requires unauthenticated link 346 GAPM_WRITE_UNAUTH = 2, 347 /// Write access requires authenticated link 348 GAPM_WRITE_AUTH = 3, 349 /// Write access requires secure connected link 350 GAPM_WRITE_SEC_CON = 4 351 }; 352 353 354 /// Attribute database configuration 355 /// 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 356 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 357 /// | DBG | RFU | SC |PCP | APP_PERM | NAME_PERM | 358 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 359 /// - Bit [0-2] : Device Name write permission requirements for peer device (@see gapm_write_att_perm) 360 /// - Bit [3-5] : Device Appearance write permission requirements for peer device (@see gapm_write_att_perm) 361 /// - Bit [6] : Slave Preferred Connection Parameters present 362 /// - Bit [7] : Service change feature present in GATT attribute database. 363 /// - Bit [8-14]: Reserved 364 /// - Bit [15] : Enable Debug Mode 365 enum gapm_att_cfg_flag 366 { 367 /// Device Name write permission requirements for peer device (@see gapm_write_att_perm) 368 GAPM_MASK_ATT_NAME_PERM = 0x0007, 369 GAPM_POS_ATT_NAME_PERM = 0x00, 370 /// Device Appearance write permission requirements for peer device (@see gapm_write_att_perm) 371 GAPM_MASK_ATT_APPEARENCE_PERM = 0x0038, 372 GAPM_POS_ATT_APPEARENCE_PERM = 0x03, 373 /// Slave Preferred Connection Parameters present in GAP attribute database. 374 GAPM_MASK_ATT_SLV_PREF_CON_PAR_EN = 0x0040, 375 GAPM_POS_ATT_SLV_PREF_CON_PAR_EN = 0x06, 376 /// Service change feature present in GATT attribute database. 377 GAPM_MASK_ATT_SVC_CHG_EN = 0x0080, 378 GAPM_POS_ATT_SVC_CHG_EN = 0x07, 379 /// Service change feature present in GATT attribute database. 380 GAPM_MASK_ATT_DBG_MODE_EN = 0x8000, 381 GAPM_POS_ATT_DBG_MODE_EN = 0x0F, 382 }; 383 384 /// Pairing mode authorized on the device 385 /// 7 6 5 4 3 2 1 0 386 /// +----+----+----+----+----+----+----+----+ 387 /// |KGEN| RFU | SCP| LP | 388 /// +----+----+----+----+----+----+----+----+ 389 enum gapm_pairing_mode 390 { 391 /// No pairing authorized 392 GAPM_PAIRING_DISABLE = 0, 393 /// Legacy pairing Authorized 394 GAPM_PAIRING_LEGACY = (1 << 0), 395 /// Secure Connection pairing Authorized 396 GAPM_PAIRING_SEC_CON = (1 << 1), 397 /// Force re-generation of P256 private and public keys 398 GAPM_PAIRING_FORCE_P256_KEY_GEN = (1<<7), 399 }; 400 401 /// LE Audio Mode Configuration 402 /// 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 403 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 404 /// | RFU | AM0| 405 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 406 enum gapm_audio_cfg_flag 407 { 408 /// LE Audio Mode 0 Supported 409 GAPM_MASK_AUDIO_AM0_SUP = 0x0001, 410 GAPM_POS_AUDIO_AM0_SUP = 0x00, 411 }; 412 413 /// Security level 414 /// 7 6 5 4 3 2 1 0 415 /// +---+---+---+---+---+---+---+---+ 416 /// |MI | RFU |EKS|SEC_LVL| 417 /// +---+---+---+---+---+---+---+---+ 418 /// bit[0-1]: Security level requirement (0=NO_AUTH, 1=UNAUTH, 2=AUTH, 3=SEC_CON) 419 /// bit[2] : Encryption Key Size length must have 16 bytes 420 /// bit[7] : Multi-instantiated task 421 enum gapm_le_psm_sec_mask 422 { 423 /// bit[0-1]: Security level requirement (0=NO_AUTH, 1=UNAUTH, 2=AUTH, 3=SEC_CON) 424 /// bit[2] : Encryption Key Size length must have 16 bytes 425 GAPM_LE_PSM_SEC_LVL_MASK = 0x07, 426 /// bit[7] : Multi-instantiated task 427 GAPM_LE_PSM_MI_TASK_MASK = 0x80, 428 }; 429 430 /* 431 * TYPE DEFINITIONS 432 **************************************************************************************** 433 */ 434 435 /// Operation command structure in order to keep requested operation. 436 struct gapm_operation_cmd 437 { 438 /// GAP request type 439 uint8_t operation; 440 }; 441 442 /// Command complete event data structure 443 struct gapm_cmp_evt 444 { 445 /// GAP requested operation 446 uint8_t operation; 447 /// Status of the request 448 uint8_t status; 449 }; 450 451 /// Reset link layer and the host command 452 struct gapm_reset_cmd 453 { 454 /// GAPM requested operation: 455 /// - GAPM_RESET: Reset BLE subsystem: LL and HL. 456 uint8_t operation; 457 }; 458 459 /// Set device configuration command 460 struct gapm_set_dev_config_cmd 461 { 462 /// GAPM requested operation: 463 /// - GAPM_SET_DEV_CONFIG: Set device configuration 464 uint8_t operation; 465 /// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. 466 uint8_t role; 467 468 /// -------------- Privacy Config ----------------------- 469 /// Duration before regenerate device address when privacy is enabled. 470 uint16_t renew_dur; 471 /// Provided own static private random address (addr_type = GAPM_CFG_ADDR_PRIVATE) 472 bd_addr_t addr; 473 /// Device IRK used for resolvable random BD address generation (LSB first) 474 struct gap_sec_key irk; 475 /// Device Address Type 476 /// - GAPM_CFG_ADDR_PUBLIC: Device Address is a Public Static address 477 /// - GAPM_CFG_ADDR_PRIVATE: Device Address is a Private Static address 478 /// - GAPM_CFG_ADDR_HOST_PRIVACY: Device Address generated using Host Privacy feature 479 /// - GAPM_CFG_ADDR_CTNL_PRIVACY: Device Address generated using Controller Privacy feature 480 uint8_t addr_type; 481 482 /// -------------- Security Config ----------------------- 483 484 /// Pairing mode authorized (see enum gapm_pairing_mode) 485 uint8_t pairing_mode; 486 487 /// -------------- ATT Database Config ----------------------- 488 489 /// GAP service start handle 490 uint16_t gap_start_hdl; 491 /// GATT service start handle 492 uint16_t gatt_start_hdl; 493 494 /// Attribute database configuration 495 /// 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 496 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 497 /// | DBG | RFU | SC |PCP | APP_PERM | NAME_PERM | 498 /// +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 499 /// - Bit [0-2] : Device Name write permission requirements for peer device (@see gapm_write_att_perm) 500 /// - Bit [3-5] : Device Appearance write permission requirements for peer device (@see gapm_write_att_perm) 501 /// - Bit [6] : Slave Preferred Connection Parameters present 502 /// - Bit [7] : Service change feature present in GATT attribute database. 503 /// - Bit [8-14]: Reserved 504 /// - Bit [15] : Enable Debug Mode 505 uint16_t att_cfg; 506 507 /// -------------- LE Data Length Extension ----------------------- 508 ///Suggested value for the Controller's maximum transmitted number of payload octets to be used 509 uint16_t sugg_max_tx_octets; 510 ///Suggested value for the Controller's maximum packet transmission time to be used 511 uint16_t sugg_max_tx_time; 512 513 /// --------------- L2CAP Configuration --------------------------- 514 /// Maximal MTU acceptable for device 515 uint16_t max_mtu; 516 /// Maximal MPS Packet size acceptable for device 517 uint16_t max_mps; 518 /// Maximum number of LE Credit based connection that can be established 519 uint8_t max_nb_lecb; 520 521 /// --------------- LE Audio Mode Supported ----------------------- 522 /// 523 /// LE Audio Mode Configuration (@see gapm_audio_cfg_flag) 524 uint16_t audio_cfg; 525 526 }; 527 528 /// Set new IRK 529 struct gapm_set_irk_cmd 530 { 531 /// GAPM requested operation: 532 /// - GAPM_SET_IRK: Set device configuration 533 uint8_t operation; 534 /// Device IRK used for resolvable random BD address generation (LSB first) 535 struct gap_sec_key irk; 536 }; 537 538 /// Set device channel map 539 struct gapm_set_channel_map_cmd 540 { 541 /// GAPM requested operation: 542 /// - GAPM_SET_CHANNEL_MAP: Set device channel map. 543 uint8_t operation; 544 /// Channel map 545 le_chnl_map_t chmap; 546 }; 547 548 549 /// Get local device info command 550 struct gapm_get_dev_info_cmd 551 { 552 /// GAPM requested operation: 553 /// - GAPM_GET_DEV_VERSION: Get Local device version 554 /// - GAPM_GET_DEV_BDADDR: Get Local device BD Address 555 /// - GAPM_GET_DEV_ADV_TX_POWER: Get device advertising power level 556 /// - GAPM_DBG_GET_MEM_INFO: Get memory usage (debug only) 557 uint8_t operation; 558 }; 559 560 /// Local device version indication event 561 struct gapm_dev_version_ind 562 { 563 /// HCI version 564 uint8_t hci_ver; 565 /// LMP version 566 uint8_t lmp_ver; 567 /// Host version 568 uint8_t host_ver; 569 /// HCI revision 570 uint16_t hci_subver; 571 /// LMP subversion 572 uint16_t lmp_subver; 573 /// Host revision 574 uint16_t host_subver; 575 /// Manufacturer name 576 uint16_t manuf_name; 577 }; 578 579 /// Local device BD Address indication event 580 struct gapm_dev_bdaddr_ind 581 { 582 /// Local device address information 583 struct gap_bdaddr addr; 584 }; 585 586 /// Advertising channel Tx power level indication event 587 struct gapm_dev_adv_tx_power_ind 588 { 589 /// Advertising channel Tx power level 590 int8_t power_lvl; 591 }; 592 593 /// Cancel ongoing operation 594 struct gapm_cancel_cmd 595 { 596 /// GAPM requested operation 597 /// - GAPM_CANCEL: Cancel running operation 598 uint8_t operation; 599 }; 600 601 602 /// White List Management Command 603 struct gapm_white_list_mgt_cmd 604 { 605 /// GAPM requested operation: 606 /// - GAPM_GET_WLIST_SIZE: Get White List Size. 607 /// - GAPM_ADD_DEV_IN_WLIST: Add devices in white list. 608 /// - GAPM_RMV_DEV_FRM_WLIST: Remove devices form white list. 609 /// - GAPM_CLEAR_WLIST: Clear all devices from white list. 610 uint8_t operation; 611 /// Number of device information present in command 612 uint8_t nb; 613 /// Device address information that can be used to add or remove element in device list. 614 struct gap_bdaddr devices[__ARRAY_EMPTY]; 615 }; 616 617 /// White List Size indication event 618 struct gapm_white_list_size_ind 619 { 620 /// White List size 621 uint8_t size; 622 }; 623 624 /// Resolving List Management Command 625 struct gapm_ral_mgt_cmd 626 { 627 /// GAPM requested operation: 628 /// - GAPM_GET_RAL_SIZE: Get Resolving List Size. 629 /// - GAPM_GET_RAL_LOC_ADDR: Get Resolving Local Address. 630 /// - GAPM_GET_RAL_PEER_ADDR: Get Resolving Peer Address. 631 /// - GAPM_ADD_DEV_IN_RAL: Add devices in resolving list. 632 /// - GAPM_RMV_DEV_FRM_RAL: Remove devices form resolving list. 633 /// - GAPM_CLEAR_RAL: Clear all devices from resolving list. 634 uint8_t operation; 635 /// Number of device information present in command 636 uint8_t nb; 637 /// Device address information that can be used to add or remove element in device list. 638 struct gap_ral_dev_info devices[__ARRAY_EMPTY]; 639 }; 640 641 /// Resolving List Size indication event 642 struct gapm_ral_size_ind 643 { 644 /// Resolving List size 645 uint8_t size; 646 }; 647 648 /// Resolving Address indication event 649 struct gapm_ral_addr_ind 650 { 651 /// Peer or local read operation 652 uint8_t operation; 653 /// Resolving List address 654 struct gap_bdaddr addr; 655 }; 656 657 /// Resolve Address command 658 struct gapm_resolv_addr_cmd 659 { 660 /// GAPM requested operation: 661 /// - GAPM_RESOLV_ADDR: Resolve device address 662 uint8_t operation; 663 /// Number of provided IRK (sahlle be > 0) 664 uint8_t nb_key; 665 /// Resolvable random address to solve 666 bd_addr_t addr; 667 /// Array of IRK used for address resolution (MSB -> LSB) 668 struct gap_sec_key irk[__ARRAY_EMPTY]; 669 }; 670 671 672 /// Indicate that resolvable random address has been solved 673 struct gapm_addr_solved_ind 674 { 675 /// Resolvable random address solved 676 bd_addr_t addr; 677 /// IRK that correctly solved the random address 678 struct gap_sec_key irk; 679 }; 680 681 682 /// Advertising data that contains information set by host. 683 struct gapm_adv_host 684 { 685 /// Advertising mode : 686 /// - GAP_NON_DISCOVERABLE: Non discoverable mode 687 /// - GAP_GEN_DISCOVERABLE: General discoverable mode 688 /// - GAP_LIM_DISCOVERABLE: Limited discoverable mode 689 /// - GAP_BROADCASTER_MODE: Broadcaster mode 690 uint8_t mode; 691 692 /// Advertising filter policy: 693 /// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone 694 /// - ADV_ALLOW_SCAN_WLST_CON_ANY: Allow both scan req from White List devices only and 695 /// connection req from anyone 696 /// - ADV_ALLOW_SCAN_ANY_CON_WLST: Allow both scan req from anyone and connection req 697 /// from White List devices only 698 /// - ADV_ALLOW_SCAN_WLST_CON_WLST: Allow scan and connection requests from White List 699 /// devices only 700 uint8_t adv_filt_policy; 701 702 /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set 703 /// Advertising AD type flags, shall not be set in advertising data 704 uint8_t adv_data_len; 705 /// Advertising data 706 uint8_t adv_data[GAP_ADV_DATA_LEN-3]; 707 /// Scan response data length- maximum 31 bytes 708 uint8_t scan_rsp_data_len; 709 /// Scan response data 710 uint8_t scan_rsp_data[GAP_SCAN_RSP_DATA_LEN]; 711 /// Peer address 712 struct gap_bdaddr peer_addr; 713 }; 714 715 /// Air operation default parameters 716 struct gapm_air_operation 717 { 718 /// Operation code. 719 uint8_t code; 720 721 /** 722 * Own BD address source of the device: 723 * - GAPM_STATIC_ADDR: Public or Private Static Address according to device address configuration 724 * - GAPM_GEN_RSLV_ADDR: Generated resolvable private random address 725 * - GAPM_GEN_NON_RSLV_ADDR: Generated non-resolvable private random address 726 */ 727 uint8_t addr_src; 728 729 /// Dummy data use to retrieve internal operation state (should be set to 0). 730 uint16_t state; 731 }; 732 733 734 /// Set advertising mode Command 735 struct gapm_start_advertise_cmd 736 { 737 /// GAPM requested operation: 738 /// - GAPM_ADV_NON_CONN: Start non connectable advertising 739 /// - GAPM_ADV_UNDIRECT: Start undirected connectable advertising 740 /// - GAPM_ADV_DIRECT: Start directed connectable advertising 741 /// - GAPM_ADV_DIRECT_LDC: Start directed connectable advertising using Low Duty Cycle 742 struct gapm_air_operation op; 743 744 /// Minimum interval for advertising 745 uint16_t intv_min; 746 /// Maximum interval for advertising 747 uint16_t intv_max; 748 749 ///Advertising channel map 750 uint8_t channel_map; 751 752 /// Advertising information 753 union gapm_adv_info 754 { 755 /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT) 756 struct gapm_adv_host host; 757 /// Direct address information (GAPM_ADV_DIRECT) 758 /// (used only if reconnection address isn't set or privacy disabled) 759 struct gap_bdaddr direct; 760 } info; 761 }; 762 763 764 /// Update Advertising Data Command - On fly update when device is advertising 765 struct gapm_update_advertise_data_cmd 766 { 767 /// GAPM requested operation: 768 /// - GAPM_UPDATE_ADVERTISE_DATA: Update on the fly advertising data 769 uint8_t operation; 770 /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set 771 /// Advertising AD type flags, shall not be set in advertising data 772 uint8_t adv_data_len; 773 /// Advertising data 774 uint8_t adv_data[GAP_ADV_DATA_LEN-3]; 775 /// Scan response data length- maximum 31 bytes 776 uint8_t scan_rsp_data_len; 777 /// Scan response data 778 uint8_t scan_rsp_data[GAP_SCAN_RSP_DATA_LEN]; 779 }; 780 781 /// Set scan mode Command 782 struct gapm_start_scan_cmd 783 { 784 /// GAPM requested operation: 785 /// - GAPM_SCAN_ACTIVE: Start active scan operation 786 /// - GAPM_SCAN_PASSIVE: Start passive scan operation 787 struct gapm_air_operation op; 788 789 /// Scan interval 790 uint16_t interval; 791 /// Scan window size 792 uint16_t window; 793 794 /// Scanning mode : 795 /// - GAP_GEN_DISCOVERY: General discovery mode 796 /// - GAP_LIM_DISCOVERY: Limited discovery mode 797 /// - GAP_OBSERVER_MODE: Observer mode 798 uint8_t mode; 799 800 /// Scan filter policy: 801 /// - SCAN_ALLOW_ADV_ALL: Allow advertising packets from anyone 802 /// - SCAN_ALLOW_ADV_WLST: Allow advertising packets from White List devices only 803 uint8_t filt_policy; 804 /// Scan duplicate filtering policy: 805 /// - SCAN_FILT_DUPLIC_DIS: Disable filtering of duplicate packets 806 /// - SCAN_FILT_DUPLIC_EN: Enable filtering of duplicate packets 807 uint8_t filter_duplic; 808 }; 809 810 811 /// Advertising or scanning report information event 812 struct gapm_adv_report_ind 813 { 814 /// Advertising report structure 815 adv_report_t report; 816 }; 817 818 819 /// Set connection initialization Command 820 struct gapm_start_connection_cmd 821 { 822 /// GAPM requested operation: 823 /// - GAPM_CONNECTION_DIRECT: Direct connection operation 824 /// - GAPM_CONNECTION_AUTO: Automatic connection operation 825 /// - GAPM_CONNECTION_SELECTIVE: Selective connection operation 826 /// - GAPM_CONNECTION_NAME_REQUEST: Name Request operation (requires to start a direct 827 /// connection) 828 /// - GAPM_CONNECTION_GENERAL: General connection operation 829 struct gapm_air_operation op; 830 831 /// Scan interval 832 uint16_t scan_interval; 833 /// Scan window size 834 uint16_t scan_window; 835 836 /// Minimum of connection interval 837 uint16_t con_intv_min; 838 /// Maximum of connection interval 839 uint16_t con_intv_max; 840 /// Connection latency 841 uint16_t con_latency; 842 /// Link supervision timeout 843 uint16_t superv_to; 844 /// Minimum CE length 845 uint16_t ce_len_min; 846 /// Maximum CE length 847 uint16_t ce_len_max; 848 849 /// Number of peer device information present in message. 850 /// Shall be 1 for GAPM_CONNECTION_DIRECT or GAPM_CONNECTION_NAME_REQUEST operations 851 /// Shall be greater than 0 for other operations 852 uint8_t nb_peers; 853 854 /// Peer device information 855 struct gap_bdaddr peers[__ARRAY_EMPTY]; 856 }; 857 858 859 /// Name of peer device indication 860 struct gapm_peer_name_ind 861 { 862 /// peer device bd address 863 bd_addr_t addr; 864 /// peer device address type 865 uint8_t addr_type; 866 /// peer device name length 867 uint8_t name_len; 868 /// peer device name 869 uint8_t name[__ARRAY_EMPTY]; 870 }; 871 872 /// Confirm connection to a specific device (Connection Operation in Selective mode) 873 struct gapm_connection_cfm 874 { 875 /// peer device bd address 876 bd_addr_t addr; 877 /// peer device address type 878 uint8_t addr_type; 879 880 /// Minimum of connection interval 881 uint16_t con_intv_min; 882 /// Maximum of connection interval 883 uint16_t con_intv_max; 884 /// Connection latency 885 uint16_t con_latency; 886 /// Link supervision timeout 887 uint16_t superv_to; 888 /// Minimum CE length 889 uint16_t ce_len_min; 890 /// Maximum CE length 891 uint16_t ce_len_max; 892 }; 893 894 /// Generate a random address. 895 struct gapm_gen_rand_addr_cmd 896 { 897 /// GAPM requested operation: 898 /// - GAPM_GEN_RAND_ADDR: Generate a random address 899 uint8_t operation; 900 /// Dummy parameter used to store the prand part of the address 901 uint8_t prand[GAP_ADDR_PRAND_LEN]; 902 /// Random address type @see gap_rnd_addr_type 903 /// - GAP_STATIC_ADDR: Static random address 904 /// - GAP_NON_RSLV_ADDR: Private non resolvable address 905 /// - GAP_RSLV_ADDR: Private resolvable address 906 uint8_t rnd_type; 907 }; 908 909 /// Parameters of the @ref GAPM_USE_ENC_BLOCK_CMD message 910 struct gapm_use_enc_block_cmd 911 { 912 /// Command Operation Code (shall be GAPM_USE_ENC_BLOCK) 913 uint8_t operation; 914 /// Operand 1 915 uint8_t operand_1[GAP_KEY_LEN]; 916 /// Operand 2 917 uint8_t operand_2[GAP_KEY_LEN]; 918 }; 919 920 /// Parameters of the @ref GAPM_USE_ENC_BLOCK_IND message 921 struct gapm_use_enc_block_ind 922 { 923 /// Result (16 bytes) 924 uint8_t result[GAP_KEY_LEN]; 925 }; 926 927 /// Parameters of the @ref GAPM_GEN_DH_KEY_CMD message 928 struct gapm_gen_dh_key_cmd 929 { 930 /// Command Operation Code (shall be GAPM_GEN_DH_KEY) 931 uint8_t operation; 932 /// X coordinate 933 uint8_t operand_1[GAP_P256_KEY_LEN]; 934 /// Y coordinate 935 uint8_t operand_2[GAP_P256_KEY_LEN]; 936 }; 937 938 /// Parameters of the @ref GAPM_GEN_DH_KEY_IND message 939 struct gapm_gen_dh_key_ind 940 { 941 /// Result (32 bytes) 942 uint8_t result[GAP_P256_KEY_LEN]; 943 }; 944 945 /// Parameters of the @ref GAPM_GEN_RAND_NB_CMD message 946 struct gapm_gen_rand_nb_cmd 947 { 948 /// Command Operation Code (shall be GAPM_GEN_RAND_NB) 949 uint8_t operation; 950 }; 951 952 /// Parameters of the @ref GAPM_GEN_RAND_NB_IND message 953 struct gapm_gen_rand_nb_ind 954 { 955 /// Generation Random Number (8 bytes) 956 rand_nb_t randnb; 957 }; 958 959 960 961 /// Create new task for specific profile 962 struct gapm_profile_task_add_cmd 963 { 964 /// GAPM requested operation: 965 /// - GAPM_PROFILE_TASK_ADD: Add new profile task 966 uint8_t operation; 967 /// Security Level : 968 /// 7 6 5 4 3 2 1 0 969 /// +----+----+----+----+----+----+----+----+ 970 /// | Reserved |DIS | AUTH |EKS | MI | 971 /// +----+----+----+----+----+----+----+----+ 972 /// 973 /// - MI: 1 - Application task is a Multi-Instantiated task, 0 - Mono-Instantiated 974 /// Only applies for service - Ignored by collectors: 975 /// - EKS: Service needs a 16 bytes encryption key 976 /// - AUTH: 0 - Disable, 1 - Enable, 2 - Unauth, 3 - Auth 977 /// - DIS: Disable the service 978 uint8_t sec_lvl; 979 /// Profile task identifier 980 uint16_t prf_task_id; 981 /// Application task number 982 uint16_t app_task; 983 /// Service start handle 984 /// Only applies for services - Ignored by collectors 985 /// 0: dynamically allocated in Attribute database 986 uint16_t start_hdl; 987 /// 32 bits value that contains value to initialize profile (database parameters, etc...) 988 uint32_t param[__ARRAY_EMPTY]; 989 }; 990 991 992 /// Inform that profile task has been added. 993 struct gapm_profile_added_ind 994 { 995 /// Profile task identifier 996 uint16_t prf_task_id; 997 /// Profile task number allocated 998 uint16_t prf_task_nb; 999 /// Service start handle 1000 /// Only applies for services - Ignored by collectors 1001 uint16_t start_hdl; 1002 }; 1003 1004 /// Indicate that a message has been received on an unknown task 1005 struct gapm_unknown_task_ind 1006 { 1007 /// Message identifier 1008 uint16_t msg_id; 1009 /// Task identifier 1010 uint16_t task_id; 1011 }; 1012 1013 /// Indicates suggested default data length 1014 struct gapm_sugg_dflt_data_len_ind 1015 { 1016 ///Host's suggested value for the Controller's maximum transmitted number of payload octets 1017 uint16_t suggted_max_tx_octets; 1018 ///Host's suggested value for the Controller's maximum packet transmission time 1019 uint16_t suggted_max_tx_time; 1020 }; 1021 1022 /// Indicates maximum data length 1023 struct gapm_max_data_len_ind 1024 { 1025 ///Maximum number of payload octets that the local Controller supports for transmission 1026 uint16_t suppted_max_tx_octets; 1027 ///Maximum time, in microseconds, that the local Controller supports for transmission 1028 uint16_t suppted_max_tx_time; 1029 ///Maximum number of payload octets that the local Controller supports for reception 1030 uint16_t suppted_max_rx_octets; 1031 ///Maximum time, in microseconds, that the local Controller supports for reception 1032 uint16_t suppted_max_rx_time; 1033 }; 1034 1035 1036 /// Register a LE Protocol/Service Multiplexer command 1037 struct gapm_lepsm_register_cmd 1038 { 1039 /// GAPM requested operation: 1040 /// - GAPM_LEPSM_REG: Register a LE Protocol/Service Multiplexer 1041 uint8_t operation; 1042 /// LE Protocol/Service Multiplexer 1043 uint16_t le_psm; 1044 /// Application task number 1045 uint16_t app_task; 1046 /// Security level 1047 /// 7 6 5 4 3 2 1 0 1048 /// +---+---+---+---+---+---+---+---+ 1049 /// |MI | RFU |EKS|SEC_LVL| 1050 /// +---+---+---+---+---+---+---+---+ 1051 /// bit[0-1]: Security level requirement (0=NO_AUTH, 1=UNAUTH, 2=AUTH, 3=SEC_CON) 1052 /// bit[2] : Encryption Key Size length must have 16 bytes 1053 /// bit[7] : Does the application task is multi-instantiated or not 1054 uint8_t sec_lvl; 1055 }; 1056 1057 1058 /// Unregister a LE Protocol/Service Multiplexer command 1059 struct gapm_lepsm_unregister_cmd 1060 { 1061 /// GAPM requested operation: 1062 /// - GAPM_LEPSM_UNREG: Unregister a LE Protocol/Service Multiplexer 1063 uint8_t operation; 1064 /// LE Protocol/Service Multiplexer 1065 uint16_t le_psm; 1066 }; 1067 1068 /* 1069 * MACROS 1070 **************************************************************************************** 1071 */ 1072 1073 1074 /* 1075 * GLOBAL VARIABLE DECLARATIONS 1076 **************************************************************************************** 1077 */ 1078 1079 /* 1080 * FUNCTION DECLARATIONS 1081 **************************************************************************************** 1082 */ 1083 1084 1085 /// @} GAPM_TASK 1086 1087 #endif /* _GAPM_TASK_H_ */ 1088