1 /* 2 * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., 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 16 /** 17 **************************************************************************************** 18 * 19 * @file sonata_gap_api.h 20 * 21 * @brief header file - gap api 22 * 23 **************************************************************************************** 24 */ 25 26 #ifndef _SONATA_GAP_API_H_ 27 #define _SONATA_GAP_API_H_ 28 29 /* 30 * INCLUDE FILES 31 **************************************************************************************** 32 */ 33 #include "sonata_config.h" 34 /// @cond 35 #if defined(STACK_BLE_HOST_PRESENT) || defined(BLE_HOST_PRESENT) 36 /// @endcond 37 #include "sonata_utils_api.h" 38 #include "sonata_gap.h" 39 40 /** 41 * @defgroup SONATA_GAP_API GAP_API 42 * @{ 43 */ 44 45 /* 46 * MACRO DEFINITIONS 47 **************************************************************************************** 48 */ 49 /// Minimum Encryption key size 50 #define SONATA_GAP_SMP_MIN_ENC_SIZE_LEN (7) 51 /// Maximum Encryption Key size 52 #define SONATA_GAP_SMP_MAX_ENC_SIZE_LEN (16) 53 54 /// GAP Manager operation type - application interface 55 typedef enum { 56 /* No Operation (if nothing has been requested) */ 57 /* ************************************************ */ 58 // /// No operation. 59 // SONATA_GAP_NO_OP = 0x00, 60 61 /* Default operations */ 62 /* ************************************************ */ 63 /// Reset BLE subsystem: LL and HL. 64 SONATA_GAP_RESET = 0x01, 65 66 /* Configuration operations */ 67 /* ************************************************ */ 68 /// Set device configuration 69 SONATA_GAP_SET_DEV_CONFIG = 0x03, 70 /// Set device channel map 71 SONATA_GAP_SET_CHANNEL_MAP = 0x04, 72 73 /* Retrieve device information */ 74 /* ************************************************ */ 75 /// Get Local device version 76 SONATA_GAP_GET_DEV_VERSION = 0x05, 77 /// Get Local device BD Address 78 SONATA_GAP_GET_DEV_BDADDR = 0x06, 79 /// Get device advertising power level 80 SONATA_GAP_GET_DEV_ADV_TX_POWER = 0x07, 81 /// Get White List Size. 82 SONATA_GAP_GET_WLIST_SIZE = 0x08, 83 /// Retrieve Antenna information 84 SONATA_GAP_GET_ANTENNA_INFO = 0x09, 85 86 /* Security / Encryption Toolbox */ 87 /* ************************************************ */ 88 /// Resolve device address 89 SONATA_GAP_RESOLV_ADDR = 0x17, 90 /// Generate a random address 91 SONATA_GAP_GEN_RAND_ADDR = 0x18, 92 /// Use the controller's AES-128 block 93 SONATA_GAP_USE_ENC_BLOCK = 0x19, 94 /// Generate a 8-byte random number 95 SONATA_GAP_GEN_RAND_NB = 0x1A, 96 97 /* Profile Management */ 98 /* ************************************************ */ 99 /// Create new task for specific profile 100 SONATA_GAP_PROFILE_TASK_ADD = 0x1B, 101 102 /* DEBUG */ 103 /* ************************************************ */ 104 /// Get memory usage 105 SONATA_GAP_DBG_GET_MEM_INFO = 0x1C, 106 /// Perform a platform reset 107 SONATA_GAP_PLF_RESET = 0x1D, 108 109 /* Data Length Extension */ 110 /* ************************************************ */ 111 /// Set Suggested Default LE Data Length 112 SONATA_GAP_SET_SUGGESTED_DFLT_LE_DATA_LEN = 0x1E, 113 /// Get Suggested Default LE Data Length 114 SONATA_GAP_GET_SUGGESTED_DFLT_LE_DATA_LEN = 0x1F, 115 /// Get Maximum LE Data Length 116 SONATA_GAP_GET_MAX_LE_DATA_LEN = 0x20, 117 118 /* Operation on Resolving List */ 119 /* ************************************************ */ 120 /// Get resolving address list size 121 SONATA_GAP_GET_RAL_SIZE = 0x21, 122 /// Get resolving local address 123 SONATA_GAP_GET_RAL_LOC_ADDR = 0x22, 124 /// Get resolving peer address 125 SONATA_GAP_GET_RAL_PEER_ADDR = 0x23, 126 127 /* Change current IRK */ 128 /* ************************************************ */ 129 /// Set IRK 130 SONATA_GAP_SET_IRK = 0x28, 131 132 /* LE Protocol/Service Multiplexer management */ 133 /* ************************************************ */ 134 /// Register a LE Protocol/Service Multiplexer 135 SONATA_GAP_LEPSM_REG = 0x29, 136 /// Unregister a LE Protocol/Service Multiplexer 137 SONATA_GAP_LEPSM_UNREG = 0x2A, 138 139 /* LE Direct Test Mode */ 140 /* ************************************************ */ 141 /// Stop the test mode 142 SONATA_GAP_LE_TEST_STOP = 0x2B, 143 /// Start RX Test Mode 144 SONATA_GAP_LE_TEST_RX_START = 0x2C, 145 /// Start TX Test Mode 146 SONATA_GAP_LE_TEST_TX_START = 0x2D, 147 148 /* Secure Connection */ 149 /* ************************************************ */ 150 /// Generate DH_Key 151 SONATA_GAP_GEN_DH_KEY = 0x2E, 152 /// Retrieve Public Key 153 SONATA_GAP_GET_PUB_KEY = 0x2F, 154 155 /* List Management */ 156 /* ************************************************ */ 157 /// Set content of white list 158 SONATA_GAP_SET_WL = 0x90, 159 /// Set content of resolving list 160 SONATA_GAP_SET_RAL = 0x91, 161 /// Set content of periodic advertiser list 162 SONATA_GAP_SET_PAL = 0x92, 163 /// Get periodic advertiser list size 164 SONATA_GAP_GET_PAL_SIZE = 0x95, 165 166 /* Air Operations */ 167 /* ************************************************ */ 168 /// Create advertising activity 169 SONATA_GAP_CREATE_ADV_ACTIVITY = 0xA0, 170 /// Create scanning activity 171 SONATA_GAP_CREATE_SCAN_ACTIVITY = 0xA1, 172 /// Create initiating activity 173 SONATA_GAP_CREATE_INIT_ACTIVITY = 0xA2, 174 /// Create periodic synchronization activity 175 SONATA_GAP_CREATE_PERIOD_SYNC_ACTIVITY = 0xA3, 176 /// Start an activity 177 SONATA_GAP_START_ACTIVITY = 0xA4, 178 /// Stop an activity 179 SONATA_GAP_STOP_ACTIVITY = 0xA5, 180 /// Stop all activities 181 SONATA_GAP_STOP_ALL_ACTIVITIES = 0xA6, 182 /// Delete an activity 183 SONATA_GAP_DELETE_ACTIVITY = 0xA7, 184 /// Delete all activities 185 SONATA_GAP_DELETE_ALL_ACTIVITIES = 0xA8, 186 /// Set advertising data 187 SONATA_GAP_SET_ADV_DATA = 0xA9, 188 /// Set scan response data 189 SONATA_GAP_SET_SCAN_RSP_DATA = 0xAA, 190 /// Set periodic advertising data 191 SONATA_GAP_SET_PERIOD_ADV_DATA = 0xAB, 192 /// Get number of available advertising sets 193 SONATA_GAP_GET_NB_ADV_SETS = 0xAC, 194 /// Get maximum advertising data length supported by the controller 195 SONATA_GAP_GET_MAX_LE_ADV_DATA_LEN = 0xAD, 196 /// Get minimum and maximum transmit powers supported by the controller 197 SONATA_GAP_GET_DEV_TX_PWR = 0xAE, 198 /// Get the RF Path Compensation values used in the TX Power Level and RSSI calculation 199 SONATA_GAP_GET_DEV_RF_PATH_COMP = 0xAF, 200 /// Enable/Disable reception of periodic advertising report 201 SONATA_GAP_PER_ADV_REPORT_CTRL = 0xB0, 202 /// Enable / Disable IQ sampling 203 SONATA_GAP_PER_SYNC_IQ_SAMPLING_CTRL = 0xB1, 204 /// Enable / Disable CTE transmission 205 SONATA_GAP_PER_ADV_CTE_TX_CTL = 0xB2, 206 207 /* Debug Commands */ 208 /* ************************************************ */ 209 /// Configure the Debug Platform I&Q Sampling generator 210 SONATA_GAP_DBG_IQGEN_CFG = 0x50, 211 212 /* Internal Operations */ 213 /* ************************************************ */ 214 /// Renew random addresses 215 SONATA_GAP_RENEW_ADDR = 0xF0, 216 } sonata_gap_operation; 217 218 /// Local device information type 219 typedef enum { 220 /// Get Local device version 221 SONATA_GET_DEV_VERSION = 0x05, 222 /// Get Local device BD Address 223 SONATA_GET_DEV_BDADDR = 0x06, 224 /// Get device advertising power level 225 SONATA_GET_DEV_ADV_TX_POWER = 0x07, 226 /// Get White List Size. 227 SONATA_GET_WLIST_SIZE = 0x08, 228 /// Retrieve Antenna information 229 SONATA_GET_ANTENNA_INFO = 0x09, 230 /// Get memory usage 231 SONATA_DBG_GET_MEM_INFO = 0x1C, 232 /// Get Suggested Default LE Data Length 233 SONATA_GET_SUGGESTED_DFLT_LE_DATA_LEN = 0x1F, 234 /// Get Maximum LE Data Length 235 SONATA_GET_MAX_LE_DATA_LEN = 0x20, 236 /// Get periodic advertiser list size 237 SONATA_GET_PAL_SIZE = 0x95, 238 /// Get resolving address list size 239 SONATA_GET_RAL_SIZE = 0x21, 240 /// Get number of available advertising sets 241 SONATA_GET_NB_ADV_SETS = 0xAC, 242 /// Get maximum advertising data length supported by the controller 243 SONATA_GET_MAX_LE_ADV_DATA_LEN = 0xAD, 244 /// Get minimum and maximum transmit powers supported by the controller 245 SONATA_GET_DEV_TX_PWR = 0xAE, 246 /// Get the RF Path Compensation values used in the TX Power Level and RSSI calculation 247 SONATA_GET_DEV_RF_PATH_COMP = 0xAF, 248 } sonata_gap_local_dev_info; 249 250 /// List of device info that should be provided by application,peer device can get it 251 typedef enum { 252 /// Device Name 253 SONATA_GAP_DEV_NAME, 254 /// Device Appearance Icon 255 SONATA_GAP_DEV_APPEARANCE, 256 /// Device Slave preferred parameters 257 SONATA_GAP_DEV_SLV_PREF_PARAMS, 258 /// Device Central address resolution 259 SONATA_GAP_DEV_CTL_ADDR_RESOL, 260 /// maximum device info parameter 261 SONATA_GAP_DEV_INFO_MAX, 262 } sonata_gap_dev_info; 263 264 ///// Option for PHY configuration 265 typedef enum { 266 /// No preference for rate used when transmitting on the LE Coded PHY 267 SONATA_GAP_PHY_OPT_LE_CODED_ALL_RATES = (1 << 0), 268 /// 500kbps rate preferred when transmitting on the LE Coded PHY 269 SONATA_GAP_PHY_OPT_LE_CODED_500K_RATE = (1 << 1), 270 /// 125kbps when transmitting on the LE Coded PHY 271 SONATA_GAP_PHY_OPT_LE_CODED_125K_RATE = (1 << 2), 272 } sonata_gap_phy_option; 273 274 /// Advertising properties bit field bit positions 275 typedef enum { 276 /// Indicate that advertising is connectable, reception of CONNECT_REQ or AUX_CONNECT_REQ 277 /// PDUs is accepted. Not applicable for periodic advertising. 278 SONATA_GAP_ADV_PROP_CONNECTABLE_POS = 0, 279 SONATA_GAP_ADV_PROP_CONNECTABLE_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_CONNECTABLE_POS), 280 281 /// Indicate that advertising is scannable, reception of SCAN_REQ or AUX_SCAN_REQ PDUs is 282 /// accepted 283 SONATA_GAP_ADV_PROP_SCANNABLE_POS = 1, 284 SONATA_GAP_ADV_PROP_SCANNABLE_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_SCANNABLE_POS), 285 286 /// Indicate that advertising targets a specific device. Only apply in following cases: 287 /// - Legacy advertising: if connectable 288 /// - Extended advertising: connectable or (non connectable and non discoverable) 289 SONATA_GAP_ADV_PROP_DIRECTED_POS = 2, 290 SONATA_GAP_ADV_PROP_DIRECTED_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_DIRECTED_POS), 291 292 /// Indicate that High Duty Cycle has to be used for advertising on primary channel 293 /// Apply only if created advertising is not an extended advertising 294 SONATA_GAP_ADV_PROP_HDC_POS = 3, 295 SONATA_GAP_ADV_PROP_HDC_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_HDC_POS), 296 297 /// Bit 4 is reserved 298 SONATA_GAP_ADV_PROP_RESERVED_4_POS = 4, 299 SONATA_GAP_ADV_PROP_RESERVED_4_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_RESERVED_4_POS), 300 301 /// Enable anonymous mode. Device address won't appear in send PDUs 302 /// Valid only if created advertising is an extended advertising 303 SONATA_GAP_ADV_PROP_ANONYMOUS_POS = 5, 304 SONATA_GAP_ADV_PROP_ANONYMOUS_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_ANONYMOUS_POS), 305 306 /// Include TX Power in the extended header of the advertising PDU. 307 /// Valid only if created advertising is not a legacy advertising 308 SONATA_GAP_ADV_PROP_TX_PWR_POS = 6, 309 SONATA_GAP_ADV_PROP_TX_PWR_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_TX_PWR_POS), 310 311 /// Include TX Power in the periodic advertising PDU. 312 /// Valid only if created advertising is a periodic advertising 313 SONATA_GAP_ADV_PROP_PER_TX_PWR_POS = 7, 314 SONATA_GAP_ADV_PROP_PER_TX_PWR_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_PER_TX_PWR_POS), 315 316 /// Indicate if application must be informed about received scan requests PDUs 317 SONATA_GAP_ADV_PROP_SCAN_REQ_NTF_EN_POS = 8, 318 SONATA_GAP_ADV_PROP_SCAN_REQ_NTF_EN_BIT = UTIL_BIT(SONATA_GAP_ADV_PROP_SCAN_REQ_NTF_EN_POS), 319 } sonata_gap_adv_prop_bf; 320 /// Advertising discovery mode 321 typedef enum { 322 /// Mode in non-discoverable 323 SONATA_GAP_ADV_MODE_NON_DISC = 0, 324 /// Mode in general discoverable 325 SONATA_GAP_ADV_MODE_GEN_DISC, 326 /// Mode in limited discoverable 327 SONATA_GAP_ADV_MODE_LIM_DISC, 328 /// Broadcast mode without presence of AD_TYPE_FLAG in advertising data 329 SONATA_GAP_ADV_MODE_BEACON, 330 SONATA_GAP_ADV_MODE_MAX, 331 } sonata_gap_adv_disc_mode; 332 333 /// Advertising properties configurations for legacy advertising 334 typedef enum { 335 /// Non connectable non scannable advertising 336 SONATA_GAP_ADV_PROP_NON_CONN_NON_SCAN_MASK = 0x0000, 337 /// Broadcast non scannable advertising - Discovery mode must be Non Discoverable 338 SONATA_GAP_ADV_PROP_BROADCAST_NON_SCAN_MASK = SONATA_GAP_ADV_PROP_NON_CONN_NON_SCAN_MASK, 339 /// Non connectable scannable advertising 340 SONATA_GAP_ADV_PROP_NON_CONN_SCAN_MASK = SONATA_GAP_ADV_PROP_SCANNABLE_BIT, 341 /// Broadcast non scannable advertising - Discovery mode must be Non Discoverable 342 SONATA_GAP_ADV_PROP_BROADCAST_SCAN_MASK = SONATA_GAP_ADV_PROP_NON_CONN_SCAN_MASK, 343 /// Undirected connectable advertising 344 SONATA_GAP_ADV_PROP_UNDIR_CONN_MASK = SONATA_GAP_ADV_PROP_CONNECTABLE_BIT | SONATA_GAP_ADV_PROP_SCANNABLE_BIT, 345 /// Directed connectable advertising 346 SONATA_GAP_ADV_PROP_DIR_CONN_MASK = SONATA_GAP_ADV_PROP_DIRECTED_BIT | SONATA_GAP_ADV_PROP_CONNECTABLE_BIT, 347 /// Directed connectable with Low Duty Cycle 348 SONATA_GAP_ADV_PROP_DIR_CONN_LDC_MASK = SONATA_GAP_ADV_PROP_DIR_CONN_MASK, 349 /// Directed connectable with High Duty Cycle 350 SONATA_GAP_ADV_PROP_DIR_CONN_HDC_MASK = SONATA_GAP_ADV_PROP_DIR_CONN_MASK | SONATA_GAP_ADV_PROP_HDC_BIT, 351 } sonata_gap_leg_adv_prop; 352 353 /// Advertising properties configurations for extended advertising 354 typedef enum { 355 /// Non connectable non scannable extended advertising 356 SONATA_GAP_EXT_ADV_PROP_NON_CONN_NON_SCAN_MASK = 0x0000, 357 /// Non connectable scannable extended advertising 358 SONATA_GAP_EXT_ADV_PROP_NON_CONN_SCAN_MASK = SONATA_GAP_ADV_PROP_SCANNABLE_BIT, 359 /// Non connectable scannable directed extended advertising 360 SONATA_GAP_EXT_ADV_PROP_NON_CONN_SCAN_DIR_MASK = SONATA_GAP_ADV_PROP_SCANNABLE_BIT | SONATA_GAP_ADV_PROP_DIRECTED_BIT, 361 /// Non connectable anonymous directed extended advertising 362 SONATA_GAP_EXT_ADV_PROP_ANONYM_DIR_MASK = SONATA_GAP_ADV_PROP_ANONYMOUS_BIT | SONATA_GAP_ADV_PROP_DIRECTED_BIT, 363 /// Undirected connectable extended advertising 364 SONATA_GAP_EXT_ADV_PROP_UNDIR_CONN_MASK = SONATA_GAP_ADV_PROP_CONNECTABLE_BIT, 365 /// Directed connectable extended advertising 366 SONATA_GAP_EXT_ADV_PROP_DIR_CONN_MASK = SONATA_GAP_ADV_PROP_CONNECTABLE_BIT | SONATA_GAP_ADV_PROP_DIRECTED_BIT, 367 } sonata_gap_ext_adv_prop; 368 369 /// Own BD address source of the device 370 typedef enum { 371 /// Public or Private Static Address according to device address configuration 372 SONATA_GAP_STATIC_ADDR, 373 /// Generated resolvable private random address 374 SONATA_GAP_GEN_RSLV_ADDR, 375 /// Generated non-resolvable private random address 376 SONATA_GAP_GEN_NON_RSLV_ADDR, 377 } sonata_gap_own_addr; 378 379 /// Scanning Types 380 typedef enum { 381 /// General discovery 382 SONATA_GAP_SCAN_TYPE_GEN_DISC = 0, 383 /// Limited discovery 384 SONATA_GAP_SCAN_TYPE_LIM_DISC, 385 /// Observer 386 SONATA_GAP_SCAN_TYPE_OBSERVER, 387 /// Selective observer 388 SONATA_GAP_SCAN_TYPE_SEL_OBSERVER, 389 /// Connectable discovery 390 SONATA_GAP_SCAN_TYPE_CONN_DISC, 391 /// Selective connectable discovery 392 SONATA_GAP_SCAN_TYPE_SEL_CONN_DISC, 393 } sonata_gap_scan_type; 394 395 /// Privacy configuration 396 typedef enum { 397 /// Indicate if identity address is a public (0) or static private random (1) address 398 SONATA_GAP_PRIV_CFG_PRIV_ADDR_BIT = (1 << 0), 399 /// Reserved 400 SONATA_GAP_PRIV_CFG_RSVD = (1 << 1), 401 /// Indicate if controller privacy is enabled 402 SONATA_GAP_PRIV_CFG_PRIV_EN_BIT = (1 << 2), 403 } sonata_gap_priv_cfg; 404 405 /// Scanning properties bit field bit value 406 typedef enum { 407 /// Scan advertisement on the LE 1M PHY 408 SONATA_GAP_SCAN_PROP_PHY_1M_BIT = (1 << 0), 409 /// Scan advertisement on the LE Coded PHY 410 SONATA_GAP_SCAN_PROP_PHY_CODED_BIT = (1 << 1), 411 /// Active scan on LE 1M PHY (Scan Request PDUs may be sent) 412 SONATA_GAP_SCAN_PROP_ACTIVE_1M_BIT = (1 << 2), 413 /// Active scan on LE Coded PHY (Scan Request PDUs may be sent) 414 SONATA_GAP_SCAN_PROP_ACTIVE_CODED_BIT = (1 << 3), 415 /// Accept directed advertising packets if we use a RPA and target address cannot be solved by the 416 /// controller 417 SONATA_GAP_SCAN_PROP_ACCEPT_RPA_BIT = (1 << 4), 418 /// Filter truncated advertising or scan response reports 419 SONATA_GAP_SCAN_PROP_FILT_TRUNC_BIT = (1 << 5), 420 } sonata_gap_scan_prop; 421 422 /// Filtering policy for duplicated packets 423 typedef enum { 424 /// Disable filtering of duplicated packets 425 SONATA_GAP_DUP_FILT_DIS = 0, 426 /// Enable filtering of duplicated packets 427 SONATA_GAP_DUP_FILT_EN, 428 /// Enable filtering of duplicated packets, reset for each scan period 429 SONATA_GAP_DUP_FILT_EN_PERIOD, 430 } sonata_gap_dup_filter_pol; 431 432 /// Periodic synchronization types 433 typedef enum { 434 /// Do not use periodic advertiser list for synchronization. Use advertiser information provided 435 /// in the GAPM_ACTIVITY_START_CMD. 436 SONATA_GAP_PER_SYNC_TYPE_GENERAL = 0, 437 /// Use periodic advertiser list for synchronization 438 SONATA_GAP_PER_SYNC_TYPE_SELECTIVE, 439 /// Use Periodic advertising sync transfer information send through connection for synchronization 440 SONATA_GAP_PER_SYNC_TYPE_PAST, 441 } sonata_gap_per_sync_type; 442 443 /// Initiating Types 444 typedef enum { 445 /// Direct connection establishment, establish a connection with an indicated device 446 SONATA_GAP_INIT_TYPE_DIRECT_CONN_EST = 0, 447 /// Automatic connection establishment, establish a connection with all devices whose address is 448 /// present in the white list 449 SONATA_GAP_INIT_TYPE_AUTO_CONN_EST, 450 /// Name discovery, Establish a connection with an indicated device in order to read content of its 451 /// Device Name characteristic. Connection is closed once this operation is stopped. 452 SONATA_GAP_INIT_TYPE_NAME_DISC, 453 } sonata_gap_init_type; 454 455 /// Initiating Properties 456 typedef enum { 457 /// Scan connectable advertisements on the LE 1M PHY. Connection parameters for the LE 1M PHY are provided 458 SONATA_GAP_INIT_PROP_1M_BIT = (1 << 0), 459 /// Connection parameters for the LE 2M PHY are provided 460 SONATA_GAP_INIT_PROP_2M_BIT = (1 << 1), 461 /// Scan connectable advertisements on the LE Coded PHY. Connection parameters for the LE Coded PHY are provided 462 SONATA_GAP_INIT_PROP_CODED_BIT = (1 << 2), 463 } sonata_gap_init_prop; 464 465 /// Advertising report information 466 typedef enum { 467 /// Report Type 468 SONATA_GAP_REPORT_INFO_REPORT_TYPE_MASK = 0x07, 469 /// Report is complete 470 SONATA_GAP_REPORT_INFO_COMPLETE_BIT = (1 << 3), 471 /// Connectable advertising 472 SONATA_GAP_REPORT_INFO_CONN_ADV_BIT = (1 << 4), 473 /// Scannable advertising 474 SONATA_GAP_REPORT_INFO_SCAN_ADV_BIT = (1 << 5), 475 /// Directed advertising 476 SONATA_GAP_REPORT_INFO_DIR_ADV_BIT = (1 << 6), 477 } sonata_gapm_adv_report_info; 478 479 /// gap role 480 typedef enum { 481 /// No role set yet 482 SONATA_GAP_ROLE_NONE = 0x00, 483 484 /// Observer role 485 SONATA_GAP_ROLE_OBSERVER = 0x01, 486 487 /// Broadcaster role 488 SONATA_GAP_ROLE_BROADCASTER = 0x02, 489 490 /// Master/Central role 491 SONATA_GAP_ROLE_CENTRAL = (0x04 | SONATA_GAP_ROLE_OBSERVER), 492 493 /// Peripheral/Slave role 494 SONATA_GAP_ROLE_PERIPHERAL = (0x08 | SONATA_GAP_ROLE_BROADCASTER), 495 496 /// Device has all role, both peripheral and central 497 SONATA_GAP_ROLE_ALL = (SONATA_GAP_ROLE_CENTRAL | SONATA_GAP_ROLE_PERIPHERAL), 498 } sonata_gap_api_role_t; 499 500 /// Pairing mode authorized on the device 501 /// 7 6 5 4 3 2 1 0 502 /// +----+----+----+----+----+----+----+----+ 503 /// | RFU | SCP| LP | 504 /// +----+----+----+----+----+----+----+----+ 505 typedef enum { 506 /// No pairing authorized 507 SONATA_GAP_PAIRING_DISABLE = 0, 508 /// Legacy pairing Authorized 509 SONATA_GAP_PAIRING_LEGACY = (1 << 0), 510 /// Secure Connection pairing Authorized 511 SONATA_GAP_PAIRING_SEC_CON = (1 << 1), 512 } sonata_gap_pairing_mode; 513 514 /// profiles id define 515 typedef enum { 516 SONATA_PRF_ID_DISS = 20, /* *< Device Information Service Server Task */ 517 SONATA_PRF_ID_DISC = 21, /* *< Device Information Service Client Task */ 518 519 SONATA_PRF_ID_PROXM = 22, /* *< Proximity Monitor Task */ 520 SONATA_PRF_ID_PROXR = 23, /* *< Proximity Reporter Task */ 521 522 SONATA_PRF_ID_FINDL = 24, /* *< Find Me Locator Task */ 523 SONATA_PRF_ID_FINDT = 25, /* *< Find Me Target Task */ 524 525 SONATA_PRF_ID_HTPC = 26, /* *< Health Thermometer Collector Task */ 526 SONATA_PRF_ID_HTPT = 27, /* *< Health Thermometer Sensor Task */ 527 528 SONATA_PRF_ID_BLPS = 28, /* *< Blood Pressure Sensor Task */ 529 SONATA_PRF_ID_BLPC = 29, /* *< Blood Pressure Collector Task */ 530 531 SONATA_PRF_ID_HRPS = 30, /* *< Heart Rate Sensor Task */ 532 SONATA_PRF_ID_HRPC = 31, /* *< Heart Rate Collector Task */ 533 534 SONATA_PRF_ID_TIPS = 32, /* *< Time Server Task */ 535 SONATA_PRF_ID_TIPC = 33, /* *< Time Client Task */ 536 537 SONATA_PRF_ID_SCPPS = 34, /* *< Scan Parameter Profile Server Task */ 538 SONATA_PRF_ID_SCPPC = 35, /* *< Scan Parameter Profile Client Task */ 539 540 SONATA_PRF_ID_BASS = 36, /* *< Battery Service Server Task */ 541 SONATA_PRF_ID_BASC = 37, /* *< Battery Service Client Task */ 542 543 SONATA_PRF_ID_HOGPD = 38, /* *< HID Device Task */ 544 SONATA_PRF_ID_HOGPBH = 39, /* *< HID Boot Host Task */ 545 SONATA_PRF_ID_HOGPRH = 40, /* *< HID Report Host Task */ 546 547 SONATA_PRF_ID_GLPS = 41, /* *< Glucose Profile Sensor Task */ 548 SONATA_PRF_ID_GLPC = 42, /* *< Glucose Profile Collector Task */ 549 550 SONATA_PRF_ID_RSCPS = 43, /* *< Running Speed and Cadence Profile Server Task */ 551 SONATA_PRF_ID_RSCPC = 44, /* *< Running Speed and Cadence Profile Collector Task */ 552 553 SONATA_PRF_ID_CSCPS = 45, /* *< Cycling Speed and Cadence Profile Server Task */ 554 SONATA_PRF_ID_CSCPC = 46, /* *< Cycling Speed and Cadence Profile Client Task */ 555 556 SONATA_PRF_ID_ANPS = 47, /* *< Alert Notification Profile Server Task */ 557 SONATA_PRF_ID_ANPC = 48, /* *< Alert Notification Profile Client Task */ 558 559 SONATA_PRF_ID_PASPS = 49, /* *< Phone Alert Status Profile Server Task */ 560 SONATA_PRF_ID_PASPC = 50, /* *< Phone Alert Status Profile Client Task */ 561 562 SONATA_PRF_ID_CPPS = 51, /* *< Cycling Power Profile Server Task */ 563 SONATA_PRF_ID_CPPC = 52, /* *< Cycling Power Profile Client Task */ 564 565 SONATA_PRF_ID_LANS = 53, /* *< Location and Navigation Profile Server Task */ 566 SONATA_PRF_ID_LANC = 54, /* *< Location and Navigation Profile Client Task */ 567 568 SONATA_PRF_ID_IPSS = 55, /* *< Internet Protocol Support Profile Server Task */ 569 SONATA_PRF_ID_IPSC = 56, /* *< Internet Protocol Support Profile Client Task */ 570 571 SONATA_PRF_ID_ENVS = 57, /* *< Environmental Sensing Profile Server Task */ 572 SONATA_PRF_ID_ENVC = 58, /* *< Environmental Sensing Profile Client Task */ 573 574 SONATA_PRF_ID_WSCS = 59, /* *< Weight Scale Profile Server Task */ 575 SONATA_PRF_ID_WSCC = 60, /* *< Weight Scale Profile Client Task */ 576 577 SONATA_PRF_ID_UDSS = 61, /* *< User Data Service Server Task */ 578 SONATA_PRF_ID_UDSC = 62, /* *< User Data Service Client Task */ 579 580 SONATA_PRF_ID_BCSS = 63, /* *< Body Composition Server Task */ 581 SONATA_PRF_ID_BCSC = 64, /* *< Body Composition Client Task */ 582 583 SONATA_PRF_ID_WPTS = 65, /* *< Wireless Power Transfer Profile Server Task */ 584 SONATA_PRF_ID_WPTC = 66, /* *< Wireless Power Transfer Profile Client Task */ 585 586 SONATA_PRF_ID_PLXS = 67, /* *< Pulse Oximeter Profile Server Task */ 587 SONATA_PRF_ID_PLXC = 68, /* *< Pulse Oximeter Profile Client Task */ 588 589 SONATA_PRF_ID_CGMS = 69, /* *< Continuous Glucose Monitoring Server Task */ 590 SONATA_PRF_ID_CGMC = 70, /* *< Continuous Glucose Monitoring Client Task */ 591 592 SONATA_PRF_ID_OTAS = 80, 593 594 SONATA_PRF_ID_MESH = 200, /* *<Mesh Task */ 595 596 /* 240 -> 241 reserved for Audio Mode 0 */ 597 SONATA_PRF_ID_AM0 = 240, /* *< BLE Audio Mode 0 Task */ 598 SONATA_PRF_ID_AM0_HAS = 241, /* *< BLE Audio Mode 0 Hearing Aid Service Task */ 599 600 SONATA_PRF_ID_THPP = 242, /* *< Throughput profile tester used for debugging */ 601 } sonata_ble_profile_id; 602 603 /// peer information type 604 typedef enum { 605 /// Retrieve name of peer device. // Will show in @see sonata_gap_peer_att_info_ind_handler 606 SONATA_GET_PEER_NAME = 0x02, 607 /// Retrieve peer device version info. // Will show in @see sonata_gap_peer_version_ind_handler 608 SONATA_GET_PEER_VERSION = 0x03, 609 /// Retrieve peer device features. // Will show in @see sonata_gap_peer_features_ind_handler 610 SONATA_GET_PEER_FEATURES = 0x04, 611 /// Get Peer device appearance // Will show in @see sonata_gap_peer_att_info_ind_handler 612 SONATA_GET_PEER_APPEARANCE = 0x05, 613 /// Get Peer device Slaved Preferred Parameters // Will show in @see sonata_gap_peer_att_info_ind_handler 614 SONATA_GET_PEER_SLV_PREF_PARAMS = 0x06, 615 /// Retrieve connection RSSI. // Will show in @see sonata_gap_con_rssi_ind_handler 616 SONATA_GET_PEER_CON_RSSI = 0x07, 617 /// Retrieve Connection Channel MAP. // Will show in @see sonata_gap_con_channel_map_ind_handler 618 SONATA_GET_PEER_CON_CHANNEL_MAP = 0x08, 619 // Will show in @see sonata_gap_le_ping_to_val_ind_handler and @see sonata_gap_le_ping_to_ind_handler 620 SONATA_GET_LE_PING_TO = 0x12, 621 // Will show in @see sonata_gap_peer_att_info_ind_handler 622 SONATA_GET_PEER_ADDR_RESOL_SUPP = 0x15, 623 // Will show in @see sonata_gap_le_phy_ind_handler 624 SONATA_GET_PHY = 0x18, 625 // Will show in @see sonata_gap_chan_sel_algo_ind_handler 626 SONATA_GET_CHAN_SEL_ALGO = 0x19, 627 } sonata_peer_info_type; 628 629 /// Bond event type. 630 /* @TRACE */ 631 typedef enum { 632 /// Bond Pairing request 633 SONATA_GAP_PAIRING_REQ, 634 /// Respond to Pairing request 635 SONATA_GAP_PAIRING_RSP, 636 637 /// Pairing Finished information 638 SONATA_GAP_PAIRING_SUCCEED, 639 /// Pairing Failed information 640 SONATA_GAP_PAIRING_FAILED, 641 642 /// Used to retrieve pairing Temporary Key 643 SONATA_GAP_TK_EXCH, 644 /// Used for Identity Resolving Key exchange 645 SONATA_GAP_IRK_EXCH, 646 /// Used for Connection Signature Resolving Key exchange 647 SONATA_GAP_CSRK_EXCH, 648 /// Used for Long Term Key exchange 649 SONATA_GAP_LTK_EXCH, 650 651 /// Bond Pairing request issue, Repeated attempt 652 SONATA_GAP_REPEATED_ATTEMPT, 653 654 /// Out of Band - exchange of confirm and rand. 655 SONATA_GAP_OOB_EXCH, 656 657 /// Numeric Comparison - Exchange of Numeric Value - 658 SONATA_GAP_NC_EXCH, 659 } sonata_gap_bond; 660 661 /// Type of activities that can be created 662 typedef enum { 663 /// Advertising activity 664 SONATA_GAP_ACTV_TYPE_ADV = 0, 665 /// Scanning activity 666 SONATA_GAP_ACTV_TYPE_SCAN, 667 /// Initiating activity 668 SONATA_GAP_ACTV_TYPE_INIT, 669 /// Periodic synchronization activity 670 SONATA_GAP_ACTV_TYPE_PER_SYNC, 671 } sonata_gapm_actv_type; 672 673 /// Type of advertising that can be created 674 typedef enum { 675 /// Legacy advertising 676 SONATA_GAP_ADV_TYPE_LEGACY = 0, 677 /// Extended advertising 678 SONATA_GAP_ADV_TYPE_EXTENDED, 679 /// Periodic advertising 680 SONATA_GAP_ADV_TYPE_PERIODIC, 681 } sonata_gap_adv_type; 682 683 /// Information source. 684 typedef enum { 685 /// Local info. 686 SONATA_GAP_SMP_INFO_LOCAL, 687 /// Peer info. 688 SONATA_GAP_SMP_INFO_PEER, 689 /// Maximum info source. 690 SONATA_GAP_SMP_INFO_MAX 691 } sonata_ble_gap_smp_addr_src; 692 693 /// Attribute database configuration 694 // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 695 // +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 696 // | DBG|DBGT| RFU |PCP | APP_PERM | NAME_PERM | 697 // +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 698 // - Bit [0-2] : Device Name write permission requirements for peer device (@see sonata_gap_write_att_perm) 699 // - Bit [3-5] : Device Appearance write permission requirements for peer device (@see sonata_gap_write_att_perm) 700 // - Bit [6] : Slave Preferred Connection Parameters present 701 // - Bit [7-13]: Reserved 702 // - Bit [14] : if Debug Mode enabled, forward all L2cap traffic to application 703 // - Bit [15] : Enable Debug Mode 704 typedef enum { 705 /// Device Name write permission requirements for peer device (@see sonata_gap_write_att_perm) 706 SONATA_GAP_ATT_NAME_PERM_MASK = 0x0007, 707 SONATA_GAP_ATT_NAME_PERM_LSB = 0x00, 708 /// Device Appearance write permission requirements for peer device (@see sonata_gap_write_att_perm) 709 SONATA_GAP_ATT_APPEARENCE_PERM_MASK = 0x0038, 710 SONATA_GAP_ATT_APPEARENCE_PERM_LSB = 0x03, 711 /// Slave Preferred Connection Parameters present in GAP attribute database. 712 SONATA_GAP_ATT_SLV_PREF_CON_PAR_EN_MASK = 0x0040, 713 SONATA_GAP_ATT_SLV_PREF_CON_PAR_EN_LSB = 0x06, 714 /// if Debug Mode enabled, forward all L2cap traffic to application 715 SONATA_GAP_ATT_DBG_L2CAP_TRAFFIC_EN_MASK = 0x4000, 716 SONATA_GAP_ATT_DBG_L2CAP_TRAFFIC_EN_LSB = 0x0E, 717 /// Enable Debug Mode 718 SONATA_GAP_ATT_DBG_MODE_EN_MASK = 0x8000, 719 SONATA_GAP_ATT_DBG_MODE_EN_LSB = 0x0F, 720 } sonata_gap_att_cfg_flag; 721 722 /// Keypress Notification types 723 typedef enum { 724 /// Passkey entry started 725 SONATA_GAP_KEY_NTF_ENTRY_STARTED = 0x00, 726 /// Passkey digit entered 727 SONATA_GAP_KEY_NTF_DIGIT_ENTERED, 728 /// Passkey digit erased 729 SONATA_GAP_KEY_NTF_DIGIT_ERASED, 730 /// Passkey cleared 731 SONATA_GAP_KEY_NTF_CLEARED, 732 /// Passkey entry completed 733 SONATA_GAP_KEY_NTF_ENTRY_COMPLETED 734 } sonata_gap_key_ntf_type; 735 736 /// Constant Tone Extension type 737 typedef enum { 738 /// Allow AoA Constant Tone Extension Response 739 SONATA_GAP_CTE_AOA = (1 << 0), 740 /// Allow AoD Constant Tone Extension Response with 1 us slots 741 SONATA_GAP_CTE_AOD_1US_SLOT = (1 << 1), 742 /// Allow AoD Constant Tone Extension Response with 2 us slots 743 SONATA_GAP_CTE_AOD_2US_SLOT = (1 << 2), 744 } sonata_gap_cte_type; 745 746 /// Advertising report type 747 typedef enum { 748 /// Extended advertising report 749 SONATA_GAP_REPORT_TYPE_ADV_EXT = 0, 750 /// Legacy advertising report 751 SONATA_GAP_REPORT_TYPE_ADV_LEG, 752 /// Extended scan response report 753 SONATA_GAP_REPORT_TYPE_SCAN_RSP_EXT, 754 /// Legacy scan response report 755 SONATA_GAP_REPORT_TYPE_SCAN_RSP_LEG, 756 /// Periodic advertising report 757 SONATA_GAP_REPORT_TYPE_PER_ADV, 758 } sonata_gap_adv_report_type; 759 760 /// gap extent advertising report indicate 761 typedef struct sonata_gap_ext_adv_report_ind { 762 /// Activity identifier 763 uint8_t actv_idx; 764 /// Bit field providing information about the received report (@see enum sonata_gap_adv_report_info) 765 uint8_t info; 766 /// Transmitter device address 767 struct sonata_gap_bdaddr trans_addr; 768 /// Target address (in case of a directed advertising report) 769 struct sonata_gap_bdaddr target_addr; 770 /// TX power (in dBm) 771 int8_t tx_pwr; 772 /// RSSI (between -127 and +20 dBm) 773 int8_t rssi; 774 /// Primary PHY on which advertising report has been received 775 uint8_t phy_prim; 776 /// Secondary PHY on which advertising report has been received 777 uint8_t phy_second; 778 /// Advertising SID 779 /// Valid only for periodic advertising report 780 uint8_t adv_sid; 781 /// Periodic advertising interval (in unit of 1.25ms, min is 7.5ms) 782 /// Valid only for periodic advertising report 783 uint16_t period_adv_intv; 784 /// Report length 785 uint16_t length; 786 /// Report 787 uint8_t data[__ARRAY_EMPTY]; 788 } sonata_gap_ext_adv_report_ind_t; 789 790 /// Indicate that a connection has been established 791 typedef struct sonata_gap_connection_req_ind { 792 /// Connection handle 793 uint16_t conhdl; 794 /// Connection interval 795 uint16_t con_interval; 796 /// Connection latency 797 uint16_t con_latency; 798 /// Link supervision timeout 799 uint16_t sup_to; 800 /// Clock accuracy 801 uint8_t clk_accuracy; 802 /// Peer address type 803 uint8_t peer_addr_type; 804 /// Peer BT address 805 sonata_bd_addr_t peer_addr; 806 /// Role of device in connection (0 = Master / 1 = Slave) 807 uint8_t role; 808 809 } sonata_gap_connection_req_ind_t; 810 811 /// device information data 812 typedef union sonata_gap_dev_info_val { 813 /// Device name 814 // @trc_union parent.req == SONATA_GAP_DEV_NAME 815 struct sonata_gap_dev_name name; 816 /// Appearance Icon 817 // @trc_union parent.req == SONATA_GAP_DEV_APPEARANCE 818 uint16_t appearance; 819 /// Slave preferred parameters 820 // @trc_union parent.req == SONATA_GAP_DEV_SLV_PREF_PARAMS 821 struct sonata_gap_slv_pref slv_pref_params; 822 /// Central address resolution 823 // @trc_union parent.req == SONATA_GAP_DEV_CTL_ADDR_RESOL 824 uint8_t ctl_addr_resol; 825 } sonata_gap_dev_info_val_t; 826 827 /// Peer device attribute DB info such as Device Name, Appearance or Slave Preferred Parameters 828 typedef struct sonata_gap_peer_att_info_ind { 829 /// Requested information 830 /// - SONATA_GAP_DEV_NAME: Device Name 831 /// - SONATA_GAP_DEV_APPEARANCE: Device Appearance Icon 832 /// - SONATA_GAP_DEV_SLV_PREF_PARAMS: Device Slave preferred parameters 833 /// - SONATA_GAP_GET_ADDR_RESOL_SUPP: Address resolution supported 834 uint8_t req; 835 /// Attribute handle 836 uint16_t handle; 837 838 /// device information data 839 union sonata_gap_dev_info_val info; 840 } sonata_gap_peer_att_info_ind_t; 841 842 /// Indication of peer version info 843 /* @TRACE */ 844 typedef struct sonata_gap_peer_version_ind { 845 /// Manufacturer name 846 uint16_t compid; 847 /// LMP subversion 848 uint16_t lmp_subvers; 849 /// LMP version 850 uint8_t lmp_vers; 851 } sonata_gap_peer_version_ind_t; 852 /// Indication of peer features info 853 854 /* @TRACE */ 855 typedef struct sonata_gap_peer_features_ind { 856 /// 8-byte array for LE features 857 uint8_t features[SONATA_GAP_LE_FEATS_LEN]; 858 } sonata_gap_peer_features_ind_t; 859 860 /// Indication of ongoing connection RSSI 861 /* @TRACE */ 862 typedef struct sonata_gap_con_rssi_ind { 863 /// RSSI value 864 int8_t rssi; 865 } sonata_gap_con_rssi_ind_t; 866 867 /// Indication of ongoing connection Channel Map 868 /* @TRACE */ 869 typedef struct sonata_gap_con_channel_map_ind { 870 /// channel map value 871 sonata_le_chnl_map_t ch_map; 872 } sonata_gap_con_channel_map_ind_t; 873 874 /// Indication of LE Ping 875 /* @TRACE */ 876 typedef struct sonata_gap_le_ping_to_val_ind { 877 /// Authenticated payload timeout 878 uint16_t timeout; 879 } sonata_gap_le_ping_to_val_ind_t; 880 881 /// Active link PHY configuration. Triggered when configuration is read or during an update. 882 /* @TRACE */ 883 typedef struct sonata_gap_le_phy_ind { 884 /// LE PHY for data transmission (@see enum gap_phy_val) 885 uint8_t tx_phy; 886 /// LE PHY for data reception (@see enum gap_phy_val) 887 uint8_t rx_phy; 888 } sonata_gap_le_phy_ind_t; 889 890 /// Parameters of the @ref SONATA_GAP_CHAN_SEL_ALGO_IND 891 /* @TRACE */ 892 typedef struct sonata_gap_chan_sel_algo_ind { 893 /// Used channel selection algorithm 894 uint8_t chan_sel_algo; 895 } sonata_gap_chan_sel_algo_ind_t; 896 897 /// peer device information indication for get peer version, features, con rssi, channel map, phy, algo 898 typedef struct sonata_gap_peer_info_ind { 899 /// Requested information 900 /// - SONATA_GET_PEER_VERSION: 901 /// - SONATA_GET_PEER_FEATURES: 902 /// - SONATA_GET_PEER_CON_RSSI: 903 /// - SONATA_GET_PEER_CON_CHANNEL_MAP: 904 /// - SONATA_GET_LE_PING_TO: 905 /// - SONATA_GET_PHY: 906 /// - SONATA_GET_CHAN_SEL_ALGO: 907 uint8_t req; 908 909 union info_ { 910 911 struct sonata_gap_peer_version_ind version; 912 struct sonata_gap_peer_features_ind features; 913 struct sonata_gap_con_rssi_ind rssi; 914 struct sonata_gap_con_channel_map_ind channel_map; 915 struct sonata_gap_le_ping_to_val_ind ping_to_value; 916 struct sonata_gap_le_phy_ind le_phy; 917 struct sonata_gap_chan_sel_algo_ind sel_algo; 918 } info; 919 920 } sonata_gap_peer_info_ind_t; 921 922 /// Set device configuration command 923 typedef struct { 924 // /// GAP requested operation: 925 // /// - SONATA_GAP_SET_DEV_CONFIG: Set device configuration 926 927 /// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. 928 uint8_t role; 929 930 /// -------------- Privacy Config ----------------------- 931 /// Duration before regenerate device address when privacy is enabled. - in seconds 932 uint16_t renew_dur; 933 /// Provided own static private random address 934 sonata_bd_addr_t addr; 935 /// Device IRK used for resolvable random BD address generation (LSB first) 936 struct sonata_gap_sec_key irk; 937 /// Privacy configuration bit field (@see enum sonata_gap_priv_cfg for bit signification) 938 uint8_t privacy_cfg; 939 940 /// -------------- Security Config ----------------------- 941 942 /// Pairing mode authorized (@see enum sonata_gap_pairing_mode) 943 uint8_t pairing_mode; 944 945 /// -------------- ATT Database Config ----------------------- 946 947 /// GAP service start handle 948 uint16_t gap_start_hdl; 949 /// GATT service start handle 950 uint16_t gatt_start_hdl; 951 952 /// Attribute database configuration (@see enum sonata_gap_att_cfg_flag) 953 uint16_t att_cfg; 954 955 // /// -------------- LE Data Length Extension ----------------------- 956 // /// Suggested value for the Controller's maximum transmitted number of payload octets to be used 957 // uint16_t sugg_max_tx_octets; 958 // /// Suggested value for the Controller's maximum packet transmission time to be used 959 // uint16_t sugg_max_tx_time; 960 961 /// --------------- L2CAP Configuration --------------------------- 962 /// Maximal MTU acceptable for device 963 uint16_t max_mtu; 964 /// Maximal MPS Packet size acceptable for device 965 uint16_t max_mps; 966 /// Maximum number of LE Credit based connection that can be established 967 uint8_t max_nb_lecb; 968 969 // /// --------------- LE Audio Mode Supported ----------------------- 970 // /// 971 // /// LE Audio Mode Configuration (@see sonata_gap_audio_cfg_flag) 972 973 // /// ------------------ LE PHY Management ------------------------- 974 // /// Preferred LE PHY for data transmission (@see enum gap_phy) 975 976 // /// Preferred LE PHY for data reception (@see enum gap_phy) 977 978 // /// ------------------ Miscellaneous 2 ---------------------------- 979 // /// RF TX Path Compensation value (from -128dB to 128dB, unit is 0.1dB) 980 981 // /// RF RX Path Compensation value (from -128dB to 128dB, unit is 0.1dB) 982 983 ///------------------ Miscellaneou 3 ----------------------------- 984 bool hl_trans_dbg; 985 /// <host layer transport debug 986 uint8_t pa_en; 987 /// <pa enable 1:pa enable 0:pa disable default:0 988 /// <pinmux: rxcore->pad12 txcore->pad17 989 } sonata_gap_set_dev_config_cmd; 990 991 /// create directed advertising 992 typedef struct sonata_gap_directed_adv_create_param { 993 // /// Advertising type (@see enum sonata_gap_adv_type) 994 995 /// Discovery mode (@see enum sonata_gap_adv_disc_mode) 996 uint8_t disc_mode; 997 /// Bit field value provided advertising properties (@see enum sonata_gap_adv_prop for bit signification) 998 uint16_t prop; 999 /// Maximum power level at which the advertising packets have to be transmitted 1000 /// (between -127 and 126 dBm) 1001 int8_t max_tx_pwr; 1002 /// Advertising filtering policy (@see enum adv_filter_policy) 1003 uint8_t filter_pol; 1004 /// Peer address configuration (only used in case of directed advertising) 1005 sonata_bd_addr_t addr; 1006 /// Address type of the device 0=public/1=private random 1007 uint8_t addr_type; 1008 /// Configuration for primary advertising 1009 /// Minimum advertising interval (in unit of 625us). Must be greater than 20ms 1010 uint32_t adv_intv_min; 1011 /// Maximum advertising interval (in unit of 625us). Must be greater than 20ms 1012 uint32_t adv_intv_max; 1013 /// Bit field indicating the channel mapping 1014 uint8_t chnl_map; 1015 /// Indicate on which PHY primary advertising has to be performed (@see enum sonata_gap_phy_type) 1016 /// Note that LE 2M PHY is not allowed and that legacy advertising only support LE 1M PHY 1017 uint8_t phy; 1018 1019 } sonata_gap_directed_adv_create_param_t; 1020 1021 /// create extended advertising 1022 typedef struct sonata_gap_extended_adv_create_param { 1023 // /// Advertising type (@see enum sonata_gap_adv_type) 1024 1025 /// Discovery mode (@see enum sonata_gap_adv_disc_mode) 1026 uint8_t disc_mode; 1027 /// Bit field value provided advertising properties (@see enum sonata_gap_adv_prop for bit signification) 1028 uint16_t prop; 1029 /// Maximum power level at which the advertising packets have to be transmitted 1030 /// (between -127 and 126 dBm) 1031 int8_t max_tx_pwr; 1032 /// Advertising filtering policy (@see enum adv_filter_policy) 1033 uint8_t filter_pol; 1034 1035 uint32_t prim_adv_intv_min; 1036 /// Maximum advertising interval (in unit of 625us). Must be greater than 20ms 1037 uint32_t prim_adv_intv_max; 1038 /// Bit field indicating the channel mapping 1039 uint8_t prim_chnl_map; 1040 /// Indicate on which PHY primary advertising has to be performed (@see enum sonata_gap_phy_type) 1041 /// Note that LE 2M PHY is not allowed and that legacy advertising only support LE 1M PHY 1042 uint8_t prim_phy; 1043 1044 /// Maximum number of advertising events the controller can skip before sending the 1045 /// AUX_ADV_IND packets. 0 means that AUX_ADV_IND PDUs shall be sent prior each 1046 /// advertising events 1047 uint8_t second_max_skip; 1048 /// Indicate on which PHY secondary advertising has to be performed (@see enum sonata_gap_phy_type) 1049 uint8_t second_phy; 1050 /// Advertising SID 1051 uint8_t second_adv_sid; 1052 1053 } sonata_gap_extended_adv_create_param_t; 1054 1055 /// create periodic advertising 1056 typedef struct sonata_gap_periodic_adv_create_param { 1057 // /// Advertising type (@see enum sonata_gap_adv_type) 1058 1059 /// Discovery mode (@see enum sonata_gap_adv_disc_mode) 1060 uint8_t disc_mode; 1061 /// Bit field value provided advertising properties (@see enum sonata_gap_adv_prop for bit signification) 1062 uint16_t prop; 1063 /// Maximum power level at which the advertising packets have to be transmitted 1064 /// (between -127 and 126 dBm) 1065 int8_t max_tx_pwr; 1066 /// Advertising filtering policy (@see enum adv_filter_policy) 1067 uint8_t filter_pol; 1068 /// Configuration for primary advertising 1069 /// Minimum advertising interval (in unit of 625us). Must be greater than 20ms 1070 uint32_t prim_adv_intv_min; 1071 /// Maximum advertising interval (in unit of 625us). Must be greater than 20ms 1072 uint32_t prim_adv_intv_max; 1073 /// Bit field indicating the channel mapping 1074 uint8_t prim_chnl_map; 1075 /// Indicate on which PHY primary advertising has to be performed (@see enum sonata_gap_phy_type) 1076 /// Note that LE 2M PHY is not allowed and that legacy advertising only support LE 1M PHY 1077 uint8_t prim_phy; 1078 /// Configuration for secondary advertising (valid only if advertising type is 1079 /// SONATA_GAP_ADV_TYPE_EXTENDED or SONATA_GAP_ADV_TYPE_PERIODIC) 1080 /// Maximum number of advertising events the controller can skip before sending the 1081 /// AUX_ADV_IND packets. 0 means that AUX_ADV_IND PDUs shall be sent prior each 1082 /// advertising events 1083 uint8_t second_max_skip; 1084 /// Indicate on which PHY secondary advertising has to be performed (@see enum sonata_gap_phy_type) 1085 uint8_t second_phy; 1086 /// Advertising SID 1087 uint8_t second_adv_sid; 1088 /// Configuration for periodic advertising (valid only if advertising type os 1089 /// SONATA_GAP_ADV_TYPE_PERIODIC) 1090 /// Minimum advertising interval (in unit of 1.25ms). Must be greater than 20ms 1091 uint16_t period_adv_intv_min; 1092 /// Maximum advertising interval (in unit of 1.25ms). Must be greater than 20ms 1093 uint16_t period_adv_intv_max; 1094 /// CTE count (number of CTEs to transmit in each periodic advertising interval, range 0x01 to 0x10) 1095 /// 0 to disable CTE transmission 1096 uint8_t period_cte_count; 1097 /// CTE type (0: AOA | 1: AOD-1us | 2: AOD-2us) (@see enum gap_cte_type) 1098 uint8_t period_cte_type; 1099 /// CTE length (in 8us unit) 1100 uint8_t period_cte_len; 1101 /// Length of switching pattern (number of antenna IDs in the pattern) 1102 uint8_t period_switching_pattern_len; 1103 /// Antenna IDs 1104 uint8_t period_antenna_id[__ARRAY_EMPTY]; 1105 } sonata_gap_periodic_adv_create_param_t; 1106 1107 /// Scan Window operation parameters 1108 typedef struct sonata_gap_scan_wd_op_param { 1109 /// Scan interval 1110 uint16_t scan_intv; 1111 /// Scan window 1112 uint16_t scan_wd; 1113 } sonata_gap_scan_wd_op_param_t; 1114 1115 /// Scanning parameters 1116 typedef struct sonata_gap_scan_param { 1117 /// Type of scanning to be started (@see enum sonata_gap_scan_type) 1118 uint8_t type; 1119 /// Properties for the scan procedure (@see enum sonata_gap_scan_prop for bit signification) 1120 uint8_t prop; 1121 /// Duplicate packet filtering policy 1122 uint8_t dup_filt_pol; 1123 /// Reserved for future use 1124 uint8_t rsvd; 1125 /// Scan window opening parameters for LE 1M PHY 1126 struct sonata_gap_scan_wd_op_param scan_param_1m; 1127 /// Scan window opening parameters for LE Coded PHY 1128 struct sonata_gap_scan_wd_op_param scan_param_coded; 1129 /// Scan duration (in unit of 10ms). 0 means that the controller will scan continuously until 1130 /// reception of a stop command from the application 1131 uint16_t duration; 1132 /// Scan period (in unit of 1.28s). Time interval betweem two consequent starts of a scan duration 1133 /// by the controller. 0 means that the scan procedure is not periodic 1134 uint16_t period; 1135 } sonata_gap_scan_param_t; 1136 1137 /// Connection parameters 1138 typedef struct sonata_gap_conn_param { 1139 /// Minimum value for the connection interval (in unit of 1.25ms). Shall be less than or equal to 1140 /// conn_intv_max value. Allowed range is 7.5ms to 4s. 1141 uint16_t conn_intv_min; 1142 /// Maximum value for the connection interval (in unit of 1.25ms). Shall be greater than or equal to 1143 /// conn_intv_min value. Allowed range is 7.5ms to 4s. 1144 uint16_t conn_intv_max; 1145 /// Slave latency. Number of events that can be missed by a connected slave device 1146 uint16_t conn_latency; 1147 /// Link supervision timeout (in unit of 10ms). Allowed range is 100ms to 32s 1148 uint16_t supervision_to; 1149 /// Recommended minimum duration of connection events (in unit of 625us) 1150 uint16_t ce_len_min; 1151 /// Recommended maximum duration of connection events (in unit of 625us) 1152 uint16_t ce_len_max; 1153 } sonata_gap_conn_param_t; 1154 1155 /// Initiating parameters 1156 typedef struct sonata_gap_init_param { 1157 /// Initiating type (@see enum sonata_gap_init_type) 1158 uint8_t type; 1159 /// Properties for the initiating procedure (@see enum sonata_gap_init_prop for bit signification) 1160 uint8_t prop; 1161 /// Timeout for automatic connection establishment (in unit of 10ms). Cancel the procedure if not all 1162 /// indicated devices have been connected when the timeout occurs. 0 means there is no timeout 1163 uint16_t conn_to; 1164 /// Scan window opening parameters for LE 1M PHY 1165 struct sonata_gap_scan_wd_op_param scan_param_1m; 1166 /// Scan window opening parameters for LE Coded PHY 1167 struct sonata_gap_scan_wd_op_param scan_param_coded; 1168 /// Connection parameters for LE 1M PHY 1169 struct sonata_gap_conn_param conn_param_1m; 1170 /// Connection parameters for LE 2M PHY 1171 struct sonata_gap_conn_param conn_param_2m; 1172 /// Connection parameters for LE Coded PHY 1173 struct sonata_gap_conn_param conn_param_coded; 1174 /// Address of peer device in case white list is not used for connection 1175 struct sonata_gap_bdaddr peer_addr; 1176 } sonata_gap_init_param_t; 1177 1178 /// Periodic advertising information 1179 typedef struct sonata_gap_period_adv_addr_cfg { 1180 /// Advertiser address information 1181 struct sonata_gap_bdaddr addr; 1182 /// Advertising SID 1183 uint8_t adv_sid; 1184 } sonata_gap_period_adv_addr_cfg_t; 1185 1186 /// Periodic synchronization parameters 1187 typedef struct sonata_gap_per_sync_param { 1188 /// Number of periodic advertising that can be skipped after a successful receive. Maximum authorized 1189 /// value is 499 1190 uint16_t skip; 1191 /// Synchronization timeout for the periodic advertising (in unit of 10ms between 100ms and 163.84s) 1192 uint16_t sync_to; 1193 /// Periodic synchronization type (@see enum sonata_gap_per_sync_type) 1194 uint8_t type; 1195 /// Connection index used for periodic sync info reception (only valid for SONATA_GAP_PER_SYNC_TYPE_PAST) 1196 uint8_t conidx; 1197 /// Address of advertiser with which synchronization has to be established (used only if use_pal is false) 1198 struct sonata_gap_period_adv_addr_cfg adv_addr; 1199 /// 1 to disable periodic advertising report, 0 to enable them by default 1200 uint8_t report_disable; 1201 /// Type of Constant Tone Extension device should sync on (@see enum sonata_gap_sync_cte_type). 1202 uint8_t cte_type; 1203 } sonata_gap_per_sync_param_t; 1204 1205 /// Local device version indication event 1206 typedef struct sonata_gap_dev_version_ind { 1207 /// HCI version 1208 uint8_t hci_ver; 1209 /// LMP version 1210 uint8_t lmp_ver; 1211 /// Host version 1212 uint8_t host_ver; 1213 /// HCI revision 1214 uint16_t hci_subver; 1215 /// LMP subversion 1216 uint16_t lmp_subver; 1217 /// Host revision 1218 uint16_t host_subver; 1219 /// Manufacturer name 1220 uint16_t manuf_name; 1221 } sonata_gap_dev_version_ind_t; 1222 1223 /// Local device BD Address indication event 1224 typedef struct sonata_gap_dev_bdaddr_ind { 1225 /// Local device address information 1226 struct sonata_gap_bdaddr addr; 1227 /// Activity index 1228 uint8_t actv_idx; 1229 } sonata_gap_dev_bdaddr_ind_t; 1230 1231 /// Advertising channel Tx power level indication event 1232 typedef struct sonata_gap_dev_adv_tx_power_ind { 1233 /// Advertising channel Tx power level 1234 int8_t power_lvl; 1235 } sonata_gap_dev_adv_tx_power_ind_t; 1236 1237 /// Indication containing controller antenna information 1238 typedef struct sonata_gap_antenna_inf_ind { 1239 /// Supported switching sampling rates bit field (@see enum sonata_gap_switch_sampling_rate) 1240 uint8_t supp_switching_sampl_rates; 1241 /// Number of antennae 1242 uint8_t antennae_num; 1243 /// Max length of switching pattern (number of antenna IDs in the pattern) 1244 uint8_t max_switching_pattern_len; 1245 /// Max CTE length 1246 uint8_t max_cte_len; 1247 } sonata_gap_antenna_inf_ind_t; 1248 1249 /// Numeric Comparison Data 1250 typedef struct sonata_gap_nc { 1251 uint8_t value[4]; 1252 } sonata_gap_nc_t; 1253 1254 /// Out of Band Information 1255 typedef struct sonata_gap_oob { 1256 /// Confirm Value 1257 uint8_t conf[SONATA_GAP_KEY_LEN]; 1258 /// Random Number 1259 uint8_t rand[SONATA_GAP_KEY_LEN]; 1260 } sonata_gap_oob_t; 1261 1262 /// Bond procedure requested information data 1263 typedef union sonata_gap_bond_req_data { 1264 /// Authentication level (@see gap_auth) (if request = SONATA_GAP_PAIRING_REQ) 1265 // @trc_union parent.request == SONATA_GAP_PAIRING_REQ 1266 uint8_t auth_req; 1267 /// LTK Key Size (if request = SONATA_GAP_LTK_EXCH) 1268 // @trc_union parent.request == SONATA_GAP_LTK_EXCH 1269 uint8_t key_size; 1270 /// Device IO used to get TK: (if request = SONATA_GAP_TK_EXCH) 1271 /// - GAP_TK_OOB: TK get from out of band method 1272 /// - GAP_TK_DISPLAY: TK generated and shall be displayed by local device 1273 /// - GAP_TK_KEY_ENTRY: TK shall be entered by user using device keyboard 1274 // @trc_union parent.request == SONATA_GAP_TK_EXCH 1275 uint8_t tk_type; 1276 1277 /// Addition OOB Data for the OOB Conf and Rand values 1278 // @trc_union parent.request == SONATA_GAP_OOB_EXCH 1279 struct sonata_gap_oob oob_data; 1280 /// Numeric Comparison Data 1281 // @trc_union parent.request == SONATA_GAP_NC_EXCH 1282 struct sonata_gap_nc nc_data; 1283 } sonata_gap_bond_req_data_t; 1284 1285 /// Bonding requested by peer device indication message. 1286 typedef struct sonata_gap_bond_req_ind { 1287 /// Bond request type (@see sonata_gap_bond) 1288 uint8_t request; 1289 1290 /// Bond procedure requested information data 1291 union sonata_gap_bond_req_data data; 1292 } sonata_gap_bond_req_ind_t; 1293 1294 /// Long Term Key information 1295 typedef struct sonata_gap_ltk { 1296 /// Long Term Key 1297 struct sonata_gap_sec_key ltk; 1298 /// Encryption Diversifier 1299 uint16_t ediv; 1300 /// Random Number 1301 sonata_rand_nb_t randnb; 1302 /// Encryption key size (7 to 16) 1303 uint8_t key_size; 1304 } sonata_gap_ltk_t; 1305 1306 /// Identity Resolving Key information 1307 typedef struct sonata_gap_irk { 1308 /// Identity Resolving Key 1309 struct sonata_gap_sec_key irk; 1310 /// Device BD Identity Address 1311 struct sonata_gap_bdaddr addr; 1312 } sonata_gap_irk_t; 1313 1314 /// Authentication information 1315 typedef struct sonata_gap_bond_auth { 1316 /// Authentication information (@see gap_auth) 1317 uint8_t info; 1318 1319 /// LTK exchanged during pairing. 1320 bool ltk_present; 1321 } sonata_gap_bond_auth_t; 1322 1323 /// Bond procedure information data 1324 typedef union sonata_gap_bond_data { 1325 /// Authentication information (@see gap_auth) 1326 /// (if info = SONATA_GAP_PAIRING_SUCCEED) 1327 // @trc_union parent.info == SONATA_GAP_PAIRING_SUCCEED 1328 struct sonata_gap_bond_auth auth; 1329 /// Pairing failed reason (if info = SONATA_GAP_PAIRING_FAILED) 1330 // @trc_union parent.info == SONATA_GAP_PAIRING_FAILED 1331 uint8_t reason; 1332 /// Long Term Key information (if info = SONATA_GAP_LTK_EXCH) 1333 // @trc_union parent.info == SONATA_GAP_LTK_EXCH 1334 struct sonata_gap_ltk ltk; 1335 /// Identity Resolving Key information (if info = SONATA_GAP_IRK_EXCH) 1336 // @trc_union parent.info == SONATA_GAP_IRK_EXCH 1337 struct sonata_gap_irk irk; 1338 /// Connection Signature Resolving Key information (if info = SONATA_GAP_CSRK_EXCH) 1339 // @trc_union parent.info == SONATA_GAP_CSRK_EXCH 1340 struct sonata_gap_sec_key csrk; 1341 } sonata_gap_bond_data_t; 1342 1343 /// Bonding information indication message 1344 typedef struct sonata_gap_bond_ind { 1345 /// Bond information type (@see sonata_gap_bond) 1346 uint8_t info; 1347 1348 /// Bond procedure information data 1349 union sonata_gap_bond_data data; 1350 } sonata_gap_bond_ind_t; 1351 1352 /// List Size indication event 1353 typedef struct sonata_gap_list_size_ind { 1354 /// Operation code, indicate list for which size has been read 1355 /// - SONATA_GAP_SET_WHITE_LIST 1356 /// - SONATA_GAP_SET_RAL 1357 /// - SONATA_GAP_SET_PAL 1358 uint8_t operation; 1359 /// List size 1360 uint8_t size; 1361 } sonata_gap_list_size_ind_t; 1362 1363 /// Indicates suggested default data length 1364 typedef struct sonata_gap_sugg_dflt_data_len_ind { 1365 /// Host's suggested value for the Controller's maximum transmitted number of payload octets 1366 uint16_t suggted_max_tx_octets; 1367 /// Host's suggested value for the Controller's maximum packet transmission time 1368 uint16_t suggted_max_tx_time; 1369 } sonata_gap_sugg_dflt_data_len_ind_t; 1370 1371 /// Indicates maximum data length 1372 typedef struct sonata_gap_max_data_len_ind { 1373 /// Maximum number of payload octets that the local Controller supports for transmission 1374 uint16_t suppted_max_tx_octets; 1375 /// Maximum time, in microseconds, that the local Controller supports for transmission 1376 uint16_t suppted_max_tx_time; 1377 /// Maximum number of payload octets that the local Controller supports for reception 1378 uint16_t suppted_max_rx_octets; 1379 /// Maximum time, in microseconds, that the local Controller supports for reception 1380 uint16_t suppted_max_rx_time; 1381 } sonata_gap_max_data_len_ind_t; 1382 1383 /// Number of available advertising sets indication event 1384 typedef struct sonata_gap_nb_adv_sets_ind { 1385 /// Number of available advertising sets 1386 uint8_t nb_adv_sets; 1387 } sonata_gap_nb_adv_sets_ind_t; 1388 1389 /// Maximum advertising data length indication event 1390 typedef struct sonata_gap_max_adv_data_len_ind { 1391 /// Maximum advertising data length supported by controller 1392 uint16_t length; 1393 } sonata_gap_max_adv_data_len_ind_t; 1394 1395 /// Indicate the transmit powers supported by the controller 1396 typedef struct sonata_gap_dev_tx_pwr_ind { 1397 /// Minimum TX power 1398 int8_t min_tx_pwr; 1399 /// Maximum TX power 1400 int8_t max_tx_pwr; 1401 } sonata_gap_dev_tx_pwr_ind_t; 1402 1403 /// Indicate the RF path compensation values 1404 typedef struct sonata_gap_dev_rf_path_comp_ind { 1405 /// RF TX path compensation 1406 uint16_t tx_path_comp; 1407 /// RF RX path compensation 1408 uint16_t rx_path_comp; 1409 } sonata_gap_dev_rf_path_comp_ind_t; 1410 1411 /// Pairing parameters 1412 typedef struct sonata_gap_pairing { 1413 /// IO capabilities (@see gap_io_cap) 1414 uint8_t iocap; 1415 /// OOB information (@see gap_oob) 1416 uint8_t oob; 1417 /// Authentication (@see gap_auth) 1418 /// Note in BT 4.1 the Auth Field is extended to include 'Key Notification' and 1419 /// and 'Secure Connections'. 1420 uint8_t auth; 1421 /// Encryption key size (7 to 16) 1422 uint8_t key_size; 1423 /// Initiator key distribution (@see gap_kdist) 1424 uint8_t ikey_dist; 1425 /// Responder key distribution (@see gap_kdist) 1426 uint8_t rkey_dist; 1427 1428 /// Device security requirements (minimum security level). (@see gap_sec_req) 1429 uint8_t sec_req; 1430 } sonata_gap_pairing_t; 1431 1432 /// Set specific link data configuration. 1433 typedef struct sonata_gap_connection_cfm { 1434 /// Local CSRK value 1435 struct sonata_gap_sec_key lcsrk; 1436 /// Local signature counter value 1437 uint32_t lsign_counter; 1438 /// Remote CSRK value 1439 struct sonata_gap_sec_key rcsrk; 1440 /// Remote signature counter value 1441 uint32_t rsign_counter; 1442 /// Authentication (@see enum gap_auth) 1443 uint8_t auth; 1444 /// Client bond data information (@see enum sonata_gap_cli_info) 1445 uint8_t cli_info; 1446 /// LTK exchanged during pairing. 1447 bool ltk_present; 1448 /// Client supported features (@see enum sonata_gap_cli_feat) 1449 uint8_t cli_feat; 1450 /// Peer GATT Service Start handle 1451 uint16_t gatt_start_handle; 1452 /// Peer GATT Service End Handle 1453 uint16_t gatt_end_handle; 1454 /// Peer Service Change value handle 1455 uint16_t svc_chg_handle; 1456 } sonata_gap_connection_cfm_t; 1457 1458 /// Indicate reception of a IQ Report event over a BLE connection 1459 /* @TRACE */ 1460 typedef struct sonata_gap_cte_iq_report_ind { 1461 /// Rx PHY (@see enum gap_phy_val) 1462 uint8_t rx_phy; 1463 /// Data channel index 1464 uint8_t data_channel_idx; 1465 /// RSSI (in 0.1 dBm) 1466 int16_t rssi; 1467 /// RSSI antenna ID 1468 uint8_t rssi_antenna_id; 1469 /// CTE type (0: AOA | 1: AOD-1us | 2: AOD-2us) (@see enum gap_cte_type) 1470 uint8_t cte_type; 1471 /// Slot durations (1: 1us | 2: 2us) 1472 uint8_t slot_dur; 1473 /// Packet status 1474 uint8_t pkt_status; 1475 /// Connection event counter 1476 uint16_t con_evt_cnt; 1477 /// Number of samples 1478 uint8_t nb_samples; 1479 /// I/Q sample 1480 struct sonata_gap_iq_sample sample[__ARRAY_EMPTY]; 1481 } sonata_gap_cte_iq_report_ind_t; 1482 1483 /// Provide statistic information about ISO exchange 1484 typedef struct sonata_gap_iso_stat_ind { 1485 /// ISO Handle of the isochronous channel (Range 0x0000-0x0EFF) 1486 uint16_t iso_hdl; 1487 1488 /// Statistics - Number of transmission attempts 1489 uint32_t nb_tx; 1490 /// Statistics - Number of transmission attempts that succeed 1491 uint32_t nb_tx_ok; 1492 /// Statistics - Number of Not granted packet packets 1493 uint32_t nb_tx_not_granted; 1494 1495 /// Statistics - Number of reception attempt 1496 uint32_t nb_rx; 1497 /// Statistics - Number of reception attempts that succeed 1498 uint32_t nb_rx_ok; 1499 /// Statistics - Number of Not granted packet packets 1500 uint32_t nb_rx_not_granted; 1501 /// Statistics - Number of wrongly received packet (invalid data) 1502 uint32_t nb_rx_data_err; 1503 /// Statistics - Number of CRC Errors 1504 uint32_t nb_rx_crc_err; 1505 /// Statistics - Number of SYNC Errors 1506 uint32_t nb_rx_sync_err; 1507 /// Statistics - Number of received empty packets 1508 uint32_t nb_rx_empty; 1509 } sonata_gap_iso_stat_ind_t; 1510 1511 /// Indicate reception of a IQ Report event over a periodic advertising sync activity 1512 typedef struct sonata_gap_per_adv_iq_report_ind { 1513 /// Activity identifier 1514 uint8_t actv_idx; 1515 /// Data channel index 1516 uint8_t channel_idx; 1517 /// RSSI (in 0.1 dBm) 1518 int16_t rssi; 1519 /// RSSI antenna ID 1520 uint8_t rssi_antenna_id; 1521 /// CTE type (0: AOA | 1: AOD-1us | 2: AOD-2us) (@see enum gap_cte_type) 1522 uint8_t cte_type; 1523 /// Slot durations (1: 1us | 2: 2us) 1524 uint8_t slot_dur; 1525 /// Packet status 1526 uint8_t pkt_status; 1527 /// Periodic Adv Event Counter 1528 uint16_t pa_evt_cnt; 1529 /// Number of samples 1530 uint8_t nb_samples; 1531 /// I/Q sample 1532 struct sonata_gap_iq_sample sample[__ARRAY_EMPTY]; 1533 } sonata_gap_per_adv_iq_report_ind_t; 1534 1535 union sonata_gap_bond_cfm_data { 1536 /// Pairing Features (request = SONATA_GAP_PAIRING_RSP) 1537 // @trc_union parent.request == SONATA_GAP_PAIRING_RSP 1538 struct sonata_gap_pairing pairing_feat; 1539 /// LTK (request = SONATA_GAP_LTK_EXCH) 1540 // @trc_union parent.request == SONATA_GAP_LTK_EXCH 1541 struct sonata_gap_ltk ltk; 1542 /// CSRK (request = SONATA_GAP_CSRK_EXCH) 1543 // @trc_union parent.request == SONATA_GAP_CSRK_EXCH 1544 struct sonata_gap_sec_key csrk; 1545 /// TK (request = SONATA_GAP_TK_EXCH) 1546 // @trc_union parent.request == SONATA_GAP_TK_EXCH 1547 struct sonata_gap_sec_key tk; 1548 /// IRK (request = SONATA_GAP_IRK_EXCH) 1549 // @trc_union parent.request == SONATA_GAP_IRK_EXCH 1550 struct sonata_gap_irk irk; 1551 /// OOB Confirm and Random from the peer (request = SONATA_GAP_OOB_EXCH) 1552 // @trc_union parent.request == SONATA_GAP_OOB_EXCH 1553 struct sonata_gap_oob oob; 1554 }; 1555 1556 struct sonata_gap_bond_cfm { 1557 /// Bond request type (@see sonata_gap_bond) 1558 uint8_t request; 1559 /// Request accepted 1560 uint8_t accept; 1561 1562 /// Bond procedure information data 1563 union sonata_gap_bond_cfm_data data; 1564 }; 1565 1566 typedef void (*PF_NOTIFY_MESH_PRF_READY)(void); 1567 extern PF_NOTIFY_MESH_PRF_READY pf_notify_mesh_prf_ready; 1568 1569 /// Ble complete event type 1570 typedef enum { 1571 // Sonata event Sonata 1572 /// Ble module on complete 1573 SONATA_GAP_CMP_BLE_ON = 0x0F01, 1574 /// Config advertising mode complete 1575 SONATA_GAP_CMP_ADVERTISING_CONFIG = 0x0F02, 1576 /// Config scanning mode complete 1577 SONATA_GAP_CMP_SCANNING_CONFIG = 0x0F03, 1578 /// Config initiating mode complete 1579 SONATA_GAP_CMP_INITIATING_CONFIG = 0x0F04, 1580 /// Config period sync mode complete 1581 SONATA_GAP_CMP_PERIOD_SYNC_CONFIG = 0x0F05, 1582 /// Start advertising mode complete 1583 SONATA_GAP_CMP_ADVERTISING_START = 0x0F06, 1584 /// Start scanning mode complete 1585 SONATA_GAP_CMP_SCANNING_START = 0x0F07, 1586 /// Start initiating mode complete 1587 SONATA_GAP_CMP_INITIATING_START = 0x0F08, 1588 /// Start period sync mode complete 1589 SONATA_GAP_CMP_PERIOD_SYNC_START = 0x0F09, 1590 /// Stop advertising mode complete 1591 SONATA_GAP_CMP_ADVERTISING_STOP = 0x0F0A, 1592 /// Stop scanning mode complete 1593 SONATA_GAP_CMP_SCANNING_STOP = 0x0F0B, 1594 /// Stop initiating mode complete 1595 SONATA_GAP_CMP_INITIATING_STOP = 0x0F0C, 1596 /// Stop period sync mode complete 1597 SONATA_GAP_CMP_PERIOD_SYNC_STOP = 0x0F0D, 1598 /// Delete advertising mode complete 1599 SONATA_GAP_CMP_ADVERTISING_DELETE = 0x0F0E, 1600 /// Delete scanning mode complete 1601 SONATA_GAP_CMP_SCANNING_DELETE = 0x0F0F, 1602 /// Delete initiating mode complete 1603 SONATA_GAP_CMP_INITIATING_DELETE = 0x0F10, 1604 /// Delete period sync mode complete 1605 SONATA_GAP_CMP_PERIOD_SYNC_DELETE = 0x0F11, 1606 1607 // System event GAPM 1608 /// Reset BLE subsystem: LL and HL. 1609 SONATA_GAP_CMP_RESET = 0x0101, 1610 /// Set device configuration 1611 SONATA_GAP_CMP_SET_DEV_CONFIG = 0x0103, 1612 /// Get Local device version 1613 SONATA_GAP_CMP_GET_DEV_VERSION = 0x0105, 1614 /// Get Local device BD Address 1615 SONATA_GAP_CMP_GET_DEV_BDADDR = 0x0106, 1616 /// Get device advertising power level 1617 SONATA_GAP_CMP_GET_DEV_ADV_TX_POWER = 0x0107, 1618 /// Get White List Size. 1619 SONATA_GAP_CMP_GET_WLIST_SIZE = 0x0108, 1620 /// Retrieve Antenna information 1621 SONATA_GAP_CMP_GET_ANTENNA_INFO = 0x0109, 1622 /// Resolve device address 1623 SONATA_GAP_CMP_RESOLV_ADDR = 0x0117, 1624 /// Generate a random address 1625 SONATA_GAP_CMP_GEN_RAND_ADDR = 0x0118, 1626 /// Use the controller's AES-128 block 1627 SONATA_GAP_CMP_ENC_BLOCK = 0x0119, 1628 /// Generate a 8-byte random number 1629 SONATA_GAP_CMP_GEN_RAND_NB = 0x011A, 1630 /// Create new task for specific profile 1631 SONATA_GAP_CMP_PROFILE_TASK_ADD = 0x011B, 1632 /// Get memory usage 1633 SONATA_GAP_CMP_DBG_GET_MEM_INFO = 0x011C, 1634 /// Get Suggested Default LE Data Length 1635 SONATA_GAP_CMP_GET_SUGGESTED_DFLT_LE_DATA_LEN = 0x011F, 1636 /// Get Maximum LE Data Length 1637 SONATA_GAP_CMP_GET_MAX_LE_DATA_LEN = 0x0120, 1638 /// Get resolving address list size 1639 SONATA_GAP_CMP_GET_RAL_SIZE = 0x0121, 1640 /// Set IRK 1641 SONATA_GAP_CMP_SET_IRK = 0x0128, 1642 /// Set content of white list 1643 SONATA_GAP_CMP_SET_WL = 0x0190, 1644 /// Get periodic advertiser list size 1645 SONATA_GAP_CMP_GET_PAL_SIZE = 0x0195, 1646 /// Stop all activities 1647 SONATA_GAP_CMP_STOP_ALL_ACTIVITIES = 0x01A6, 1648 /// Delete all activities 1649 SONATA_GAP_CMP_DELETE_ALL_ACTIVITIES = 0x01A8, 1650 /// Set advertising data 1651 SONATA_GAP_CMP_SET_ADV_DATA = 0x01A9, 1652 /// Set scan response data 1653 SONATA_GAP_CMP_SET_SCAN_RSP_DATA = 0x01AA, 1654 /// Get number of available advertising sets 1655 SONATA_GAP_CMP_GET_NB_ADV_SETS = 0x01AC, 1656 /// Get maximum advertising data length supported by the controller 1657 SONATA_GAP_CMP_GET_MAX_LE_ADV_DATA_LEN = 0x01AD, 1658 /// Get minimum and maximum transmit powers supported by the controller 1659 SONATA_GAP_CMP_GET_DEV_TX_PWR = 0x01AE, 1660 /// Get the RF Path Compensation values used in the TX Power Level and RSSI calculation 1661 SONATA_GAP_CMP_GET_DEV_RF_PATH_COMP = 0x01AF, 1662 1663 // System event GAPC 1664 /// Disconnect 1665 SONATA_GAP_CMP_DISCONNECT = 0x0201, 1666 /// Retrieve name of peer device. 1667 SONATA_GAP_CMP_GET_PEER_NAME = 0x0202, 1668 /// Retrieve peer device version info. 1669 SONATA_GAP_CMP_GET_PEER_VERSION = 0x0203, 1670 /// Retrieve peer device features. 1671 SONATA_GAP_CMP_GET_PEER_FEATURES = 0x0204, 1672 /// Get Peer device appearance 1673 SONATA_GAP_CMP_GET_PEER_APPEARANCE = 0x0205, 1674 /// Get Peer device Slaved Preferred Parameters 1675 SONATA_GAP_CMP_GET_PEER_SLV_PREF_PARAMS = 0x0206, 1676 /// Retrieve connection RSSI. 1677 SONATA_GAP_CMP_GET_CON_RSSI = 0x0207, 1678 /// Retrieve Connection Channel MAP. 1679 SONATA_GAP_CMP_GET_CON_CHANNEL_MAP = 0x0208, 1680 /// Perform update of connection parameters. 1681 SONATA_GAP_CMP_UPDATE_PARAMS = 0x0209, 1682 /// Start security request procedure 1683 SONATA_GAP_CMP_SECURITY_REQ = 0x020C, 1684 /// get timer timeout value 1685 SONATA_GAP_CMP_GET_LE_PING_TO = 0x0212, 1686 /// set timer timeout value 1687 SONATA_GAP_CMP_SET_LE_PING_TO = 0x0213, 1688 /* LE Data Length extension */ 1689 /// LE Set Data Length 1690 SONATA_GAP_CMP_SET_LE_PKT_SIZE = 0x0214, 1691 /// Central Address resolution supported 1692 SONATA_GAP_CMP_GET_ADDR_RESOL_SUPP = 0x0215, 1693 /// Retrieve PHY configuration of active link 1694 SONATA_GAP_CMP_GET_PHY = 0x0218, 1695 /// Constant Tone Extension Transmission configuration 1696 SONATA_GAP_CMP_CTE_TX_CFG = 0x0220, 1697 /// Constant Tone Extension Reception configuration 1698 SONATA_GAP_CMP_CTE_RX_CFG = 0x0221, 1699 /// Constant Tone Extension request control (enable / disable) 1700 SONATA_GAP_CMP_CTE_REQ_CTRL = 0x0222, 1701 /// Constant Tone Extension Response control (enable / disable) 1702 SONATA_GAP_CMP_CTE_RSP_CTRL = 0x0223, 1703 1704 // System event GATTM 1705 1706 // System event GATTC 1707 /// Discover all services 1708 SONATA_GATT_CMP_DISC_ALL_SVC = 0x0402, 1709 /// Read attribute 1710 SONATA_GATT_CMP_READ = 0x0408, 1711 /// Write attribute 1712 SONATA_GATT_CMP_WRITE = 0x040C, 1713 /// Write no response 1714 SONATA_GATT_CMP_WRITE_NO_RESPONSE = 0x040D, 1715 /// Write signed 1716 SONATA_GATT_CMP_WRITE_SIGNED = 0x040E, 1717 /// Execute write 1718 SONATA_GATT_CMP_EXEC_WRITE = 0x040F, 1719 /// Send an attribute notification 1720 SONATA_GATT_CMP_NOTIFY = 0x0412, 1721 /// Send an attribute indication 1722 SONATA_GATT_CMP_INDICATE = 0x0413, 1723 1724 } sonata_ble_complete_type; 1725 1726 /// Callbacks for GAP module. If app finished works in callback, should return CB_DONE @see CBStatus. 1727 1728 typedef struct { 1729 /*************** GAP Manager ***************/ 1730 /// @deprecated use @see ble_complete_callback 1731 void (*ble_on_complete)(uint16_t status); 1732 /// @deprecated use @see ble_complete_callback 1733 void (*advertising_config_complete)(uint16_t status); 1734 /// @deprecated use @see ble_complete_callback 1735 void (*initiating_config_complete)(uint16_t status); 1736 /// @deprecated use @see ble_complete_callback 1737 void (*scanning_config_complete)(uint16_t status); 1738 /// @deprecated use @see ble_complete_callback 1739 void (*advertising_start_complete)(uint16_t status); 1740 /// @deprecated use @see ble_complete_callback 1741 void (*initiating_start_complete)(uint16_t status); 1742 /// @deprecated use @see ble_complete_callback 1743 void (*scanning_start_complete)(uint16_t status); 1744 /// @deprecated use @see ble_complete_callback 1745 void (*advertising_stopped_complete)(uint16_t reason); 1746 /// @deprecated use @see ble_complete_callback 1747 void (*initiating_stopped_complete)(uint16_t reason); 1748 /// @deprecated use @see ble_complete_callback 1749 void (*scanning_stopped_complete)(uint16_t reason); 1750 /// @deprecated use @see ble_complete_callback 1751 void (*advertising_deleted_complete)(uint16_t status); 1752 /// @deprecated use @see ble_complete_callback 1753 void (*initiating_deleted_complete)(uint16_t status); 1754 /// @deprecated use @see ble_complete_callback 1755 void (*scanning_deleted_complete)(uint16_t status); 1756 /// @deprecated use @see ble_complete_callback 1757 void (*set_advertising_data)(uint16_t status); 1758 /// @deprecated use @see ble_complete_callback 1759 void (*set_white_list_complete)(uint16_t status); 1760 /// @deprecated use @see ble_complete_callback 1761 1762 /// Callback for getting device version, BT address, advertising TX power, antenna inf. 1763 uint16_t (*get_local_dev_info)(sonata_gap_local_dev_info info_type, 1764 void *info); // gap_dev_version,gap_dev_bdaddr,gap_dev_adv_tx_power,gap_antenna_inf,gap_dbg_mem_info 1765 1766 /// Callback for scan result 1767 uint16_t (*gap_scan_result)(sonata_gap_ext_adv_report_ind_t *result); 1768 1769 /// Callback for get peer name 1770 uint16_t (*gap_get_peer_name)(uint8_t addr_type, uint8_t *peer_addr, uint8_t name_len, uint8_t *name); 1771 1772 /// Callback for random address has been solved 1773 uint16_t (*gap_addr_solved)(uint8_t *addr, uint8_t *key); 1774 1775 /// Callback for AES-128 block result indication 1776 uint16_t (*gap_use_enc_block)(uint8_t *result); 1777 1778 /// Callback for gap generate random number 1779 uint16_t (*gap_gen_random_number)(uint8_t *number); 1780 1781 /// Callback for Resolving address list 1782 uint16_t (*gap_resolving_address)(uint8_t operation, uint8_t addr_type, uint8_t *addr); 1783 1784 /// Callback for provide statistic information about ISO exchange 1785 uint16_t (*gap_iso_statistic)(sonata_gap_iso_stat_ind_t *param); 1786 1787 /// Callback for DH Key computation is complete and available (GAP_P256_KEY_LEN) 1788 uint16_t (*gap_gen_dh_key)(uint8_t *key); 1789 1790 /// Callback for public Key Pair value 1791 uint16_t (*gap_pubblic_key_pair_value)(uint8_t *keyX, uint8_t *keyY); 1792 1793 /// Callback for reception of a scan request 1794 uint16_t (*gap_scan_request)(uint8_t actv_idx, uint8_t addr_type, uint8_t *addr); 1795 1796 /// callback for indicate reception of a IQ Report event over a periodic advertising sync activity 1797 uint16_t (*gap_periodic_advertising_iq_report)(sonata_gap_per_adv_iq_report_ind_t *report); 1798 1799 /// Callback for Indicate that synchronization has been successfully established with a periodic advertiser 1800 uint16_t (*gap_sync_established)(uint8_t actv_idx, uint8_t phy, uint16_t intv, uint8_t adv_sid, 1801 uint8_t clk_acc, uint16_t serv_data, uint8_t addr_type, uint8_t *addr); 1802 1803 /*************** GAP Controller ***************/ 1804 /// @deprecated use @see ble_complete_callback 1805 uint16_t (*gap_disconnect_complete)(uint8_t conidx, uint16_t status); 1806 /// @deprecated use @see ble_complete_callback 1807 void (*gap_params_updated_complete)(uint8_t conidx, uint16_t status); 1808 /// @deprecated use @see ble_complete_callback 1809 void (*gap_bond_complete)(uint8_t conidx, uint16_t status); 1810 1811 /// Callback for disconnect IND message 1812 uint16_t (*gap_disconnect_ind)(uint8_t conidx, uint16_t conhdl, uint8_t reason); 1813 1814 /// Callback for param update request 1815 uint16_t (*gap_param_update_req)(uint8_t conidx, uint16_t intv_min, uint16_t intv_max, uint16_t latency, 1816 uint16_t time_out); 1817 1818 /// Callback for param update 1819 uint16_t (*gap_param_updated)(uint8_t conidx, uint16_t con_interval, uint16_t con_latency, uint16_t sup_to); 1820 1821 /// Callback for param update timeout 1822 uint16_t (*gap_param_update_timeout)(uint8_t conidx); 1823 1824 /// Callback for peer device request set local device name information 1825 uint16_t (*gap_peer_set_local_device_name)(uint8_t conidx, uint16_t length, uint8_t *name); 1826 1827 /// Callback for connection REQ message 1828 uint16_t (*gap_connection_req)(uint8_t conidx, sonata_gap_connection_req_ind_t *req); 1829 1830 /// Callback for getting peer attribute info 1831 uint16_t (*gap_get_peer_att_info)(uint8_t conidx, sonata_gap_peer_att_info_ind_t *info); 1832 1833 /// Callback for getting peer version, feature,device information @see sonata_peer_info_type 1834 uint16_t (*gap_get_peer_info)(uint8_t conidx, sonata_gap_peer_info_ind_t *info); 1835 1836 /// Callback for peer device get local device informations. 1837 uint16_t (*gap_peer_get_local_info)(uint8_t conidx, sonata_gap_dev_info opt); 1838 1839 /// Callback if advertising, initationg,scanning or period_sync active created 1840 uint16_t (*gap_active_created)(uint8_t actv_idx, uint8_t type, int8_t tx_pwr); 1841 1842 /// Callback if advertising, initationg,scanning or period_sync active stopped. 1843 /// App can do some work and then delete the current active @see sonata_ble_delete_active() in this callback, 1844 /// Or app can return CB_REJECT @see CBStatus, SDK will delete the current active. 1845 /// But if app return CB_DONE, SDK will do nothing. 1846 uint16_t (*gap_active_stopped)(uint8_t actv_idx, uint8_t type, uint8_t reason, uint8_t per_adv_stop); 1847 1848 /// Callback for profile added 1849 uint16_t (*gap_profile_added)(uint16_t prf_task_id, uint16_t prf_task_nb, uint16_t start_hdl); 1850 1851 /// Callback for bond request 1852 uint16_t (*gap_bond_req)(uint8_t conidx, struct sonata_gap_bond_req_ind *request); 1853 /// Callback for bond 1854 uint16_t (*gap_bond)(uint8_t conidx, struct sonata_gap_bond_ind *ind); 1855 1856 /// Callback for get le package size 1857 uint16_t (*gap_le_pkt_size)(uint8_t conidx, uint16_t max_tx_octets, uint16_t max_tx_time, uint16_t max_rx_octets, 1858 uint16_t max_rx_time); 1859 1860 /// Callback for encrypt request 1861 uint16_t (*gap_encrypt_req)(uint8_t conidx, uint16_t ediv, uint8_t *nb); 1862 1863 /// Callback for encrypt indicate 1864 uint16_t (*gap_encrypt)(uint8_t conidx, uint8_t auth_level); 1865 1866 /// Callback for security indicate 1867 uint16_t (*gap_security)(uint8_t conidx, uint8_t auth_level); 1868 1869 /// Callback for sign counter 1870 uint16_t (*gap_sign_counter)(uint8_t conidx, uint32_t local_sign_counter, uint32_t peer_sign_counter); 1871 1872 /// Callback for key press notification 1873 uint16_t (*gap_key_press_notification)(uint8_t conidx, uint8_t type); 1874 1875 /// Callback for indicate reception of a IQ Report event over a ble connection 1876 uint16_t (*gap_cte_iq_report)(uint8_t conidx, sonata_gap_cte_iq_report_ind_t *param); 1877 1878 /// Callback for signature result 1879 uint16_t (*gap_signature)(uint8_t conidx, uint8_t operation, uint16_t byte_len, uint8_t *signed_msg); 1880 1881 /// Callback for pairing procedure timeout indication 1882 uint16_t (*gap_smp_timeout)(uint8_t conidx); 1883 /// Callback for pairing repeated attempts procedure timeout indication 1884 uint16_t (*gap_smp_rep_attempts_timeout)(uint8_t conidx); 1885 1886 } ble_gap_callback; 1887 1888 /// Ble complete event callback 1889 typedef struct { 1890 uint16_t (*ble_complete_event)(sonata_ble_complete_type id, uint8_t status, uint16_t param, uint32_t dwparam); 1891 1892 } ble_complete_callback; 1893 1894 /// Ble gatt response event callback 1895 typedef struct { 1896 uint16_t (*ble_rsp_event)(uint16_t opt_id, uint8_t status, uint16_t handle, uint16_t perm, uint16_t ext_perm, 1897 uint16_t length, void *param); 1898 1899 } ble_response_callback; 1900 1901 /*! 1902 * @brief Turn on ble module 1903 * @param param @see sonata_gap_set_dev_config_cmd 1904 * @return API_SUCCESS 1905 */ 1906 uint16_t sonata_ble_on(sonata_gap_set_dev_config_cmd *param); 1907 1908 /*! 1909 * @brief Register GAP callback functions for ble module 1910 * @param cb @see ble_gap_callback 1911 * @return API_SUCCESS 1912 */ 1913 uint16_t sonata_ble_register_gap_callback(ble_gap_callback *cb); 1914 1915 /*! 1916 * @brief Register ble complete event callback functions 1917 * @param cb @see ble_complete_callback 1918 * @return API_SUCCESS 1919 */ 1920 uint16_t sonata_ble_register_complete_callback(ble_complete_callback *cb); 1921 1922 /*! 1923 * @brief Register ble response for GATT module 1924 * @param cb @see ble_response_callback 1925 * @return API_SUCCESS 1926 */ 1927 uint16_t sonata_ble_register_response_callback(ble_response_callback *cb); 1928 1929 /*! 1930 * @brief Config legacy advertising 1931 * @param own_addr_type: device's address type, @see sonata_gap_own_addr 1932 * @param param:data for advertising, @see sonata_gap_directed_adv_create_param_t 1933 * @return API_SUCCESS 1934 */ 1935 uint16_t sonata_ble_config_legacy_advertising(uint8_t own_addr_type, sonata_gap_directed_adv_create_param_t *param); 1936 1937 /*! 1938 * @brief Config extended advertising 1939 * @param own_addr_type: device's address type, @see sonata_gap_own_addr 1940 * @param param:data for advertising, @see sonata_gap_extended_adv_create_param_t 1941 * @return API_SUCCESS 1942 */ 1943 uint16_t sonata_ble_config_extended_advertising(uint8_t own_addr_type, sonata_gap_extended_adv_create_param_t *param); 1944 1945 // uint16_t sonata_ble_config_periodic_advertising(uint8_t own_addr_type, sonata_gap_periodic_adv_create_param_t *param); 1946 /*! 1947 * @brief Config scanning data 1948 * @param own_addr_type: device's address type, @see sonata_gap_own_addr 1949 * @return API_SUCCESS 1950 */ 1951 uint16_t sonata_ble_config_scanning(uint8_t own_addr_type); 1952 1953 /*! 1954 * @brief Config initiating data 1955 * @param own_addr_type: device's address type, @see sonata_gap_own_addr 1956 * @return API_SUCCESS 1957 */ 1958 uint16_t sonata_ble_config_initiating(uint8_t own_addr_type); 1959 1960 /*! 1961 * @brief Set advertising data 1962 * @param length: Data length 1963 * @param data: Value for data 1964 * @return API_SUCCESS 1965 */ 1966 uint16_t sonata_ble_set_advertising_data(uint16_t length, uint8_t *data); 1967 1968 /*! 1969 * @brief Set advertising data 1970 * @param id The advertising id 1971 * @param length: Data length 1972 * @param data: Value for data 1973 * @return API_SUCCESS 1974 */ 1975 uint16_t sonata_ble_set_advertising_data_byid(uint8_t id, uint16_t length, uint8_t *data); 1976 1977 /*! 1978 * @brief Set scan response data 1979 * @param length: Data length 1980 * @param data: Value for data 1981 * @return API_SUCCESS 1982 */ 1983 uint16_t sonata_ble_set_scan_response_data(uint16_t length, uint8_t *data); 1984 1985 /*! 1986 * @brief Set scan response data 1987 * @param id The advertising id 1988 * @param length: Data length 1989 * @param data: Value for data 1990 * @return API_SUCCESS 1991 */ 1992 uint16_t sonata_ble_set_scan_response_data_byid(uint8_t id, uint16_t length, uint8_t *data); 1993 1994 /*! 1995 * @brief Start advertising 1996 * @param duration: Advertising duration (in unit of 10ms). 0 means that advertising continues until the host disable it 1997 * @param max_adv_evt: Maximum number of extended advertising events the controller shall attempt to send prior to 1998 terminating the extending advertising. Valid only if extended advertising 1999 * @return API_SUCCESS 2000 */ 2001 uint16_t sonata_ble_start_advertising(uint16_t duration, uint8_t max_adv_evt); /* uint8_t index */ 2002 2003 /*! 2004 * @brief Start the advertising 2005 * @param id the advertisning id 2006 * @param duration: Advertising duration (in unit of 10ms). 0 means that advertising continues until the host disable it 2007 * @param max_adv_evt: Maximum number of extended advertising events the controller shall attempt to send prior to 2008 terminating the extending advertising. Valid only if extended advertising 2009 * @return API_SUCCESS 2010 */ 2011 uint16_t sonata_ble_start_advertising_byid(uint8_t id, uint16_t duration, uint8_t max_adv_evt); 2012 2013 /*! 2014 * @brief Stop advertising 2015 * @return API_SUCCESS 2016 */ 2017 uint16_t sonata_ble_stop_advertising(void); 2018 2019 /*! 2020 * @brief Stop the advertising 2021 * @param id the advertising id 2022 * @return API_SUCCESS 2023 */ 2024 uint16_t sonata_ble_stop_advertising_byid(uint8_t id); 2025 /*! 2026 * @brief Start Scanning 2027 * @param param: @see sonata_gap_scan_param_t 2028 * @return API_SUCCESS 2029 */ 2030 uint16_t sonata_ble_start_scanning(sonata_gap_scan_param_t *param); 2031 2032 /*! 2033 * @brief Start the scanning 2034 * @param id The scanning id 2035 * @param param: @see sonata_gap_scan_param_t 2036 * @return API_SUCCESS 2037 */ 2038 uint16_t sonata_ble_start_scanning_byid(uint8_t id, sonata_gap_scan_param_t *param); 2039 /*! 2040 * @brief Stop scanning 2041 * @return API_SUCCESS 2042 */ 2043 uint16_t sonata_ble_stop_scanning(void); 2044 2045 /*! 2046 * @brief Stop the scanning 2047 * @param id The scanning id 2048 * @return API_SUCCESS 2049 */ 2050 uint16_t sonata_ble_stop_scanning_byid(uint8_t id); 2051 /*! 2052 * @brief Delete current advertising, initiating, scanning, or period_sync active 2053 * @param index active index 2054 * @return API_SUCCESS 2055 */ 2056 uint16_t sonata_ble_delete_active(uint8_t index); 2057 /*! 2058 * @brief Start initiating 2059 * @param param: @see sonata_gap_init_param_t 2060 * @return API_SUCCESS 2061 */ 2062 uint16_t sonata_ble_start_initiating(sonata_gap_init_param_t *param); 2063 2064 /*! 2065 * @brief Start the initiating 2066 * @param id The initiating id 2067 * @param param: @see sonata_gap_init_param_t 2068 * @return API_SUCCESS 2069 */ 2070 uint16_t sonata_ble_start_initiating_byid(uint8_t id, sonata_gap_init_param_t *param); 2071 /*! 2072 * @brief Stop initiating 2073 * @return API_SUCCESS 2074 */ 2075 uint16_t sonata_ble_stop_initiating(void); 2076 2077 /*! 2078 * @brief Stop the initiating 2079 * @param id The initiating id 2080 * @return API_SUCCESS 2081 */ 2082 uint16_t sonata_ble_stop_initiating_byid(uint8_t id); 2083 /*! 2084 * @brief Send confirm message when received peer device get device name request 2085 * @param length length of the data 2086 * @param name value of the name 2087 * @return API_SUCCESS 2088 */ 2089 uint16_t sonata_ble_gap_send_get_dev_info_cfm_for_dev_name(uint8_t conidx, uint16_t length, uint8_t *name); 2090 /*! 2091 * @brief Send confirm message when received peer device get device appearance request 2092 * @param appearance 2093 * @return API_SUCCESS 2094 */ 2095 uint16_t sonata_ble_gap_send_get_dev_info_cfm_for_dev_appearance(uint8_t conidx, uint16_t appearance); 2096 2097 /*! 2098 * @brief Send confirm message when received peer device get device slave preferred parameters request 2099 * @param con_intv_min Connection interval minimum 2100 * @param con_intv_max Connection interval maximum 2101 * @param slave_latency Slave latency 2102 * @param conn_timeout Connection supervision timeout multiplier 2103 * @return API_SUCCESS 2104 */ 2105 uint16_t sonata_ble_gap_send_get_dev_info_cfm_for_slv_pref_params(uint8_t conidx, uint16_t con_intv_min, 2106 uint16_t con_intv_max, uint16_t slave_latency, uint16_t conn_timeout); 2107 2108 /*! 2109 * @brief Send confirm message when peer device set local device's name 2110 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2111 * @param status 2112 * @return API_SUCCESS 2113 */ 2114 uint16_t sonata_ble_gap_send_set_dev_name_cfm(uint8_t conidx, uint8_t status); 2115 /*! 2116 * @brief Send confirm message when received peer device get device device central address resolution request 2117 * @param ctl_addr_resol Central address resolution 2118 * @return API_SUCCESS 2119 */ 2120 uint16_t sonata_ble_gap_send_get_dev_info_cfm_for_ctl_addr_resol(uint8_t conidx, uint8_t ctl_addr_resol); 2121 2122 /*! 2123 * @brief Set white list 2124 * @param size white list size 2125 * @param addrs white list values 2126 * @return API_SUCCESS 2127 */ 2128 uint16_t sonata_ble_gap_set_white_list(uint8_t size, struct sonata_gap_bdaddr *addrs); 2129 2130 /*! 2131 * @brief Set IRK 2132 * @param key 2133 * @return API_SUCCESS 2134 */ 2135 uint16_t sonata_ble_gap_set_irk(uint8_t *key); 2136 2137 /*! 2138 * @brief Update connection parameters 2139 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2140 * @param pkt_id Internal parameter used to manage internally l2cap packet identifier for signaling, set to 0 for default 2141 * @param intv_min Connection interval minimum (6~3200 means 7.5ms~4S) 2142 * @param intv_max Connection interval maximum (6~3200 means 7.5ms~4S) 2143 * @param latency Latency (0~499) 2144 * @param time_out Supervision timeout (10~3200 means 100ms~32S) 2145 * @param ce_len_min Minimum Connection Event Duration 2146 * @param ce_len_max Maximum Connection Event Duration 2147 * @return API_SUCCESS 2148 */ 2149 uint16_t sonata_ble_gap_update_connection_params(uint8_t conidx, uint8_t pkt_id, uint16_t intv_min, uint16_t intv_max, 2150 uint16_t latency, 2151 uint16_t time_out, uint16_t ce_len_min, uint16_t ce_len_max); 2152 2153 /*! 2154 * @brief Disconnect 2155 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2156 * @param reason disconnect reason 2157 * @return API_SUCCESS 2158 */ 2159 uint16_t sonata_ble_gap_disconnect(uint8_t conidx, uint8_t reason); 2160 /*! 2161 * @brief Send bond confirm message for pairing request mode 2162 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2163 * @param reqInd @see sonata_gap_bond_req_ind 2164 * @param accept Request accepted 2165 * @param iocap IO capabilities (@see sonata_gap_io_cap) 2166 * @param oob OOB information (@see sonata_gap_oob) 2167 * @param auth Authentication (@see sonata_gap_auth) 2168 * @param key_size Encryption key size (7 to 16) 2169 * @param ikey_dist Initiator key distribution (@see sonata_gap_kdist) 2170 * @param rkey_dist Responder key distribution (@see sonata_gap_kdist) 2171 * @param sec_req Device security requirements (minimum security level). (@see sonata_gap_sec_req) 2172 * @return API_SUCCESS 2173 */ 2174 uint16_t sonata_ble_gap_send_bond_cfm_for_pairing_req(uint8_t conidx, struct sonata_gap_bond_req_ind *reqInd, 2175 uint8_t accept, 2176 enum sonata_gap_io_cap iocap, enum sonata_gap_oob_auth oob, enum sonata_gap_auth auth, uint8_t key_size, 2177 enum sonata_gap_kdist ikey_dist, enum sonata_gap_kdist rkey_dist, enum sonata_gap_sec_req sec_req); 2178 2179 /*! 2180 * @brief Send bond confirm message for ltk exchange 2181 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2182 * @param accept Request accepted 2183 * @param ediv Encryption Diversifier 2184 * @param randnb Random Number 2185 * @param key_size Encryption key size (7 to 16) 2186 * @param key Encryption key 2187 * @return API_SUCCESS 2188 */ 2189 uint16_t sonata_ble_gap_send_bond_cfm_for_ltk_exchange(uint8_t conidx, uint8_t accept, uint16_t ediv, uint8_t *randnb, 2190 uint8_t key_size, uint8_t *key); 2191 2192 /*! 2193 * @brief Send bond confirm for csrk exchange 2194 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2195 * @param accept Request accepted 2196 * @param csrk CSRK 2197 * @return API_SUCCESS 2198 */ 2199 uint16_t sonata_ble_gap_send_bond_cfm_for_csrk_exchange(uint8_t conidx, uint8_t accept, uint8_t *csrk); 2200 2201 /*! 2202 * @brief Send bond confirm for tk exchange 2203 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2204 * @param accept Request accepted 2205 * @param tk TK 2206 * @return API_SUCCESS 2207 */ 2208 uint16_t sonata_ble_gap_send_bond_cfm_for_tk_exchange(uint8_t conidx, uint8_t accept, uint8_t *tk); 2209 /*! 2210 * @brief Send bond confirm for irk exchange 2211 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2212 * @param accept Request accepted 2213 * @param irk IRK 2214 * @param addr_type Address type of the device 0=public/1=private random 2215 * @param addr Device BD Identity Address 2216 * @return API_SUCCESS 2217 */ 2218 uint16_t sonata_ble_gap_send_bond_cfm_for_irk_exchange(uint8_t conidx, uint8_t accept, uint8_t *irk, uint8_t addr_type, 2219 uint8_t *addr); 2220 2221 /*! 2222 * @brief Send bond confirm for OOB exchange 2223 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2224 * @param accept Request accepted 2225 * @param oob_conf OOB confirm value 2226 * @param oob_rand OOB random value 2227 * @return API_SUCCESS 2228 */ 2229 uint16_t sonata_ble_gap_send_bond_cfm_for_oob_exchange(uint8_t conidx, uint8_t accept, uint8_t *oob_conf, 2230 uint8_t *oob_rand); 2231 /*! 2232 * @brief Send bond confirm for Number compair exchange 2233 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2234 * @param accept Request accepted 2235 * @return API_SUCCESS 2236 */ 2237 uint16_t sonata_ble_gap_send_bond_cfm_for_nc_exchange(uint8_t conidx, uint8_t accept); 2238 /*! 2239 * @brief Get local device informations 2240 * @param operation @see sonata_gap_local_dev_info 2241 * @return API_SUCCESS 2242 */ 2243 2244 uint16_t sonata_ble_gap_get_dev_info(sonata_gap_local_dev_info operation); 2245 2246 /*! 2247 * @brief Resolve address command 2248 * @param address address value 2249 * @param nb_key Number of provided IRK (sahlle be > 0) 2250 * @param irk Array of IRK used for address resolution (MSB -> LSB) 2251 * @return API_SUCCESS 2252 */ 2253 uint16_t sonata_ble_gap_resolve_address(uint8_t *address, uint8_t nb_key, struct sonata_gap_sec_key *irk); 2254 /*! 2255 * @brief Generate random address 2256 * @param rnd_type @see sonata_gap_rnd_addr_type. 2257 * - BD_ADDR_STATIC: Static random address; 2258 * - BD_ADDR_NON_RSLV: Private non resolvable address; 2259 * - BD_ADDR_RSLV: Private resolvable address 2260 * @param prand Dummy parameter used to store the prand part of the address 2261 * @return 2262 */ 2263 uint16_t sonata_ble_gap_generate_random_address(uint8_t rnd_type, uint8_t *prand); 2264 2265 /*! 2266 * @brief Generate random number 2267 * @return API_SUCCESS 2268 */ 2269 uint16_t sonata_ble_gap_generate_random_number(void); 2270 /*! 2271 * @brief Send encrypt confirm 2272 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2273 * @param found 2274 * @param key_size 2275 * @param ltk 2276 * @return 2277 */ 2278 uint16_t sonata_ble_gap_send_encrypt_cfm(uint8_t conidx, uint8_t found, uint8_t key_size, uint8_t *ltk); 2279 2280 /*! 2281 * @brief Send key press notification 2282 * @param conidx 2283 * @param notification_type 2284 * @return 2285 */ 2286 uint16_t sonata_ble_gap_send_key_press_notification(uint8_t conidx, uint8_t notification_type); 2287 /*! 2288 * @brief Start bond 2289 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2290 * @param iocap @see sonata_gap_io_cap 2291 * @param oob @see sonata_gap_oob 2292 * @param auth @see sonata_gap_auth 2293 * @param key_size @see SONATA_GAP_SMP_MAX_ENC_SIZE_LEN, @see SONATA_GAP_SMP_MIN_ENC_SIZE_LEN 2294 * @param ikey_dist @see sonata_gap_kdist 2295 * @param rkey_dist @see sonata_gap_kdist 2296 * @param sec_req @see sonata_gap_sec_req 2297 * @return API_SUCCESS 2298 */ 2299 uint16_t sonata_ble_gap_bond(uint8_t conidx, uint8_t iocap, uint8_t oob, uint8_t auth, uint8_t key_size, 2300 uint8_t ikey_dist, uint8_t rkey_dist, uint8_t sec_req); 2301 /*! 2302 * @brief Add profile module 2303 * @param prf_id Profile task identifier 2304 * @param sec_lvl Security Level 2305 * @param start_hdl Service start handle 2306 * @param value_len value length for parameter value 2307 * @param value value to initialize profile 2308 * @return API_SUCCESS 2309 */ 2310 uint16_t sonata_ble_gap_add_profile(sonata_ble_profile_id prf_id, uint8_t sec_lvl, uint16_t start_hdl, 2311 uint16_t value_len, void *value); 2312 2313 /*! 2314 * @brief Get peer information 2315 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2316 * @param operation @see sonata_peer_info_type 2317 * @return API_SUCCESS 2318 */ 2319 uint16_t sonata_ble_gap_get_peer_info(uint8_t conidx, sonata_peer_info_type operation); 2320 2321 /*! 2322 * @brief Start security 2323 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2324 * @param auth_level 2325 * @return API_SUCCESS 2326 */ 2327 uint16_t sonata_ble_gap_start_security(uint8_t conidx, uint8_t auth_level); 2328 2329 /*! 2330 * @brief set packet size 2331 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2332 * @param tx_octets 2333 * @param tx_time 2334 * @return API_SUCCESS 2335 */ 2336 uint16_t sonata_ble_gap_set_le_pkt_size(uint8_t conidx, uint16_t tx_octets, uint16_t tx_time); 2337 2338 /*! 2339 * @brief Send parameter update confirm command 2340 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2341 * @param accept True to accept slave connection parameters, False else. 2342 * @param ce_len_min Minimum Connection Event Duration 2343 * @param ce_len_max Maximum Connection Event Duration 2344 * @return API_SUCCESS 2345 */ 2346 uint16_t sonata_ble_gap_send_param_update_cfm(uint8_t conidx, bool accept, uint16_t ce_len_min, uint16_t ce_len_max); 2347 2348 /* 2349 * FUNCTION DECLARATIONS Connection help function 2350 **************************************************************************************** 2351 */ 2352 /*! 2353 * @brief Get connection index form peer address 2354 * @param peer_addr peer devices address 2355 * @return Connection index OR GAP_INVALID_CONIDX 2356 */ 2357 uint8_t sonata_ble_get_conidx(uint8_t *peer_addr); 2358 /*! 2359 * @brief Get peer device's address form connection index 2360 * @param connection_id connection index 2361 * @return peer devices's address. 2362 */ 2363 uint8_t *sonata_ble_get_peer_addr(uint8_t connection_id); 2364 2365 /*! 2366 * @brief Send connection confirm command 2367 * @param conidx connecting index, used for multiple connection. for single connection, set it to 0. 2368 * @param cfm @see sonata_gap_connection_cfm_t 2369 * @return API_SUCCESS 2370 */ 2371 uint16_t sonata_ble_gap_send_connection_cfm(uint8_t conidx, sonata_gap_connection_cfm_t *cfm); 2372 2373 /// @hide 2374 void sonata_ble_show_connection_info(void); 2375 2376 struct sonata_gap_bdaddr *sonata_ble_gap_get_bdaddr(uint8_t conidx, uint8_t src); 2377 2378 /// @hide 2379 uint16_t sonata_ble_gap_cte_set_tx_config(uint8_t conidx, uint8_t cte_types, uint8_t switching_pattern_len, 2380 uint8_t *antenna_id); 2381 2382 /// @hide 2383 uint16_t sonata_ble_gap_cte_response_control(uint8_t conidx, bool enable); 2384 2385 /** @}*/ 2386 2387 #endif // BLE_HOST_PRESENT 2388 2389 #endif // _SONATA_GAP_API_H_ 2390 2391