1 /******************************************************************************* 2 * @file rsi_ble_apis.h 3 ******************************************************************************* 4 * # License 5 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> 6 ******************************************************************************* 7 * 8 * SPDX-License-Identifier: Zlib 9 * 10 * The licensor of this software is Silicon Laboratories Inc. 11 * 12 * This software is provided 'as-is', without any express or implied 13 * warranty. In no event will the authors be held liable for any damages 14 * arising from the use of this software. 15 * 16 * Permission is granted to anyone to use this software for any purpose, 17 * including commercial applications, and to alter it and redistribute it 18 * freely, subject to the following restrictions: 19 * 20 * 1. The origin of this software must not be misrepresented; you must not 21 * claim that you wrote the original software. If you use this software 22 * in a product, an acknowledgment in the product documentation would be 23 * appreciated but is not required. 24 * 2. Altered source versions must be plainly marked as such, and must not be 25 * misrepresented as being the original software. 26 * 3. This notice may not be removed or altered from any source distribution. 27 * 28 ******************************************************************************/ 29 30 #ifndef RSI_BLE_APIS_H 31 #define RSI_BLE_APIS_H 32 33 #include "rsi_bt_common.h" 34 35 /****************************************************** 36 * * Macros 37 * ******************************************************/ 38 39 /** @addtogroup BT_BLE_CONSTANTS 40 * @{ 41 */ 42 /// Maximum number of response list for BLE. 43 #define RSI_BLE_MAX_RESP_LIST 0x05 44 /// Maximum size of an advertising report. 45 #define RSI_MAX_ADV_REPORT_SIZE 31 46 /// Size of the BLE passkey. 47 #define BLE_PASSKEY_SIZE 6 48 49 /// Defines the output power front end loss for BLE 50 #ifndef BLE_OUTPUT_POWER_FRONT_END_LOSS 51 #define BLE_OUTPUT_POWER_FRONT_END_LOSS 0 /* db */ 52 #endif 53 54 /// Host descriptor length 55 #define RSI_HOST_DESC_LENGTH 16 56 57 /** @} */ 58 59 /****************************************************** 60 * * Constants 61 * ******************************************************/ 62 /****************************************************** 63 * * Enumerations 64 * ******************************************************/ 65 66 /****************************************************** 67 * * Type Definitions 68 * ******************************************************/ 69 70 /****************************************************** 71 * * Structures 72 ******************************************************/ 73 74 /** @addtogroup BT_BLE_EVENT_TYPES Event Types 75 * @{ */ 76 77 // GAP Event structures 78 79 //Advertise report event structure 80 /** 81 * @brief Structure representing a BLE advertising report event. 82 */ 83 typedef struct rsi_ble_event_adv_report_s { 84 /**Address type of the advertising device */ 85 uint8_t dev_addr_type; 86 /**Address of the advertising device*/ 87 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 88 /**Raw advertisement data length*/ 89 uint8_t adv_data_len; 90 /**advertisement data*/ 91 uint8_t adv_data[RSI_MAX_ADV_REPORT_SIZE]; 92 /**Signal strength*/ 93 int8_t rssi; 94 /** Report type 95 - 96 0x00 Connectable and scannable undirected advertising (ADV_IND) 97 - 98 0x01 Connectable directed advertising (ADV_DIRECT_IND) 99 - 100 0x02 Scannable undirected advertising (ADV_SCAN_IND) 101 - 102 0x03 Non connectable undirected advertising (ADV_NONCONN_IND) 103 - 104 0x04 Scan Response (SCAN_RSP) 105 - 106 All other values Reserved for future use*/ 107 uint8_t report_type; 108 } rsi_ble_event_adv_report_t; 109 110 //Connection status event structure 111 /** 112 * @brief Structure representing the connection status event in the BLE module. 113 */ 114 typedef struct rsi_ble_event_conn_status_s { 115 /** Address type of the connected device */ 116 uint8_t dev_addr_type; 117 /** Address of the connected device */ 118 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 119 /** Status of the connection - success/failure */ 120 uint16_t status; 121 } rsi_ble_event_conn_status_t; 122 123 //enhance connection status event structure 124 /** 125 * @brief Structure representing the enhanced connection status event in the BLE module. 126 */ 127 typedef struct rsi_ble_event_enhnace_conn_status_s { 128 129 /**Device address type of the Connected Remote Device*/ 130 uint8_t dev_addr_type; 131 /**Device address of the remote device.*/ 132 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 133 /**Local Device resolvable address*/ 134 uint8_t local_resolvlable_addr[RSI_DEV_ADDR_LEN]; 135 /**Remote Device resolvable address*/ 136 uint8_t peer_resolvlable_addr[RSI_DEV_ADDR_LEN]; 137 /**The role of the device - central/ peripheral*/ 138 uint8_t role; 139 /**Connection interval used on this connection. Range: 0x0006 to 0x0C80*/ 140 uint16_t conn_interval; 141 /**Peripheral latency for the connection in number of connection events. Range: 0x0000 to 0x01F3*/ 142 uint16_t conn_latency; 143 /**Connection supervision timeout. Range: 0x000A to 0x0C80*/ 144 uint16_t supervision_timeout; 145 /**Only applicable for peripheral, for central this value is set to 0x00*/ 146 uint8_t master_clock_accuracy; 147 /**Status of the Connection - success/failure*/ 148 uint16_t status; 149 } rsi_ble_event_enhance_conn_status_t; 150 151 //Disconnect event structure 152 /** 153 * @brief Disconnection event structure for BLE. 154 * 155 * This structure contains information about the disconnection event of a BLE device. 156 */ 157 typedef struct rsi_ble_event_disconnect_s { 158 /** Device address of the disconnected device */ 159 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 160 /** The type of the disconnected device (LE) */ 161 uint8_t dev_type; 162 } rsi_ble_event_disconnect_t; 163 164 //le ping timeout expired event structure 165 /** 166 * @brief Structure representing the BLE event for LE ping time expiration. 167 */ 168 typedef struct rsi_ble_event_le_ping_time_expired_s { 169 /**Device address of the disconnected device*/ 170 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 171 172 } rsi_ble_event_le_ping_time_expired_t; 173 174 //le ltk request event Structure 175 /** 176 * @brief Structure representing a Bluetooth Low Energy (LE) Long Term Key (LTK) request event. 177 */ 178 typedef struct rsi_bt_event_le_ltk_request_s { 179 /**BD Address of the remote device*/ 180 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 181 /**ediv of local device*/ 182 uint16_t localediv; 183 /**rand of local device*/ 184 uint8_t localrand[8]; 185 /**Address type of remote device*/ 186 uint8_t dev_addr_type; 187 } rsi_bt_event_le_ltk_request_t; 188 189 //le security keys event Structure 190 /** 191 * @brief Structure representing the Bluetooth Low Energy (BLE) event for security keys. 192 */ 193 typedef struct rsi_bt_event_le_security_keys_s { 194 /**BD Address of the remote device*/ 195 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 196 /**16 byte irk of the local device*/ 197 uint8_t local_irk[16]; 198 /**16 byte irk of the remote device*/ 199 uint8_t remote_irk[16]; 200 /**remote device ediv value*/ 201 uint16_t remote_ediv; 202 /**remote device rand value*/ 203 uint8_t remote_rand[16]; 204 /**remote device ltk value*/ 205 uint8_t remote_ltk[16]; 206 /**Identity address type - public/random 207 - 208 0x00 --> Public Identity Address 209 - 210 0x01 --> Random (static) Identity Address 211 - 212 All other values Reserved for future use*/ 213 uint8_t Identity_addr_type; 214 /**Identity address which is resolved after security keys exchange*/ 215 uint8_t Identity_addr[6]; 216 /**Device address type*/ 217 uint8_t dev_addr_type; 218 } rsi_bt_event_le_security_keys_t; 219 220 //encryption enabled structure 221 /** 222 * @brief Structure to hold the event data for encryption enabled event. 223 */ 224 typedef struct rsi_bt_event_encryption_enabled_s { 225 /**Remote device Address*/ 226 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 227 /**Status of the Encryption 228 - 229 ENCRYPT_ENABLED BIT(0) --> To indicate or set encryption is enabled AUTH_LTK_OR_STK_ENC 230 - 231 BIT(1) --> To indicate or set Authenticated Pairing and Encryption UN_AUTH_LTK_OR_STK_ENC 232 - 233 BIT(2) --> To indicate or set UnAuthenticated pairing and Encryption AUTH_LTK_WITH_LE_SC_ENC 234 - 235 BIT(3) --> To indicate or set Authenticated Pairing and Enc with LE SC */ 236 uint8_t enabled; 237 /**BLE Secure Connections Enable/disable indication 238 - 239 0 --> Disable 240 - 241 1 --> Enable */ 242 uint8_t sc_enable; 243 /**Local device EDIV*/ 244 uint16_t localediv; 245 /**Local RAND*/ 246 uint8_t localrand[8]; 247 /**Local Long term Key*/ 248 uint8_t localltk[16]; 249 /**Remote Device Address type*/ 250 uint8_t dev_addr_type; 251 } rsi_bt_event_encryption_enabled_t; 252 253 //SMP protocol structure 254 //SMP Request event structure 255 /** 256 * @brief Structure to hold the Security Manager Protocol (SMP) request event. 257 */ 258 typedef struct rsi_bt_event_smp_req_s { 259 /**address of remote device*/ 260 uint8_t dev_addr[6]; 261 /**auth req of remote device*/ 262 uint8_t auth_req; 263 } rsi_bt_event_smp_req_t; 264 265 //SMP Response event structure 266 /** 267 * @brief Structure to hold the SMP response event data. 268 */ 269 typedef struct rsi_bt_event_smp_resp_s { 270 /**address of remote device*/ 271 uint8_t dev_addr[6]; 272 /**Device input output capability 273 - 274 0x00 - Display Only 275 - 276 0x01 - Display Yes/No 277 - 278 0x02 - Keyboard Only 279 - 280 0x03 - No Input No Output 281 0x04 - Keyboard Display*/ 282 uint8_t io_cap; 283 /**Out Of the Band data*/ 284 uint8_t oob_data; 285 /**Authentication Request contains bonding type 286 - 287 MITM Request - BIT(2) 288 - 289 Secure Connections - BIT(3) 290 - 291 Keypress - BIT(4) 292 - 293 CT2 - BIT(5)*/ 294 uint8_t auth_req; 295 /**Minimum required key size*/ 296 uint8_t min_req_key_size; 297 /** Initiator generates/requires the no .of keys after successful paring 298 - 299 BIT(0) - EncKey: Initiator distributes the LTK followed by EDIV and Rand 300 - 301 BIT(1) - IdKey : Initiator distributes the IRK followed by its address 302 - 303 BIT(2) - Sign : Initiator distributes the CSRK 304 - 305 BIT(3) - BIT(7): Reserved for future use */ 306 uint8_t ini_key_distrb; 307 /** Responder generates/requires the no .of keys after successful paring 308 - 309 BIT(0) - EncKey: Responder distributes the LTK followed by EDIV and Rand 310 - 311 BIT(1) - IdKey : Responder distributes the IRK followed by its address 312 - 313 BIT(2) - Sign : Responder distributes the CSRK 314 - 315 BIT(3) - BIT(7): Reserved for future use */ 316 uint8_t resp_key_distrb; 317 } rsi_bt_event_smp_resp_t; 318 319 //SMP passkey event structure 320 /** 321 * @brief Structure to hold the SMP passkey event data. 322 */ 323 typedef struct rsi_bt_event_smp_passkey_s { 324 /**address of remote device*/ 325 uint8_t dev_addr[6]; 326 } rsi_bt_event_smp_passkey_t; 327 328 //SMP passkey display event structure 329 /** 330 * @brief Structure to hold the SMP passkey display event. 331 */ 332 typedef struct rsi_bt_event_smp_passkey_display_s { 333 /**address of remote device*/ 334 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 335 /**This is the key required in pairing process( 6 bytes)*/ 336 uint8_t passkey[BLE_PASSKEY_SIZE]; 337 } rsi_bt_event_smp_passkey_display_t; 338 339 //SC passkey display event structure 340 /** 341 * @brief Structure to hold the Secure Connections (SC) passkey event. 342 */ 343 typedef struct rsi_bt_event_sc_passkey_s { 344 /**address of remote device*/ 345 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 346 /**Reserved for future use*/ 347 uint8_t reserved[2]; 348 /**This is the key required in pairing process*/ 349 uint32_t passkey; 350 } rsi_bt_event_sc_passkey_t; 351 352 //SMP failed event structure 353 /** 354 * @brief Structure to hold the information related to a Bluetooth Low Energy (BLE) Security Manager Protocol (SMP) failed event. 355 */ 356 typedef struct rsi_bt_event_smp_failed_s { 357 /**device address of the disconnected device*/ 358 uint8_t dev_addr[6]; 359 } rsi_bt_event_smp_failed_t; 360 361 //Security Methods event structure 362 /** 363 * @brief Structure to define the Bluetooth event security method. 364 */ 365 typedef struct rsi_bt_event_sc_method_s { 366 /**Security Method --> Justworks or Passkey 367 - 368 RSI_BT_LE_SC_JUST_WORKS 0x01 369 - 370 RSI_BT_LE_SC_PASSKEY 0x02 */ 371 uint8_t sc_method; 372 } rsi_bt_event_sc_method_t; 373 374 /** 375 * @brief Structure representing the BLE event for Cross Transport Key Derivation (CTKD). 376 * 377 * This structure is used to define the parameters for the BLE event related to Cross Transport Key Derivation, 378 * including the remote device address and the derived key. 379 */ 380 typedef struct rsi_bt_event_ctkd_s { 381 /** Address of the remote device */ 382 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 383 /** Derived key */ 384 uint8_t key[16]; 385 } rsi_ble_event_ctkd_t; 386 387 // phy update complete event 388 /** 389 * @brief Structure to hold the BLE PHY update event information. 390 */ 391 typedef struct rsi_ble_event_phy_update_s { 392 393 /**Device address of the remote device.*/ 394 uint8_t dev_addr[6]; 395 /**Transmission PHY rate(1 byte) 396 - 397 BIT(0) - The Host prefers to use the LE 1M transmitter PHY (possibly among others) 398 - 399 BIT(1) - The Host prefers to use the LE 2M transmitter PHY (possibly among others) 400 - 401 BIT(2) - The Host prefers to use the LE Coded transmitter PHY (possibly among others) 402 - 403 BIT(3) - BIT(7) Reserved for future use */ 404 uint8_t TxPhy; 405 /**Reception PHY rate(1 byte) 406 - 407 BIT(0) - The Host prefers to use the LE 1M transmitter PHY (possibly among others) 408 - 409 BIT(1) - The Host prefers to use the LE 2M transmitter PHY (possibly among others) 410 - 411 BIT(2) - The Host prefers to use the LE Coded transmitter PHY (possibly among others) 412 - 413 BIT(3) - BIT(7) Reserved for future use */ 414 uint8_t RxPhy; 415 } rsi_ble_event_phy_update_t; 416 417 // connection parameters complete event 418 419 /** 420 * @brief Structure to hold the data of the BLE connection update event. 421 * 422 */ 423 typedef struct rsi_ble_event_conn_update_s { 424 /**Device address of the remote device*/ 425 uint8_t dev_addr[6]; 426 /**Connection Interval*/ 427 uint16_t conn_interval; 428 /**Slave Latency*/ 429 uint16_t conn_latency; 430 /**Supervision Timeout*/ 431 uint16_t timeout; 432 } rsi_ble_event_conn_update_t; 433 434 // remote conn params request event //event_id : 0x152E 435 436 /** 437 * @brief Structure representing the parameters of a remote connection parameter request event in BLE. 438 */ 439 typedef struct rsi_ble_event_remote_conn_param_req_s { 440 /** Device address of the remote device */ 441 uint8_t dev_addr[6]; 442 /** Minimum connection interval */ 443 uint16_t conn_interval_min; 444 /** Maximum connection interval */ 445 uint16_t conn_interval_max; 446 /** Slave Latency */ 447 uint16_t conn_latency; 448 /** Supervision Timeout */ 449 uint16_t timeout; 450 } rsi_ble_event_remote_conn_param_req_t; 451 452 // remote features event 453 /** 454 * @brief Structure to hold the data of the remote features event. 455 */ 456 typedef struct rsi_ble_event_remote_features_s { 457 /**Remote device address*/ 458 uint8_t dev_addr[6]; 459 /**Remote device supported features 460 - 461 @note please refer spec for the supported features list */ 462 uint8_t remote_features[8]; 463 } rsi_ble_event_remote_features_t; 464 465 // LE Device Buffer Indication 466 /** 467 * @brief Structure to hold the BLE event LE device buffer indication. 468 */ 469 typedef struct rsi_ble_event_le_dev_buf_ind_s { 470 471 /**Remote device address*/ 472 uint8_t remote_dev_bd_addr[RSI_DEV_ADDR_LEN]; 473 /**No. of Available buffer*/ 474 uint8_t avail_buf_cnt; 475 } rsi_ble_event_le_dev_buf_ind_t; 476 477 // PHY update complete event 478 /** 479 * @brief Structure representing the data for the BLE length update event. 480 * 481 */ 482 typedef struct rsi_ble_event_data_length_update_s { 483 484 /**Device address of the remote device.*/ 485 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 486 /**Maximum TX Octets to be transmitted*/ 487 uint16_t MaxTxOctets; 488 /**Maximum TX time to transmit the MaxTxOctets*/ 489 uint16_t MaxTxTime; 490 /**Maximum Rx Octets to be received*/ 491 uint16_t MaxRxOctets; 492 /**Maximum Rx time to receive the MaxRxOctets*/ 493 uint16_t MaxRxTime; 494 } rsi_ble_event_data_length_update_t; 495 496 // Basic GATT structures 497 498 // 128 bit UUID format structure 499 /** 500 * @brief Structure representing a 128-bit UUID. 501 */ 502 typedef struct uuid128_s { 503 /** Holds the value of data1 */ 504 uint32_t data1; 505 /** Holds the value of data2 */ 506 uint16_t data2; 507 /** 508 * @brief Holds the value of data3. 509 */ 510 uint16_t data3; 511 /** 512 * @brief Array to store 8 bytes of data. 513 */ 514 uint8_t data4[8]; 515 } uuid128_t; 516 517 /// 16 bit UUID format structure 518 typedef uint16_t uuid16_t; 519 520 /// 32 bit UUID format structure 521 typedef uint32_t uuid32_t; 522 523 // UUID format structure 524 525 /** 526 * @brief Structure representing a Universally Unique Identifier (UUID). 527 * 528 * This structure encapsulates a UUID, which can be of varying sizes—16-bit, 32-bit, or 128-bit. 529 * It includes the size of the UUID, a reserved field, and a union to hold the value 530 * of one of the three types of UUIDs. 531 */ 532 typedef struct uuid_s { 533 /** 534 * Size of the UUID. 535 * Indicates the size of the UUID in bits. It can be 16, 32, or 128, depending on the type of UUID used. 536 */ 537 uint8_t size; 538 539 /** 540 * Reserved field. 541 * This field is reserved for future use. 542 */ 543 uint8_t reserved[3]; 544 545 /** 546 * @brief Union representing the value of the UUID. 547 * This union stores the value of the UUID, which can be of three different sizes: 548 * 128-bit, 32-bit, or 16-bit. The appropriate field in the union should be used 549 * depending on the size of the UUID. 550 */ 551 union uuid_t { 552 /** 553 * @brief 128-bit UUID value. \ref uuid128_t 554 * 555 * This member holds the value of a 128-bit UUID, which is divided into four segments: 556 * - The first 32 bits (`data1`) 557 * - The next 16 bits (`data2`) 558 * - The following 16 bits (`data3`) 559 * - The final 64 bits (`data4`), stored as an array of 8 bytes 560 * 561 * These segments together represent a full 128-bit UUID, compliant with the standard UUID format. 562 */ 563 uuid128_t val128; 564 565 /** 566 * 32-bit UUID value. 567 * This field holds the value of a 32-bit UUID, stored as an array of 4 bytes. 568 */ 569 uuid32_t val32; 570 571 /** 572 * 16-bit UUID value. 573 * This field holds the value of a 16-bit UUID, stored as an array of 2 bytes. 574 */ 575 uuid16_t val16; 576 } val; ///< Value of one of the 3 types (128-bit, 32-bit, or 16-bit) of UUIDs 577 } uuid_t; 578 579 /** @} */ 580 /** @addtogroup BT_BLE_TYPES 581 * @{ */ 582 // profile descriptor/primary service structure 583 /** 584 * @brief Represents the data of the particular profile descriptor. 585 */ 586 typedef struct profile_descriptor_s { 587 /** Start handle. */ 588 uint8_t start_handle[2]; 589 /** End handle. */ 590 uint8_t end_handle[2]; 591 /** profile uuid. */ 592 uuid_t profile_uuid; 593 } profile_descriptors_t; 594 /** @} */ 595 596 // GATT attribute descriptor structure 597 /** @addtogroup BT_BLE_TYPES 598 * @{ */ 599 /** 600 * @brief Structure representing an attribute descriptor. 601 * 602 * This structure is used to define the parameters for an attribute descriptor, 603 * including the attribute handle, reserved field, and attribute UUID. 604 */ 605 typedef struct att_desc_s { 606 /** Attribute handle */ 607 uint8_t handle[2]; 608 /** Reserved */ 609 uint8_t reserved[2]; 610 /** Attribute UUID (attribute type) */ 611 uuid_t att_type_uuid; 612 } att_desc_t; 613 614 //characteristic service attribute value structure 615 616 /** 617 * @brief Structure representing characteristic service data. 618 * 619 * This structure is used to define the parameters for characteristic service data, 620 * including the characteristic value property, handle, and UUID. 621 */ 622 typedef struct char_serv_data_s { 623 /** Characteristic value property */ 624 uint8_t char_property; 625 /** Reserved */ 626 uint8_t reserved; 627 /** Characteristic value handle */ 628 uint16_t char_handle; 629 /** Characteristic value attributes UUID */ 630 uuid_t char_uuid; 631 } char_serv_data_t; 632 633 //characteristic service attribute structure 634 635 /** 636 * @brief Structure representing a characteristic service. 637 * 638 * This structure is used to define the parameters for a characteristic service, 639 * including the attribute handle, reserved space for future use, and the characteristic service attribute value. 640 */ 641 typedef struct char_serv_s { 642 /** Characteristic service attribute handle */ 643 uint16_t handle; 644 /** Reserved for future use */ 645 uint8_t reserved[2]; 646 /** Characteristic service attribute value */ 647 char_serv_data_t char_data; 648 } char_serv_t; 649 650 //include service attribute value structure 651 /** 652 * @brief Structure representing the included service data. 653 */ 654 typedef struct inc_serv_data_s { 655 656 /**include service start handle*/ 657 uint16_t start_handle; 658 /**include service end handle*/ 659 uint16_t end_handle; 660 /**UUID value of the included service*/ 661 uuid_t uuid; 662 } inc_serv_data_t; 663 664 // include service attribute structure 665 /** 666 * @brief Structure representing an included service attribute in a GATT server. 667 * 668 */ 669 typedef struct inc_serv_s { 670 /**Include service attribute handle*/ 671 uint16_t handle; 672 /**Reserved field */ 673 uint8_t reserved[2]; 674 /**Include service attribute data structure */ 675 inc_serv_data_t inc_serv; 676 } inc_serv_t; 677 678 /** @} */ 679 /** @addtogroup BT_BLE_TYPES 680 * @{ */ 681 // GATT Request structures 682 // add new attributes to service request structure 683 /** 684 * @brief Structure representing a request to add an attribute in the BLE stack. 685 */ 686 typedef struct rsi_ble_req_add_att_s { 687 /** service handler */ 688 void *serv_handler; 689 /** Attribute handle */ 690 uint16_t handle; 691 /** If this variable is 1, Host has to maintain attributes and records in the application. 692 - 693 If 0, Stack will maintain the attributes and records 694 */ 695 uint16_t config_bitmap; 696 /** Attribute type UUID */ 697 uuid_t att_uuid; 698 /** Attribute property */ 699 uint8_t property; 700 /** Attribute data length */ 701 uint16_t data_len; 702 /** Attribute data. The maximum value is 240, please refer RSI_DEV_ATT_LEN Macro*/ 703 uint8_t data[RSI_DEV_ATT_LEN]; 704 } rsi_ble_req_add_att_t; 705 /** @} */ 706 707 // GATT Response structures 708 709 //Presentation Format descriptor structure 710 // actual value = char value * 10 ^ exponent; 711 /** 712 * @brief Structure representing the presentation format of a Bluetooth Low Energy (BLE) device. 713 */ 714 typedef struct rsi_ble_presentation_format { 715 /**Format of the data*/ 716 uint8_t format; 717 /**Exponent of the data*/ 718 uint8_t exponent; 719 /**uints of the data*/ 720 uint16_t unit; 721 /**name space of the data*/ 722 uint8_t name_space; 723 /**Description for data*/ 724 uint16_t description; 725 } rsi_ble_pesentation_format_t; 726 727 /** @addtogroup BT_BLE_EVENT_TYPES Event Types 728 * @{ */ 729 730 //RSI_BLE_EVENT_GATT_ERROR_RESP, event_id: 0x1500 731 /** 732 * @brief Structure representing the response for a BLE event error. 733 */ 734 typedef struct rsi_ble_event_error_resp_s { 735 736 /**remote device address*/ 737 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 738 /**attribute handle*/ 739 uint8_t handle[2]; 740 /**Error indicates the type of Gatt Error*/ 741 uint8_t error[2]; 742 } rsi_ble_event_error_resp_t; 743 744 //RSI_BLE_EVENT_GATT_CHAR_DESC - event_ix = 1501 745 746 /** 747 * @brief Structure representing a GATT descriptor event. 748 */ 749 typedef struct rsi_ble_event_gatt_desc_s { 750 /**remote device address*/ 751 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 752 /**number of descriptors found*/ 753 uint8_t num_of_att; 754 /**Reserved for future use*/ 755 uint8_t reserved; 756 /**Attribute descriptors list. The maximum value is 5*/ 757 att_desc_t att_desc[RSI_BLE_MAX_RESP_LIST]; 758 } rsi_ble_event_gatt_desc_t; 759 760 //RSI_BLE_EVENT_GATT_PRIMARY_SERVICE_LIST, event_id: 0x1509 761 762 /** 763 * @brief Structure representing the BLE event profiles list. 764 * 765 * This structure is used to define the parameters for the BLE event profiles list, 766 * including the remote device address, number of profiles found, and the list of found profiles. 767 */ 768 typedef struct rsi_ble_event_profiles_list_s { 769 /** Remote device address */ 770 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 771 /** Number of profiles found */ 772 uint8_t number_of_profiles; 773 /** Reserved for future use */ 774 uint8_t reserved; 775 /** List of found profiles. The maximum value is 5 */ 776 profile_descriptors_t profile_desc[RSI_BLE_MAX_RESP_LIST]; 777 } rsi_ble_event_profiles_list_t; 778 779 //RSI_BLE_EVENT_GATT_PRIMARY_SERVICE_BY_UUID, event_id = 0x1502 780 /** 781 * @brief Structure to hold the BLE event profile by UUID. 782 */ 783 typedef struct rsi_ble_event_profile_by_uuid_s { 784 785 /**remote device address*/ 786 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 787 /**profile start handle*/ 788 uint8_t start_handle[2]; 789 /**profile end handle*/ 790 uint8_t end_handle[2]; 791 } rsi_ble_event_profile_by_uuid_t; 792 793 //RSI_BLE_EVENT_GATT_READ_CHAR_SERVS, event_id = 0x1503 794 /** 795 * @brief Structure representing the BLE event for reading characteristic services by type. 796 * 797 * This structure is used to represent the BLE event `RSI_BLE_EVENT_GATT_READ_CHAR_SERVS` 798 * with event ID `0x1503`. It provides information related to the read operation 799 * of characteristic services. 800 */ 801 typedef struct rsi_ble_event_read_by_type1_s { 802 /** Remote device address */ 803 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 804 /** Number of characteristic services found */ 805 uint8_t num_of_services; 806 /** Reserved for future use */ 807 uint8_t reserved; 808 /** It contains the characteristic service list. The maximum value is 5. */ 809 char_serv_t char_services[RSI_BLE_MAX_RESP_LIST]; 810 } rsi_ble_event_read_by_type1_t; 811 812 //RSI_BLE_EVENT_GATT_READ_INC_SERVS, event_id = 0x1504 813 /** 814 * @brief Structure for BLE event read by type 2. 815 */ 816 typedef struct rsi_ble_event_read_by_type2_s { 817 818 /**remote device address*/ 819 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 820 /**number of characteristic services found*/ 821 uint8_t num_of_services; 822 /**Reserved for future use*/ 823 uint8_t reserved; 824 /**list of included services. The maximum value is 5*/ 825 inc_serv_t services[RSI_BLE_MAX_RESP_LIST]; 826 } rsi_ble_event_read_by_type2_t; 827 828 //RSI_BLE_EVENT_GATT_READ_VAL_BY_UUID, event_id = 0x1505 829 /** 830 * @brief Structure definition for the BLE event "Read By Type 3" response. 831 */ 832 typedef struct rsi_ble_event_read_by_type3_s { 833 834 /**remote device address*/ 835 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 836 /**attribute handle*/ 837 uint8_t handle[2]; 838 /**length of attribute value*/ 839 uint16_t length; 840 /**This contains the attribute value. The maximum value is 240, please refer RSI_DEV_ATT_LEN Macro*/ 841 uint8_t att_value[RSI_DEV_ATT_LEN]; 842 } rsi_ble_event_read_by_type3_t; 843 844 //RSI_BLE_EVENT_GATT_READ_RESP , evet_id = 0x1506,0x1507,0x1508 845 /** 846 * @brief Structure representing the BLE ATT value event. 847 */ 848 typedef struct rsi_ble_event_att_value_s { 849 850 /**remote device address*/ 851 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 852 /**length of attribute value*/ 853 uint16_t length; 854 /**This contains the attribute value. The maximum value is 240, please refer RSI_DEV_ATT_LEN Macro*/ 855 uint8_t att_value[RSI_DEV_ATT_LEN]; 856 } rsi_ble_event_att_value_t; 857 858 //RSI_BLE_EVENT_GATT_WRITE_RESP, event_id: 0x150A,0x150C 859 /** 860 * @brief Structure to hold the response for the BLE set attribute request. 861 */ 862 typedef struct rsi_ble_set_att_resp_s { 863 /**remote device address*/ 864 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 865 } rsi_ble_set_att_resp_t; 866 867 //RSI_BLE_EVENT_GATT_PREPARE_WRITE_RESP, event_id: 0x150B 868 /** 869 * @brief Structure representing the response for the prepare write operation in BLE. 870 */ 871 typedef struct rsi_ble_prepare_write_resp_s { 872 873 /**remote device address*/ 874 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 875 /**attribute handle*/ 876 uint8_t handle[2]; 877 /**attribute value offset*/ 878 uint8_t offset[2]; 879 /**length of attribute value*/ 880 uint8_t length; 881 /**This contains the attribute value. The maximum value is 240, please refer RSI_DEV_ATT_LEN Macro*/ 882 uint8_t att_value[RSI_DEV_ATT_LEN]; 883 } rsi_ble_prepare_write_resp_t; 884 885 // GATT Profiles list response structure 886 /** 887 * @brief Structure to hold the response for the BLE profiles list command. 888 */ 889 typedef struct rsi_ble_resp_profiles_list_s { 890 /** Number of profiles found */ 891 uint8_t number_of_profiles; 892 /** Reserved */ 893 uint8_t reserved[3]; 894 /** List of found profiles 895 - 896 The maximum value is 5 */ 897 profile_descriptors_t profile_desc[RSI_BLE_MAX_RESP_LIST]; 898 } rsi_ble_resp_profiles_list_t; 899 900 /** 901 * @brief Structure representing the response for querying profile descriptors in BLE. 902 */ 903 typedef struct rsi_ble_resp_query_profile_descriptor_s { 904 /**remote device address*/ 905 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 906 /**List of found profiles 907 - 908 The maximum value is 5 */ 909 profile_descriptors_t profile_desc[RSI_BLE_MAX_RESP_LIST]; 910 } rsi_ble_resp_query_profile_descriptor_t; 911 912 // GATT characteristic query service response structure 913 914 #ifndef RSI_BLE_APIS_H 915 #define RSI_BLE_APIS_H 916 917 #include <stdint.h> 918 919 /** 920 * @brief Structure to hold the response of characteristic services. 921 */ 922 typedef struct rsi_ble_resp_char_serv_s { 923 uint8_t num_of_services; /**< The number of profiles found */ 924 uint8_t reserved[3]; /**< Reserved */ 925 char_serv_t char_services[RSI_BLE_MAX_RESP_LIST]; /**< Characteristic service array. The maximum value is 5. */ 926 } rsi_ble_resp_char_services_t; 927 928 #endif /* RSI_BLE_APIS_H */ 929 /** 930 * @brief Structure to hold the response of characteristic services. 931 */ 932 typedef struct rsi_ble_resp_char_serv_s { 933 /** The number of profiles found */ 934 uint8_t num_of_services; 935 /** Reserved */ 936 uint8_t reserved[3]; 937 /** Characteristic service array. 938 - 939 The maximum value is 5. */ 940 char_serv_t char_services[RSI_BLE_MAX_RESP_LIST]; 941 } rsi_ble_resp_char_services_t; 942 943 // GATT include service response structure 944 /** 945 * @brief Structure representing the response for including a service in BLE. 946 */ 947 typedef struct rsi_ble_resp_inc_serv { 948 /** Number of profiles found */ 949 uint8_t num_of_services; 950 /** Reserved */ 951 uint8_t reserved[3]; 952 /** Include service list. 953 - 954 The maximum value is 5. */ 955 inc_serv_t services[RSI_BLE_MAX_RESP_LIST]; 956 } rsi_ble_resp_inc_services_t; 957 958 // GATT attribute value response structure 959 /** 960 * @brief Structure representing the response for an Attribute Protocol (ATT) value in Bluetooth Low Energy (BLE). 961 */ 962 typedef struct rsi_ble_resp_att_value_t { 963 /** Length of attribute value */ 964 uint8_t len; 965 /** Attribute values list. 966 - 967 Each attribute value is maximum of size 240, see RSI_DEV_ATT_LEN Macro */ 968 uint8_t att_value[RSI_DEV_ATT_LEN]; 969 } rsi_ble_resp_att_value_t; 970 971 // GATT attribute descriptors response structure 972 /** 973 * @brief Structure representing the response for Attribute Descriptors in BLE. 974 */ 975 typedef struct rsi_ble_resp_att_descs_s { 976 /** Number of descriptors found */ 977 uint8_t num_of_att; 978 /** Reserved */ 979 uint8_t reserved[3]; 980 /** Attribute descriptors list. 981 - 982 The maximum value is 5. */ 983 att_desc_t att_desc[RSI_BLE_MAX_RESP_LIST]; 984 } rsi_ble_resp_att_descs_t; 985 986 // add new service response structure 987 /** 988 * @brief Structure representing the response for adding a service in BLE. 989 */ 990 typedef struct rsi_ble_resp_add_serv_s { 991 /** Contains the address of the service record stored in the Silicon Labs stack. */ 992 void *serv_handler; 993 /** The handle from where the service starts. */ 994 uint16_t start_handle; 995 } rsi_ble_resp_add_serv_t; 996 997 // read local attribute value response structure 998 /** 999 * @brief Structure representing the response for local attribute value in BLE. 1000 */ 1001 typedef struct rsi_ble_resp_local_att_value_s { 1002 /** Attribute handle */ 1003 uint16_t handle; 1004 /** Attribute value length */ 1005 uint16_t data_len; 1006 /** Attribute value (data). The maximum value is 240, see RSI_DEV_ATT_LEN Macro */ 1007 uint8_t data[RSI_DEV_ATT_LEN]; 1008 } rsi_ble_resp_local_att_value_t; 1009 1010 /** 1011 * @brief Structure representing the BLE event for remote device information. 1012 * 1013 * This structure is used to define the parameters for a BLE event 1014 * that provides information about a remote device. 1015 */ 1016 typedef struct rsi_ble_event_remote_device_info_s { 1017 /** Remote device address */ 1018 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1019 /** Remote device version */ 1020 uint8_t remote_version; 1021 /** Remote device company ID */ 1022 uint16_t remote_company_id; 1023 /** Remote device sub-version */ 1024 uint16_t remote_sub_version; 1025 } rsi_ble_event_remote_device_info_t; 1026 1027 /** 1028 * @brief Structure representing the BLE event for received Remote Control Protocol (RCP) information. 1029 * 1030 * This structure is used to define the parameters for a BLE event 1031 * that involves receiving RCP information. 1032 */ 1033 typedef struct rsi_ble_event_rcp_rcvd_info_s { 1034 /** Received RCP data */ 1035 uint8_t data[1024]; 1036 } rsi_ble_event_rcp_rcvd_info_t; 1037 // GATT Event structures 1038 1039 // GATT Write event structure 1040 /** 1041 * @brief Structure representing a BLE write event. 1042 */ 1043 typedef struct rsi_ble_event_write_s { 1044 /** remote device address */ 1045 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1046 /** Reserved for future use */ 1047 uint8_t reserved; 1048 1049 /** @addtogroup BT_BLE_CONSTANTS 1050 * @{ 1051 */ 1052 1053 /// BLE write command event 1054 #define RSI_BLE_WRITE_CMD_EVENT 0x01 1055 /// BLE write request event 1056 #define RSI_BLE_WRITE_REQUEST_EVENT 0x02 1057 /// BLE notification event 1058 #define RSI_BLE_NOTIFICATION_EVENT 0x03 1059 /// BLE indication event 1060 #define RSI_BLE_INDICATION_EVENT 0x04 1061 /** @} */ 1062 /**Type of the event received from the remote device 1063 - 1064 RSI_BLE_WRITE_CMD_EVENT 0x01 1065 - 1066 RSI_BLE_WRITE_REQUEST_EVENT 0x02 1067 - 1068 RSI_BLE_NOTIFICATION_EVENT 0x03 1069 - 1070 RSI_BLE_INDICATION_EVENT 0x04 */ 1071 uint8_t pkt_type; 1072 /**attribute handle*/ 1073 uint8_t handle[2]; 1074 /**length of attribute value*/ 1075 uint8_t length; 1076 /**This contains the attribute value. The maximum value is 240, see RSI_DEV_ATT_LEN Macro*/ 1077 uint8_t att_value[RSI_DEV_ATT_LEN]; 1078 } rsi_ble_event_write_t; 1079 1080 // GATT prepare Write event structure 1081 /** 1082 * @brief Structure definition for preparing a write operation in BLE event. 1083 */ 1084 typedef struct rsi_ble_event_prepare_write_s { 1085 1086 /**remote device address*/ 1087 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1088 /**attribute handle*/ 1089 uint8_t handle[2]; 1090 /**attribute value offset*/ 1091 uint8_t offset[2]; 1092 /**length of attribute value*/ 1093 uint16_t length; 1094 /**This contains the attribute value. The maximum value is 240, see RSI_DEV_ATT_LEN Macro*/ 1095 uint8_t att_value[RSI_DEV_ATT_LEN]; 1096 } rsi_ble_event_prepare_write_t; 1097 1098 /** 1099 * @brief Structure representing the BLE execute write request. 1100 * 1101 * This structure is used to define the parameters for an execute write request 1102 * to a remote BLE device. 1103 */ 1104 typedef struct rsi_ble_execute_write_s { 1105 /** Remote device address (6 bytes) */ 1106 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1107 /** Execute write flag */ 1108 uint8_t exeflag; 1109 } rsi_ble_execute_write_t; 1110 1111 // GATT Read event structure 1112 1113 /** 1114 * @brief Structure representing the BLE read request. 1115 * 1116 * This structure is used to define the parameters for a BLE read request, 1117 * including the remote device address, attribute handle, request type, and offset. 1118 */ 1119 typedef struct rsi_ble_read_req_s { 1120 /** Remote device address */ 1121 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1122 /** Attribute handle */ 1123 uint16_t handle; 1124 /** Request type: 0 - Read request, 1 - Read Blob request */ 1125 uint8_t type; 1126 /** Reserved for future use */ 1127 uint8_t reserved; 1128 /** Offset of attribute value to be read */ 1129 uint16_t offset; 1130 } rsi_ble_read_req_t; 1131 1132 // GATT MTU event structure 1133 /** 1134 * @brief Structure to hold the BLE MTU event information. 1135 */ 1136 typedef struct rsi_ble_event_mtu_s { 1137 1138 /**remote device address*/ 1139 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1140 /**MTU size*/ 1141 uint16_t mtu_size; 1142 } rsi_ble_event_mtu_t; 1143 /** @addtogroup BT_BLE_CONSTANTS 1144 * @{ 1145 */ 1146 #define PEER_DEVICE_INITATED_MTU_EXCHANGE 0x1 ///< Indicates that the MTU exchange was initiated by the peer device. 1147 #define LOCAL_DEVICE_INITATED_MTU_EXCHANGE 0x2 ///< Indicates that the MTU exchange was initiated by the local device. 1148 /** @} */ 1149 //MTU Exchange Information event structure 1150 /** 1151 * @brief Structure to hold the MTU exchange information for a BLE event. 1152 */ 1153 typedef struct rsi_ble_event_mtu_exchange_information_s { 1154 /**uint8_t[6], remote device address*/ 1155 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1156 /**uint8_t[2], Remote MTU Size*/ 1157 uint16_t remote_mtu_size; 1158 /**uint8_t[2], Local MTU Size*/ 1159 uint16_t local_mtu_size; 1160 /**uint8_t Initiated role, who initiated MTU exchange 1161 - 1162 PEER_DEVICE_INITATED_MTU_EXCHANGE 0x01 1163 - 1164 LOCAL_DEVICE_INITATED_MTU_EXCHANGE 0x02 */ 1165 uint8_t initiated_role; 1166 } rsi_ble_event_mtu_exchange_information_t; 1167 // GATT Notification event structure 1168 /** 1169 * @brief Structure for BLE event notification. 1170 */ 1171 typedef struct rsi_ble_event_notify_s { 1172 1173 /**remote device address*/ 1174 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1175 /**attribute handle*/ 1176 uint8_t handle[2]; 1177 /**length of attribute value*/ 1178 uint8_t length; 1179 /**This contains the attribute value. The maximum value is 240, see RSI_DEV_ATT_LEN Macro*/ 1180 uint8_t att_value[RSI_DEV_ATT_LEN]; 1181 } rsi_ble_event_notify_t; 1182 1183 // GATT Indication event structure 1184 1185 /** 1186 * @brief Structure representing the BLE event for an indication. 1187 * 1188 * This structure is used to define the parameters for a BLE event 1189 * that involves an indication from a remote device. 1190 */ 1191 typedef struct rsi_ble_event_indication_s { 1192 /** Remote device address */ 1193 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1194 /** Attribute handle */ 1195 uint8_t handle[2]; 1196 /** Length of attribute value */ 1197 uint8_t length; 1198 /** This contains the attribute value. The maximum value is 240, see RSI_DEV_ATT_LEN Macro */ 1199 uint8_t att_value[RSI_DEV_ATT_LEN]; 1200 } rsi_ble_event_indication_t; 1201 1202 /** 1203 * @brief Structure to hold the information of a directed advertising report event. 1204 */ 1205 typedef struct rsi_ble_event_directedadv_report_s { 1206 /**Event type 1207 - 1208 0x01 Connectable directed advertising (ADV_DIRECT_IND) */ 1209 uint16_t event_type; 1210 /**Address type of remote device*/ 1211 uint8_t dev_addr_type; 1212 /**Address of the remote device*/ 1213 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1214 /**Directed address type*/ 1215 uint8_t directed_addr_type; 1216 /**Directed device address*/ 1217 uint8_t directed_dev_addr[RSI_DEV_ADDR_LEN]; 1218 /**rssi value*/ 1219 int8_t rssi; 1220 } rsi_ble_event_directedadv_report_t; 1221 1222 /** 1223 * @brief Structure representing the BLE event for CBFC connection request. 1224 * 1225 * This structure is used to define the parameters for a BLE event 1226 * that involves a Circular Buffer Flow Control (CBFC) connection request from a remote device. 1227 */ 1228 typedef struct rsi_ble_event_cbfc_conn_req_s { 1229 /** Address of the remote device */ 1230 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1231 /** Protocol/Service Multiplexer (PSM) value */ 1232 uint16_t psm; 1233 /** Local Channel Identifier (LCID) */ 1234 uint16_t lcid; 1235 } rsi_ble_event_cbfc_conn_req_t; 1236 1237 /** 1238 * @brief Structure representing the BLE event for CBFC connection complete. 1239 * 1240 * This structure is used to define the parameters for a BLE event 1241 * that indicates the completion of a Circular Buffer Flow Control (CBFC) connection with a remote device. 1242 */ 1243 typedef struct rsi_ble_event_cbfc_conn_complete_s { 1244 /** Address of the remote device */ 1245 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1246 /** Protocol/Service Multiplexer (PSM) value */ 1247 uint16_t psm; 1248 /** Maximum Transmission Unit (MTU) size */ 1249 uint16_t mtu; 1250 /** Maximum PDU Size (MPS) */ 1251 uint16_t mps; 1252 /** Local Channel Identifier (LCID) */ 1253 uint16_t lcid; 1254 } rsi_ble_event_cbfc_conn_complete_t; 1255 1256 /** 1257 * @brief Structure representing the BLE event for CBFC received data. 1258 * 1259 * This structure is used to define the parameters for a BLE event 1260 * that involves receiving data over a Circular Buffer Flow Control (CBFC) connection from a remote device. 1261 */ 1262 typedef struct rsi_ble_event_cbfc_rx_data_s { 1263 /** Address of the remote device */ 1264 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1265 /** Local Channel Identifier (LCID) */ 1266 uint16_t lcid; 1267 /** Length of the received data */ 1268 uint16_t len; 1269 /** Received data */ 1270 uint8_t data[RSI_DEV_ATT_LEN]; 1271 } rsi_ble_event_cbfc_rx_data_t; 1272 1273 /** 1274 * @brief Structure representing the BLE event for CBFC disconnection. 1275 * 1276 * This structure is used to define the parameters for a BLE event 1277 * that involves the disconnection of a Circular Buffer Flow Control (CBFC) connection with a remote device. 1278 */ 1279 typedef struct rsi_ble_event_cbfc_disconn_s { 1280 /** Address of the remote device */ 1281 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1282 /** Local Channel Identifier (LCID) */ 1283 uint16_t lcid; 1284 } rsi_ble_event_cbfc_disconn_t; 1285 1286 /** @addtogroup BT-LOW-ENERGY1 GAP 1287 * @{ */ 1288 // SMP pairing capabilities cmd_ix = 0x00FE 1289 /** 1290 * @brief Structure for setting SMP pairing capability data. 1291 */ 1292 typedef struct rsi_ble_set_smp_pairing_capabilty_data { 1293 1294 /**Device input output capability 1295 - 1296 0x00 - Display Only 1297 - 1298 0x01 - Display Yes/No 1299 - 1300 0x02 - Keyboard Only 1301 - 1302 0x03 - No Input No Output 1303 0x04 - Keyboard Display*/ 1304 uint8_t io_capability; 1305 /** oob_data_flag 1306 - 1307 0 - disable 1308 - 1 - enable */ 1309 uint8_t oob_data_flag; 1310 /** Authentication Request contains bonding type 1311 - 1312 MITM Request - BIT(2) 1313 - 1314 Secure Connections - BIT(3) 1315 - 1316 Keypress - BIT(4) 1317 - 1318 CT2 - BIT(5) */ 1319 uint8_t auth_req; 1320 /** Supported Encryption key size 7 to 16 bytes */ 1321 uint8_t enc_key_size; 1322 /** Initiator generates/requires the no .of keys after successful paring 1323 - 1324 BIT(0) - EncKey: Initiator distributes the LTK followed by EDIV and Rand 1325 - 1326 BIT(1) - IdKey : Initiator distributes the IRK followed by its address 1327 - 1328 BIT(2) - Sign : Initiator distributes the CSRK 1329 - 1330 BIT(3) - BIT(7): Reserved for future use */ 1331 uint8_t ini_key_distribution; 1332 /** Responder generates/requires the no .of keys after successful paring 1333 - 1334 BIT(0) - EncKey: Responder distributes the LTK followed by EDIV and Rand 1335 - 1336 BIT(1) - IdKey : Responder distributes the IRK followed by its address 1337 - 1338 BIT(2) - Sign : Responder distributes the CSRK 1339 - 1340 BIT(3) - BIT(7): Reserved for future use */ 1341 uint8_t rsp_key_distribution; 1342 1343 } rsi_ble_set_smp_pairing_capabilty_data_t; 1344 1345 //LE read PHY request command response structure, cmd_ix - 0x00B0 1346 1347 /** 1348 * @brief Structure to hold the response for the BLE read PHY command. 1349 */ 1350 typedef struct rsi_ble_resp_read_phy_s { 1351 /** Remote device Bluetooth Address*/ 1352 uint8_t dev_addr[RSI_DEV_ADDR_LEN]; 1353 /** TX PHY Rate 1354 - 1355 0x01 The transmitter PHY for the connection is LE 1M 1356 - 1357 0x02 The transmitter PHY for the connection is LE 2M 1358 - 1359 0x03 The transmitter PHY for the connection is LE Coded 1360 - 1361 All other values Reserved for future use*/ 1362 uint8_t tx_phy; 1363 /** RX PHY Rate 1364 - 1365 0x01 The receiver PHY for the connection is LE 1M 1366 - 1367 0x02 The receiver PHY for the connection is LE 2M 1368 - 1369 0x03 The receiver PHY for the connection is LE Coded 1370 - 1371 All other values Reserved for future use*/ 1372 uint8_t rx_phy; 1373 } rsi_ble_resp_read_phy_t; 1374 1375 //LE read max data length command response structure, cmd_ix - 0x00B3 1376 /** 1377 * @brief Structure representing the response for reading the maximum data length in BLE. 1378 */ 1379 typedef struct rsi_ble_resp_read_max_data_length_s { 1380 /** maxtxoctets 1381 - 1382 Preferred maximum number of payload octets that the local Controller should 1383 include in a single Link Layer packet on this connection. */ 1384 uint16_t maxtxoctets; 1385 /** maxtxtime 1386 - 1387 Preferred maximum number of microseconds that the local Controller 1388 should use to transmit a single Link Layer packet on this connection */ 1389 uint16_t maxtxtime; 1390 /** maxrxoctets 1391 - 1392 Maximum number of payload octets that the local Controller supports 1393 for reception of a single Link Layer packet on a data connection */ 1394 uint16_t maxrxoctets; 1395 /** maxrxtime 1396 - 1397 Maximum time, in microseconds, that the local Controller supports for 1398 reception of a single Link Layer packet on a data connection. */ 1399 uint16_t maxrxtime; 1400 } rsi_ble_read_max_data_length_t; 1401 1402 /** @} */ 1403 1404 /** @addtogroup BT-LOW-ENERGY6 Test Mode 1405 * @{ */ 1406 //LE Per Transmit mode, cmd_ix = 0x00BE 1407 1408 /** 1409 * @brief Structure to hold the parameters for BLE periodic advertising transmission. 1410 */ 1411 typedef struct rsi_ble_per_transmit_s { 1412 /** Command ID 1413 - 1414 Takes per BLE_TRANSMIT_CMD_ID of value 0x13*/ 1415 uint8_t cmd_ix; 1416 /** Enables/disables the BLE per transmit mode 1417 - 1418 1 PER Transmit Enable 1419 - 1420 0 PER Transmit Disable */ 1421 uint8_t transmit_enable; 1422 /** Access address with which packets are transmitted */ 1423 uint8_t access_addr[4]; 1424 /** Phy rate at which packets are transmitted 1425 - 1426 1 1Mbps 1427 - 1428 2 2 Mbps 1429 - 1430 4 125 Kbps Coded 1431 - 1432 8 500 Kbps Coded */ 1433 uint8_t phy_rate; 1434 /** Rx channel number (0 - 39) 1435 @note Removed the BLE packet transmission on channel-39 (2480MHz) at a 2Mbps data rate */ 1436 uint8_t rx_chnl_num; 1437 /** Tx channel number (0 - 39) 1438 @note Removed the BLE packet transmission on channel-39 (2480MHz) at a 2Mbps data rate */ 1439 uint8_t tx_chnl_num; 1440 /** Initial seed to be used for whitening. It should be set to 0 in order to disable whitening. 1441 - 1442 In order to enable, one should give the scrambler seed value which is used on the receive side */ 1443 uint8_t scrambler_seed; 1444 /** LE channel type (data or advertise channel) 1445 - 1446 0x00 Advertise Channel 1447 - 1448 0x01 Data Channel (to be used by Default) */ 1449 uint8_t le_chnl_type; 1450 /** Frequency hopping type to be used 1451 - 1452 0 No Hopping 1453 - 1454 1 Fixed Hopping 1455 - 1456 2 Random Hopping (rx_chnl_num, tx_chnl_num parameters are unused in this mode) */ 1457 uint8_t freq_hop_en; 1458 /** Select the antenna to be used. Refer to the data sheet for your hardware to check whether or not it contains an onboard antenna. 1459 - 1460 2 ONBOARD_ANT_SEL 1461 - 1462 3 EXT_ANT_SEL */ 1463 uint8_t ant_sel; 1464 /** pll_mode type to be used 1465 - 1466 0 PLL_MODE0 (to be used by Default) 1467 - 1468 1 PLL_MODE1 */ 1469 uint8_t pll_mode; 1470 /** Selection of RF type (internal/external) 1471 - 1472 0 BT_EXTERNAL_RF 1473 - 1474 1 BT_INTERNAL_RF (to be used by Default) 1475 @note The above macros are applicable for both BT and BLE */ 1476 uint8_t rf_type; 1477 /** Selection of RF Chain (HP/LP) to be used 1478 - 1479 2 BT_HP_CHAIN 1480 - 1481 3 BT_LP_CHAIN 1482 @note The above macros are applicable for both BT and BLE */ 1483 uint8_t rf_chain; 1484 /** Length of the packet to be transmitted*/ 1485 uint8_t pkt_len[2]; 1486 /** Type of payload data sequence 1487 - 1488 0x00 PRBS9 sequence �11111111100000111101... 1489 - 1490 0x01 Repeated �11110000� 1491 - 1492 0x02 Repeated �10101010� 1493 - 1494 0x03 PRBS15 1495 - 1496 0x04 Repeated �11111111� 1497 - 1498 0x05 Repeated �00000000� 1499 - 1500 0x06 Repeated '00001111' 1501 - 1502 0x07 Repeated '01010101' */ 1503 uint8_t payload_type; 1504 /** Transmit Power 1505 - 1506 Default Value for BLE TX Power Index is 31, The range for the BLE TX Power Index is 1 to 127 (0, 32 indexes are invalid). 1507 - 1508 TX power index for the BLE LP Chain : 1 to 31 (0dBm Mode), 33 to 63 ( 10dBm Mode) 1509 - 1510 TX power index for the BLE HP Chain : 1 to 127 1511 - 1512 @note For the LP Chain - Power index vs Outpt power in dBm. 1513 1514 * ----------------------------------------------------------------------------------------- 1515 * | Power Index | Output Power in dBm | 1516 * ----------------------|------------------------------------------------------------------- 1517 * | 1 | -22.3054959 | 1518 * | 2 | -16.59332574 | 1519 * | 3 | -13.38278365 | 1520 * | 4 | -11.19804718 | 1521 * | 5 | -9.576522466 | 1522 * | 6 | -8.312070432 | 1523 * | 7 | -7.294640362 | 1524 * | 8 | -6.458448154 | 1525 * | 9 | -5.760963318 | 1526 * | 10 | -5.173042366 | 1527 * | 11 | -4.673788189 | 1528 * | 12 | -4.247653993 | 1529 * | 13 | -3.882708784 | 1530 * | 14 | -3.569545894 | 1531 * | 15 | -3.300567503 | 1532 * | 16 | -3.069499167 | 1533 * | 17 | -2.871050592 | 1534 * | 18 | -2.700672503 | 1535 * | 19 | -2.554378603 | 1536 * | 20 | -2.428612817 | 1537 * | 21 | -2.32014891 | 1538 * | 22 | -2.226013876 | 1539 * | 23 | -2.143429275 | 1540 * | 24 | -2.069766557 | 1541 * | 25 | -2.002513642 | 1542 * | 26 | -1.939250859 | 1543 * | 27 | -1.87763493 | 1544 * | 28 | -1.815390046 | 1545 * | 29 | -1.750305305 | 1546 * | 30 | -1.680237892 | 1547 * | 31 | -1.603121401 | 1548 * | 32 | NA | 1549 * | 33 | -10.4822997 | 1550 * | 34 | -4.9531679 | 1551 * | 35 | -1.931961022 | 1552 * | 36 | 0.057132993 | 1553 * | 37 | 1.476764101 | 1554 * | 38 | 2.5332116 | 1555 * | 39 | 3.336771823 | 1556 * | 40 | 3.953605265 | 1557 * | 41 | 4.426779615 | 1558 * | 42 | 4.786171523 | 1559 * | 43 | 5.053647759 | 1560 * | 44 | 5.246007208 | 1561 * | 45 | 5.37676618 | 1562 * | 46 | 5.457304255 | 1563 * | 47 | 5.497635316 | 1564 * | 48 | 5.506945838 | 1565 * | 49 | 5.493978354 | 1566 * | 50 | 5.467302132 | 1567 * | 51 | 5.435491631 | 1568 * | 52 | 5.407220119 | 1569 * | 53 | 5.391268248 | 1570 * | 54 | 5.396444507 | 1571 * | 55 | 5.431416481 | 1572 * | 56 | 5.504458826 | 1573 * | 57 | 5.62313521 | 1574 * | 58 | 5.793945208 | 1575 * | 59 | 6.02197959 | 1576 * | 60 | 6.310634089 | 1577 * | 61 | 6.661428559 | 1578 * | 62 | 7.073964236 | 1579 * | 63 | 7.546029076 | 1580 * ----------------------------------------------------------------------------------------- 1581 - 1582 @note For the HP Chain - Power index vs Outpt power in dBm. 1583 1584 * ----------------------------------------------------------------------------------------- 1585 * | Power Index | Output Power in dBm | 1586 * ----------------------|------------------------------------------------------------------- 1587 * | 1 | 1 | 1588 * | 2 | 2 | 1589 * | 3 | 3 | 1590 * | 4 | 4 | 1591 * | 5 | 5 | 1592 * | 6 | 6 | 1593 * | 7 | 7 | 1594 * | 8 | 8 | 1595 * | 9 | 9 | 1596 * | 10 | 10 | 1597 * | - | - | 1598 * | - | - | 1599 * | - | - | 1600 * | - | - | 1601 * | 41 | 0.5 | 1602 * | 42 | 1 | 1603 * | 43 | 1.5 | 1604 * | 44 | 2 | 1605 * | 45 | 2.5 | 1606 * | 46 | 3 | 1607 * | 47 | 3.5 | 1608 * | 48 | 4 | 1609 * | 49 | 4.5 | 1610 * | 50 | 5 | 1611 * | - | - | 1612 * | - | - | 1613 * | 127 | (Max Power Supported by Country region) | 1614 * ----------------------|------------------------------------------------------------------- 1615 */ 1616 1617 uint8_t tx_power; 1618 /** Transmit mode to be used either Burst/Continuous 1619 - 1620 0 BURST_MODE 1621 - 1622 1 CONTINUOUS_MODE 1623 - 1624 2 CONTINUOUS_WAVE_MODE (CW_MODE) */ 1625 uint8_t transmit_mode; 1626 /** This field takes the value of inter packet gap. 1627 - 1628 Number of slots to be skipped between two packets - Each slot will be 1250 usec */ 1629 uint8_t inter_pkt_gap; 1630 /** This field defines the number of packets to be transmitted, default to zero for continuous transmission */ 1631 uint8_t num_pkts[4]; 1632 } rsi_ble_per_transmit_t; 1633 1634 //LE Per Receive mode, cmd_ix = 0x00BF 1635 /** 1636 * @brief Structure representing the parameters for BLE periodic receive operation. 1637 */ 1638 typedef struct rsi_ble_per_receive_s { 1639 /** Command ID 1640 - 1641 Takes per BLE_RECEIVE_CMD_ID of value 0x14*/ 1642 uint8_t cmd_ix; 1643 /** Enables/disables the ble per receive mode 1644 - 1645 1 PER Receive Enable 1646 - 1647 0 PER Receive Disable */ 1648 uint8_t receive_enable; 1649 /** Access address with which packets are received */ 1650 uint8_t access_addr[4]; 1651 /** Phy rate at which packets are received 1652 - 1653 1 1Mbps 1654 - 1655 2 2 Mbps 1656 - 1657 4 125 Kbps Coded 1658 - 1659 8 500 Kbps Coded */ 1660 uint8_t phy_rate; 1661 /** Rx channel number (0 - 39) */ 1662 uint8_t rx_chnl_num; 1663 /** Tx channel number (0 - 39) */ 1664 uint8_t tx_chnl_num; 1665 /** Initial seed to be used for whitening. It should be set to 0 in order to disable whitening. 1666 - 1667 In order to enable, one should give the scrambler seed value which is used on the transmit side */ 1668 uint8_t scrambler_seed; 1669 /** LE channel type (data or advertise channel) 1670 - 1671 0x00 Advertise Channel 1672 - 1673 0x01 Data Channel (to be used by Default) */ 1674 uint8_t le_chnl_type; 1675 /** Frequency hopping type to be used 1676 - 1677 0 No Hopping 1678 - 1679 1 Fixed Hopping 1680 - 1681 2 Random Hopping (rx_chnl_num, tx_chnl_num parameters are unused in this mode) */ 1682 uint8_t freq_hop_en; 1683 /** Select the antenna to be used. Refer to the datasheet for your hardware to check whether or not it contains an onboard antenna. 1684 - 1685 2 ONBOARD_ANT_SEL 1686 - 1687 3 EXT_ANT_SEL */ 1688 uint8_t ant_sel; 1689 /** pll_mode type to be used 1690 - 1691 0 PLL_MODE0 (to be used by Default) 1692 - 1693 1 PLL_MODE1 */ 1694 uint8_t pll_mode; 1695 /** Selection of RF type (internal/external) 1696 - 1697 0 BT_EXTERNAL_RF 1698 - 1699 1 BT_INTERNAL_RF (to be used by Default) 1700 @note The above macros are applicable for both BT and BLE */ 1701 uint8_t rf_type; 1702 /** Selection of RF Chain (HP/LP) to be used 1703 - 1704 2 BT_HP_CHAIN 1705 - 1706 3 BT_LP_CHAIN 1707 @note The above macros are applicable for both BT and BLE */ 1708 uint8_t rf_chain; 1709 /** This field enables/disables the extended data length 1710 - 1711 0 Extended Data length disabled 1712 - 1713 1 Extended Data length enabled */ 1714 uint8_t ext_data_len_indication; 1715 /** This field defines the loopback to be enable or disable 1716 - 1717 0 LOOP_BACK_MODE_DISABLE 1718 - 1719 1 LOOP_BACK_MODE_ENABLE*/ 1720 uint8_t loop_back_mode; 1721 /** This field enables/disables the duty cycling 1722 - 1723 0 Duty Cycling Disabled (to be used by Default) 1724 - 1725 1 Duty Cycling Enabled */ 1726 uint8_t duty_cycling_en; 1727 } rsi_ble_per_receive_t; 1728 /** @} */ 1729 /** @addtogroup BT_BLE_CONSTANTS 1730 * @{ 1731 */ 1732 1733 ///The maximum length of advertising data. 1734 #define ADV_DATA_LEN 210 1735 ///Length of the device address in bytes. 1736 #define DEVICE_ADDR_LEN 6 1737 /** @} */ 1738 //! ae adv report event 1739 typedef struct rsi_ble_ae_adv_report_s { 1740 /** 1741 * ----------------------------------------------------------------------------------------- 1742 * | Bit Number | Parameter Description | 1743 * ----------------------|------------------------------------------------------------------- 1744 * | 0 | Connectable Advertising | 1745 * | 1 | Scannable Advertising | 1746 * | 2 | Direct Advertising | 1747 * | 3 | Scan Response | 1748 * | 4 | Legacy Advertising PDUs used | 1749 * | 5 to 6 | Data status : 1750 * | 1751 * | | 0b00 = complete 1752 * | 1753 * | | 0b01 = Incomplete, more data to come 1754 * | 1755 * | | 0b10 = Incomplete, data truncated, no more to come 1756 *| 1757 * | | 0b11 = Reserved for future use | 1758 */ 1759 uint16_t event_type; 1760 /** 1761 uint8_t Remote Address Type, Indicates the type of the Address 1762 0x00 - Public Device Address 1763 0x01 - Random Device Address 1764 0x02 - Public Identity Address (corresponds to Resolved Private Address) 1765 0x03 - Random (static) Identity Address (corresponds to Resolved Private Address) 1766 */ 1767 uint8_t remote_addr_type; 1768 /** uint8[6] remote_Address : Address of the remote address Type */ 1769 uint8_t remote_addr[DEVICE_ADDR_LEN]; 1770 /** 1771 uint8_t Primary PHY 1772 0x01 - Advertiser PHY is LE 1M 1773 0x03 - Advertiser PHY is LE Coded 1774 */ 1775 uint8_t pri_phy; 1776 /** 1777 uint8_t Secondary PHY 1778 0x00 - No packets on the secondary advertising physical channel 1779 0x01 - Advertiser PHY is LE 1M 1780 0x02 - Advertiser PHY is LE 2M 1781 0x03 - Advertiser PHY is LE Coded 1782 */ 1783 uint8_t sec_phy; 1784 /** uint8_t Advertising_SID 1785 * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1786 * | Value | Parameter Description | 1787 * ----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1788 * | 0x00 to 0x0F | Value of the Advertising SID subfield in the ADI field of the PDU or, 1789 * for scan responses, in the ADI field of the original scannable advertisement | 1790 * | 0xFF | No ADI field provided | 1791 * 1792 */ 1793 uint8_t SID; 1794 /** 1795 uint8_t TX_Power, It shall be set based on the AUX_SYNC_IND PDU 1796 TX_Power ranges from -127 to +20 and it's units is in dBm 1797 */ 1798 uint8_t tx_power; 1799 /** 1800 uint8_t RSSI , this parameter contains the RSSI value, excluding any constant tone Extension. 1801 RSSI ranges from -127 to +20 and it's units is in dBm 1802 */ 1803 uint8_t RSSI; 1804 /** uint16_t Periodic_Advertising_Interval. This parameter specifies the interval between the periodic advertising events */ 1805 uint16_t per_adv_interval; 1806 /** 1807 uint8_t Direct Address Type ,Indicates the type of the Address 1808 0x00 - Public Device Address 1809 0x01 - Random Device Address 1810 0x02 - Public Identity Address (corresponds to Resolved Private Address) 1811 0x03 - Random (static) Identity Address (corresponds to Resolved Private Address) 1812 0xFE - Resolves Private Address 1813 */ 1814 uint8_t direct_addr_type; 1815 /** uint8[6] Direct_Address, Direct_Address of the Advertiser type */ 1816 uint8_t direct_addr[DEVICE_ADDR_LEN]; 1817 /** uint8_t Data _length , Length of the Data field for each device which responded , ranges from 0 to 229 */ 1818 uint8_t data_len; 1819 /** uint8[256] Data */ 1820 uint8_t data[ADV_DATA_LEN]; 1821 } rsi_ble_ae_adv_report_t; 1822 1823 //! ae periodic sync establishment report event 1824 typedef struct rsi_ble_per_adv_sync_estbl_s { 1825 /** 1826 uint8_t status , It indicates whether Periodic Advertising is successful or not 1827 0 - Periodic advertising sync successful 1828 !0 - Periodic advertising sync failed 1829 */ 1830 uint8_t status; 1831 /** uint16_t Sync_Handle, It identifies the periodic Advertising train. Range : 0x0000 to 0x0EFF */ 1832 uint16_t sync_handle; 1833 /** uint8_t Advertising_SID, Value of the Advertising SID subfield in the ADI field of the PDU, Range : 0x00 to 0x0F */ 1834 uint8_t adv_sid; 1835 /** 1836 uint8_t Advertiser_Address_Type : Indicates the type of the Address 1837 0x00 - Public Device Address 1838 0x01 - Random Device Address 1839 0x02 - Public Identity Address (corresponds to Resolved Private Address) 1840 0x03 - Random (static) Identity Address (corresponds to Resolved Private Address) 1841 */ 1842 uint8_t advertiser_addr_type; 1843 /** uint8[6], Advertiser_Address of the Advertiser type */ 1844 uint8_t advertiser_addr[DEVICE_ADDR_LEN]; 1845 /** 1846 uint8_t Advertiser_PHY. This parameter specifies the PHY used for the periodic advertising. 1847 0x01 - Advertiser PHY is LE 1M 1848 0x02 - Advertiser PHY is LE 2M 1849 0x03 - Advertiser PHY is LE Coded 1850 */ 1851 uint8_t advertiser_phy; 1852 /** uint16_t Periodic_Advertising_Interval. This parameter specifies the interval between the periodic advertising events. */ 1853 uint16_t per_adv_interval; 1854 /** 1855 uint16_t Advertiser_Clock_Accuracy. This parameter specifies the accuracy of the periodic advertiser's clock. 1856 0x00 - 500ppm 1857 0x01 - 250ppm 1858 0x02 - 150ppm 1859 0x03 - 100 ppm 1860 0x04 - 75 ppm 1861 0x05 - 50 ppm 1862 0x06 - 30 ppm 1863 0x07 - 20 ppm 1864 */ 1865 uint16_t advertiser_clock_accuracy; 1866 } rsi_ble_per_adv_sync_estbl_t; 1867 1868 //! ae periodic adv report event 1869 typedef struct rsi_ble_per_adv_report_s { 1870 /** uint16_t Sync_Handle, It identifies the periodic Advertising train. Range : 0x0000 to 0x0EFF */ 1871 uint16_t sync_handle; 1872 /** int8_t TX_Power, It shall be set based on the AUX_SYNC_IND PDU 1873 TX_Power ranges from -127 to +20 and it's units is in dBm 1874 */ 1875 int8_t tx_power; 1876 /** int8_t RSSI , this parameter contains the RSSI value, excluding any constant tone Extension. 1877 RSSI ranges from -127 to +20 and it's units is in dBm 1878 */ 1879 int8_t RSSI; 1880 /** Unused byte for alignment */ 1881 uint8_t unused; 1882 /** 1883 uint8_t Data_Status, It specifies about the status of the data sent 1884 0x00 - Data Complete 1885 0x01 - Data Incomplete, more Data to come 1886 */ 1887 uint8_t data_status; 1888 /** uint8_t Data_Length ,Length of the Data Field, Ranges from 0 to 247 */ 1889 uint8_t data_len; 1890 /** uint8[256] Data, Data received from a Periodic Advertising Packet */ 1891 uint8_t data[ADV_DATA_LEN]; 1892 } rsi_ble_per_adv_report_t; 1893 1894 //! ae periodic sync lost report event 1895 typedef struct rsi_ble_per_adv_sync_lost_s { 1896 /** uint16_t Sync_Handle, It identifies the periodic Advertising train. Range : 0x0000 to 0x0EFF */ 1897 uint16_t sync_handle; 1898 } rsi_ble_per_adv_sync_lost_t; 1899 1900 //! ae scan timeout report event 1901 typedef struct rsi_ble_scan_timeout_s { 1902 /** uint8_t status , Status indicates that scanning has ended because the duration has expired */ 1903 uint8_t status; 1904 } rsi_ble_scan_timeout_t; 1905 1906 //! ae adv set terminated report event 1907 typedef struct rsi_ble_adv_set_terminated_s { 1908 /** uint8_t status : Status shows the status on how the Advertising ended 1909 0 - Advertising successfully ended with a connection being created 1910 !0 - Advertising ended for another reason and usually error codes would be listed 1911 */ 1912 uint8_t status; 1913 /** uint8_t Advertising_Handle : Advertising_Handle in which Advertising has ended, Range : 0x00 to 0xEF */ 1914 uint8_t adv_handle; 1915 /** uint16_t Connection_Handle : It is the Connection Handle of the connection whose creation ended the advertising, Range : 0x00 to 0xEF */ 1916 uint16_t conn_handle; 1917 /** 1918 uint8_t Num_Completed_Extended_Advertising_Events 1919 Number of completed extended advertising events transmitted by the Controller 1920 */ 1921 uint8_t num_completed_ae_events; 1922 } rsi_ble_adv_set_terminated_t; 1923 1924 //! ae scan request recvd report event 1925 typedef struct rsi_ble_scan_req_recvd_s { 1926 /** uint8_t Advertising_Handle : Used to identify an Advertising set , Range : 0x00 to 0xEF */ 1927 uint8_t adv_handle; 1928 /** 1929 uint8_t Scanner_Address_Type : Indicates the type of the Address 1930 0x00 - Public Device Address 1931 0x01 - Random Device Address 1932 0x02 - Public Identity Address (corresponds to Resolved Private Address) 1933 0x03 - Random (static) Identity Address (corresponds to Resolved Private Address) 1934 */ 1935 uint8_t scanner_addr_type; 1936 /** uint8[6] Scanner_Address : Address of the Advertising Type */ 1937 uint8_t scanner_addr[DEVICE_ADDR_LEN]; 1938 } rsi_ble_scan_req_recvd_t; 1939 1940 /****************************************************** 1941 * * Global Variables 1942 * ******************************************************/ 1943 /** 1944 * @brief Structure representing the BLE buffer statistics. 1945 * 1946 * This structure is used to define the parameters for BLE buffer statistics, 1947 * including the utilization of Asynchronous Connection-Less (ACL) buffers and command packet buffers. 1948 */ 1949 typedef struct chip_ble_buffers_stats_s { 1950 /** Utilization of ACL (Asynchronous Connection-Less) buffers*/ 1951 uint8_t acl_buffer_utilization; 1952 /** Utilization of command packet buffers */ 1953 uint8_t cp_buffer_utilization; 1954 } chip_ble_buffers_stats_t; 1955 1956 /****************************************************** 1957 * * GAP API's Declarations 1958 * ******************************************************/ 1959 1960 #ifdef __cplusplus 1961 extern "C" { 1962 #endif 1963 1964 /** 1965 * @fn uint8_t rsi_convert_db_to_powindex(int8_t tx_power_in_dBm) 1966 * @brief Converts the given transmit power in dBm to power index. 1967 * 1968 * This function takes a transmit power value in dBm and converts it to a power index value. 1969 * The power index is used to set the transmit power level in the BLE module. 1970 * 1971 * @param tx_power_in_dBm The transmit power in dBm. 1972 * @return The power index corresponding to the given transmit power. 1973 */ 1974 uint8_t rsi_convert_db_to_powindex(int8_t tx_power_in_dBm); 1975 1976 /** @addtogroup BT-LOW-ENERGY1 1977 * @{ 1978 */ 1979 /*==============================================*/ 1980 /** 1981 * @fn int32_t rsi_ble_set_random_address(void) 1982 * @brief Request the local device to set a random address. This is a blocking API. 1983 * @pre Pre-conditions: 1984 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 1985 * @return The following values are returned: 1986 * * - 0 - Success 1987 * Non-Zero Value - Failure 1988 * If the return value is less than 0 1989 * -4 - Buffer not available to serve the command 1990 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 1991 */ 1992 int32_t rsi_ble_set_random_address(void); 1993 1994 /*==============================================*/ 1995 /** 1996 * @fn int32_t rsi_ble_set_random_address_with_value(uint8_t *random_addr) 1997 * @brief Request the local device to set a given random address. This is a blocking API. 1998 * @pre Pre-condition: 1999 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2000 * @param[in] random_addr - random address of the device to be set 2001 * @return The following values are returned: 2002 * * - 0 - Success 2003 * Non-Zero Value - Failure 2004 * If the return value is less than 0 2005 * -4 - Buffer not available to serve the command 2006 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2007 */ 2008 int32_t rsi_ble_set_random_address_with_value(uint8_t *random_addr); 2009 2010 /*==============================================*/ 2011 /** 2012 * @fn int32_t rsi_ble_start_advertising(void) 2013 * @brief Request the local device to start advertising. This is a blocking API. 2014 * A received event \ref rsi_ble_on_enhance_connect_t/ \ref rsi_ble_on_connect_t indicates remote device given ble connect command and got connected 2015 * @pre Pre-condition: 2016 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2017 * @return The following values are returned: 2018 * * - 0 - Success 2019 * Non-Zero Value - Failure 2020 * If the return value is less than 0 2021 * -4 - Buffer not available to serve the command 2022 * 0x4E0C - Command disallowed 2023 * 0x4046 - Invalid Arguments 2024 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2025 */ 2026 2027 int32_t rsi_ble_start_advertising(void); 2028 2029 /*==============================================*/ 2030 /** 2031 * @fn int32_t rsi_ble_start_advertising_with_values(const void *rsi_ble_adv) 2032 * @brief Request the local device to start advertising with specified values. This is a blocking API. 2033 * A received event \ref rsi_ble_on_enhance_connect_t/ \ref rsi_ble_on_connect_t indicates remote device given ble connect command and got connected 2034 * @pre Pre-condition: 2035 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API, this is a blocking API. 2036 * @param[in] rsi_ble_adv - This structure pointer holds the information of advertising values. This variable is the pointer of the \ref rsi_ble_req_adv_s structure. 2037 * @return The following values are returned: 2038 * * - 0 - Success 2039 * Non-Zero Value - Failure 2040 * If the return value is less than 0 2041 * -4 - Buffer not available to serve the command 2042 * 0x4E0C - Command disallowed 2043 * 0x4046 - Invalid Arguments 2044 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2045 */ 2046 int32_t rsi_ble_start_advertising_with_values(const void *rsi_ble_adv); 2047 2048 /*==============================================*/ 2049 /** 2050 * @fn int32_t rsi_ble_encrypt(const uint8_t *key, const uint8_t *data, uint8_t *resp) 2051 * @brief Encrypt the plain text data fed by the user using the key provided, it uses the AES-128 bit block cypher a logo to generate encrypted data, refer to Bluetooth Spec 5.0 for further details. 2052 * @pre Pre-conditions: 2053 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API, this is a blocking API. 2054 * @param[in] key - 16 Bytes key for Encryption of data. 2055 * @param[in] data - 16 Bytes of Data request to encrypt. 2056 * @param[out] resp - Encrypted data 2057 * @return The following values are returned: 2058 * * - 0 - Success 2059 * Non-Zero Value - Failure 2060 * If the return value is less than 0 2061 * -4 - Buffer not available to serve the command 2062 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2063 */ 2064 int32_t rsi_ble_encrypt(const uint8_t *key, const uint8_t *data, uint8_t *resp); 2065 2066 /*==============================================*/ 2067 /** 2068 * @fn int32_t rsi_ble_stop_advertising(void) 2069 * @brief Stop advertising, this is a Blocking API 2070 * @pre Pre-conditions: 2071 * Call rsi_ble_start_advertising() before calling this API. 2072 * @return The following values are returned: 2073 * * - 0 - Success 2074 * Non-Zero Value - Failure 2075 * If the return value is less than 0 2076 * -4 - Buffer not available to serve the command 2077 * 0x4E0C - Command disallowed 2078 * 0x4046 - Invalid Arguments 2079 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2080 */ 2081 int32_t rsi_ble_stop_advertising(void); 2082 2083 /*==============================================*/ 2084 /** 2085 * @fn int32_t rsi_ble_set_advertise_data(const uint8_t *data, uint16_t data_len) 2086 * @brief Set the advertising data. This is a blocking API. 2087 * @pre Pre-condition: 2088 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2089 * @param[in] data - Advertising data. 2090 * @param[in] data_len - Total length of advertising data. 2091 * @return The following values are returned: 2092 * * - 0 - Success 2093 * Non-Zero Value - Failure 2094 * If the return value is less than 0 2095 * -4 - Buffer not available to serve the command 2096 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2097 * @note The maximum length of advertising data payload is 31 bytes. 2098 * @note The basic format of advertising payload record contains length and data. 2099 */ 2100 int32_t rsi_ble_set_advertise_data(const uint8_t *data, uint16_t data_len); 2101 2102 /*========================================================*/ 2103 /** 2104 * @fn int32_t rsi_ble_set_scan_response_data(const uint8_t *data, uint16_t data_len); 2105 * @brief Request the local device to set the scan response data, this is a Blocking API 2106 * @pre Pre-conditions: 2107 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API, this is a Blocking API. 2108 * @param[in] data - Data about to be sent 2109 * @param[in] data_len - Length of data, which is about to be sent 2110 * @return The following values are returned: 2111 * * - 0 - Success 2112 * Non-Zero Value - Failure 2113 * If the return value is less than 0 2114 * -4 - Buffer not available to serve the command 2115 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2116 */ 2117 int32_t rsi_ble_set_scan_response_data(const uint8_t *data, uint16_t data_len); 2118 2119 /*==============================================*/ 2120 /** 2121 * @fn int32_t rsi_ble_start_scanning(void) 2122 * @brief Start scanning, this is a Blocking API 2123 * A received event \ref rsi_ble_on_adv_report_event_t indicates advertise report of remote device received. 2124 * @pre Pre-condition: 2125 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API, this is a Blocking API. 2126 * @return The following values are returned: 2127 * * - 0 - Success 2128 * Non-Zero Value - Failure 2129 * If the return value is less than 0 2130 * -4 - Buffer not available to serve the command 2131 * 0x4E0C - Command disallowed 2132 * 0x4046 - Invalid Arguments 2133 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2134 */ 2135 int32_t rsi_ble_start_scanning(void); 2136 2137 /*==============================================*/ 2138 /** 2139 * @fn int32_t rsi_ble_start_scanning_with_values(void *rsi_ble_scan_params) 2140 * @brief Start scanning with values. This is a blocking API. A received event \ref rsi_ble_on_adv_report_event_t indicates the advertise report of a remote device received. 2141 * @pre Pre-condition: 2142 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2143 * @param[in] rsi_ble_scan_params - BLE scan parameters structure 2144 * please refer rsi_ble_req_scan_s structure for more info 2145 * @return The following values are returned: 2146 * * - 0 - Success 2147 * Non-Zero Value - Failure 2148 * 0x4E0C - Command disallowed 2149 * 0x4046 - Invalid Arguments 2150 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2151 */ 2152 int32_t rsi_ble_start_scanning_with_values(void *rsi_ble_scan_params); 2153 2154 /*==============================================*/ 2155 /** 2156 * @fn int32_t rsi_ble_stop_scanning(void) 2157 * @brief Stop scanning. This is a blocking API 2158 * @pre Pre-conditions: 2159 * - \ref rsi_ble_start_scanning() API needs to be called before this API. 2160 * @return The following values are returned: 2161 * * - 0 - Success 2162 * Non-Zero Value - Failure 2163 * If the return value is less than 0 2164 * -4 - Buffer not available to serve the command 2165 * 0x4E0C - Command disallowed 2166 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2167 */ 2168 int32_t rsi_ble_stop_scanning(void); 2169 2170 /*==============================================*/ 2171 /** 2172 * @fn int32_t rsi_ble_connect_with_params(uint8_t remote_dev_addr_type, 2173 * const int8_t *remote_dev_addr, 2174 * uint16_t scan_interval, 2175 * uint16_t scan_window, 2176 * uint16_t conn_interval_max, 2177 * uint16_t conn_interval_min, 2178 * uint16_t conn_latency, 2179 * uint16_t supervision_tout) 2180 * @brief Connect to the remote BLE device with the user configured parameters. This is a blocking API, 2181 * a received event \ref rsi_ble_on_enhance_connect_t / \ref rsi_ble_on_connect_t indicates that the connection successful and 2182 * a received event \ref rsi_ble_on_disconnect_t indicates that connection failures have occurred. 2183 * @pre Pre-conditions: 2184 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2185 * @param[in] remote_dev_addr_type - AddressType - Specifies the type of the address mentioned in BD Address 2186 * - 0 - Public Address 2187 * - 1 - Random Address 2188 * @param[in] remote_dev_addr - This parameter describes the device address of remote device 2189 * @param[in] scan_interval - LE Scan Interval : N=0xXXXX 2190 * - It is defined as the time interval from when the Controller started its last LE scan until it 2191 * begins the subsequent LE scan. 2192 * - Range: 0x0004 to 0x4000 2193 * - Time = N * 0.625 msec 2194 * - Time Range: 2.5 msec to 10 . 24 seconds 2195 * @param[in] scan_window - LE Scan Window : N=0xXXXX 2196 * - Amount of time for the duration of the LE scan. LE_Scan_Window 2197 * must be less than or equal to LE_Scan_Interval 2198 * - Range: 0x0004 to 0x4000 2199 * - Time = N * 0.625 msec 2200 * - Time Range: 2.5 msec to 10 . 24 seconds 2201 * @param[in] conn_interval_max - Max Connection Interval : N=0xXXXX 2202 * - Minimum value for the connection event interval, which must 2203 * be greater than or equal to Conn_Interval_Min. 2204 * - Range: 0x0006 to 0x0C80 2205 * - Time = N * 1.25 msec 2206 * - Time Range: 7.5 msec to 4 seconds. 2207 * - 0x0000 - 0x0005 and 0x0C81 - 0xFFFF - Reserved for future use 2208 * @param[in] conn_interval_min - Min Connection Interval : N=0xXXXX 2209 * - Minimum value for the connection event interval, which must 2210 * be greater than or equal to Conn_Interval_Max. 2211 * - Range: 0x0006 to 0x0C80 2212 * - Time = N * 1.25 msec 2213 * - Time Range: 7.5 msec to 4 seconds. 2214 * - 0x0000 - 0x0005 and 0x0C81 - 0xFFFF - Reserved for future use 2215 * @param[in] conn_latency - Connection Latency : N = 0xXXXX 2216 * - Peripheral latency for the connection in number of connection events. 2217 * - Range: 0x0000 to 0x01F4 2218 * @param[in] supervision_tout - Supervision Timeout : N = 0xXXXX 2219 * - Supervision timeout for the LE Link. 2220 * - Range: 0x000A to 0x0C80 2221 * - Time = N * 10 msec 2222 * - Time Range: 100 msec to 32 seconds 2223 * - 0x0000 - 0x0009 and 0x0C81 - 0xFFFF - Reserved for future use 2224 * @return The following values are returned: 2225 * - 0 - Success 2226 * - Non-Zero Value - Failure 2227 * - 0x4E0C - Command disallowed 2228 * - 0x4046 - Invalid Arguments 2229 * @note If a connection can't be established, for example, the remote device has gone out of range, has entered into deep sleep, or is not advertising, 2230 * the stack will try to connect forever. In this case, the application will not get an event related to the connection request. 2231 * @note To recover from this situation, the application can implement a timeout and call rsi_ble_connect_cancel() to cancel the connection request. 2232 * Subsequent calls of this command have to wait for the ongoing command to complete. 2233 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2234 */ 2235 int32_t rsi_ble_connect_with_params(uint8_t remote_dev_addr_type, 2236 const int8_t *remote_dev_addr, 2237 uint16_t scan_interval, 2238 uint16_t scan_window, 2239 uint16_t conn_interval_max, 2240 uint16_t conn_interval_min, 2241 uint16_t conn_latency, 2242 uint16_t supervision_tout); 2243 2244 /*==============================================*/ 2245 /** 2246 * @fn int32_t rsi_ble_connect(uint8_t remote_dev_addr_type, const int8_t *remote_dev_addr) 2247 * @brief Connect to the remote BLE device. This is a blocking API, 2248 * a received event \ref rsi_ble_on_enhance_connect_t/ \ref rsi_ble_on_connect_t indicates that the connection successful and 2249 * a received event \ref rsi_ble_on_disconnect_t indicates that connection failures have occurred. 2250 * @pre Pre-conditions: 2251 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2252 * @param[in] remote_dev_addr_type - This parameter describes the address type of the remote device 2253 * @param[in] remote_dev_addr - This parameter describes the device address of the remote device 2254 * @return The following values are returned: 2255 * * - 0 - Success 2256 * Non-Zero Value - Failure 2257 * 0x4E0C - Command disallowed 2258 * 0x4046 - Invalid Arguments 2259 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2260 * @note If a connection can't be established, for example, the remote device has gone out of range, has entered into deep sleep, or is not advertising, 2261 * @note The stack will try to connect forever. In this case, the application will not get an event related to the connection request. 2262 * @note To recover from this situation, the application can implement a timeout and call rsi_ble_connect_cancel() to cancel the connection request. 2263 * @note Subsequent calls of this command have to wait for the ongoing command to complete. 2264 */ 2265 int32_t rsi_ble_connect(uint8_t remote_dev_addr_type, const int8_t *remote_dev_addr); 2266 2267 /*==============================================*/ 2268 /** 2269 * @fn int32_t rsi_ble_enhance_connect_with_params(void* ble_enhance_conn_params) 2270 * @brief Connect to the remote BLE device with the user configured parameters. 2271 * @pre Pre-conditions: 2272 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2273 * @param[in] ble_enhance_conn_params - BLE enhance connection parameter structure. See notes for the fields in this structure. 2274 * @return The following values are returned: 2275 * * - 0 - Success 2276 * Non-Zero Value - Failure 2277 * If the return value is less than 0 2278 * -4 - Buffer not available to serve the command 2279 * 0x4E0C - Command disallowed 2280 * 0x4046 - Invalid Arguments 2281 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors). 2282 * @note The following fields are included in the ble_enhance_conn_params parameter structure: 2283 * - dev_addr_type - Address type of the device to connect. 2284 * - 0 - Public Address 2285 * - 1 - Random Address 2286 * - dev_addr - Address of the device to connect. 2287 * - filter_policy - Policy used to determine whether the filter accept list is used. 2288 * - 0 - Filter accept list is not used to determine which advertiser to connect to. 2289 * - 1 - Filter accept list is used to determine which advertiser to connect to. 2290 * - own_addr_type - Own address type 2291 * - le_scan_interval - The time interval from when the Controller started its last LE scan until it begins the subsequent LE scan. 2292 * - Range: 0x0004 to 0x4000 2293 * - Time = le_scan_interval * 0.625 msec 2294 * - Time Range: 2.5 msec to 10 . 24 seconds 2295 * - le_scan_window - Amount of time for the duration of the LE scan. This must be less than or equal to le_scan_interval. 2296 * - Range: 0x0004 to 0x4000 2297 * - Time = le_scan_window * 0.625 msec 2298 * - Time Range: 2.5 msec to 10 . 24 seconds 2299 * - conn_interval_min - Minimum value for the connection event interval. This must be greater than or equal to conn_interval_max. 2300 * - Range: 0x0006 to 0x0C80 2301 * - Time = conn_interval_min * 1.25 msec 2302 * - Time Range: 7.5 msec to 4 seconds. 2303 * - 0x0000 - 0x0005 and 0x0C81 - 0xFFFF - Reserved for future use 2304 * - conn_interval_max - Maximum value for the connection event interval. This must be greater than or equal to conn_interval_min. 2305 * - Range: 0x0006 to 0x0C80 2306 * - Time = conn_interval_max * 1.25 msec 2307 * - Time Range: 7.5 msec to 4 seconds. 2308 * - 0x0000 - 0x0005 and 0x0C81 - 0xFFFF - Reserved for future use 2309 * - conn_latency - Peripheral latency for the connection in number of connection events. 2310 * - Range: 0x0000 to 0x01F4 2311 * - supervision_tout - Supervision timeout for the LE Link. 2312 * - Range: 0x000A to 0x0C80 2313 * - Time = N * 10 msec 2314 * - Time Range: 100 msec to 32 seconds 2315 * - 0x0000 - 0x0009 and 0x0C81 - 0xFFFF - Reserved for future use 2316 * - min_ce_length - Minimum length of connection event recommended for this LE connection. 2317 * - Range: 0x0000 to 0xFFFF 2318 * - Time = N * 0.625 msec 2319 * - max_ce_length - Maximum length of connection event recommended for this LE connection. 2320 * - Range: 0x0000 to 0xFFFF 2321 * - Time = N * 0.625 msec 2322 */ 2323 int32_t rsi_ble_enhance_connect_with_params(void *ble_enhance_conn_params); 2324 2325 /*==============================================*/ 2326 /** 2327 * @fn int32_t rsi_ble_connect_cancel(const int8_t *remote_dev_address) 2328 * @brief Cancel the connection to the remote BLE device. This is a blocking API, 2329 * A received event \ref rsi_ble_on_disconnect_t indicates disconnect complete. 2330 * @pre Pre-conditions: 2331 * \ref rsi_ble_connect() API needs to be called before this API. 2332 * @param[in] remote_dev_address - This parameter describes the device address of the remote device 2333 * @return The following values are returned: 2334 * - 0 - Success 2335 * - Non-Zero Value - Failure 2336 * - 0x4E0C - Command disallowed 2337 * - 0x4046 - Invalid Arguments 2338 * - 0x4E02 - Unknown Connection Identifier 2339 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2340 */ 2341 int32_t rsi_ble_connect_cancel(const int8_t *remote_dev_address); 2342 2343 /*==============================================*/ 2344 /** 2345 * @fn int32_t rsi_ble_disconnect(const int8_t *remote_dev_address) 2346 * @brief Disconnect with the remote BLE device. This is a blocking API. 2347 * @pre Pre-conditions: 2348 * \ref rsi_ble_connect() API needs to be called before this API. 2349 * @param[in] remote_dev_address - This parameter describes the device address of the remote device 2350 * @return The following values are returned: 2351 * 0 - Success 2352 * Non-Zero Value - Failure 2353 * 0x4E0C - Command disallowed 2354 * 0x4D05 BLE socket not available 2355 * 0x4E62 Invalid Parameters 2356 * 0x4D04 BLE not connected 2357 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2358 */ 2359 int32_t rsi_ble_disconnect(const int8_t *remote_dev_address); 2360 2361 /*==============================================*/ 2362 /** 2363 * @fn int32_t rsi_ble_get_device_state(uint8_t *resp) 2364 * @brief Get the local device state. This is a blocking API. The state value is filled in "resp". 2365 * @pre Pre-conditions: 2366 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2367 * @param[out] resp - This is an output parameter which consists of local device state. 2368 * This is a 1-byte value. The possible states are described below: 2369 * BIT(0) Advertising state 2370 * BIT(1) Scanning state 2371 * BIT(2) Initiating state 2372 * BIT(3) Connected state 2373 * BIT(4) Extended Advertising state 2374 * BIT(5) Extended Scanning state 2375 * BIT(6) Extended Initiating state 2376 * @return The following values are returned: 2377 * - 0 - Success 2378 * - Non-Zero Value - Failure 2379 * - If the return value is less than 0 2380 * - -4 - Buffer not available to serve the command 2381 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2382 */ 2383 int32_t rsi_ble_get_device_state(uint8_t *resp); 2384 2385 /*==============================================*/ 2386 /** 2387 * @fn int32_t rsi_ble_set_smp_pairing_cap_data(rsi_ble_set_smp_pairing_capabilty_data_t *smp_pair_cap_data) 2388 * @brief Set the SMP Pairing Capability of local device. This is a blocking API. 2389 * @pre Pre-conditions: 2390 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2391 * @param[in] smp_pair_cap_data - This structure pointer holds the information of the SMP capability data values 2392 * please refer rsi_ble_set_smp_pairing_capabilty_data structure for more info 2393 * @return The following values are returned: 2394 * - 0 - Success 2395 * - Non-Zero Value - Failure 2396 * - If the return value is less than 0 2397 * - -4 - Buffer not available to serve the command 2398 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2399 */ 2400 int32_t rsi_ble_set_smp_pairing_cap_data(rsi_ble_set_smp_pairing_capabilty_data_t *smp_pair_cap_data); 2401 2402 /*==============================================*/ 2403 /** 2404 * @fn int32_t rsi_ble_set_local_irk_value(const uint8_t *l_irk) 2405 * @brief Set the IRK value to the local device. This is a blocking API. 2406 * @pre Pre-conditions: 2407 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2408 * @param[in] l_irk - l_irk Pointer to local_irk 2409 * @return The following values are returned: 2410 * - 0 - Success 2411 * - Non-Zero Value - Failure 2412 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2413 */ 2414 int32_t rsi_ble_set_local_irk_value(const uint8_t *l_irk); 2415 2416 /*==============================================*/ 2417 /** 2418 * @fn int32_t rsi_ble_conn_param_resp(const uint8_t *remote_dev_address, uint8_t status) 2419 * @brief Give the response for the remote device connection parameter request. This is a blocking API. 2420 * A received event \ref rsi_ble_on_conn_update_complete_t indicates connection update procedure is successful. 2421 * @pre Pre-conditions: 2422 * \ref rsi_ble_connect() API needs to be called before this API. 2423 * @param[in] remote_dev_address - remote device address 2424 * @param[in] status - accept or reject the connection parameters update request 2425 * - 0 - ACCEPT, 2426 * - 1 - REJECT 2427 * @return The following values are returned: 2428 * - 0 - Success 2429 * - Non-Zero Value - Failure 2430 * - 0x4E0C - Command disallowed 2431 * - 0x4046 - Invalid Arguments 2432 * - 0x4E02 - Unknown Connection Identifier 2433 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2434 */ 2435 int32_t rsi_ble_conn_param_resp(const uint8_t *remote_dev_address, uint8_t status); 2436 2437 /*==============================================*/ 2438 /** 2439 * @fn int32_t rsi_ble_smp_pair_request(uint8_t *remote_dev_address, uint8_t io_capability, uint8_t mitm_req) 2440 * @brief Request the SMP pairing process with the remote device. This is a blocking API. 2441 * - A received event \ref rsi_ble_on_smp_request_t indicated remote device is given Security Request and need to respond back with \ref rsi_ble_smp_pair_request 2442 * - A received event \ref rsi_ble_on_smp_response_t indicated remote device is given SMP Pair Request and need to respond back with \ref rsi_ble_smp_pair_response 2443 * - A received event \ref rsi_ble_on_smp_failed_t indicated SMP procedure have failed 2444 * @pre Pre-conditions: 2445 * - \ref rsi_ble_connect() API needs to be called before this API. 2446 * @param[in] remote_dev_address - This is the remote device address 2447 * @param[in] io_capability - This is the device input output capability 2448 * - 0x00 - Display Only 2449 * - 0x01 - Display Yes/No 2450 * - 0x02 - Keyboard Only 2451 * - 0x03 - No Input No Output 2452 * @param[in] mitm_req - MITM enable/disable 2453 * - 0 - Disable 2454 * - 1 - Enable 2455 * @return The following values are returned: 2456 * - 0 - Success 2457 * - Non-Zero Value - Failure 2458 * - If the return value is less than 0 2459 * - -4 - Buffer not available to serve the command 2460 * - 0x4D05 BLE socket not available 2461 * - 0x4E62 Invalid Parameters 2462 * - 0x4D04 BLE not connected 2463 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2464 */ 2465 int32_t rsi_ble_smp_pair_request(uint8_t *remote_dev_address, uint8_t io_capability, uint8_t mitm_req); 2466 2467 /*==============================================*/ 2468 /** 2469 * @fn int32_t rsi_ble_smp_pair_failed(uint8_t *remote_dev_address, uint8_t reason) 2470 * @brief Send SMP pairing failure reason to the remote device. 2471 * @pre Pre-conditions: 2472 * \ref rsi_ble_connect() API needs to be called before this API. 2473 * @param[in] remote_dev_address - This is the remote device address 2474 * @param[in] reason - This is the reason for SMP Pairing Failure 2475 * - 0x05 - Pairing Not Supported 2476 * - 0x08 - Unspecified Reason 2477 * - 0x09 - Repeated Attempts 2478 * @return The following values are returned: 2479 * - 0 - Success 2480 * - Non-Zero Value - Failure 2481 * - If the return value is less than 0 2482 * - -4 - Buffer not available to serve the command 2483 */ 2484 int32_t rsi_ble_smp_pair_failed(uint8_t *remote_dev_address, uint8_t reason); 2485 2486 /*==============================================*/ 2487 /** 2488 * @fn int32_t rsi_ble_ltk_req_reply(uint8_t *remote_dev_address, 2489 * uint8_t reply_type, const uint8_t *ltk) 2490 * @brief Send the local long term key of its associated local EDIV and local Rand. This is a blocking API. 2491 * - A received event \ref rsi_ble_on_encrypt_started_t indicated encrypted event is received from module 2492 * - A received event \ref rsi_ble_on_smp_failed_t indicated SMP procedure have failed 2493 * @param[in] remote_dev_address - remote device address 2494 * @param[in] reply_type - 0 - Negative reply 2495 * - BIT(0) - Positive Reply (Encryption Enabled) 2496 * - BIT(1) - Un authenticated LTK or STK-based Encryption Enabled 2497 * - BIT(2) - Authenticated LTK or STK-based Encryption Enabled 2498 * - BIT(3) - Authenticated LTK with LE Secure Connections based Encryption Enabled 2499 * - BIT(4) to BIT(6) - Reserved for Future use 2500 * - BIT(7) - LE Secure Connection Enabled 2501 * @param[in] ltk - Long Term Key 16 bytes 2502 * @return The following values are returned: 2503 * - 0 - Success 2504 * - Non-Zero Value - Failure 2505 * - If the return value is less than 0 2506 * - -4 - Buffer not available to serve the command 2507 * - 0x4D05 BLE socket not available 2508 * - 0x4E62 Invalid Parameters 2509 * - 0x4D04 BLE not connected 2510 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2511 */ 2512 int32_t rsi_ble_ltk_req_reply(uint8_t *remote_dev_address, uint8_t reply_type, const uint8_t *ltk); 2513 2514 /*==============================================*/ 2515 /** 2516 * @fn int32_t rsi_ble_smp_pair_response(uint8_t *remote_dev_address, uint8_t io_capability, uint8_t mitm_req) 2517 * @brief Send SMP pairing response during the process of pairing with the remote device. This is a blocking API. 2518 * - A received event \ref rsi_ble_on_smp_passkey_t indicated Legacy SMP passkey is received and need to respond back with \ref rsi_ble_smp_passkey() 2519 * - A received event \ref rsi_ble_on_sc_passkey_t indicated BLE SC passkey is received and need to respond back with \ref rsi_ble_smp_passkey() 2520 * - A received event \ref rsi_ble_on_smp_passkey_display_t indicates SMP passkey display is received from the module 2521 * - A received event \ref rsi_ble_on_smp_failed_t indicated SMP Failed event is received 2522 * @pre Pre-condition: 2523 * \ref rsi_ble_connect() API needs to be called before this API. 2524 * @param[in] remote_dev_address - This is the remote device address 2525 * @param[in] io_capability - This is the device input output capability 2526 * 0x00 - Display Only 2527 * 0x01 - Display Yes/No 2528 * 0x02 - Keyboard Only 2529 * 0x03 - No Input No Output 2530 * @param[in] mitm_req - MITM Request info 2531 * - 0 - Disable 2532 * - 1 - Enable 2533 * @return The following values are returned: 2534 * - 0 - Success 2535 * - Non-Zero Value - Failure 2536 * - If the return value is less than 0 2537 * - -4 - Buffer not available to serve the command 2538 * - 0x4D05 BLE socket not available 2539 * - 0x4E62 Invalid Parameters 2540 * - 0x4D04 BLE not connected 2541 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2542 */ 2543 int32_t rsi_ble_smp_pair_response(uint8_t *remote_dev_address, uint8_t io_capability, uint8_t mitm_req); 2544 2545 /*==============================================*/ 2546 /** 2547 * @fn int32_t rsi_ble_smp_passkey(uint8_t *remote_dev_address, uint32_t passkey) 2548 * @brief Send SMP passkey during SMP pairing process with the remote device. This is a Blocking API 2549 * A received event \ref rsi_ble_on_encrypt_started_t indicated encrypted event is received from module 2550 * A received event \ref rsi_ble_on_le_security_keys_t indicates exchange of security keys completed after encryption 2551 * A received event \ref rsi_ble_on_smp_failed_t indicated SMP procedure have failed 2552 * @pre Pre-conditions: 2553 * Call \ref rsi_ble_smp_pair_request and \ref rsi_ble_smp_pair_response 2554 * before calling this API. 2555 * @param[in] remote_dev_address - This is the remote device address 2556 * @param[in] passkey - This is the key required in pairing process 2557 * @return The following values are returned: 2558 * - 0 - Success 2559 * - Non-Zero Value - Failure 2560 * - If the return value is less than 0 2561 * - -4 - Buffer not available to serve the command 2562 * - 0x4D05 BLE socket not available 2563 * - 0x4E62 Invalid Parameters 2564 * - 0x4D04 BLE not connected 2565 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2566 */ 2567 int32_t rsi_ble_smp_passkey(uint8_t *remote_dev_address, uint32_t passkey); 2568 2569 /*==============================================*/ 2570 /** 2571 * @fn int32_t rsi_ble_get_le_ping_timeout(uint8_t *remote_dev_address, uint16_t *time_out) 2572 * @brief Get the timeout value of the LE ping. This is a blocking API. 2573 * @pre Pre-conditions: 2574 * \ref rsi_ble_connect() API needs to be called before this API. 2575 * @param[in] remote_dev_address - This is the remote device address 2576 * @param[out] time_out - This a response parameter which holds timeout value for 2577 * authentication payload command. 2578 * @return The following values are returned: 2579 * - 0 - Success 2580 * - Non-Zero Value - Failure 2581 * - If the return value is less than 0 2582 * - -4 - Buffer not available to serve the command 2583 * - 0x4D05 BLE socket not available 2584 * - 0x4E62 Invalid Parameters 2585 * - 0x4D04 BLE not connected 2586 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2587 * @note Currently Get ping is not supported. 2588 */ 2589 int32_t rsi_ble_get_le_ping_timeout(uint8_t *remote_dev_address, uint16_t *time_out); 2590 2591 /*==============================================*/ 2592 /** 2593 * @fn int32_t rsi_ble_set_le_ping_timeout(uint8_t *remote_dev_address, uint16_t time_out) 2594 * @brief Set the timeout value of the LE ping. This is a blocking API. 2595 * A received event of \ref rsi_ble_on_le_ping_payload_timeout_t indicates LE ping payload timeout expired 2596 * @pre Pre-conditions: 2597 * - \ref rsi_ble_connect() API needs to be called before this API. 2598 * @param[in] remote_dev_address - This is the remote device address 2599 * @param[out] time_out - This input parameter sets timeout value for authentication 2600 * payload command.(in milliseconds) 2601 * @return The following values are returned: 2602 * - 0 - Success 2603 * - Non-Zero Value - Failure 2604 * - If the return value is less than 0 2605 * - -4 - Buffer not available to serve the command 2606 * - 0x4D05 BLE socket not available 2607 * - 0x4E62 Invalid Parameters 2608 * - 0x4D04 BLE not connected 2609 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2610 */ 2611 int32_t rsi_ble_set_le_ping_timeout(uint8_t *remote_dev_address, uint16_t time_out); 2612 2613 /*==============================================*/ 2614 /** 2615 * @fn int32_t rsi_ble_clear_acceptlist(void) 2616 * @brief Clear all the BD address present in accept list. This is a blocking API. 2617 * @pre Pre-conditions: 2618 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2619 * @return The following values are returned: 2620 * - 0 - Success 2621 * - Non-Zero Value - Failure 2622 * - If the return value is less than 0 2623 * - -4 - Buffer not available to serve the command 2624 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2625 */ 2626 int32_t rsi_ble_clear_acceptlist(void); 2627 2628 /*==============================================*/ 2629 /** 2630 * @fn int32_t rsi_ble_addto_acceptlist(const int8_t *dev_address, uint8_t dev_addr_type) 2631 * @brief Add BD address to accept list. This is a blocking API. 2632 * @pre Pre-conditions: 2633 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2634 * @param[in] dev_address - Address of the device which is going to add in accept list 2635 * @param[in] dev_addr_type - address type of BD address 2636 * @return The following values are returned: 2637 * - 0 - Success 2638 * - Non-Zero Value - Failure 2639 * - If the return value is less than 0 2640 * - -4 - Buffer not available to serve the command 2641 * @note Maximum number of device address that firmware can store is 10. 2642 * Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2643 */ 2644 int32_t rsi_ble_addto_acceptlist(const int8_t *dev_address, uint8_t dev_addr_type); 2645 2646 /*==============================================*/ 2647 /** 2648 * @fn int32_t rsi_ble_deletefrom_acceptlist(const int8_t *dev_address, uint8_t dev_addr_type) 2649 * @brief Delete particular BD address from accept list. This is a blocking API. 2650 * @pre Pre-conditions: 2651 * - \ref rsi_ble_addto_acceptlist() API needs to be called before this API. 2652 * @param[in] dev_address - Address of the device which is going to delete from accept list 2653 * @param[in] dev_addr_type - address type of BD address 2654 * @return The following values are returned: 2655 * - 0 - Success 2656 * - Non-Zero Value - Failure 2657 * - If the return value is less than 0 2658 * - -4 - Buffer not available to serve the command 2659 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2660 */ 2661 int32_t rsi_ble_deletefrom_acceptlist(const int8_t *dev_address, uint8_t dev_addr_type); 2662 /*==============================================*/ 2663 /** 2664 * @fn int32_t rsi_ble_resolvlist(uint8_t process_type, 2665 * uint8_t remote_dev_addr_type, 2666 * uint8_t *remote_dev_address, 2667 * const uint8_t *peer_irk, 2668 * const uint8_t *local_irk) 2669 * @brief Resolvlist API used for multiple purposes based on the process type. It will be used to add/remove/clear a device to/from the list. This is a blocking API. 2670 * @pre Pre-conditions: 2671 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2672 * @param[in] process_type - Indicates which type of process this is, as follows: 2673 * 1 - add a device to the resolve list 2674 * 2 - remove a device from the resolve list 2675 * 3 - clear the entire resolve list 2676 * @param[in] remote_dev_addr_type - typr of the remote device address 2677 * @param[in] remote_dev_address - remote device address 2678 * 0 - Public identity address 2679 * 1 - Random (static) identity address 2680 * @param[in] peer_irk - 16-byte IRK of the peer device 2681 * @param[in] local_irk - 16-byte IRK of the local device 2682 * @return The following values are returned: 2683 * - 0 - Success 2684 * - Non-Zero Value - Failure 2685 * - If the return value is less than 0 2686 * - -4 - Buffer not available to serve the command 2687 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2688 */ 2689 int32_t rsi_ble_resolvlist(uint8_t process_type, 2690 uint8_t remote_dev_addr_type, 2691 uint8_t *remote_dev_address, 2692 const uint8_t *peer_irk, 2693 const uint8_t *local_irk); 2694 2695 /*==============================================*/ 2696 /** 2697 * @fn int32_t rsi_ble_get_resolving_list_size(uint8_t *resp) 2698 * @brief Request to get resolving list size. This is a blocking API. 2699 * @pre Pre-conditions: 2700 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2701 * @param[out] resp - output parameter which consists of supported resolving the list size. 2702 * @return The following values are returned: 2703 * - 0 - Success 2704 * - Non-Zero Value - Failure 2705 * - If the return value is less than 0 2706 * - -4 : Buffer not available to serve the command 2707 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2708 */ 2709 int32_t rsi_ble_get_resolving_list_size(uint8_t *resp); 2710 /*==============================================*/ 2711 /** 2712 * @fn int32_t rsi_ble_set_addr_resolution_enable(uint8_t enable, uint16_t tout) 2713 * @brief Request to enable address resolution, and to set resolvable private address timeout. This is a blocking API. 2714 * @pre Pre-conditions: 2715 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2716 * @param[in] enable - value to enable/disable address resolution 2717 * - 1 - enables address resolution 2718 * - 0 - disables address resolution 2719 * @param[in] tout - the period for changing address of our local device in seconds 2720 * Value ranges from 0x0001 to 0xA1B8 (1 s to approximately 11.5 hours) 2721 * @return The following values are returned: 2722 * - 0 - Success 2723 * - Non-Zero Value - Failure 2724 * - If the return value is less than 0 2725 * - -4 : Buffer not available to serve the command 2726 */ 2727 int32_t rsi_ble_set_addr_resolution_enable(uint8_t enable, uint16_t tout); 2728 /*==============================================*/ 2729 /** 2730 * @fn int32_t rsi_ble_set_privacy_mode(uint8_t remote_dev_addr_type, 2731 * uint8_t *remote_dev_address, uint8_t privacy_mode) 2732 * @brief Request to set privacy mode for particular device, this is a Blocking API 2733 * @pre Pre-conditions: 2734 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2735 * @param[in] remote_dev_addr_type - type of the remote device address 2736 * 0 - Public Identity Address 2737 * 1 - Random (static) Identity Address 2738 * @param[in] remote_dev_address - remote device address 2739 * @param[in] privacy_mode - type of the privacy mode 2740 * 0 - Network privacy mode 2741 * 1 - Device privacy mode 2742 * @return The following values are returned: 2743 * 0 - Success 2744 * Non-Zero Value - Failure 2745 * If the return value is less than 0 2746 * -4 : Buffer not available to serve the command 2747 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2748 */ 2749 int32_t rsi_ble_set_privacy_mode(uint8_t remote_dev_addr_type, uint8_t *remote_dev_address, uint8_t privacy_mode); 2750 /*==============================================*/ 2751 /** 2752 * @fn int32_t rsi_ble_readphy(const int8_t *remote_dev_address, rsi_ble_resp_read_phy_t *resp) 2753 * @brief Reads the TX and RX PHY rates of the Connection. This is a blocking API. 2754 * @pre Pre-conditions: 2755 * \ref rsi_ble_connect() API needs to be called before this API. 2756 * @param[in] remote_dev_address - remote device address 2757 * @param[out] resp - pointer to store the response 2758 please refer \ref rsi_ble_resp_read_phy_s structure for more info. 2759 * @return The following values are returned: 2760 * 0 - Success 2761 * Non-Zero Value - Failure 2762 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2763 */ 2764 int32_t rsi_ble_readphy(const int8_t *remote_dev_address, rsi_ble_resp_read_phy_t *resp); 2765 2766 /*==============================================*/ 2767 /** 2768 * @fn int32_t rsi_ble_setphy(const int8_t *remote_dev_address, uint8_t tx_phy, uint8_t rx_phy, 2769 * uint16_t coded_phy) 2770 * @brief Set TX and RX PHY. This is a blocking API. 2771 * A received event \ref rsi_ble_on_phy_update_complete_t indicates PHY rate update complete. 2772 * @pre Pre-conditions: 2773 * \ref rsi_ble_connect() API needs to be called before this API. 2774 * @param[in] remote_dev_address - remote device address 2775 * @param[in] tx_phy - transmit PHY rate 2776 * BIT(0) - Host prefers to use the LE 1M transmitter PHY (possibly among others) 2777 * - BIT(1) - Host prefers to use the LE 2M transmitter PHY (possibly among others) 2778 * - BIT(2) - Host prefers to use the LE Coded transmitter PHY (possibly among others) 2779 * - BIT(3) - BIT(7) Reserved for future use 2780 * @param[in] rx_phy - receive PHY rate 2781 * BIT(0) - Host prefers to use the LE 1M receiver PHY (possibly among others) 2782 * - BIT(1) - Host prefers to use the LE 2M receiver PHY (possibly among others) 2783 * - BIT(2) - Host prefers to use the LE Coded receiver PHY (possibly among others) 2784 * - BIT(3) - BIT(7) Reserved for future use 2785 * @param[in] coded_phy - TX/RX coded PHY rate 2786 * - 0 = Host has no preferred coding when transmitting on the LE Coded PHY 2787 * - 1 = Host prefers that S=2 coding be used when transmitting on the LE Coded PHY 2788 * - 2 = Host prefers that S=8 coding be used when transmitting on the LE Coded PHY 2789 * - 3 = Reserved for future use 2790 * @return The following values are returned: 2791 * 0 - Success 2792 * Non-Zero Value - Failure 2793 * 0x4D05 BLE socket not available 2794 * 0x4E62 Invalid Parameters 2795 * 0x4D04 BLE not connected 2796 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2797 */ 2798 int32_t rsi_ble_setphy(const int8_t *remote_dev_address, uint8_t tx_phy, uint8_t rx_phy, uint16_t coded_phy); 2799 2800 /*==============================================*/ 2801 /** 2802 * @fn int32_t rsi_ble_conn_params_update(const uint8_t *remote_dev_address, 2803 * uint16_t min_int, 2804 * uint16_t max_int, 2805 * uint16_t latency, 2806 * uint16_t timeout) 2807 * @brief Requests the connection parameters change with the remote device, 2808 * When the Silicon Labs device acts as a central, this API is used to update the connection parameters. 2809 * When the Silicon Labs device acts as a peripheral, this API is used to request the central to initiate the connection update procedure. This is a blocking API. 2810 * A received event \ref rsi_ble_on_conn_update_complete_t indicates connection parameters update complete. 2811 * @pre Pre-conditions: 2812 * \ref rsi_ble_connect() API needs to be called before this API. 2813 * @param[in] remote_dev_address - remote device address 2814 * @param[in] min_int - minimum value for the connection interval. 2815 * this shall be less than or equal to max_int . 2816 * @param[in] max_int - maximum value for the connection interval. 2817 * this shall be greater than or equal to min_int. 2818 * @param[in] latency - peripheral latency for the connection in number of connection events. 2819 * Ranges from 0 to 499 2820 * @param[in] timeout - supervision timeout for the LE Link. 2821 * Ranges from 10 to 3200 (Time = N * 10 ms, Time Range: 100 ms to 32 s) 2822 * @return The following values are returned: 2823 * - 0 - Success 2824 * - Non-Zero Value - Failure 2825 * - 0x4D05 BLE socket not available 2826 * - 0x4E62 Invalid Parameters 2827 * - 0x4D04 BLE not connected 2828 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors). 2829 * @note min_int and max_int values ranges from 6 to 3200 (Time = N * 1.25 ms, Time Range: 7.5 ms to 4 s) 2830 latency : If latency value is greater than 32 ,Limiting the peripheral latency value to 32 2831 Max supported peripheral latency is 32 when Device is in peripheral Role. 2832 * 2833 */ 2834 int32_t rsi_ble_conn_params_update(const uint8_t *remote_dev_address, 2835 uint16_t min_int, 2836 uint16_t max_int, 2837 uint16_t latency, 2838 uint16_t timeout); 2839 2840 /*==============================================*/ 2841 /** 2842 * @fn int32_t rsi_ble_set_data_len(uint8_t *remote_dev_address, uint16_t tx_octets, uint16_t tx_time) 2843 * @brief Sets the TX octets and the TX time of specified link (remote device connection), this is a Blocking API. 2844 * A received event \ref rsi_ble_on_data_length_update_t indicates data length update complete. 2845 * @pre Pre-conditions: 2846 * - \ref rsi_ble_connect() API needs to be called before this API. 2847 * @param[in] remote_dev_address - remote device device 2848 * @param[in] tx_octets - preferred maximum number of payload octets that the local Controller 2849 * should include in a single Link Layer packet on this connection. 2850 * @param[in] tx_time - preferred maximum number of microseconds that the local Controller 2851 * should use to transmit a single Link Layer packet on this connection. 2852 * @return The following values are returned: 2853 * - 0 - LE_Set_Data_Length command succeeded. 2854 * - Non-Zero Value - Failure 2855 * - 0x4D05 BLE socket not available 2856 * - 0x4E62 Invalid Parameters 2857 * - 0x4D04 BLE not connected 2858 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2859 */ 2860 int32_t rsi_ble_set_data_len(uint8_t *remote_dev_address, uint16_t tx_octets, uint16_t tx_time); 2861 2862 /*==============================================*/ 2863 /** 2864 * @fn int32_t rsi_ble_read_max_data_len(rsi_ble_read_max_data_length_t *blereaddatalen) 2865 * @brief reads the max supported values of TX octets, TX time, RX octets and Rx time. This is a blocking API. 2866 * @pre Pre-conditions: 2867 * - \ref rsi_ble_connect() API needs to be called before this API. 2868 * @param[out] blereaddatalen - pointer to structure variable, 2869 Please refer rsi_ble_resp_read_max_data_length_s structure for more info. 2870 * @return The following values are returned: 2871 * - 0 - command success 2872 * - Non-Zero Value - Failure 2873 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2874 */ 2875 int32_t rsi_ble_read_max_data_len(rsi_ble_read_max_data_length_t *blereaddatalen); 2876 /** @} */ 2877 2878 /** @addtogroup BT-LOW-ENERGY6 2879 * @{ 2880 */ 2881 2882 /*==============================================*/ 2883 /** 2884 * @fn int32_t rsi_ble_rx_test_mode(uint8_t rx_channel, uint8_t phy, uint8_t modulation) 2885 * @brief Start the BLE RX test mode in controller. This is a blocking API. 2886 * @param[in] rx_channel - Channel in which packet have to be received (0 - 39) 2887 * @param[in] phy - 0x00 Reserved for future use 2888 * 0x01 Receiver set to use the LE 1M PHY 2889 * 0x02 Receiver set to use the LE 2M PHY 2890 * 0x03 Receiver set to use the LE Coded PHY 2891 * (0x04 - 0xFF) Reserved for future use. 2892 * @param[in] modulation - 0x00 Assume transmitter will have a standard standard modulation index 2893 * 0x01 Assume transmitter will have a stable modulation index 2894 * (0x02 - 0xFF) Reserved for future use 2895 * @return The following values are returned: 2896 * - 0 - Success 2897 * - Non-Zero Value - Failure 2898 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2899 */ 2900 int32_t rsi_ble_rx_test_mode(uint8_t rx_channel, uint8_t phy, uint8_t modulation); 2901 2902 /*==============================================*/ 2903 /** 2904 * @fn int32_t rsi_ble_tx_test_mode(uint8_t tx_channel, uint8_t phy, 2905 * uint8_t tx_len, uint8_t mode) 2906 * @brief Start the BLE TX test mode in controller. This is a blocking API. 2907 * @param[in] tx_channel - RF Channel (0-39). 2908 * @param[in] phy - 0x00 Reserved for future use 2909 * - 0x01 Transmitter set to use the LE 1M PHY 2910 * - 0x02 Transmitter set to use the LE 2M PHY 2911 * - 0x03 Transmitter set to use the LE Coded PHY with S=8 data coding 2912 * - 0x04 Transmitter set to use the LE Coded PHY with S=2 data coding 2913 * - (0x05 - 0xFF) Reserved for future use. 2914 * @param[in] tx_len - Length in bytes of payload data in each packet ( 1 - 251 bytes). 2915 * @param[in] mode - 0x00 PRBS9 sequence '11111111100000111101...' 2916 * - 0x01 Repeated '11110000' 2917 * - 0x02 Repeated '10101010' 2918 * - 0x03 PRBS15 2919 * - 0x04 Repeated '11111111' 2920 * - 0x05 Repeated '00000000' 2921 * - 0x06 Repeated '00001111' 2922 * - 0x07 Repeated '01010101' 2923 * - 0x08 - 0xFF Reserved for future use 2924 * @return The following values are returned: 2925 * - 0 - Success 2926 * - Non-Zero Value - Failure 2927 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2928 */ 2929 int32_t rsi_ble_tx_test_mode(uint8_t tx_channel, uint8_t phy, uint8_t tx_len, uint8_t mode); 2930 2931 /*==============================================*/ 2932 /** 2933 * @fn int32_t rsi_ble_end_test_mode(uint16_t *num_of_pkts) 2934 * @brief Stop the BLE TX / RX test mode in controller. This is a blocking API. 2935 * @param[out] num_of_pkts - Number of RX packets received are displayed when RX test is stopped 2936 * @return The following values are returned: 2937 * - 0 - Success 2938 * - Non-Zero Value - Failure 2939 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2940 */ 2941 int32_t rsi_ble_end_test_mode(uint16_t *num_of_pkts); 2942 2943 /*==============================================*/ 2944 /** 2945 * @fn int32_t rsi_ble_per_transmit(struct rsi_ble_per_transmit_s *rsi_ble_per_tx) 2946 * @brief Initiate the BLE transmit PER mode in the controller. This is a blocking API. 2947 * @pre Pre-conditions: 2948 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2949 * @param[in] rsi_ble_per_tx - This parameter is the buffer to hold the structure values 2950 * This is a structure variable of struct \ref rsi_ble_per_transmit_s 2951 * @return The following values are returned: 2952 * - 0 - Success 2953 * - Non-Zero Value - Failure 2954 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2955 */ 2956 int32_t rsi_ble_per_transmit(struct rsi_ble_per_transmit_s *rsi_ble_per_tx); 2957 2958 /*==============================================*/ 2959 /** 2960 * @fn int32_t rsi_ble_per_receive(struct rsi_ble_per_receive_s *rsi_ble_per_rx) 2961 * @brief Initiate the BLE receive PER mode in the controller. This is a blocking API. 2962 * @pre Pre-conditions: 2963 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2964 * @param[in] rsi_ble_per_rx - This parameter is the buffer to hold the structure values 2965 * This is a structure variable of struct \ref rsi_ble_per_receive_s 2966 * @return The following values are returned: 2967 * - 0 - Success 2968 * - Non-Zero Value - Failure 2969 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2970 */ 2971 int32_t rsi_ble_per_receive(struct rsi_ble_per_receive_s *rsi_ble_per_rx); 2972 /** @} */ 2973 2974 /** @addtogroup BT-LOW-ENERGY1 2975 * @{ 2976 */ 2977 /*==============================================*/ 2978 /** 2979 * @fn int32_t rsi_ble_accept_list_using_adv_data(uint8_t enable, 2980 * uint8_t data_compare_index, 2981 * uint8_t len_for_compare_data, 2982 * const uint8_t *payload) 2983 * @brief Give vendor-specific command to set the acceptlist feature based on 2984 * the advertisers advertising payload, this is a Blocking API 2985 * @pre Pre-conditions: 2986 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 2987 * @param[in] enable - enable/disable 2988 * @param[in] data_compare_index - the starting index of the data to compare 2989 * @param[in] len_for_compare_data - total length of data to compare 2990 * @param[in] payload - Payload 2991 * @return The following values are returned: 2992 * - 0 - Success 2993 * - Non-Zero Value - Failure 2994 * - If the return value is less than 0 2995 * - -4 - Buffer not available to serve the command 2996 * - 0x4E62 Invalid Parameters 2997 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 2998 */ 2999 int32_t rsi_ble_accept_list_using_adv_data(uint8_t enable, 3000 uint8_t data_compare_index, 3001 uint8_t len_for_compare_data, 3002 const uint8_t *payload); 3003 3004 /*==============================================*/ 3005 /** 3006 * @fn void BT_LE_ADPacketExtract(uint8_t *remote_name, const uint8_t *pbuf, uint8_t buf_len); 3007 * @brief Used to extract remote Bluetooth device name from the received advertising report. 3008 * @pre Pre-conditions: 3009 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 3010 * @param[in] remote_name - device name 3011 * @param[in] pbuf - advertise data packet buffer pointer 3012 * @param[in] buf_len - buffer length 3013 * 3014 */ 3015 void BT_LE_ADPacketExtract(uint8_t *remote_name, const uint8_t *pbuf, uint8_t buf_len); 3016 3017 /*==============================================*/ 3018 /** 3019 * @fn int32_t rsi_ble_start_encryption(uint8_t *remote_dev_address, uint16_t ediv, 3020 * const uint8_t *rand, const uint8_t *ltk) 3021 * @brief Start the encryption process with the remote device. This is a blocking API. 3022 * A received event \ref rsi_ble_on_encrypt_started_t indicated encrypted event is received from module. 3023 * A received event \ref rsi_ble_on_le_security_keys_t indicates exchange of security keys completed after encryption. 3024 * A received event \ref rsi_ble_on_smp_failed_t indicated SMP procedure have failed. 3025 * @pre Pre-conditions: 3026 * - Encryption enabled event should come before calling this API for second time SMP connection. 3027 * @param[in] remote_dev_address - Remote BD address in string format 3028 * @param[in] ediv - remote device ediv value. 3029 * @param[in] rand - remote device rand value. 3030 * @param[in] ltk - remote device ltk value. 3031 * @return The following values are returned: 3032 * - 0 - Success 3033 * - Non-Zero Value - Failure 3034 * - If the return value is less than 0 3035 * - -4 - Buffer not available to serve the command 3036 * - 0x4D05 BLE socket not available 3037 * - 0x4E62 Invalid Parameters 3038 * - 0x4D04 BLE not connected 3039 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors). 3040 */ 3041 int32_t rsi_ble_start_encryption(uint8_t *remote_dev_address, uint16_t ediv, const uint8_t *rand, const uint8_t *ltk); 3042 3043 /*==============================================*/ 3044 /** 3045 * @fn int32_t rsi_ble_set_ble_tx_power(int8_t tx_power) 3046 * @brief Set TX power 3047 * @param[in] tx_power Power value 3048 * @return The following values are returned: 3049 * - 0 - Success 3050 * - Non-zero value - Failure 3051 * - 0x4E02 - Unknown connection identifier 3052 * - 0x4E01 - Unknown HCI command 3053 * - 0x4E0C - Command disallowed 3054 * - 0x4046 - Invalid arguments 3055 * - 0x4D04 - BLE not connected 3056 * - 0x4D14 - BLE parameter out of mandatory range 3057 * - 0x4D15 - Unsuported power index for 915 3058 * @note This is a Blocking API. 3059 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors). 3060 * @note The higher power will be backed off based on country region. 3061 * @note Use the following setting to indicate tx_power as an index: `#define RSI_BLE_PWR_INX 30` 3062 * Default value for power index is 31. 3063 * Valid values for power index range from 1 to 31 and 33 to 127: 3064 * - 1 to 31: BLE - 0dBm mode. 3065 * - 33 to 63: BLE - 10dBm mode. 3066 * - 64 to 82: BLE - 1dBm - 18dBm HP mode in the resolution of 1dBm. 3067 * - 104 to 126: BLE - 0.5dBm - 11dBm HP mode in the resolution of 0.5dbm. 3068 * - 127: BLE HP Mode, max power supported. 3069 * @note Use the following setting to indicate tx_power in dBm (-8dBm to 18dBm): `#define RSI_BLE_PWR_INX_DBM 1` 3070 * @note When switching between HP mode and LP mode, please ensure that no protocol activity is running. 3071 * @note For the LP Chain - Power index vs output power in dBm in E2E mode: 3072 * | Power Index | Output Power in dBm | 3073 * ----------------------|-------------------------------------------------------------------| 3074 * | 1 | -22.3054959 | 3075 * | 2 | -16.59332574 | 3076 * | 3 | -13.38278365 | 3077 * | 4 | -11.19804718 | 3078 * | 5 | -9.576522466 | 3079 * | 6 | -8.312070432 | 3080 * | 7 | -7.294640362 | 3081 * | 8 | -6.458448154 | 3082 * | 9 | -5.760963318 | 3083 * | 10 | -5.173042366 | 3084 * | 11 | -4.673788189 | 3085 * | 12 | -4.247653993 | 3086 * | 13 | -3.882708784 | 3087 * | 14 | -3.569545894 | 3088 * | 15 | -3.300567503 | 3089 * | 16 | -3.069499167 | 3090 * | 17 | -2.871050592 | 3091 * | 18 | -2.700672503 | 3092 * | 19 | -2.554378603 | 3093 * | 20 | -2.428612817 | 3094 * | 21 | -2.32014891 | 3095 * | 22 | -2.226013876 | 3096 * | 23 | -2.143429275 | 3097 * | 24 | -2.069766557 | 3098 * | 25 | -2.002513642 | 3099 * | 26 | -1.939250859 | 3100 * | 27 | -1.87763493 | 3101 * | 28 | -1.815390046 | 3102 * | 29 | -1.750305305 | 3103 * | 30 | -1.680237892 | 3104 * | 31 | -1.603121401 | 3105 * | 32 | N/A | 3106 * | 33 | -10.4822997 | 3107 * | 34 | -4.9531679 | 3108 * | 35 | -1.931961022 | 3109 * | 36 | 0.057132993 | 3110 * | 37 | 1.476764101 | 3111 * | 38 | 2.5332116 | 3112 * | 39 | 3.336771823 | 3113 * | 40 | 3.953605265 | 3114 * | 41 | 4.426779615 | 3115 * | 42 | 4.786171523 | 3116 * | 43 | 5.053647759 | 3117 * | 44 | 5.246007208 | 3118 * | 45 | 5.37676618 | 3119 * | 46 | 5.457304255 | 3120 * | 47 | 5.497635316 | 3121 * | 48 | 5.506945838 | 3122 * | 49 | 5.493978354 | 3123 * | 50 | 5.467302132 | 3124 * | 51 | 5.435491631 | 3125 * | 52 | 5.407220119 | 3126 * | 53 | 5.391268248 | 3127 * | 54 | 5.396444507 | 3128 * | 55 | 5.431416481 | 3129 * | 56 | 5.504458826 | 3130 * | 57 | 5.62313521 | 3131 * | 58 | 5.793945208 | 3132 * | 59 | 6.02197959 | 3133 * | 60 | 6.310634089 | 3134 * | 61 | 6.661428559 | 3135 * | 62 | 7.073964236 | 3136 * | 63 | 7.546029076 | 3137 * @note For the HP Chain - Power index vs output power in dBm in E2E mode: 3138 * | Power Index | Output Power in dBm | 3139 * |---------------------|-------------------------------------------------------------------| 3140 * | 64 | 1 | 3141 * | 65 | 2 | 3142 * | 66 | 3 | 3143 * | 67 | 4 | 3144 * | 68 | 5 | 3145 * | 69 | 6 | 3146 * | 70 | 7 | 3147 * | 71 | 8 | 3148 * | 72 | 9 | 3149 * | 73 | 10 | 3150 * | 74 | 11 | 3151 * | 75 | 12 | 3152 * | 76 | 13 | 3153 * | 77 | 14 | 3154 * | 78 | 15 | 3155 * | - | - | 3156 * | - | - | 3157 * | 104 | 0.5 | 3158 * | 105 | 1 | 3159 * | 106 | 1.5 | 3160 * | 107 | 2 | 3161 * | 108 | 2.5 | 3162 * | 109 | 3 | 3163 * | 110 | 3.5 | 3164 * | 111 | 4 | 3165 * | - | - | 3166 * | 126 | 10.5 | 3167 * | 127 | Max Power Supported by Country region | 3168 */ 3169 int32_t rsi_ble_set_ble_tx_power(int8_t tx_power); 3170 /** @} */ 3171 3172 /****************************************************** 3173 * * GATT Client API's Declarations 3174 * ******************************************************/ 3175 3176 /** @addtogroup BT-LOW-ENERGY3 3177 * @{ 3178 */ 3179 3180 /*==============================================*/ 3181 /** 3182 * @fn int32_t rsi_ble_get_profiles(uint8_t *dev_addr, 3183 * uint16_t start_handle, 3184 * uint16_t end_handle, 3185 * rsi_ble_resp_profiles_list_t *p_prof_list) 3186 * @brief Get the supported profiles / services of the connected 3187 * remote device. The \ref rsi_ble_on_profiles_list_resp_t callback 3188 * function will be called after the profiles list response is received. This is a non-blocking API, 3189 * Still user need to wait until the callback \ref rsi_ble_on_profiles_list_resp_t is received from the device, 3190 * to initiate further attribute related transactions on this remote device address. 3191 * @pre Pre-conditions: 3192 * \ref rsi_ble_connect() API needs to be called before this API. 3193 * @param[in] dev_addr - remote device address 3194 * @param[in] start_handle - start handle (index) of the remote device's service records 3195 * @param[in] end_handle - end handle (index) of the remote device's service records 3196 * @param[out] p_prof_list - profiles/services information will be filled in this structure after retrieving from the remote device, 3197 please refer rsi_ble_resp_profiles_list_s structure for more info. 3198 * 3199 * @return The following values are returned: 3200 * - 0 - Success 3201 * - Non-Zero Value - Failure 3202 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3203 */ 3204 int32_t rsi_ble_get_profiles(uint8_t *dev_addr, 3205 uint16_t start_handle, 3206 uint16_t end_handle, 3207 rsi_ble_resp_profiles_list_t *p_prof_list); 3208 3209 /*==============================================*/ 3210 /** 3211 * @fn int32_t rsi_ble_get_profile(uint8_t *dev_addr, uuid_t profile_uuid, 3212 * profile_descriptors_t *p_profile) 3213 * @brief Get the specific profile / service of the connected remote device. 3214 * The \ref rsi_ble_on_profile_resp_t callback function is called after the service 3215 * characteristics response is received. This is a non-blocking API, 3216 * Still user need to wait until the callback \ref rsi_ble_on_profile_resp_t is received from the device, 3217 * to initiate further attribute related transactions on this remote device address. 3218 * @pre Pre-conditions: 3219 * \ref rsi_ble_connect() API needs to be called before this API. 3220 * @param[in] dev_addr - remote device address 3221 * @param[in] profile_uuid - services/profiles which are searched using profile_uuid 3222 * 3223 * @param[out] p_profile - profile / service information filled in this structure after retrieving from the remote device. 3224 See profile_descriptor_s structure for more info. 3225 * 3226 * @return The following values are returned: 3227 * - 0 - Success 3228 * - Non-Zero Value - Failure 3229 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3230 */ 3231 int32_t rsi_ble_get_profile(uint8_t *dev_addr, uuid_t profile_uuid, profile_descriptors_t *p_profile); 3232 3233 /*==============================================*/ 3234 /** 3235 * @fn int32_t rsi_ble_get_char_services(uint8_t *dev_addr, 3236 * uint16_t start_handle, 3237 * uint16_t end_handle, 3238 * rsi_ble_resp_char_services_t *p_char_serv_list) 3239 * @brief Get the service characteristic services of the connected / remote device, 3240 * \ref rsi_ble_on_char_services_resp_t callback function is called after the characteristic service 3241 * response is received, this is a non-blocking API, 3242 * Still user need to wait until the callback \ref rsi_ble_on_char_services_resp_t is received from the device, 3243 * to initiate further attribute related transactions on this remote device address. 3244 * @pre Pre-conditions: 3245 * - \ref rsi_ble_connect() API needs to be called before this API. 3246 * @param[in] dev_addr - remote device address 3247 * @param[in] start_handle - start handle (index) of the remote device's service records 3248 * @param[in] end_handle - end handle (index) of the remote device's service records 3249 * @param[out] p_char_serv_list - service characteristics details are filled in this structure, please refer rsi_ble_resp_char_serv_s structure for more info. 3250 * 3251 * @return The following values are returned: 3252 * - 0 - Success 3253 * - Non-Zero Value - Failure 3254 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3255 */ 3256 int32_t rsi_ble_get_char_services(uint8_t *dev_addr, 3257 uint16_t start_handle, 3258 uint16_t end_handle, 3259 rsi_ble_resp_char_services_t *p_char_serv_list); 3260 3261 /*==============================================*/ 3262 /** 3263 * @fn int32_t rsi_ble_get_inc_services(uint8_t *dev_addr, 3264 * uint16_t start_handle, 3265 * uint16_t end_handle, 3266 * rsi_ble_resp_inc_services_t *p_inc_serv_list) 3267 * @brief Get the supported include services of the connected / remote device. 3268 * The \ref rsi_ble_on_inc_services_resp_t callback function is called after 3269 * the include service response is received. This is a non-blocking API. 3270 * Still user need to wait until the callback \ref rsi_ble_on_inc_services_resp_t is received from the device, 3271 * to initiate further attribute related transactions on this remote device address. 3272 * @pre Pre-conditions: 3273 * \ref rsi_ble_connect() API needs to be called before this API. 3274 * @param[in] dev_addr - remote device address 3275 * @param[in] start_handle - start handle (index) of the remote device's service records 3276 * @param[in] end_handle - end handle (index) of the remote device's service records 3277 * @param[out] p_inc_serv_list - include service characteristics details are filled in this structure, please refer rsi_ble_resp_inc_serv structure for more info. 3278 * 3279 * @return The following values are returned: 3280 * - 0 - Success 3281 * - Non-Zero Value - Failure 3282 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3283 */ 3284 int32_t rsi_ble_get_inc_services(uint8_t *dev_addr, 3285 uint16_t start_handle, 3286 uint16_t end_handle, 3287 rsi_ble_resp_inc_services_t *p_inc_serv_list); 3288 3289 /*==============================================*/ 3290 /** 3291 * @fn int32_t rsi_ble_get_char_value_by_uuid(uint8_t *dev_addr, 3292 * uint16_t start_handle, 3293 * uint16_t end_handle, 3294 * uuid_t char_uuid, 3295 * rsi_ble_resp_att_value_t *p_char_val) 3296 * @brief Get the characteristic value by UUID (char_uuid). 3297 * The \ref rsi_ble_on_read_resp_t callback function is called after the attribute value is received. This is a non-blocking API. 3298 * Still user need to wait until the callback \ref rsi_ble_on_read_resp_t is received from the device, 3299 * to initiate further attribute related transactions on this remote device address. 3300 * @pre Pre-conditions: 3301 * - \ref rsi_ble_connect() API needs to be called before this API. 3302 * @param[in] dev_addr - remote device address 3303 * @param[in] start_handle - start handle (index) of the remote device's service records 3304 * @param[in] end_handle - end handle (index) of the remote device's service records 3305 * @param[in] char_uuid - UUID of the characteristic 3306 * @param[out] p_char_val - Characteristic value is filled in this structure. See rsi_ble_resp_att_value_s structure for more info. 3307 * 3308 * @return The following values are returned: 3309 * - 0 - Success 3310 * - Non-Zero Value - Failure 3311 * - If the return value is less than 0 3312 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3313 */ 3314 int32_t rsi_ble_get_char_value_by_uuid(uint8_t *dev_addr, 3315 uint16_t start_handle, 3316 uint16_t end_handle, 3317 uuid_t char_uuid, 3318 rsi_ble_resp_att_value_t *p_char_val); 3319 3320 /*==============================================*/ 3321 /** 3322 * @fn int32_t rsi_ble_get_att_descriptors(uint8_t *dev_addr, 3323 * uint16_t start_handle, 3324 * uint16_t end_handle, 3325 * rsi_ble_resp_att_descs_t *p_att_desc) 3326 * @brief Get the characteristic descriptors list from the remote device. 3327 * The \ref rsi_ble_on_att_desc_resp_t callback function is called after 3328 * the attribute descriptors response is received. This is a non-blocking API. 3329 * Still user need to wait until the callback \ref rsi_ble_on_att_desc_resp_t is received from the device, 3330 * to initiate further attribute related transactions on this remote device address. 3331 * @pre Pre-conditions: 3332 * \ref rsi_ble_connect() API needs to be called before this API. 3333 * @param[in] dev_addr - remote device address 3334 * @param[in] start_handle - start handle (index) of the remote device's service records 3335 * @param[in] end_handle - end handle (index) of the remote device's service records 3336 * @param[out] p_att_desc - pointer to characteristic descriptor structure, Please refer rsi_ble_resp_att_descs_s structure for more info. 3337 * @return The following values are returned: 3338 * - 0 - Success 3339 * - Non-Zero Value - Failure 3340 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3341 */ 3342 int32_t rsi_ble_get_att_descriptors(uint8_t *dev_addr, 3343 uint16_t start_handle, 3344 uint16_t end_handle, 3345 rsi_ble_resp_att_descs_t *p_att_desc); 3346 3347 /*==============================================*/ 3348 /** 3349 * @fn int32_t rsi_ble_get_att_value(uint8_t *dev_addr, uint16_t handle, rsi_ble_resp_att_value_t *p_att_val) 3350 * @brief Get the attribute by handle. 3351 * The \ref rsi_ble_on_read_resp_t callback function is called upon receiving the attribute value. This is a non-blocking API. 3352 * Still user need to wait until the callback \ref rsi_ble_on_read_resp_t is received from the device, 3353 * to initiate further attribute related transactions on this remote device address. 3354 * @pre Pre-conditions: 3355 * - \ref rsi_ble_connect() API needs to be called before this API. 3356 * @param[in] dev_addr - remote device address 3357 * @param[in] handle - handle value of the attribute 3358 * @param[out] p_att_val - attribute value is filled in this structure, Please refer rsi_ble_resp_att_value_s structure for more info. 3359 * @return The following values are returned: 3360 * - 0 - Success 3361 * - Non-Zero Value - Failure 3362 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3363 * 3364 */ 3365 int32_t rsi_ble_get_att_value(uint8_t *dev_addr, uint16_t handle, rsi_ble_resp_att_value_t *p_att_val); 3366 3367 /*==============================================*/ 3368 /** 3369 * @fn int32_t rsi_ble_get_multiple_att_values(uint8_t *dev_addr, 3370 * uint8_t num_of_handlers, 3371 * const uint16_t *handles, 3372 * rsi_ble_resp_att_value_t *p_att_vals) 3373 * @brief Get the multiple attribute values by using multiple handles. 3374 * The \ref rsi_ble_on_read_resp_t callback function is called after the attribute value is received. This is a non-blocking API, 3375 * Still user need to wait until the callback \ref rsi_ble_on_read_resp_t is received from the device, 3376 * to initiate further attribute related transactions on this remote device address. 3377 * @pre Pre-conditions: 3378 * \ref rsi_ble_connect() API needs to be called before this API. 3379 * @param[in] dev_addr - remote device address 3380 * @param[in] num_of_handlers - number of handles in the list 3381 * @param[in] handles - list of attribute handles 3382 * @param[out] p_att_vals - attribute values filled in this structure, please refer rsi_ble_resp_att_value_s structure for more info. 3383 * @return The following values are returned: 3384 * - 0 - Success 3385 * - Non-Zero Value - Failure 3386 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3387 */ 3388 int32_t rsi_ble_get_multiple_att_values(uint8_t *dev_addr, 3389 uint8_t num_of_handlers, 3390 const uint16_t *handles, 3391 rsi_ble_resp_att_value_t *p_att_vals); 3392 3393 /*==============================================*/ 3394 /** 3395 * @fn int32_t rsi_ble_get_long_att_value(uint8_t *dev_addr, 3396 * uint16_t handle, 3397 * uint16_t offset, 3398 * rsi_ble_resp_att_value_t *p_att_vals) 3399 * @brief Get the long attribute value by using handle and offset. 3400 * The \ref rsi_ble_on_read_resp_t callback function is called after the attribute value is received. This is a non-blocking API. 3401 * Still user need to wait until the callback \ref rsi_ble_on_read_resp_t is received from the device, 3402 * to initiate further attribute related transactions on this remote device address. 3403 * @pre Pre-conditions: 3404 * - \ref rsi_ble_connect() API needs to be called before this API. 3405 * @param[in] dev_addr - remote device address 3406 * @param[in] handle - attribute handle 3407 * @param[in] offset - offset within the attribute value 3408 * @param[out] p_att_vals - attribute value filled in this structure, please refer rsi_ble_resp_att_value_s structure for more info. 3409 * @return The following values are returned: 3410 * - 0 - Success 3411 * - Non-Zero Value - Failure 3412 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3413 */ 3414 int32_t rsi_ble_get_long_att_value(uint8_t *dev_addr, 3415 uint16_t handle, 3416 uint16_t offset, 3417 rsi_ble_resp_att_value_t *p_att_vals); 3418 3419 /*==============================================*/ 3420 /** 3421 * @fn int32_t rsi_ble_set_att_value(uint8_t *dev_addr, uint16_t handle, 3422 * uint8_t data_len, const uint8_t *p_data) 3423 * @brief Set the attribute value of the remote device, 3424 * \ref rsi_ble_on_write_resp_t callback function is called if the attribute set action is completed, this is a non-blocking API, 3425 * Still user need to wait until the callback \ref rsi_ble_on_write_resp_t is received from the device, 3426 * to initiate further attribute related transactions on this remote device address. 3427 * @pre Pre-conditions: 3428 * - \ref rsi_ble_connect() API needs to be called before this API. 3429 * @param[in] dev_addr - remote device address 3430 * @param[in] handle - attribute value handle 3431 * @param[in] data_len - attribute value length 3432 * @param[in] p_data - attribute value 3433 * @return The following values are returned: 3434 * - 0 - Success 3435 * - Non-Zero Value - Failure 3436 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3437 */ 3438 int32_t rsi_ble_set_att_value(uint8_t *dev_addr, uint16_t handle, uint8_t data_len, const uint8_t *p_data); 3439 3440 /*==============================================*/ 3441 /** 3442 * @fn int32_t rsi_ble_set_att_cmd(uint8_t *dev_addr, uint16_t handle, 3443 * uint8_t data_len, const uint8_t *p_data) 3444 * @brief Set the attribute value without waiting for an ACK from the remote device. This is a blocking API. 3445 * If the API returns RSI_ERROR_BLE_DEV_BUF_FULL (-31) error then wait until the \ref rsi_ble_on_le_more_data_req_t event gets received from the module. 3446 * @pre Pre-conditions: 3447 * \ref rsi_ble_connect() API needs to be called before this API. 3448 * @param[in] dev_addr - remote device address 3449 * @param[in] handle - attribute value handle 3450 * @param[in] data_len - attribute value length 3451 * @param[in] p_data - attribute value 3452 * @return The following values are returned: 3453 * - 0 - Success 3454 * - Non-Zero Value - Failure 3455 * - 0x4E60 - Invalid Handle range 3456 * - 0x4E62 - Invalid Parameters 3457 * - 0x4D04 - BLE not connected 3458 * - 0x4D05 - BLE Socket not available 3459 * - 0x4E65 - Invalid Attribute Length When Small Buffer Mode is Configured 3460 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3461 */ 3462 int32_t rsi_ble_set_att_cmd(uint8_t *dev_addr, uint16_t handle, uint8_t data_len, const uint8_t *p_data); 3463 3464 /*==============================================*/ 3465 /** 3466 * @fn int32_t rsi_ble_set_long_att_value(uint8_t *dev_addr, 3467 * uint16_t handle, 3468 * uint16_t offset, 3469 * uint8_t data_len, 3470 * const uint8_t *p_data) 3471 * @brief Set the long attribute value of the remote device. The \ref rsi_ble_on_write_resp_t 3472 * callback function is called after the attribute set action is completed. This is a non-blocking API. 3473 * Still user need to wait until the callback \ref rsi_ble_on_write_resp_t is received from the device, 3474 * to initiate further attribute related transactions on this remote device address. 3475 * @pre Pre-conditions: 3476 * \ref rsi_ble_connect() API needs to be called before this API. 3477 * @param[in] dev_addr - remote device address 3478 * @param[in] handle - attribute handle 3479 * @param[in] offset - attribute value offset 3480 * @param[in] data_len - attribute value length 3481 * @param[in] p_data - attribute value 3482 * @return The following values are returned: 3483 * - 0 - Success 3484 * - Non-Zero Value - Failure 3485 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3486 */ 3487 int32_t rsi_ble_set_long_att_value(uint8_t *dev_addr, 3488 uint16_t handle, 3489 uint16_t offset, 3490 uint8_t data_len, 3491 const uint8_t *p_data); 3492 3493 /*==============================================*/ 3494 /** 3495 * @fn int32_t rsi_ble_prepare_write(uint8_t *dev_addr, uint16_t handle, uint16_t offset, 3496 * uint8_t data_len, const uint8_t *p_data) 3497 * @brief Prepare the attribute value. The \ref rsi_ble_on_write_resp_t 3498 * callback function is called after the prepare attribute write action is completed. This is a non-blocking API. 3499 * Still user need to wait until the callback \ref rsi_ble_on_write_resp_t is received from the device, 3500 * to initiate further attribute related transactions on this remote device address. 3501 * @pre Pre-conditions: 3502 * - \ref rsi_ble_connect() API needs to be called before this API. 3503 * @param[in] dev_addr - remote device address 3504 * @param[in] handle - attribute handle 3505 * @param[in] offset - attribute value offset 3506 * @param[in] data_len - attribute value length 3507 * @param[in] p_data - attribute value 3508 * @return The following values are returned: 3509 * - 0 - Success 3510 * - Non-Zero Value - Failure 3511 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3512 * 3513 */ 3514 int32_t rsi_ble_prepare_write(uint8_t *dev_addr, 3515 uint16_t handle, 3516 uint16_t offset, 3517 uint8_t data_len, 3518 const uint8_t *p_data); 3519 3520 /*==============================================*/ 3521 /** 3522 * @fn int32_t rsi_ble_execute_write(uint8_t *dev_addr, uint8_t exe_flag) 3523 * @brief Execute the prepared attribute values. The \ref rsi_ble_on_write_resp_t 3524 * callback function is called after the execute attribute write action is completed. This is a non-blocking API. 3525 * Still user need to wait until the callback \ref rsi_ble_on_write_resp_t is received from the device, 3526 * to initiate further attribute related transactions on this remote device address. 3527 * @pre Pre-conditions: 3528 * \ref rsi_ble_connect() API needs to be called before this API. 3529 * @param[in] dev_addr - remote device address 3530 * @param[in] exe_flag - execute flag to write, possible values mentioned below 3531 * - 0 - BLE_ATT_EXECUTE_WRITE_CANCEL 3532 * - 1 - BLE_ATT_EXECUTE_PENDING_WRITES_IMMEDIATELY 3533 * @return The following values are returned: 3534 * - 0 - Success 3535 * - Non-Zero Value - Failure 3536 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3537 */ 3538 int32_t rsi_ble_execute_write(uint8_t *dev_addr, uint8_t exe_flag); 3539 /** @} */ 3540 3541 /******************************************************** 3542 * * GATT Server API's Declarations 3543 * ******************************************************/ 3544 /** @addtogroup BT-LOW-ENERGY5 3545 * @{ 3546 */ 3547 3548 /*==============================================*/ 3549 /** 3550 * @fn int32_t rsi_ble_add_service(uuid_t service_uuid, rsi_ble_resp_add_serv_t *p_resp_serv) 3551 * @brief Add a new service to the local GATT Server. This is a blocking API. 3552 * @pre Pre-conditions: 3553 * - Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 3554 * @param[in] service_uuid - new service UUID value, please refer uuid_s structure for more info. 3555 * @param[out] p_resp_serv - new service handler filled in this structure, please refer rsi_ble_resp_add_serv_s structure for more info. 3556 * @return The following values are returned: 3557 * - 0 - Success 3558 * - Non-Zero Value - Failure 3559 * - 0x4046 - Invalid Arguments 3560 * - 0x4D08 - Profile record full 3561 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3562 */ 3563 int32_t rsi_ble_add_service(uuid_t service_uuid, rsi_ble_resp_add_serv_t *p_resp_serv); 3564 3565 /*==============================================*/ 3566 /** 3567 * @fn int32_t rsi_ble_add_attribute(rsi_ble_req_add_att_t *p_attribute) 3568 * @brief Add a new attribute to a specific service. This is a blocking API. 3569 * @pre Pre-conditions: 3570 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 3571 * @param[in] p_attribute - add a new attribute to the service, please refer rsi_ble_req_add_att_s structure for more info. 3572 * @return The following values are returned: 3573 * - 0 - Success 3574 * - Non-Zero Value - Failure 3575 * - 0x4046 - Invalid Arguments 3576 * - 0x4D09 - Attribute record full 3577 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3578 */ 3579 int32_t rsi_ble_add_attribute(rsi_ble_req_add_att_t *p_attribute); 3580 3581 /*==============================================*/ 3582 /** 3583 * @fn int32_t rsi_ble_set_local_att_value(uint16_t handle, uint16_t data_len, 3584 * const uint8_t *p_data) 3585 * @brief Change the local attribute value. This is a blocking API. 3586 * @pre Pre-conditions: 3587 * \ref rsi_ble_connect() API needs to be called before this API. 3588 * @param[in] handle - attribute value handle 3589 * @param[in] data_len - attribute value length 3590 * @param[in] p_data - attribute value 3591 * @return The following values are returned: 3592 * - 0 - Success 3593 * - Non-Zero Value - Failure 3594 * - 0x4046 - Invalid Arguments 3595 * - 0x4D06 - Attribute record not found 3596 * - 0x4E60 - Invalid Handle Range 3597 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3598 * @note This API can only be used if the service is maintained inside the firmware. 3599 * @note The services which are maintained by firmware must follow the below rules. 3600 * @note Rule 1: The attribute_data_size is less than 20 bytes during the service_creation 3601 * @note Rule 2: while creating the service, don't use the RSI_BLE_ATT_MAINTAIN_IN_HOST bit 3602 * in the RSI_BLE_ATT_CONFIG_BITMAP macro. 3603 * @note Rule 3: The data_len must be less than or equal to the dat_length mentioned while 3604 * creating the service/attribute 3605 * @note Rule 4: If the services are maintained in the Application/Host, 3606 * then need to use \ref rsi_ble_notify_value() API to send the notifications to the remote devices. 3607 */ 3608 int32_t rsi_ble_set_local_att_value(uint16_t handle, uint16_t data_len, const uint8_t *p_data); 3609 3610 /*==============================================*/ 3611 /** 3612 * @fn int32_t rsi_ble_set_wo_resp_notify_buf_info(const uint8_t *dev_addr, uint8_t buf_mode, 3613 * uint8_t buf_cnt) 3614 * @brief Configure the buf mode for Notify and WO response commands for the remote device. This is a blocking API. 3615 * @param[in] dev_addr - remote device address 3616 * @param[in] buf_mode - buffer mode configuration 3617 * - 0 - BLE_SMALL_BUFF_MODE 3618 * - 1 - BLE_BIG_BUFF_MODE 3619 * @param[in] buf_cnt - no of buffers to be configured 3620 * only value 1 and 2 are supported in BLE_SMALL_BUFF_MODE 3621 in BLE_BIG_BUFF_MODE, buffers allocated based on the below notations. 3622 intial available_buf_cnt = RSI_BLE_NUM_CONN_EVENTS, 3623 a) When connection 1 is formed, the possible range of buffers is (available_buf_cnt - remaining possible number of connections) 3624 b) After allocating X buffers using \ref rsi_ble_set_wo_resp_notify_buf_info to the 1st connection remaining available_buf_cnt = (available_buf_cnt - X ) 3625 * @return The following values are returned: 3626 * - 0 - Success 3627 * - Non-Zero Value - Failure 3628 * - 0x4046 - Invalid Arguments 3629 * - 0x4D05 - BLE socket not available 3630 * - 0x4D06 - Attribute record not found 3631 * - 0x4E60 - Invalid Handle Range 3632 * - 0x4E63 - BLE Buffer Count Exceeded 3633 * - 0x4E64 - BLE Buffer already in use 3634 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 3635 */ 3636 int32_t rsi_ble_set_wo_resp_notify_buf_info(const uint8_t *dev_addr, uint8_t buf_mode, uint8_t buf_cnt); 3637 3638 /*==============================================*/ 3639 /** 3640 * @fn int32_t rsi_ble_notify_value(const uint8_t *dev_addr, uint16_t handle, 3641 * uint16_t data_len, const uint8_t *p_data) 3642 * @brief Notify the local value to the remote device. This is a blocking API. 3643 * If the API returns RSI_ERROR_BLE_DEV_BUF_FULL (-31) error then wait until the \ref rsi_ble_on_le_more_data_req_t event gets received from the module. 3644 * @pre Pre-conditions: 3645 * - \ref rsi_ble_connect() API needs to be called before this API. 3646 * @param[in] dev_addr - remote device address 3647 * @param[in] handle - local attribute handle 3648 * @param[in] data_len - attribute value length 3649 * @param[in] p_data - attribute value 3650 * @return The following values are returned: 3651 * - 0 - Success 3652 * - Non-Zero Value - Failure 3653 * - 0x4046 - Invalid Arguments 3654 * - 0x4A0D - Invalid attribute value length 3655 * - 0x4D05 - BLE socket not available 3656 * - 0x4D06 - Attribute record not found 3657 * - 0x4E60 - Invalid Handle Range 3658 * - 0x4E65 - Invalid Attribute Length When Small Buffer Mode is Configured 3659 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3660 * @note If the services are maintained in the Application/Host, 3661 * then need to use \ref rsi_ble_notify_value() API instead of using \ref rsi_ble_set_local_att_value() API 3662 * to send the notifications to the remote devices. 3663 */ 3664 int32_t rsi_ble_notify_value(const uint8_t *dev_addr, uint16_t handle, uint16_t data_len, const uint8_t *p_data); 3665 3666 /*==============================================*/ 3667 /** 3668 * @fn int32_t rsi_ble_indicate_value(const uint8_t *dev_addr, uint16_t handle, 3669 * uint16_t data_len, const uint8_t *p_data) 3670 * @brief Indicate the local value to the remote device. This is a blocking API and can unblock the application 3671 * on the reception of the callback functions either \ref rsi_ble_on_event_indicate_confirmation_t. 3672 * @pre Pre-conditions: 3673 * - \ref rsi_ble_connect() API needs to be called before this API. 3674 * @param[in] dev_addr - remote device address 3675 * @param[in] handle - local attribute handle 3676 * @param[in] data_len - attribute value length 3677 * @param[in] p_data - attribute value 3678 * @return The following values are returned: 3679 * - 0 - Success 3680 * - Non-Zero Value - Failure 3681 * - 0x4D05 - BLE socket not available 3682 * - 0x4E60 - Invalid Handle Range 3683 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3684 */ 3685 int32_t rsi_ble_indicate_value(const uint8_t *dev_addr, uint16_t handle, uint16_t data_len, const uint8_t *p_data); 3686 /** @} */ 3687 3688 /** @addtogroup BT-LOW-ENERGY4 3689 * @{ 3690 */ 3691 3692 /*==============================================*/ 3693 /** 3694 * @fn int32_t rsi_ble_indicate_value_sync(const uint8_t *dev_addr, uint16_t handle, 3695 * uint16_t data_len, const uint8_t *p_data) 3696 * @brief Indicate the local value to the remote device. This is a blocking API. 3697 * 3698 * This will not send any confirmation event to the application instead 3699 * 3700 * send the status as success on receiving confirmation from remote side. 3701 * @pre Pre-conditions: 3702 * \ref rsi_ble_connect() API needs to be called before this API. 3703 * @param[in] dev_addr - remote device address 3704 * @param[in] handle - local attribute handle 3705 * @param[in] data_len - attribute value length 3706 * @param[in] p_data - attribute value 3707 * @return The following values are returned: 3708 * - 0 - Success 3709 * - Non-Zero Value - Failure 3710 * - 0x4D05 - BLE socket not available 3711 * - 0x4E60 - Invalid Handle Range 3712 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3713 */ 3714 int32_t rsi_ble_indicate_value_sync(const uint8_t *dev_addr, uint16_t handle, uint16_t data_len, const uint8_t *p_data); 3715 3716 /*==============================================*/ 3717 /** 3718 * @fn int32_t rsi_ble_indicate_confirm(const uint8_t *dev_addr) 3719 * @brief Send indicate confirmation to the remote device. This is a blocking API. 3720 * @pre Pre-conditions: 3721 * \ref rsi_ble_connect() API needs to be called before this API. 3722 * @param[in] dev_addr - remote device address 3723 * @return The following values are returned: 3724 * - 0 - Success 3725 * - Non-Zero Value - Failure 3726 * - 0x4D05 - BLE socket not available 3727 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3728 */ 3729 int32_t rsi_ble_indicate_confirm(const uint8_t *dev_addr); 3730 /** @} */ 3731 3732 /** @addtogroup BT-LOW-ENERGY5 3733 * @{ 3734 */ 3735 3736 /*==============================================*/ 3737 /** 3738 * @fn int32_t rsi_ble_get_local_att_value(uint16_t handle, 3739 * rsi_ble_resp_local_att_value_t *p_resp_local_att_val) 3740 * @brief Get the local attribute value. This is a blocking API. 3741 * @pre Pre-conditions: 3742 * \ref rsi_ble_connect() API needs to be called before this API. 3743 * @param[in] handle - local attribute handle 3744 * @param[out] p_resp_local_att_val - local attribute value filled in this structure, see rsi_ble_resp_local_att_value_s structure for more info. 3745 * @return The following values are returned: 3746 * - 0 - Success 3747 * - Non-Zero Value - Failure 3748 * - 0x4046 - Invalid Arguments 3749 * - 0x4D06 - Attribute record not found 3750 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3751 * @note This API can only be used if the service is maintained inside the firmware. The services which are maintained by firmware must 3752 * follow the below rules. 3753 * @note Rule 1: The attribute_data_size is less than 20 bytes during the service_creation 3754 * @note Rule 2: While creating the service, don't use the RSI_BLE_ATT_MAINTAIN_IN_HOST bit in the RSI_BLE_ATT_CONFIG_BITMAP macro. 3755 */ 3756 int32_t rsi_ble_get_local_att_value(uint16_t handle, rsi_ble_resp_local_att_value_t *p_resp_local_att_val); 3757 3758 /*==============================================*/ 3759 /** 3760 * @fn int32_t rsi_ble_gatt_read_response(uint8_t *dev_addr, 3761 * uint8_t read_type, 3762 * uint16_t handle, 3763 * uint16_t offset, 3764 * uint16_t length, 3765 * const uint8_t *p_data) 3766 * @brief Send the response for the read request received from the remote device This is a blocking API. 3767 * @pre Pre-conditions: 3768 * - \ref rsi_ble_connect() API needs to be called before this API. 3769 * @param[in] dev_addr - remote device Address 3770 * @param[in] read_type - read value type 3771 * - 0 - Read response 3772 * - 1 - Read blob response 3773 * @param[in] handle - attribute value handle 3774 * @param[in] offset - attribute value offset 3775 * @param[in] length - attribute value length 3776 * @param[in] p_data - attribute value 3777 * @return The following values are returned: 3778 * - 0 - Success 3779 * - Non-Zero Value - Failure 3780 * - 0x4D04 - BLE not connected 3781 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3782 */ 3783 int32_t rsi_ble_gatt_read_response(uint8_t *dev_addr, 3784 uint8_t read_type, 3785 uint16_t handle, 3786 uint16_t offset, 3787 uint16_t length, 3788 const uint8_t *p_data); 3789 3790 /*==============================================*/ 3791 /** 3792 * @fn int32_t rsi_ble_remove_gatt_service(uint32_t service_handler) 3793 * @brief Remove the GATT service record. This is a blocking API. 3794 * @pre Pre-conditions: 3795 * \ref rsi_ble_connect() API needs to be called before this API. 3796 * @param[in] service_handler - GATT service record handle 3797 * @return The following values are returned: 3798 * - 0 - Success 3799 * - Non-Zero Value - Failure 3800 * - 0x4D0A - BLE profile not found (profile handler invalid) 3801 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3802 */ 3803 int32_t rsi_ble_remove_gatt_service(uint32_t service_handler); 3804 3805 /*==============================================*/ 3806 /** 3807 * @fn int32_t rsi_ble_remove_gatt_attibute(uint32_t service_handler, uint16_t att_hndl) 3808 * @brief Remove the GATT attribute record. This is a blocking API. 3809 * @pre Pre-conditions: 3810 * \ref rsi_ble_connect() API needs to be called before this API. 3811 * @param[in] service_handler - GATT service record handle 3812 * @param[in] att_hndl - attribute handle 3813 * @return The following values are returned: 3814 * - 0 - Success 3815 * - Non-Zero Value - Failure 3816 * - 0x4D06 - Attribute record not found 3817 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3818 */ 3819 int32_t rsi_ble_remove_gatt_attibute(uint32_t service_handler, uint16_t att_hndl); 3820 3821 /*==============================================*/ 3822 /** 3823 * @fn int32_t rsi_ble_att_error_response(uint8_t *dev_addr, uint16_t handle, 3824 * uint8_t opcode, uint8_t err) 3825 * @brief Send attribute error response for any of the att request. This is a blocking API. 3826 * @pre Pre-conditions: 3827 * \ref rsi_ble_connect() API needs to be called before this API. 3828 * @param[in] dev_addr - remote device address 3829 * @param[in] handle - attribute handle 3830 * @param[in] opcode - error response opcode 3831 * @param[in] err - specific error related Gatt 3832 * @return The following values are returned: 3833 * - 0 - Success 3834 * - Non-Zero Value - Failure 3835 * - 0x4D04 - BLE not Connected 3836 * - 0x4E62 - Invalid Parameters 3837 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3838 */ 3839 int32_t rsi_ble_att_error_response(uint8_t *dev_addr, uint16_t handle, uint8_t opcode, uint8_t err); 3840 /** @} */ 3841 3842 /** @addtogroup BT-LOW-ENERGY3 3843 * @{ 3844 */ 3845 3846 /*==============================================*/ 3847 /** 3848 * @fn int32_t rsi_ble_mtu_exchange_event(uint8_t *dev_addr, uint8_t mtu_size) 3849 * @brief Initiates the MTU exchange request with the remote device. 3850 * This is a blocking API and will receive a callback event \ref rsi_ble_on_mtu_event_t as the response for this API. 3851 * @pre Pre-conditions: 3852 * - \ref rsi_ble_connect() API needs to be called before this API. 3853 * @param[in] dev_addr - remote device address 3854 * @param[in] mtu_size - requested MTU value 3855 * @return The following values are returned: 3856 * - 0 - Success 3857 * - Non-Zero Value - Failure 3858 * - 0x4D04 - BLE not Connected 3859 * - 0x4E62 - Invalid Parameters 3860 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3861 */ 3862 int32_t rsi_ble_mtu_exchange_event(uint8_t *dev_addr, uint8_t mtu_size); 3863 3864 /*==============================================*/ 3865 /** 3866 * @fn int32_t rsi_ble_mtu_exchange_resp(uint8_t *dev_addr, uint8_t mtu_size) 3867 * @brief This function (Exchange MTU Response) is sent in reply to a received Exchange MTU Request. 3868 * @pre Pre-conditions: 3869 * - \ref rsi_ble_connect() API needs to be called before this API. 3870 * @param[in] dev_addr - Remote Device Address 3871 * @param[in] mtu_size - requested MTU value 3872 * @return The following values are returned: 3873 * - 0 - Success 3874 * - 0x4D0C - When RSI_BLE_MTU_EXCHANGE_FROM_HOST BIT is not SET. 3875 * - 0x4D05 - BLE Socket Not Available. 3876 * - Non-Zero Value - Failure 3877 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3878 */ 3879 int32_t rsi_ble_mtu_exchange_resp(uint8_t *dev_addr, uint8_t mtu_size); 3880 /** @} */ 3881 3882 /** @addtogroup BT-LOW-ENERGY5 3883 * @{ 3884 */ 3885 3886 /*==============================================*/ 3887 /** 3888 * @fn int32_t rsi_ble_gatt_write_response(uint8_t *dev_addr, uint8_t type) 3889 * @brief Send the response to the write request received from the remote device. This is a blocking API. 3890 * @pre Pre-conditions: 3891 * \ref rsi_ble_connect() API needs to be called before this API. 3892 * @param[in] dev_addr - remote device address 3893 * @param[in] type - response type 3894 * - 0 - write response, 3895 * - 1 - execute write response. 3896 * @return The following values are returned: 3897 * - 0 - Success 3898 * - Non-Zero Value - Failure 3899 * - 0x4046 - Invalid Arguments 3900 * - 0x4D04 - BLE not Connected 3901 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3902 */ 3903 int32_t rsi_ble_gatt_write_response(uint8_t *dev_addr, uint8_t type); 3904 3905 /*==============================================*/ 3906 /** 3907 * @fn int32_t rsi_ble_gatt_prepare_write_response(uint8_t *dev_addr, 3908 * uint16_t handle, 3909 * uint16_t offset, 3910 * uint16_t length, 3911 * const uint8_t *data) 3912 * @brief Send the response for the prepare write requests received from the remote device. This is a blocking API. 3913 * @pre Pre-conditions: 3914 * \ref rsi_ble_connect() API needs to be called before this API. 3915 * @param[in] dev_addr - remote device address 3916 * @param[in] handle - attribute value handle 3917 * @param[in] offset - attribute value offset 3918 * @param[in] length - attribute value length 3919 * @param[in] data - attribute value 3920 * @return The following values are returned: 3921 * - 0 - Success 3922 * - Non-Zero Value - Failure 3923 * - 0x4046 - Invalid Arguments 3924 * - 0x4D04 - BLE not Connected 3925 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) 3926 */ 3927 int32_t rsi_ble_gatt_prepare_write_response(uint8_t *dev_addr, 3928 uint16_t handle, 3929 uint16_t offset, 3930 uint16_t length, 3931 const uint8_t *data); 3932 /** @} */ 3933 3934 /** @addtogroup BT-LOW-ENERGY1 3935 * @{ */ 3936 /*========================================================*/ 3937 /** 3938 * @fn int32_t rsi_ble_get_max_adv_data_len(uint8_t *resp) 3939 * @brief Get maximum advertising data length 3940 * @param[out] resp Maximum supported advertising data length returned by the controller. Possible values range from 0x001F to 0x0672. 3941 * @return The following values are returned: 3942 * - 0 = success 3943 * @return The following values are returned: 3944 * - !0 = failure 3945 * @note This function requests the controller to return the maximum supported advertising data length. 3946 */ 3947 int32_t rsi_ble_get_max_adv_data_len(uint8_t *resp); 3948 3949 /*========================================================*/ 3950 /** 3951 * @fn int32_t rsi_ble_get_max_no_of_supp_adv_sets(uint8_t *resp) 3952 * @brief Get maximum number of advertising sets 3953 * @param[out] resp Number of supported advertising sets returned by the controller. Possible values range from 0x01 to 0xF0. 3954 * @return The following values are returned: 3955 * 0 = success 3956 * @return The following values are returned: 3957 * !0 = failure 3958 * @note This function requests the controller to return the maximum number of supporting advertising sets. 3959 * @note The number of supported advertising sets can be configured through the operating modes. 3960 */ 3961 int32_t rsi_ble_get_max_no_of_supp_adv_sets(uint8_t *resp); 3962 3963 /*==============================================*/ 3964 /** 3965 * @fn rsi_ble_set_ae_set_random_address(uint8_t handle, const uint8_t *rand_addr) 3966 * @brief Update AE random address 3967 * @param[in] handle The advertising handle used to identify an advertising set 3968 * @param[in] rand_addr Random device address set to either a static or private address 3969 * @return The following values are returned: 3970 * - 0 = success 3971 * @return The following values are returned: 3972 * - !0 = failure 3973 */ 3974 int32_t rsi_ble_set_ae_set_random_address(uint8_t handle, const uint8_t *rand_addr); 3975 3976 /*========================================================*/ 3977 /** 3978 * @fn int32_t rsi_ble_set_ae_data(void *ble_ae_data) 3979 * @brief Update AE advertiser data 3980 * @param[in] ble_ae_data Extended Advertising data to be updated 3981 * @return The following values are returned: 3982 * 0 = success 3983 * @return The following values are returned: 3984 * !0 = failure 3985 * @note This function sets the AE advertiser data used in advertising PDUs. 3986 * @note Refer to Bluetooth specification 5.3 for possible combinations ae_adv/scanresp data can be set for . 3987 */ 3988 int32_t rsi_ble_set_ae_data(void *ble_ae_data); 3989 3990 /*========================================================*/ 3991 /** 3992 * @fn int32_t rsi_ble_set_ae_params(void *ble_ae_params, int8_t *sel_tx_pwr) 3993 * @brief Update AE parameters 3994 * @param[in] ble_ae_params Extended Advertising parameters to be updated 3995 * @param[out] sel_tx_pwr Output transmit power in dBm, ranging from -127 to +20. 3996 * @return The following values are returned: 3997 * 0 = success 3998 * @return The following values are returned: 3999 * !0 = failure 4000 */ 4001 int32_t rsi_ble_set_ae_params(void *ble_ae_params, int8_t *sel_tx_pwr); 4002 4003 /*==============================================*/ 4004 /** 4005 * @fn int32_t rsi_ble_start_ae_advertising(void *adv_enable) 4006 * @brief Enable or disable AE advertising 4007 * @param[in] adv_enable Parameters to enable or disable specific advertising sets identified by advertising handle 4008 * @return The following values are returned: 4009 * 0 = success 4010 * @return The following values are returned: 4011 * !0 = failure 4012 */ 4013 int32_t rsi_ble_start_ae_advertising(void *adv_enable); 4014 4015 /*==============================================*/ 4016 /** 4017 * @fn int32_t rsi_ble_app_adv_set_clear_or_remove(uint8_t type, uint8_t handle) 4018 * @brief Clear or remove an advertising set 4019 * @param[in] type Set to 1 to clear, or 2 to remove an advertising set 4020 * @param[in] handle Advertising handle identifying the advertising set to remove or clear. Possible values range from 0x00 to 0xEF. 4021 * @return The following values are returned: 4022 * 0 = success 4023 * @return The following values are returned: 4024 * !0 = failure 4025 */ 4026 int32_t rsi_ble_app_adv_set_clear_or_remove(uint8_t type, uint8_t handle); 4027 4028 /*==============================================*/ 4029 /** 4030 * @fn int32_t rsi_ble_app_set_periodic_ae_params(void *periodic_adv_params) 4031 * @brief Update periodic AE parameters 4032 * @param[in] periodic_adv_params Periodic advertising parameters to be updated 4033 * @return The following values are returned: 4034 * 0 = success 4035 * @return The following values are returned: 4036 * !0 = failure 4037 */ 4038 int32_t rsi_ble_app_set_periodic_ae_params(void *periodic_adv_params); 4039 4040 /*==============================================*/ 4041 /** 4042 * @fn int32_t rsi_ble_app_set_periodic_ae_enable(uint8_t enable, uint8_t handle) 4043 * @brief Enable or disable periodic advertising 4044 * @param[in] enable Set to 0 to enable, or 1 to include the ADI field in AUX_SYNC_IND PDUs 4045 * @param[in] handle Advertising handle of the advertising set to enable or disable 4046 * @return The following values are returned: 4047 * 0 = success 4048 * @return The following values are returned: 4049 * !0 = failure 4050 * @note 4051 * This function requests the controller to enable or disable periodic advertising for the specified advertising set. 4052 */ 4053 int32_t rsi_ble_app_set_periodic_ae_enable(uint8_t enable, uint8_t handle); 4054 4055 /*========================================================*/ 4056 /** 4057 * @fn int32_t rsi_ble_ae_set_scan_params(void *ae_scan_params) 4058 * @brief Update AE scan parameters 4059 * @param[in] ae_scan_params Extended scan parameters to be updated 4060 * @return The following values are returned: 4061 * 0 = success 4062 * @return The following values are returned: 4063 * !0 = failure 4064 * @note 4065 * This function sets the extended scan parameters to be used on the physical advertising channels. 4066 */ 4067 int32_t rsi_ble_ae_set_scan_params(void *ae_scan_params); 4068 4069 /*==============================================*/ 4070 /** 4071 * @fn int32_t rsi_ble_ae_set_scan_enable(void *ae_scan_enable) 4072 * @brief Enable or disable legacy and extended scanning 4073 * @param[in] ae_scan_enable Parameters specify whether to enable or disable both legacy and extended advertising PDUs 4074 * @return The following values are returned: 4075 * 0 = success 4076 * @return The following values are returned: 4077 * !0 = failure 4078 */ 4079 int32_t rsi_ble_ae_set_scan_enable(void *ae_scan_enable); 4080 4081 /*==============================================*/ 4082 /** 4083 * @fn int32_t rsi_ble_ae_set_periodic_sync(uint8_t type, void *periodic_sync_data) 4084 * @brief Synchronize periodic advertising with advertiser 4085 * @param[in] type Set to 1 to begin, 2 to cancel, or 3 to terminate the periodic advertising sync 4086 * @param[in] periodic_sync_data Parameters for starting a perodic advertising sync operation 4087 * @return The following values are returned: 4088 * 0 = success 4089 * @return The following values are returned: 4090 * 0x4E42 = unknown advertising identifier 4091 * @return The following values are returned: 4092 * 0x4E0C = command not permitted 4093 * @note 4094 * This function performs an operation to synchronize with a periodic advertising train from an advertiser and begin receiving periodic advertising packets. 4095 * @note 4096 * The operation is either started, cancelled or terminated depending on the type parameter. 4097 */ 4098 int32_t rsi_ble_ae_set_periodic_sync(uint8_t type, void *periodic_sync_data); 4099 4100 /*==============================================*/ 4101 /** 4102 * @fn int32_t rsi_ble_ae_dev_to_periodic_list(void *dev_to_list) 4103 * @brief Manage a device in the periodic advertiser list 4104 * @param[in] dev_to_list Details of a device to be added to the periodic advertiser list 4105 * @return The following values are returned: 4106 * 0 = success 4107 * @return The following values are returned: 4108 * !0 = failure 4109 * @note 4110 * This function adds, removes, or clears a device from the periodic advertiser list. 4111 */ 4112 int32_t rsi_ble_ae_dev_to_periodic_list(void *dev_to_list); 4113 4114 /*==============================================*/ 4115 /** 4116 * @fn int32_t rsi_ble_ae_read_periodic_adv_list_size(uint8_t *resp) 4117 * @brief Get periodic advertiser list size 4118 * @param[out] resp Periodic advertiser list size returned by the controller 4119 * @return The following values are returned: 4120 * 0 = success 4121 * @return The following values are returned: 4122 * !0 = failure 4123 */ 4124 int32_t rsi_ble_ae_read_periodic_adv_list_size(uint8_t *resp); 4125 4126 /*==============================================*/ 4127 /** 4128 * @fn int32_t rsi_ble_extended_connect_with_params(void *ble_extended_conn_params) 4129 * @brief Establish ACL connection to advertiser 4130 * @param[in] ble_extended_conn_params Connection parameters 4131 * @return The following values are returned: 4132 * 0 = success 4133 * @return The following values are returned: 4134 * !0 = failure 4135 * @note 4136 * This function establishes an ACL connection to an advertiser, with the local device in the BLE central role. 4137 */ 4138 int32_t rsi_ble_extended_connect_with_params(void *ext_create_conn); 4139 4140 /*==============================================*/ 4141 /** 4142 * @fn int32_t rsi_ble_read_transmit_power(void *resp) 4143 * @brief Get supported transmit power range 4144 * @param[out] resp Minimum and maximum supported transmit power, returned by the controller. Power ranges from -127 dBm to +20 dBm. 4145 * @return The following values are returned: 4146 * 0 = success 4147 * @return The following values are returned: 4148 * !0 = failure 4149 * @note 4150 * This function requests the controller to return the minimum and maximum supported transmit power. 4151 */ 4152 int32_t rsi_ble_read_transmit_power(void *resp); 4153 4154 /** @} */ 4155 4156 // GATT Client Functions 4157 /********************************************************************** 4158 * In all GAT client APIs, all actions (get/set/write) are referred to 4159 * the GATT server running on the remote / connected device. 4160 *********************************************************************/ 4161 4162 /** @addtogroup BT-LOW-ENERGY4 4163 * @{ 4164 */ 4165 4166 /*==============================================*/ 4167 /** 4168 * @fn int32_t rsi_ble_get_profiles_async(uint8_t *dev_addr, 4169 * uint16_t start_handle, 4170 * uint16_t end_handle, 4171 * rsi_ble_resp_profiles_list_t *p_prof_list) 4172 * @brief Get the supported profiles / services of the connected 4173 * remote device asynchronously. The \ref rsi_ble_on_event_profiles_list_t callback function will be 4174 * called after the profiles list event is received. This is a blocking API and can unblock the application 4175 * on the reception of the callback functions either \ref rsi_ble_on_event_profiles_list_t or \ref rsi_ble_on_gatt_error_resp_t. 4176 * @pre Pre-conditions: 4177 * \ref rsi_ble_connect() API needs to be called before this API. 4178 * @param[in] dev_addr - remote device address 4179 * @param[in] start_handle - start handle (index) of the remote device's service records 4180 * @param[in] end_handle - end handle (index) of the remote device's service records 4181 * @param[out] p_prof_list - Profiles/services information will be filled in this structure after retrieving from the remote device. 4182 See the rsi_ble_resp_profiles_list_s structure for more info. 4183 * 4184 * @note p_prof_list structure should be passed as NULL because nothing will be filled in this structure 4185 * 4186 * @return The following values are returned: 4187 * - 0 - Success 4188 * - Non-Zero Value - Failure 4189 * - 0x4E62 - Invalid Parameters 4190 * - 0x4D04 - BLE not connected 4191 * - 0x4D05 - BLE Socket not available 4192 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4193 */ 4194 4195 int32_t rsi_ble_get_profiles_async(uint8_t *dev_addr, 4196 uint16_t start_handle, 4197 uint16_t end_handle, 4198 rsi_ble_resp_profiles_list_t *p_prof_list); 4199 4200 /*==============================================*/ 4201 /** 4202 * @fn int32_t rsi_ble_get_profile_async(uint8_t *dev_addr, uuid_t profile_uuid, 4203 * profile_descriptors_t *p_profile) 4204 * @brief Get the specific profile / service of the connected remote device. 4205 * The rsi_ble_one_event_profile_by_uuid_t callback function is called after 4206 * the service characteristics response is received. This is a blocking API and can unblock the application 4207 * on the reception of the callback functions either rsi_ble_one_event_profile_by_uuid_t or \ref rsi_ble_on_gatt_error_resp_t. 4208 * @pre Pre-conditions: 4209 * - \ref rsi_ble_connect() API needs to be called before this API. 4210 * @param[in] dev_addr - remote device address 4211 * @param[in] profile_uuid - services/profiles which are searched using profile_uuid 4212 * @param[out] p_profile - profile / service information filled in this structure after retrieving from the remote device, 4213 * please refer profile_descriptor_s structure for more info. 4214 * @note p_profile structure should be passed as NULL because nothing will be filled in this structure 4215 * @return The following values are returned: 4216 * - 0 - Success 4217 * - Non-Zero Value - Failure 4218 * - 0x4E62 - Invalid Parameters 4219 * - 0x4D04 - BLE not connected 4220 * - 0x4D05 - BLE Socket not available 4221 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4222 */ 4223 int32_t rsi_ble_get_profile_async(uint8_t *dev_addr, uuid_t profile_uuid, profile_descriptors_t *p_profile); 4224 4225 /*==============================================*/ 4226 /** 4227 * @fn rint32_t rsi_ble_get_char_services_async(uint8_t *dev_addr, 4228 * uint16_t start_handle, 4229 * uint16_t end_handle, 4230 * rsi_ble_resp_char_services_t *p_char_serv_list) 4231 * @brief Get the service characteristics of the connected / remote device. 4232 * The \ref rsi_ble_on_event_read_by_char_services_t callback function is called after 4233 * the included service characteristics response is received. This is a blocking API and can unblock the application 4234 * on the reception of the callback functions either \ref rsi_ble_on_event_read_by_char_services_t or \ref rsi_ble_on_gatt_error_resp_t. 4235 * @pre Pre-conditions: 4236 * \ref rsi_ble_connect() API needs to be called before this API. 4237 * @param[in] dev_addr - remote device address 4238 * @param[in] start_handle - start handle (index) of the remote device's service records 4239 * @param[in] end_handle - end handle (index) of the remote device's service records 4240 * @param[out] p_char_serv_list - Service Characteristics details are filled in this structure. See rsi_ble_resp_char_serv_s structure for more info. 4241 * 4242 * @note p_char_services_list structure should be passed as NULL because nothing will be filled in this structure 4243 * 4244 * @return The following values are returned: 4245 * - 0 - Success 4246 * - Non-Zero Value - Failure 4247 * - 0x4E60 - Invalid Handle range 4248 * - 0x4E62 - Invalid Parameters 4249 * - 0x4D04 - BLE not connected 4250 * - 0x4D05 - BLE Socket not available 4251 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4252 */ 4253 int32_t rsi_ble_get_char_services_async(uint8_t *dev_addr, 4254 uint16_t start_handle, 4255 uint16_t end_handle, 4256 rsi_ble_resp_char_services_t *p_char_serv_list); 4257 4258 /*==============================================*/ 4259 /** 4260 * @fn int32_t rsi_ble_get_inc_services_async(uint8_t *dev_addr, 4261 * uint16_t start_handle, 4262 * uint16_t end_handle, 4263 * rsi_ble_resp_inc_services_t *p_inc_serv_list) 4264 * @brief Get the supported include services of the connected / remote device. 4265 * The \ref rsi_ble_on_event_read_by_inc_services_t callback function is called after 4266 * the service characteristics response is received. This is a blocking API and can unblock the application 4267 * on the reception of the callback functions either \ref rsi_ble_on_event_read_by_inc_services_t or \ref rsi_ble_on_gatt_error_resp_t. 4268 * @pre Pre-conditions: 4269 * \ref rsi_ble_connect() API needs to be called before this API. 4270 * @param[in] dev_addr - remote device address 4271 * @param[in] start_handle - start handle (index) of the remote device's service records 4272 * @param[in] end_handle - end handle (index) of the remote device's service records 4273 * @param[out] p_inc_serv_list - include service characteristics details are filled in this structure, please refer rsi_ble_resp_inc_serv structure for more info. 4274 * 4275 * @note p_inc_serv_list structure should be passed as NULL because nothing will be filled in this structure 4276 * @return The following values are returned: 4277 * - 0 - Success 4278 * - Non-Zero Value - Failure 4279 * - 0x4E60 - Invalid Handle range 4280 * - 0x4E62 - Invalid Parameters 4281 * - 0x4D04 - BLE not connected 4282 * - 0x4D05 - BLE Socket not available 4283 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4284 */ 4285 int32_t rsi_ble_get_inc_services_async(uint8_t *dev_addr, 4286 uint16_t start_handle, 4287 uint16_t end_handle, 4288 rsi_ble_resp_inc_services_t *p_inc_serv_list); 4289 4290 /*==============================================*/ 4291 /** 4292 * @fn int32_t rsi_ble_get_char_value_by_uuid_async(uint8_t *dev_addr, 4293 * uint16_t start_handle, 4294 * uint16_t end_handle, 4295 * uuid_t char_uuid, 4296 * rsi_ble_resp_att_value_t *p_char_val) 4297 * @brief Get the characteristic value by UUID (char_uuid). 4298 * The \ref rsi_ble_on_event_read_att_value_t callback function is called 4299 * after the attribute value is received. This is a blocking API and can unblock the application 4300 * on the reception of the callback functions either \ref rsi_ble_on_event_read_att_value_t or \ref rsi_ble_on_gatt_error_resp_t. 4301 * @pre Pre-conditions: 4302 * - \ref rsi_ble_connect() API needs to be called before this API. 4303 * @param[in] dev_addr - remote device address 4304 * @param[in] start_handle - start handle (index) of the remote device's service records 4305 * @param[in] end_handle - end handle (index) of the remote device's service records 4306 * @param[in] char_uuid - UUID of the characteristic 4307 * @param[out] p_char_val - characteristic value is filled in this structure, please refer rsi_ble_resp_att_value_s structure for more info. 4308 * @note p_char_val structure should be passed as NULL because nothing will be filled in this structure 4309 * @return The following values are returned: 4310 * - 0 - Success 4311 * - Non-Zero Value - Failure 4312 * - 0x4E60 - Invalid Handle range 4313 * - 0x4E62 - Invalid Parameters 4314 * - 0x4D04 - BLE not connected 4315 * - 0x4D05 - BLE Socket not available 4316 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4317 */ 4318 int32_t rsi_ble_get_char_value_by_uuid_async(uint8_t *dev_addr, 4319 uint16_t start_handle, 4320 uint16_t end_handle, 4321 uuid_t char_uuid, 4322 rsi_ble_resp_att_value_t *p_char_val); 4323 4324 /*==============================================*/ 4325 /** 4326 * @fn int32_t rsi_ble_get_att_descriptors_async(uint8_t *dev_addr, 4327 * uint16_t start_handle, 4328 * uint16_t end_handle, 4329 * rsi_ble_resp_att_descs_t *p_att_desc) 4330 * @brief Get the characteristic descriptors list from the remote device. The \ref rsi_ble_on_gatt_desc_val_event_t 4331 * callback function is called after the attribute descriptors response is received. This is a blocking API and can unblock the application 4332 * on the reception of the callback functions either \ref rsi_ble_on_gatt_desc_val_event_t or \ref rsi_ble_on_gatt_error_resp_t. 4333 * @pre Pre-conditions: 4334 * \ref rsi_ble_connect() API needs to be called before this API. 4335 * @param[in] dev_addr - remote device address 4336 * @param[in] start_handle - start handle (index) of the remote device's service records 4337 * @param[in] end_handle - end handle (index) of the remote device's service records 4338 * @param[out] p_att_desc - pointer to characteristic descriptor structure, Please refer rsi_ble_resp_att_descs_s strcuture for more info. 4339 * 4340 * @note p_att_desc structure should be passed as NULL because nothing will be filled in this structure 4341 * 4342 * @return The following values are returned: 4343 * - 0 - Success 4344 * - Non-Zero Value - Failure 4345 * - 0x4E60 - Invalid Handle range 4346 * - 0x4E62 - Invalid Parameters 4347 * - 0x4D04 - BLE not connected 4348 * - 0x4D05 - BLE Socket not available 4349 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4350 */ 4351 int32_t rsi_ble_get_att_descriptors_async(uint8_t *dev_addr, 4352 uint16_t start_handle, 4353 uint16_t end_handle, 4354 rsi_ble_resp_att_descs_t *p_att_desc); 4355 4356 /*==============================================*/ 4357 /** 4358 * @fn int32_t rsi_ble_get_att_value_async(uint8_t *dev_addr, uint16_t handle, 4359 * rsi_ble_resp_att_value_t *p_att_val) 4360 * @brief Get the attribute with a handle. 4361 * The \ref rsi_ble_on_event_read_resp_t callback function is called upon receiving the attribute value. This is a blocking API and can unblock the application 4362 * on the reception of the callback functions either \ref rsi_ble_on_event_read_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4363 * @pre Pre-conditions: 4364 * \ref rsi_ble_connect() API needs to be called before this API. 4365 * @param[in] dev_addr - remote device address 4366 * @param[in] handle - handle value of the attribute 4367 * @param[out] p_att_val - attribute value is filled in this structure, Please refer rsi_ble_resp_att_value_s structure for more info. 4368 * @note p_att_val structure should be passed as NULL because nothing will be filled in this structure 4369 * @return The following values are returned: 4370 * - 0 - Success 4371 * - Non-Zero Value - Failure 4372 * - 0x4E60 - Invalid Handle range 4373 * - 0x4E62 - Invalid Parameters 4374 * - 0x4D04 - BLE not connected 4375 * - 0x4D05 - BLE Socket not available 4376 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4377 */ 4378 int32_t rsi_ble_get_att_value_async(uint8_t *dev_addr, uint16_t handle, rsi_ble_resp_att_value_t *p_att_val); 4379 4380 /*==============================================*/ 4381 /** 4382 * @fn int32_t rsi_ble_get_multiple_att_values_async(uint8_t *dev_addr, 4383 * uint8_t num_of_handlers, 4384 * const uint16_t *handles, 4385 * rsi_ble_resp_att_value_t *p_att_vals) 4386 * @brief Get the multiple attribute values by using multiple handles. 4387 * The \ref rsi_ble_on_event_read_resp_t callback function is called after the attribute value is received. This is a blocking API and can unblock the application 4388 * on the reception of the callback functions either \ref rsi_ble_on_event_read_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4389 * @pre Pre-conditions: 4390 * \ref rsi_ble_connect() API needs to be called before this API. 4391 * @param[in] dev_addr - remote device address 4392 * @param[in] num_of_handlers - number of handles in the list 4393 * @param[in] handles - list of attribute handles 4394 * @param[out] p_att_vals - attribute values filled in this structure, please refer rsi_ble_resp_att_value_s structure for more info. 4395 * @note p_att_vals structure should be passed as NULL because nothing will be filled in this structure 4396 * @return The following values are returned: 4397 * - 0 - Success 4398 * - 0x4E60 - Invalid Handle range 4399 * - 0x4E62 - Invalid Parameters 4400 * - 0x4D04 - BLE not connected 4401 * - 0x4D05 - BLE Socket not available 4402 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4403 */ 4404 int32_t rsi_ble_get_multiple_att_values_async(uint8_t *dev_addr, 4405 uint8_t num_of_handlers, 4406 const uint16_t *handles, 4407 rsi_ble_resp_att_value_t *p_att_vals); 4408 4409 /*==============================================*/ 4410 /** 4411 * @fn int32_t rsi_ble_get_long_att_value_async(uint8_t *dev_addr, 4412 * uint16_t handle, 4413 * uint16_t offset, 4414 * rsi_ble_resp_att_value_t *p_att_vals) 4415 * @brief Get the long attribute value by using handle and offset. 4416 * The \ref rsi_ble_on_event_read_resp_t callback function is called after the attribute value is received. This is a blocking API and can unblock the application 4417 * on the reception of the callback functions either \ref rsi_ble_on_event_read_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4418 * @pre Pre-conditions: 4419 * \ref rsi_ble_connect() API needs to be called before this API. 4420 * @param[in] dev_addr - remote device address 4421 * @param[in] handle - attribute handle 4422 * @param[in] offset - offset within the attribute value 4423 * @param[out] p_att_vals - attribute value filled in this structure, please refer rsi_ble_resp_att_value_s structure for more info. 4424 * @note p_att_vals structure should be passed as NULL because nothing will be filled in this structure 4425 * @return The following values are returned: 4426 * - 0 - Success 4427 * - Non-Zero Value - Failure 4428 * - 0x4E60 - Invalid Handle range 4429 * - 0x4E62 - Invalid Parameters 4430 * - 0x4D04 - BLE not connected 4431 * - 0x4D05 - BLE Socket not available 4432 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4433 */ 4434 int32_t rsi_ble_get_long_att_value_async(uint8_t *dev_addr, 4435 uint16_t handle, 4436 uint16_t offset, 4437 rsi_ble_resp_att_value_t *p_att_vals); 4438 4439 /*==============================================*/ 4440 /** 4441 * @fn int32_t rsi_ble_set_att_value_async(uint8_t *dev_addr, uint16_t handle, 4442 * uint8_t data_len, const uint8_t *p_data) 4443 * @brief Set the attribute value of the remote device. The \ref rsi_ble_on_event_write_resp_t 4444 * callback function is called after the attribute set action is completed. This is a blocking API and can unblock the application 4445 * on the reception of the callback functions either \ref rsi_ble_on_event_write_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4446 * @pre Pre-conditions: 4447 * \ref rsi_ble_connect() API needs to be called before this API. 4448 * @param[in] dev_addr - remote device address 4449 * @param[in] handle - attribute value handle 4450 * @param[in] data_len - attribute value length 4451 * @param[in] p_data - attribute value 4452 * @return The following values are returned: 4453 * - 0 - Success 4454 * - Non-Zero Value - Failure 4455 * - 0x4E60 - Invalid Handle range 4456 * - 0x4E62 - Invalid Parameters 4457 * - 0x4D04 - BLE not connected 4458 * - 0x4D05 - BLE Socket not available 4459 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4460 */ 4461 int32_t rsi_ble_set_att_value_async(uint8_t *dev_addr, uint16_t handle, uint8_t data_len, const uint8_t *p_data); 4462 4463 /*==============================================*/ 4464 /** 4465 * @fn int32_t rsi_ble_prepare_write_async(uint8_t *dev_addr, 4466 * uint16_t handle, 4467 * uint16_t offset, 4468 * uint8_t data_len, 4469 * const uint8_t *p_data) 4470 * @brief Prepare the attribute value. The \ref rsi_ble_on_event_prepare_write_resp_t 4471 * callback function is called after the prepare attribute write action is completed. This is a blocking API and can unblock the application 4472 * on the reception of the callback functions either \ref rsi_ble_on_event_prepare_write_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4473 * @pre Pre-conditions: 4474 * \ref rsi_ble_connect() API needs to be called before this API 4475 * @param[in] dev_addr - remote device address 4476 * @param[in] handle - attribute handle 4477 * @param[in] offset - attribute value offset 4478 * @param[in] data_len - attribute value length 4479 * @param[in] p_data - attribute value 4480 * @return The following values are returned: 4481 * - 0 - Success 4482 * - 0x4E60 - Invalid Handle range 4483 * - 0x4E62 - Invalid Parameters 4484 * - 0x4D04 - BLE not connected 4485 * - 0x4D05 - BLE Socket not available 4486 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4487 */ 4488 int32_t rsi_ble_prepare_write_async(uint8_t *dev_addr, 4489 uint16_t handle, 4490 uint16_t offset, 4491 uint8_t data_len, 4492 const uint8_t *p_data); 4493 4494 /*==============================================*/ 4495 /** 4496 * @fn int32_t rsi_ble_execute_write_async(uint8_t *dev_addr, uint8_t exe_flag) 4497 * @brief Execute the prepared attribute values. The \ref rsi_ble_on_event_write_resp_t 4498 * callback function is called after the execute attribute write action is completed. This is a blocking API and can unblock the application 4499 * on the reception of the callback functions either \ref rsi_ble_on_event_write_resp_t or \ref rsi_ble_on_gatt_error_resp_t. 4500 * @pre Pre-conditions: 4501 * \ref rsi_ble_connect() API needs to be called before this API. 4502 * @param[in] dev_addr - remote device address 4503 * @param[in] exe_flag - execute flag to write, possible values mentioned below 4504 * - 0 - BLE_ATT_EXECUTE_WRITE_CANCEL 4505 * - 1 - BLE_ATT_EXECUTE_PENDING_WRITES_IMMEDIATELY 4506 * @return The following values are returned: 4507 * - 0 - Success 4508 * - Non-Zero Value - Failure 4509 * - 0x4D05 - BLE Socket not available 4510 * @note Refer to the Status Codes section for the above error codes at [additional-status-codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) . 4511 */ 4512 int32_t rsi_ble_execute_write_async(uint8_t *dev_addr, uint8_t exe_flag); 4513 /** @} */ 4514 4515 /*==============================================*/ 4516 4517 /** 4518 * @fn uint32_t rsi_ble_cbfc_connreq(uint8_t *dev_addr, uint16_t psm) 4519 * @brief Sends a connection request to a remote device using the Credit Based Flow Control (CBFC) mechanism. 4520 * 4521 * This function sends a connection request to a remote device using the CBFC mechanism. It takes the device address and the Protocol Service Multiplexer (PSM) as input parameters. 4522 * 4523 * @param dev_addr Pointer to the device address of the remote device. 4524 * @param psm The Protocol Service Multiplexer (PSM) value. 4525 * 4526 * @return Returns a 32-bit unsigned integer indicating the status of the connection request. 4527 * - 0: If the connection request is successful. 4528 * - Non-zero: If there is an error in sending the connection request. 4529 */ 4530 uint32_t rsi_ble_cbfc_connreq(uint8_t *dev_addr, uint16_t psm); 4531 4532 /** 4533 * @fn uint32_t rsi_ble_cbfc_connresp(uint8_t *dev_addr, uint16_t lcid, uint8_t result) 4534 * @brief Sends a connection response for a credit-based flow control (CBFC) connection. 4535 * 4536 * This function is used to send a connection response for a CBFC connection in the Bluetooth Low Energy (BLE) module. 4537 * 4538 * @param dev_addr The device address of the remote device. 4539 * @param lcid The logical channel ID of the connection. 4540 * @param result The result of the connection response. 4541 * 4542 * @return The status of the operation. Returns a 32-bit unsigned integer. 4543 */ 4544 uint32_t rsi_ble_cbfc_connresp(uint8_t *dev_addr, uint16_t lcid, uint8_t result); 4545 4546 /** 4547 * @fn uint32_t rsi_ble_cbfc_data_tx(uint8_t *dev_addr, uint16_t lcid, uint16_t len, uint8_t *p_data) 4548 * @brief Transmits data over a Connection-Based Flow Control (CBFC) channel in the Bluetooth Low Energy (BLE) module. 4549 * 4550 * This function is used to transmit data over a CBFC channel in the BLE module. It takes the device address, logical channel ID (LCID), 4551 * length of the data, and a pointer to the data as input parameters. The function returns a 32-bit unsigned integer as the status of the transmission. 4552 * 4553 * @param dev_addr Pointer to the device address of the BLE module. 4554 * @param lcid Logical channel ID of the CBFC channel. 4555 * @param len Length of the data to be transmitted. 4556 * @param p_data Pointer to the data to be transmitted. 4557 * 4558 * @return 32-bit unsigned integer representing the status of the transmission. 4559 */ 4560 uint32_t rsi_ble_cbfc_data_tx(uint8_t *dev_addr, uint16_t lcid, uint16_t len, uint8_t *p_data); 4561 4562 /** 4563 * @fn uint32_t rsi_ble_cbfc_disconnect(uint8_t *dev_addr, uint16_t lcid) 4564 * @brief Disconnects a Connection-Based Flow Control (CBFC) connection with the specified device address and logical channel ID. 4565 * 4566 * This function is used to disconnect a CBFC connection with the specified device address and logical channel ID. 4567 * 4568 * @param dev_addr The device address of the remote device. 4569 * @param lcid The logical channel ID of the CBFC connection. 4570 * 4571 * @return The status code indicating the success or failure of the operation. 4572 * - Returns 0 on success. 4573 * - Returns a non-zero value on failure. 4574 */ 4575 uint32_t rsi_ble_cbfc_disconnect(uint8_t *dev_addr, uint16_t lcid); 4576 4577 /****************************************************** 4578 * * BLE GAP Callbacks Declarations 4579 * ******************************************************/ 4580 /** @addtogroup BT-LOW-ENERGY8 4581 * @{ 4582 */ 4583 /** 4584 * @typedef void (*rsi_ble_on_adv_report_event_t)(rsi_ble_event_adv_report_t *rsi_ble_event_adv); 4585 * @brief Callback function advertise event report from the module. 4586 * This callback function is called whenever an advertise event report is received from the module. 4587 * It has to registered using the `rsi_ble_gap_register_callbacks` API. 4588 * @param[out] rsi_ble_event_adv contains the advertise report information. Please refer rsi_ble_event_adv_report_s for more info. 4589 * @return The following values are returned: 4590 * void 4591 */ 4592 typedef void (*rsi_ble_on_adv_report_event_t)(rsi_ble_event_adv_report_t *rsi_ble_event_adv); 4593 4594 /** 4595 * @typedef void (*rsi_ble_on_connect_t)(rsi_ble_event_conn_status_t *rsi_ble_event_conn); 4596 * @brief Callback function for the BLE connection status from the module. 4597 * 4598 * This callback function is called whenever the BLE connection status is received from the module. 4599 * For BLE 4.1 and lower versions, this callback will be called. 4600 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4601 * @param[out] rsi_ble_event_conn contains the BLE connection status. Please refer rsi_ble_event_conn_status_s for more info. 4602 * @return The following values are returned: 4603 * void 4604 */ 4605 typedef void (*rsi_ble_on_connect_t)(rsi_ble_event_conn_status_t *rsi_ble_event_conn); 4606 4607 /** 4608 * @typedef void (*rsi_ble_on_enhance_connect_t)(rsi_ble_event_enhance_conn_status_t *rsi_ble_event_enhance_conn); 4609 * @brief Callback function for the BLE connection status from the module. 4610 * 4611 * This callback function is called whenever the BLE connection status is received from the module. 4612 * For BLE 4.2 and above versions, this callback will be called. 4613 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4614 * @param[out] rsi_ble_event_enhance_conn contains the BLE connection status. Please refer rsi_ble_event_enhance_conn_status_s for more info. 4615 * @return The following values are returned: 4616 * void 4617 */ 4618 typedef void (*rsi_ble_on_enhance_connect_t)(rsi_ble_event_enhance_conn_status_t *rsi_ble_event_enhance_conn); 4619 4620 /** 4621 * @typedef void (*rsi_ble_on_disconnect_t)(rsi_ble_event_disconnect_t *rsi_ble_event_disconnect, uint16_t reason); 4622 * @brief Callback function for the disconnect status event from the module. 4623 * 4624 * This callback function is called whenever the disconnect status event is received from the module. 4625 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4626 * @param[out] rsi_ble_event_disconnect contains the disconnect status. Please refer rsi_ble_event_disconnect_s for more information. 4627 * @param[out] reason contains reason for failure. 4628 * @note Few reason for failure are given below 4629 * 0x4E13 Remote user terminated connection 4630 * 0x4E14 Remote device terminated connection due to low resources 4631 * 0x4E15 Remote device terminated connection due to power off 4632 * 0x4E3D Connection terminated due to MIC failure 4633 * 0x4E3E Connection Failed to be Established 4634 * 0x4E60 Invalid Handle Range 4635 * @return The following values are returned: 4636 * void 4637 * 4638 */ 4639 typedef void (*rsi_ble_on_disconnect_t)(rsi_ble_event_disconnect_t *rsi_ble_event_disconnect, uint16_t reason); 4640 4641 /** 4642 * @typedef void (*rsi_ble_on_le_ping_payload_timeout_t)(rsi_ble_event_le_ping_time_expired_t *rsi_ble_event_timeout_expired); 4643 * @brief Callback function for the LE ping time expired event from the module. 4644 * 4645 * This callback function is called whenever the LE ping time expired event is received from the module. 4646 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4647 * @param[out] rsi_ble_event_timeout_expired contains the disconnect status. See rsi_ble_event_le_ping_time_expired_s for more information. 4648 * @return The following values are returned: 4649 * void 4650 */ 4651 typedef void (*rsi_ble_on_le_ping_payload_timeout_t)( 4652 rsi_ble_event_le_ping_time_expired_t *rsi_ble_event_timeout_expired); 4653 4654 /** 4655 * @typedef void (*rsi_ble_on_le_ltk_req_event_t)(rsi_bt_event_le_ltk_request_t *rsi_ble_event_le_ltk_request); 4656 * @brief Callback function for the LE LTK request event from the module. 4657 * 4658 * This callback function is called whenever the LE LTK request event is received from the module. 4659 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4660 * @param[out] rsi_ble_event_le_ltk_request contains the LTK request info. See rsi_bt_event_le_ltk_request_s for more information. 4661 * @return The following values are returned: 4662 * void 4663 */ 4664 typedef void (*rsi_ble_on_le_ltk_req_event_t)(rsi_bt_event_le_ltk_request_t *rsi_ble_event_le_ltk_request); 4665 4666 /** 4667 * @typedef void (*rsi_ble_on_le_security_keys_t)(rsi_bt_event_le_security_keys_t *rsi_ble_event_le_security_keys); 4668 * @brief Callback function for the LE security keys event from the module. 4669 * 4670 * This callback function is called whenever the LE security keys event is received from the module. 4671 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4672 * @param[out] rsi_ble_event_le_security_keys contains security keys. See rsi_bt_event_le_security_keys_s for more information. 4673 * @return The following values are returned: 4674 * void 4675 */ 4676 typedef void (*rsi_ble_on_le_security_keys_t)(rsi_bt_event_le_security_keys_t *rsi_ble_event_le_security_keys); 4677 /** @} */ 4678 4679 /****************************************************** 4680 * * BLE SMP EVENT Callbacks Declarations 4681 * ******************************************************/ 4682 /** @addtogroup BT-LOW-ENERGY8 4683 * @{ 4684 */ 4685 /** 4686 * @typedef void (*rsi_ble_on_smp_request_t)(rsi_bt_event_smp_req_t *remote_dev_address); 4687 * @brief Callback function for SMP request in central mode from the remote device. 4688 * 4689 * This callback function is called whenever an SMP request is received in central mode from the remote device. 4690 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4691 * @param[out] remote_dev_address contains the smp requested device address. See rsi_bt_event_smp_req_s for more information. 4692 * @return The following values are returned: 4693 * void 4694 * 4695 */ 4696 typedef void (*rsi_ble_on_smp_request_t)(rsi_bt_event_smp_req_t *remote_dev_address); 4697 4698 /*==============================================*/ 4699 /** 4700 * @typedef void (*rsi_ble_on_smp_response_t)(rsi_bt_event_smp_resp_t *remote_dev_address); 4701 * @brief Callback function for SMP request in peripheral mode from the remote device. 4702 * 4703 * This callback function is called whenever an SMP request is received in peripheral mode from the remote device. 4704 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4705 * @param[out] remote_dev_address contains the smp resp information. See rsi_bt_event_smp_resp_s for more information. 4706 * @return The following values are returned: 4707 * void 4708 * 4709 */ 4710 typedef void (*rsi_ble_on_smp_response_t)(rsi_bt_event_smp_resp_t *remote_dev_address); 4711 4712 /*==============================================*/ 4713 /** 4714 * @typedef void (*rsi_ble_on_smp_passkey_t)(rsi_bt_event_smp_passkey_t *remote_dev_address); 4715 * @brief Callback function for SMP passkey event from the module. 4716 * 4717 * This callback function is called whenever an SMP passkey event is received from the module. 4718 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4719 * @param[out] remote_dev_address contains the remote device address. See rsi_bt_event_smp_passkey_s for more information. 4720 * @return The following values are returned: 4721 * void 4722 * 4723 * 4724 */ 4725 typedef void (*rsi_ble_on_smp_passkey_t)(rsi_bt_event_smp_passkey_t *remote_dev_address); 4726 4727 /*==============================================*/ 4728 /** 4729 * @typedef void (*rsi_ble_on_smp_passkey_display_t)(rsi_bt_event_smp_passkey_display_t *smp_passkey_display); 4730 * @brief Callback function for SMP passkey display event from the module. 4731 * 4732 * This callback function is called whenever an SMP passkey display event is received from the module. 4733 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4734 * @param[out] smp_passkey_display contains the smp passkey display information. See rsi_bt_event_smp_passkey_display_s for more information. 4735 * @return The following values are returned: 4736 * void 4737 * 4738 4739 */ 4740 typedef void (*rsi_ble_on_smp_passkey_display_t)(rsi_bt_event_smp_passkey_display_t *smp_passkey_display); 4741 4742 /*==============================================*/ 4743 /** 4744 * @typedef void (*rsi_ble_on_smp_failed_t)(uint16_t resp_status, rsi_bt_event_smp_failed_t *remote_dev_address); 4745 * @brief Callback function for SMP failed event from the module. 4746 * 4747 * This callback function will be called if the smp process is failed with remote device. 4748 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4749 * @param[out] resp_status contains the response status (Success or Error code) 4750 * @note Error codes for SMP FAILED are given below: 4751 * 0x4B01 SMP Passkey entry failed 4752 * 0x4B02 SMP OOB not available 4753 * 0x4B03 SMP Authentication Requirements 4754 * 0x4B04 SMP confirm value failed 4755 * 0x4B05 SMP Pairing not supported 4756 * 0x4B06 SMP Encryption key size insufficient 4757 * 0x4B07 SMP command not supported 4758 * 0x4B08 SMP Unspecified Reason 4759 * 0x4B09 SMP repeated attempts 4760 * 0x4B0C SMP Numeric Comparison Failed 4761 * 0x4B0B DHKEY Check Failed 4762 * @param[out] remote_dev_address contains the remote device address. See rsi_bt_event_smp_failed_s for more information. 4763 * @return The following values are returned: 4764 * void 4765 * 4766 */ 4767 typedef void (*rsi_ble_on_smp_failed_t)(uint16_t resp_status, rsi_bt_event_smp_failed_t *remote_dev_address); 4768 4769 /*==============================================*/ 4770 /** 4771 * @typedef void (*rsi_ble_on_sc_method_t)(rsi_bt_event_sc_method_t *scmethod); 4772 * @brief Callback function for a security method event from the module. 4773 * 4774 * This callback function will be called if the SC method is done with remote device. 4775 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4776 * @param[out] scmethod contains Security Method 1 means Just works or 2 means Passkey. See rsi_bt_event_sc_method_s for more information. 4777 * @return The following values are returned: 4778 * void 4779 * 4780 */ 4781 typedef void (*rsi_ble_on_sc_method_t)(rsi_bt_event_sc_method_t *scmethod); 4782 4783 /*==============================================*/ 4784 /** 4785 * @typedef void (*rsi_ble_on_encrypt_started_t)(uint16_t resp_status, rsi_bt_event_encryption_enabled_t *enc_enabled); 4786 * @brief Callback function an encrypted event from the module. 4787 * 4788 * This callback function will be called if the encryption process is started with remote device. 4789 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4790 * @param[out] resp_status contains the response status (Success or Error code) 4791 * @param[out] enc_enabled contains encryption information. See rsi_bt_event_encryption_enabled_s for more information. 4792 * @return The following values are returned: 4793 * void 4794 * 4795 */ 4796 typedef void (*rsi_ble_on_encrypt_started_t)(uint16_t resp_status, rsi_bt_event_encryption_enabled_t *enc_enabled); 4797 4798 /*==============================================*/ 4799 /** 4800 * @typedef void (*rsi_ble_on_sc_passkey_t)(rsi_bt_event_sc_passkey_t *sc_passkey); 4801 * @brief Callback function for a BLE Secure Connection passkey event from the module. 4802 * 4803 * This callback function is called whenever a BLE Secure Connection passkey event is received from the module. 4804 * It has to be registered using the `rsi_ble_smp_register_callbacks` API. 4805 * @param[out] sc_passkey contains LE SC Passkey information. See rsi_bt_event_encryption_enabled_s for more information. 4806 * @return The following values are returned: 4807 * void 4808 * 4809 * 4810 * 4811 */ 4812 typedef void (*rsi_ble_on_sc_passkey_t)(rsi_bt_event_sc_passkey_t *sc_passkey); 4813 4814 /** 4815 * @typedef void (*rsi_ble_on_phy_update_complete_t)(rsi_ble_event_phy_update_t *rsi_ble_event_phy_update_complete); 4816 * @brief Callback function for receiving the PHY update complete event. 4817 * 4818 * This callback function is called whenever the PHY update complete event is received. 4819 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4820 * @param[out] rsi_ble_event_phy_update_complete contains the controller support PHY information. See rsi_ble_event_phy_update_s for more information. 4821 * @return The following values are returned: 4822 * void 4823 * 4824 * 4825 * 4826 */ 4827 typedef void (*rsi_ble_on_phy_update_complete_t)(rsi_ble_event_phy_update_t *rsi_ble_event_phy_update_complete); 4828 4829 /** 4830 * @typedef void (*rsi_ble_on_conn_update_complete_t)(rsi_ble_event_conn_update_t *rsi_ble_event_conn_update_complete, 4831 uint16_t resp_status); 4832 * @brief Callback function for a connection update complete event from the module. 4833 * 4834 * This callback function is called whenever the connection update complete event is received. 4835 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4836 * @param[out] rsi_ble_event_conn_update_complete contains the controller support conn information. See rsi_ble_event_conn_update_s for more information. 4837 * @param[out] resp_status contains the response status (Success or Error code) 4838 * @return The following values are returned: 4839 * void 4840 * 4841 * 4842 * 4843 */ 4844 typedef void (*rsi_ble_on_conn_update_complete_t)(rsi_ble_event_conn_update_t *rsi_ble_event_conn_update_complete, 4845 uint16_t resp_status); 4846 /** 4847 * @typedef void (*rsi_ble_on_remote_conn_params_request_t)( 4848 * rsi_ble_event_remote_conn_param_req_t *rsi_ble_event_remote_conn_param, 4849 * uint16_t resp_status); 4850 * @brief Callback function for remote connection parameters request. 4851 * 4852 * This callback function is called whenever a remote connection parameters request is received. 4853 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4854 * @param[out] resp_status contains the response status (Success or Error code) 4855 * @param[out] rsi_ble_event_remote_conn_param contains the remote device connection parameters. See rsi_ble_event_remote_conn_param_req_s for more information. 4856 * @return The following values are returned: 4857 * void 4858 * 4859 * 4860 */ 4861 typedef void (*rsi_ble_on_remote_conn_params_request_t)( 4862 rsi_ble_event_remote_conn_param_req_t *rsi_ble_event_remote_conn_param, 4863 uint16_t resp_status); 4864 4865 /** 4866 * @typedef void (*rsi_ble_on_remote_features_t)(rsi_ble_event_remote_features_t *rsi_ble_event_remote_features); 4867 * @brief Callback function for peer device supported features. 4868 * This callback function will be called when conn update complete event is received. 4869 * it has to be registered using rsi_ble_gap_extended_register_callbacks API. 4870 * @param[out] rsi_ble_event_remote_features contains the remote device supported features. See rsi_ble_event_remote_features_s for more information. 4871 * @return The following values are returned: 4872 * void 4873 * 4874 */ 4875 typedef void (*rsi_ble_on_remote_features_t)(rsi_ble_event_remote_features_t *rsi_ble_event_remote_features); 4876 4877 /** 4878 * @typedef void (*rsi_ble_on_le_more_data_req_t)(rsi_ble_event_le_dev_buf_ind_t *rsi_ble_more_data_evt); 4879 * @brief Callback function for the LE more data event. 4880 * 4881 * This callback function is called whenever an LE more data event is received. 4882 * It has to be registered using the `rsi_ble_gap_extended_register_callbacks` API. 4883 * @param[out] rsi_ble_more_data_evt contains the LE Device Buffer Indication information. See rsi_ble_event_le_dev_buf_ind_s for more infomation. 4884 * @return The following values are returned: 4885 * void 4886 * 4887 * 4888 * 4889 */ 4890 typedef void (*rsi_ble_on_le_more_data_req_t)(rsi_ble_event_le_dev_buf_ind_t *rsi_ble_more_data_evt); 4891 4892 /*==============================================*/ 4893 /** 4894 * @typedef void (*rsi_ble_on_data_length_update_t)(rsi_ble_event_data_length_update_t *remote_dev_address); 4895 * @brief Callback function for the data length update complete event. 4896 * 4897 * This callback function is called whenever the data length update complete event is received. 4898 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4899 * @param[out] remote_dev_address contains the controller support TX and RX length information. See rsi_ble_event_data_length_update_s for more information. 4900 * @return The following values are returned: 4901 * void 4902 * 4903 */ 4904 typedef void (*rsi_ble_on_data_length_update_t)(rsi_ble_event_data_length_update_t *remote_dev_address); 4905 4906 /** 4907 * @typedef void (*rsi_ble_on_directed_adv_report_event_t)(rsi_ble_event_directedadv_report_t *rsi_ble_event_directed); 4908 * @brief Callback function for a directed advertise report event from the module. 4909 * 4910 * This callback function is called whenever a directed advertise report event is received from the module. 4911 * It has to be registered using the `rsi_ble_gap_register_callbacks` API. 4912 * @param[in] rsi_ble_event_directed contains the advertise report information 4913 * 4914 */ 4915 typedef void (*rsi_ble_on_directed_adv_report_event_t)(rsi_ble_event_directedadv_report_t *rsi_ble_event_directed); 4916 /** @} */ 4917 4918 /** @addtogroup BT-LOW-ENERGY7 4919 * @{ 4920 */ 4921 /*==============================================*/ 4922 /** 4923 * @brief Register GAP callbacks. 4924 * @param[in] ble_on_adv_report_event - Callback function for Advertise events 4925 * @param[in] ble_on_conn_status_event - Callback function for Connect events 4926 * @param[in] ble_on_disconnect_event - Callback function for Disconnect events 4927 * @param[in] timeout_expired_event - Callback function for LE ping timeout events 4928 * @param[in] ble_on_phy_update_complete_event - Callback function for PHY update complete events 4929 * @param[in] ble_on_data_length_update_complete_event - Callback function for data length update events 4930 * @param[in] ble_on_enhance_conn_status_event - Callback function for enhanced connection status events 4931 * @param[in] ble_on_directed_adv_report_event - Callback function for directed advertising report events 4932 * @param[in] ble_on_conn_update_complete_event - Callback function for conn update complete events 4933 * @param[in] ble_on_remote_conn_params_request_event - Callback function to remote conn params request events 4934 * 4935 */ 4936 void rsi_ble_gap_register_callbacks(rsi_ble_on_adv_report_event_t ble_on_adv_report_event, 4937 rsi_ble_on_connect_t ble_on_conn_status_event, 4938 rsi_ble_on_disconnect_t ble_on_disconnect_event, 4939 rsi_ble_on_le_ping_payload_timeout_t timeout_expired_event, 4940 rsi_ble_on_phy_update_complete_t ble_on_phy_update_complete_event, 4941 rsi_ble_on_data_length_update_t ble_on_data_length_update_complete_event, 4942 rsi_ble_on_enhance_connect_t ble_on_enhance_conn_status_event, 4943 rsi_ble_on_directed_adv_report_event_t ble_on_directed_adv_report_event, 4944 rsi_ble_on_conn_update_complete_t ble_on_conn_update_complete_event, 4945 rsi_ble_on_remote_conn_params_request_t ble_on_remote_conn_params_request_event); 4946 4947 /*==============================================*/ 4948 /** 4949 * @brief Register GAP Extended responses/events callbacks. 4950 * @pre Pre-conditions: 4951 * Call [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) before calling this API. 4952 * @param[in] ble_on_remote_features_event - Call back function for Remote feature request 4953 * @param[in] ble_on_le_more_data_req_event - Call back function for LE More data request 4954 * @note For more information about each callback, see the GAP Extended callbacks description section. 4955 * 4956 */ 4957 4958 void rsi_ble_gap_extended_register_callbacks(rsi_ble_on_remote_features_t ble_on_remote_features_event, 4959 rsi_ble_on_le_more_data_req_t ble_on_le_more_data_req_event); 4960 4961 /** 4962 * @fn uint32_t rsi_ble_enhanced_gap_extended_register_callbacks(uint16_t callback_id, 4963 * void (*callback_handler_ptr)(uint16_t status, 4964 * uint8_t *buffer)); 4965 * @brief Registers a callback function for the Enhanced GAP Extended feature in the RSI BLE module. 4966 * 4967 * This function allows you to register a callback function to handle events related to the Enhanced GAP Extended feature. 4968 * The callback function will be called when an event occurs, providing the status and a buffer containing additional data. 4969 * 4970 * @param callback_id The ID of the callback to register. 4971 * @param callback_handler_ptr A pointer to the callback function that will handle the events. 4972 * 4973 * @return The status of the registration process. Possible values are defined by the uint16_t data type. 4974 * 4975 * @note Ensure that the callback function is implemented to handle the specific events you are interested in. 4976 * The callback function should match the signature specified in the function parameters. 4977 * This function should be called during the initialization phase of your application to ensure that 4978 * the callbacks are registered before any events occur. 4979 */ 4980 uint32_t rsi_ble_enhanced_gap_extended_register_callbacks(uint16_t callback_id, 4981 void (*callback_handler_ptr)(uint16_t status, 4982 uint8_t *buffer)); 4983 4984 /*==============================================*/ 4985 /** 4986 * 4987 */ 4988 /** 4989 * @fn int32_t rsi_ble_adv_ext_events_register_callbacks(uint16_t callback_id, 4990 * void (*callback_handler_ptr)(uint16_t status, uint8_t *buffer)); 4991 * @brief Registers callback functions for extended advertising events in the BLE module. 4992 * 4993 * This function allows the application to register callback functions to handle extended advertising events 4994 * in the BLE module. The callback functions will be invoked when an extended advertising event occurs. 4995 * 4996 * @param callback_id The ID of the callback function to register. 4997 * @param callback_handler_ptr A pointer to the callback function that will handle the extended advertising events. 4998 * The callback function should have the following signature: 4999 * void callback_handler(uint16_t status, uint8_t *buffer) 5000 * - status: The status of the extended advertising event. 5001 * - buffer: A pointer to the buffer containing the extended advertising event data. 5002 * 5003 * @return Returns 0 on success, or a negative error code on failure. 5004 */ 5005 int32_t rsi_ble_adv_ext_events_register_callbacks(uint16_t callback_id, 5006 void (*callback_handler_ptr)(uint16_t status, uint8_t *buffer)); 5007 5008 /*==============================================*/ 5009 /** 5010 * @brief Register the SMP callbacks 5011 * @param[in] ble_on_smp_request_event - smp request callback 5012 * @param[in] ble_on_smp_response_event - smp response callback 5013 * @param[in] ble_on_smp_passkey_event - smp passkey callback 5014 * @param[in] ble_on_smp_fail_event - smp failed callback 5015 * @param[in] rsi_ble_on_encrypt_started_event - encryption enabled callback 5016 * @param[in] ble_on_smp_passkey_display_event - smp passkey display callback 5017 * @param[in] ble_sc_passkey_event - sc passkey display callback 5018 * @param[in] ble_on_le_ltk_req_event - This is the SMP LTK request callback 5019 * @param[in] ble_on_le_security_keys_event - This is the SMP security keys callback 5020 * @param[in] ble_on_cli_smp_response_event - This is the client smp response callback - 5021 * @param[in] ble_on_sc_method_event - sc method display callback 5022 * 5023 */ 5024 void rsi_ble_smp_register_callbacks(rsi_ble_on_smp_request_t ble_on_smp_request_event, 5025 rsi_ble_on_smp_response_t ble_on_smp_response_event, 5026 rsi_ble_on_smp_passkey_t ble_on_smp_passkey_event, 5027 rsi_ble_on_smp_failed_t ble_on_smp_fail_event, 5028 rsi_ble_on_encrypt_started_t rsi_ble_on_encrypt_started_event, 5029 rsi_ble_on_smp_passkey_display_t ble_on_smp_passkey_display_event, 5030 rsi_ble_on_sc_passkey_t ble_sc_passkey_event, 5031 rsi_ble_on_le_ltk_req_event_t ble_on_le_ltk_req_event, 5032 rsi_ble_on_le_security_keys_t ble_on_le_security_keys_event, 5033 rsi_ble_on_smp_response_t ble_on_cli_smp_response_event, 5034 rsi_ble_on_sc_method_t ble_on_sc_method_event); 5035 5036 /** @} */ 5037 5038 /****************************************************** 5039 * * BLE GATT Response Callbacks Declarations 5040 * ******************************************************/ 5041 /** @addtogroup BT-LOW-ENERGY8 5042 * @{ 5043 */ 5044 /** 5045 * @typedef void (*rsi_ble_on_gatt_error_resp_t)(uint16_t event_status, rsi_ble_event_error_resp_t *rsi_ble_gatt_error); 5046 * @brief Callback function for a GATT error event from the module. 5047 * 5048 * This callback function is called whenever a GATT error event is received from the module. 5049 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5050 * @param[out] event_status contains the error response 5051 * Non-Zero Value - Failure 5052 * Attribute protocol error codes 5053 * 0x4A01 - Invalid Handle 5054 * 0x4A06 - Request not supported 5055 * 0x4A0A - Attribute not found 5056 * 0x4A05 - Insufficient authentication 5057 * 0x4A08 - Insufficient authorization 5058 * 0x4A0C - Insufficient encryption key size 5059 * 0x4A0F - Insufficient encryption 5060 * 0x4A02 - Read not permitted 5061 * 0x4A03 - Write not permitted 5062 * 0x4A07 - Invalid offset 5063 * 0x4A0B - Attribute not Long 5064 * @param[out] rsi_ble_gatt_error contains the GATT error information. Please refer rsi_ble_event_error_resp_s for more info 5065 * @return The following values are returned: 5066 * void 5067 * 5068 */ 5069 typedef void (*rsi_ble_on_gatt_error_resp_t)(uint16_t event_status, rsi_ble_event_error_resp_t *rsi_ble_gatt_error); 5070 /** 5071 * @typedef void (*rsi_ble_on_gatt_desc_val_event_t)(uint16_t event_status, 5072 rsi_ble_event_gatt_desc_t *rsi_ble_gatt_desc_val); 5073 * @brief Callback function for an attribute descriptors event from the module. 5074 * 5075 * This callback function is called whenever an attribute descriptors event is received from the module. 5076 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5077 * @param[out] event_status contains the response status 5078 * - 0 - Success 5079 * - Non-Zero Value - Failure 5080 * 5081 * @param[out] rsi_ble_gatt_desc_val contains the profiles list event information. Please refer rsi_ble_event_gatt_desc_s for more info 5082 * @return The following values are returned: 5083 * void 5084 * 5085 */ 5086 typedef void (*rsi_ble_on_gatt_desc_val_event_t)(uint16_t event_status, 5087 rsi_ble_event_gatt_desc_t *rsi_ble_gatt_desc_val); 5088 5089 /** 5090 * @typedef void (*rsi_ble_on_event_profiles_list_t)(uint16_t event_status, 5091 rsi_ble_event_profiles_list_t *rsi_ble_event_profiles); 5092 * @brief Callback function for a profiles list response from the module. 5093 * 5094 * This callback function is called whenever a profiles list response is received from the module. 5095 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5096 * @param[out] event_status contains the response status 5097 * 5098 * - 0 - Success 5099 * - Non-Zero Value - Failure 5100 * 5101 * @param[out] rsi_ble_event_profiles contains the profiles list event information. Please refer rsi_ble_event_profiles_list_s for more info 5102 * @return The following values are returned: 5103 * void 5104 * 5105 * 5106 * 5107 */ 5108 typedef void (*rsi_ble_on_event_profiles_list_t)(uint16_t event_status, 5109 rsi_ble_event_profiles_list_t *rsi_ble_event_profiles); 5110 5111 /** 5112 * @typedef void (*rsi_ble_on_event_profile_by_uuid_t)(uint16_t event_status, 5113 rsi_ble_event_profile_by_uuid_t *rsi_ble_event_profile); 5114 * @brief Callback function for a profile response from the module. 5115 * 5116 * This callback function is called whenever a profile response is received from the module. 5117 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5118 * @param[out] event_status contains the response status 5119 * 5120 * - 0 - Success 5121 * - Non-Zero Value - Failure 5122 * 5123 * @param[out] rsi_ble_event_profile contains the profile response information. Please refer rsi_ble_event_profile_by_uuid_s for more info. 5124 * @return The following values are returned: 5125 * void 5126 * 5127 * 5128 * 5129 */ 5130 typedef void (*rsi_ble_on_event_profile_by_uuid_t)(uint16_t event_status, 5131 rsi_ble_event_profile_by_uuid_t *rsi_ble_event_profile); 5132 /** 5133 * @typedef void (*rsi_ble_on_event_read_by_char_services_t)(uint16_t event_status, 5134 rsi_ble_event_read_by_type1_t *rsi_ble_event_read_type1); 5135 * @brief This callback function will be called if the characteristic services list response is received from the module. 5136 * @param[out] event_status contains the response status 5137 * 5138 * - 0 - Success 5139 * - Non-Zero Value - Failure 5140 * @param[out] rsi_ble_event_read_type1 contains the char services event information. Please refer rsi_ble_event_read_by_type1_s for more info. 5141 * @return The following values are returned: 5142 * void 5143 * 5144 * 5145 */ 5146 typedef void (*rsi_ble_on_event_read_by_char_services_t)(uint16_t event_status, 5147 rsi_ble_event_read_by_type1_t *rsi_ble_event_read_type1); 5148 5149 /** 5150 * @typedef void (*rsi_ble_on_event_read_by_inc_services_t)(uint16_t event_status, 5151 rsi_ble_event_read_by_type2_t *rsi_ble_event_read_type2); 5152 * @brief Callback function for an include services list response from the module. 5153 * 5154 * This callback function is called whenever an include services list response is received from the module. 5155 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5156 * @param[out] event_status contains the response status 5157 * 5158 * - 0 - Success 5159 * - Non-Zero Value - Failure 5160 * @param[out] rsi_ble_event_read_type2 contains the inc services information. Please refer rsi_ble_event_read_by_type2_s for more info. 5161 * @return The following values are returned: 5162 * void 5163 * 5164 * 5165 * 5166 * 5167 */ 5168 typedef void (*rsi_ble_on_event_read_by_inc_services_t)(uint16_t event_status, 5169 rsi_ble_event_read_by_type2_t *rsi_ble_event_read_type2); 5170 /** 5171 * @typedef void (*rsi_ble_on_event_read_att_value_t)(uint16_t event_status, 5172 rsi_ble_event_read_by_type3_t *rsi_ble_event_read_type3); 5173 * @brief Callback function for an attribute value response from the module. 5174 * 5175 * This callback function is called whenever an attribute value response is received from the module. 5176 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5177 * @param[out] event_status contains the response status 5178 * 5179 * - 0 - Success 5180 * - Non-Zero Value - Failure 5181 * @param[out] rsi_ble_event_read_type3 contains the char services event information. Please refer rsi_ble_event_read_by_type3_s for more info. 5182 * @return The following values are returned: 5183 * void 5184 * 5185 */ 5186 typedef void (*rsi_ble_on_event_read_att_value_t)(uint16_t event_status, 5187 rsi_ble_event_read_by_type3_t *rsi_ble_event_read_type3); 5188 5189 /** 5190 * @typedef void (*rsi_ble_on_event_read_resp_t)(uint16_t event_status, rsi_ble_event_att_value_t *rsi_ble_event_att_val); 5191 * @brief Callback function for an attribute value from the module. 5192 * 5193 * This callback function is called whenever an attribute value is received from the module. 5194 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5195 * @param[out] event_status contains the response status 5196 * 5197 * - 0 - Success 5198 * - Non-Zero Value - Failure 5199 * @param[out] rsi_ble_event_att_val contains the profile response information. Please refer rsi_ble_event_att_value_s for more info. 5200 * @return The following values are returned: 5201 * void 5202 * 5203 */ 5204 typedef void (*rsi_ble_on_event_read_resp_t)(uint16_t event_status, rsi_ble_event_att_value_t *rsi_ble_event_att_val); 5205 5206 /** 5207 * @typedef void (*rsi_ble_on_event_write_resp_t)(uint16_t event_status, rsi_ble_set_att_resp_t *rsi_ble_event_set_att_rsp); 5208 * @brief Callback function for a GATT write response from the module. 5209 * 5210 * This callback function is called whenever a GATT write response is received from the module. 5211 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5212 * @param[out] event_status contains the response status 5213 * 5214 * - 0 - Success 5215 * - Non-Zero Value - Failure 5216 * 5217 * @param[out] rsi_ble_event_set_att_rsp contains the profile response information. Please refer rsi_ble_set_att_resp_t for more info. 5218 * @return The following values are returned: 5219 * void 5220 * 5221 */ 5222 typedef void (*rsi_ble_on_event_write_resp_t)(uint16_t event_status, rsi_ble_set_att_resp_t *rsi_ble_event_set_att_rsp); 5223 /** 5224 * @typedef void (*rsi_ble_on_event_indicate_confirmation_t)(uint16_t event_status, 5225 rsi_ble_set_att_resp_t *rsi_ble_event_set_att_rsp); 5226 * @brief Callback function for indication confirmation event 5227 * 5228 * This callback function is called whenever an indication confirmation response is received from the module. 5229 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5230 * @param[out] event_status contains the response status 5231 * 5232 * - 0 - Success 5233 * - Non-Zero Value - Failure 5234 * @param[out] rsi_ble_event_set_att_rsp contains the profile response information. Please refer rsi_ble_set_att_resp_s for more info. 5235 * @return The following values are returned: 5236 * void 5237 * 5238 */ 5239 typedef void (*rsi_ble_on_event_indicate_confirmation_t)(uint16_t event_status, 5240 rsi_ble_set_att_resp_t *rsi_ble_event_set_att_rsp); 5241 /** 5242 * @typedef void (*rsi_ble_on_event_prepare_write_resp_t)(uint16_t event_status, 5243 rsi_ble_prepare_write_resp_t *rsi_ble_event_prepare_write); 5244 * @brief Callback function for a GATT prepare response from the module. 5245 * 5246 * This callback function is called whenever a GATT prepare response is received from the module. 5247 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5248 * @param[out] event_status contains the response status 5249 * - 0 - Success 5250 * - Non-Zero Value - Failure 5251 * @param[out] rsi_ble_event_prepare_write contains the char services event information. Please refer rsi_ble_prepare_write_resp_s for more info. 5252 * @return The following values are returned: 5253 * void 5254 * 5255 */ 5256 typedef void (*rsi_ble_on_event_prepare_write_resp_t)(uint16_t event_status, 5257 rsi_ble_prepare_write_resp_t *rsi_ble_event_prepare_write); 5258 5259 /** 5260 * @typedef void (*rsi_ble_on_profiles_list_resp_t)(uint16_t resp_status, 5261 rsi_ble_resp_profiles_list_t *rsi_ble_resp_profiles); 5262 * @brief Callback function for a profiles list response from the module. 5263 * 5264 * This callback function is called whenever a profiles list response is received from the module. 5265 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5266 * @param[out] resp_status contains the response status 5267 * - 0 - Success 5268 * - Non-Zero Value - Failure 5269 * @note Attribute protocol error codes 5270 * 0x4A01 - Invalid Handle 5271 * 0x4A0A - Attribute not found 5272 * @param[out] rsi_ble_resp_profiles contains the profiles list response information. Please refer rsi_ble_resp_profiles_list_s for more info. 5273 * @return The following values are returned: 5274 * void 5275 * 5276 */ 5277 typedef void (*rsi_ble_on_profiles_list_resp_t)(uint16_t resp_status, 5278 rsi_ble_resp_profiles_list_t *rsi_ble_resp_profiles); 5279 5280 /** 5281 * @typedef void (*rsi_ble_on_profile_resp_t)(uint16_t resp_status, profile_descriptors_t *rsi_ble_resp_profile); 5282 * @brief Callback function for a profile response from the module. 5283 * 5284 * This callback function is called whenever a profile response is received from the module. 5285 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5286 * @param[out] resp_status contains the response status 5287 * - 0 - Success 5288 * - Non-Zero Value - Failure 5289 * @note Attribute protocol error codes 5290 * 0x4A01 - Invalid Handle 5291 * 0x4A06 - Request not supported 5292 * 0x4A0A - Attribute not found 5293 * @param[out] rsi_ble_resp_profile contains the profile response information. Please refer profile_descriptors_s for more info 5294 * @return The following values are returned: 5295 * void 5296 * 5297 */ 5298 typedef void (*rsi_ble_on_profile_resp_t)(uint16_t resp_status, profile_descriptors_t *rsi_ble_resp_profile); 5299 5300 /** 5301 * @typedef void (*rsi_ble_on_char_services_resp_t)(uint16_t resp_status, 5302 rsi_ble_resp_char_services_t *rsi_ble_resp_char_serv); 5303 * @brief Callback function for a service characteristics response from the module. 5304 * 5305 * This callback function is called whenever a service characteristics response is received from the module. 5306 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5307 * @param[out] resp_status contains the response status 5308 * 5309 * - 0 - Success 5310 * - Non-Zero Value - Failure 5311 * @note Attribute protocol error codes 5312 * 0x4A01 - Invalid Handle 5313 * 0x4A06 - Request not supported 5314 * 0x4A0A - Attribute not found 5315 * 0x4A05 - Insufficient authentication 5316 * 0x4A08 - Insufficient authorization 5317 * 0x4A0C - Insufficient encryption key size 5318 * 0x4A0F - Insufficient encryption 5319 * 0x4A02 - Read not permitted 5320 * @param[out] rsi_ble_resp_char_serv contains the service characteristics response information. Please refer rsi_ble_resp_char_services_s for more info 5321 * @return The following values are returned: 5322 * void 5323 */ 5324 typedef void (*rsi_ble_on_char_services_resp_t)(uint16_t resp_status, 5325 rsi_ble_resp_char_services_t *rsi_ble_resp_char_serv); 5326 5327 /** 5328 * @typedef void (*rsi_ble_on_inc_services_resp_t)(uint16_t resp_status, 5329 rsi_ble_resp_inc_services_t *rsi_ble_resp_inc_serv); 5330 * @brief Callback function for an include service response from the module. 5331 * 5332 * This callback function is called whenever an include service response is received from the module. 5333 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5334 * @param[out] resp_status contains the response status 5335 * 5336 * - 0 - Success 5337 * - Non-Zero Value - Failure 5338 * @note Attribute protocol error codes 5339 * 0x4A01 - Invalid Handle 5340 * 0x4A06 - Request not supported 5341 * 0x4A0A - Attribute not found 5342 * 0x4A05 - Insufficient authentication 5343 * 0x4A08 - Insufficient authorization 5344 * 0x4A0C - Insufficient encryption key size 5345 * 0x4A0F - Insufficient encryption 5346 * 0x4A02 - Read not permitted 5347 * @param[out] rsi_ble_resp_inc_serv contains the include services response information. Please refer rsi_ble_resp_inc_services_s for more info 5348 * @return The following values are returned: 5349 * void 5350 * 5351 * 5352 * 5353 */ 5354 typedef void (*rsi_ble_on_inc_services_resp_t)(uint16_t resp_status, 5355 rsi_ble_resp_inc_services_t *rsi_ble_resp_inc_serv); 5356 5357 /** 5358 * @typedef void (*rsi_ble_on_att_desc_resp_t)(uint16_t resp_status, rsi_ble_resp_att_descs_t *rsi_ble_resp_att_desc); 5359 * @brief Callback function for an attribute descriptors response from the module. 5360 * 5361 * This callback function is called whenever an attribute descriptors response is received from the module. 5362 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5363 * @param[out] resp_status contains the response status 5364 * - 0 - Success 5365 * - Non-Zero Value - Failure 5366 * @note Attribute protocol error codes 5367 * 0x4A01 - Invalid Handle 5368 * 0x4A0A - Attribute not found 5369 * 0x4A05 - Insufficient authentication 5370 * 0x4A08 - Insufficient authorization 5371 * 0x4A0C - Insufficient encryption key size 5372 * 0x4A0F - Insufficient encryption 5373 * 0x4A02 - Read not permitted 5374 * @param[out] rsi_ble_resp_att_desc contains the attribute descriptors response information. Please refer rsi_ble_resp_att_descs_s for more info 5375 * @return The following values are returned: 5376 * void 5377 * 5378 */ 5379 typedef void (*rsi_ble_on_att_desc_resp_t)(uint16_t resp_status, rsi_ble_resp_att_descs_t *rsi_ble_resp_att_desc); 5380 5381 /** 5382 * @typedef void (*rsi_ble_on_read_resp_t)(uint16_t resp_status, 5383 uint16_t resp_id, 5384 rsi_ble_resp_att_value_t *rsi_ble_resp_att_val); 5385 * @brief Callback function for receiving an attribute value from the module. 5386 * 5387 * This callback function is called upon receiving an attribute value from the module. 5388 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5389 * @param[out] resp_status contains the response status 5390 * - 0 - Success 5391 * - Non-Zero Value - Failure 5392 * @note Attribute protocol error codes 5393 * 0x4A01 - Invalid Handle 5394 * 0x4A0A - Attribute not found 5395 * 0x4A05 - Insufficient authentication 5396 * 0x4A08 - Insufficient authorization 5397 * 0x4A0C - Insufficient encryption key size 5398 * 0x4A0F - Insufficient encryption 5399 * 0x4A02 - Read not permitted 5400 * 0x4A06 - Request not supported 5401 * 0x4A07 - Invalid offset 5402 * 0x4A0B - Attribute not Long 5403 * @param[out] resp_id contains the response id because of which, this callback is called 5404 * response ids: (RSI_BLE_RSP_READ_VAL, RSI_BLE_RSP_READ_BY_UUID, RSI_BLE_RSP_LONG_READ, RSI_BLE_RSP_MULTIPLE_READ) 5405 * @param[out] rsi_ble_resp_att_val contains the attribute value. Please refer rsi_ble_resp_att_value_s for more info 5406 * @return The following values are returned: 5407 * void 5408 * 5409 * 5410 */ 5411 typedef void (*rsi_ble_on_read_resp_t)(uint16_t resp_status, 5412 uint16_t resp_id, 5413 rsi_ble_resp_att_value_t *rsi_ble_resp_att_val); 5414 5415 /** 5416 * @typedef void (*rsi_ble_on_write_resp_t)(uint16_t resp_status, uint16_t resp_id); 5417 * @brief Callback function for attribute set/prepare/execute action completion. 5418 * 5419 * This callback function is called when an attribute set, prepare, or execute action is completed. 5420 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5421 * @param[out] resp_status contains the response status 5422 * 5423 * - 0 - Success 5424 * - Non-Zero Value - Failure 5425 * @note Attribute protocol error codes 5426 * 0x4A01 - Invalid Handle 5427 * 0x4A0A - Attribute not found 5428 * 0x4A05 - Insufficient authentication 5429 * 0x4A08 - Insufficient authorization 5430 * 0x4A0C - Insufficient encryption key size 5431 * 0x4A0F - Insufficient encryption 5432 * 0x4A03 - Write not permitted 5433 * 0x4A07 - Invalid offset 5434 * 0x4A0D - Invalid attribute value length 5435 * @param[out] resp_id contains the response id because of which, this callback is called 5436 * response ids: (RSI_BLE_RSP_WRITE, RSI_BLE_RSP_WRITE_NO_ACK, RSI_BLE_RSP_LONG_WRITE, RSI_BLE_RSP_EXECUTE_WRITE) 5437 * 5438 */ 5439 typedef void (*rsi_ble_on_write_resp_t)(uint16_t resp_status, uint16_t resp_id); 5440 /** @} */ 5441 5442 /****************************************************** 5443 * * BLE GATT Event Callbacks Declarations 5444 * ******************************************************/ 5445 /** @addtogroup BT-LOW-ENERGY8 5446 * @{ 5447 */ 5448 /** 5449 * @typedef void (*rsi_ble_on_gatt_write_event_t)(uint16_t event_id, rsi_ble_event_write_t *rsi_ble_write); 5450 * @brief Callback function for GATT write, notify, or indicate events from the module. 5451 * 5452 * This callback function is called when GATT write, notify, or indicate events are received from the module. 5453 * It has to be registered using the `rsi_ble_gatt_register_callbacks` API. 5454 * @param[out] event_id contains the gatt_write event id (RSI_BLE_EVENT_GATT_WRITE) 5455 * @param[out] rsi_ble_write contains the GATT event information. Please refer rsi_ble_event_write_s for more info 5456 * 5457 */ 5458 typedef void (*rsi_ble_on_gatt_write_event_t)(uint16_t event_id, rsi_ble_event_write_t *rsi_ble_write); 5459 5460 /** 5461 * @typedef void (*rsi_ble_on_gatt_prepare_write_event_t)(uint16_t event_id, rsi_ble_event_prepare_write_t *rsi_ble_write); 5462 * @brief The callback function will be called if the GATT prepare events are received. 5463 * This callback has to be registered using rsi_ble_gatt_register_callbacks API. 5464 * @param[out] event_id contains the gatt_prepare_write event id (RSI_BLE_EVENT_PREPARE_WRITE) 5465 * @param[out] rsi_ble_write contains the GATT prepare event information. Please refer rsi_ble_event_prepare_write_s for more info 5466 * 5467 * 5468 */ 5469 typedef void (*rsi_ble_on_gatt_prepare_write_event_t)(uint16_t event_id, rsi_ble_event_prepare_write_t *rsi_ble_write); 5470 5471 /** 5472 * @typedef void (*rsi_ble_on_execute_write_event_t)(uint16_t event_id, rsi_ble_execute_write_t *rsi_ble_execute_write); 5473 * @brief The callback function will be called if the GATT execute events are received. 5474 * This callback has to be registered using rsi_ble_gatt_register_callbacks API. 5475 * @param[out] event_id contains the gatt_execute_write event id (RSI_BLE_EVENT_EXECUTE_WRITE) 5476 * 5477 * @param[out] rsi_ble_execute_write contains the GATT event information. Please refer rsi_ble_execute_write_s for more info. 5478 * 5479 * 5480 */ 5481 typedef void (*rsi_ble_on_execute_write_event_t)(uint16_t event_id, rsi_ble_execute_write_t *rsi_ble_execute_write); 5482 5483 /** 5484 * @typedef void (*rsi_ble_on_read_req_event_t)(uint16_t event_id, rsi_ble_read_req_t *rsi_ble_read_req); 5485 * @brief The callback function will be called if the GATT read request events are received. 5486 * This callback has to be registered using rsi_ble_gatt_register_callbacks API. 5487 * @param[out] event_id contains the gatt_read_req_event id (RSI_BLE_EVENT_READ_REQ) 5488 * @param[out] rsi_ble_read_req contains the GATT event information. Please refer rsi_ble_read_req_s for more info. 5489 * 5490 */ 5491 typedef void (*rsi_ble_on_read_req_event_t)(uint16_t event_id, rsi_ble_read_req_t *rsi_ble_read_req); 5492 5493 /** 5494 * @typedef void (*rsi_ble_on_mtu_event_t)(rsi_ble_event_mtu_t *rsi_ble_event_mtu); 5495 * @brief The callback function will be called if MTU size request is received. 5496 * This callback function will be called when connected to indicate MTU size. 5497 * This callback has to be registered using rsi_ble_gatt_register_callbacks API. 5498 * @param[out] rsi_ble_event_mtu contains the MTU size information. Please refer rsi_ble_event_mtu_s for more info. 5499 * 5500 */ 5501 typedef void (*rsi_ble_on_mtu_event_t)(rsi_ble_event_mtu_t *rsi_ble_event_mtu); 5502 5503 /** 5504 * @typedef void (*rsi_ble_on_mtu_exchange_info_t)(rsi_ble_event_mtu_exchange_information_t *rsi_ble_event_mtu_exchange_info); 5505 * @brief Callback function to indicate MTU size and who initiated MTU Exchange Request. 5506 * This callback function will be called when connected, this event will contain MTU Exchange Information. 5507 * This callback has to be registered using rsi_ble_gatt_extended_register_callbacks API. 5508 * @param[out] rsi_ble_event_mtu_exchange_info contains the MTU exchange information. Please refer rsi_ble_event_mtu_exchange_information_s for more info. 5509 * 5510 * 5511 */ 5512 typedef void (*rsi_ble_on_mtu_exchange_info_t)( 5513 rsi_ble_event_mtu_exchange_information_t *rsi_ble_event_mtu_exchange_info); 5514 5515 /** 5516 * @typedef void (*rsi_ble_on_remote_device_info_t)(uint16_t status, rsi_ble_event_remote_device_info_t *resp_buffer); 5517 * @brief Callback function to peer device information.This callback function will be called when conn update complete event is received 5518 * This callback has to be registered using rsi_ble_enhanced_gap_extended_register_callbacks API. 5519 * @param[out] status contains the response status (Success or Error code) 5520 * - 0 - SUCCESS 5521 * - Non-Zero Value - ErrorCodes 5522 * @note Refer Bluetooth Generic Error Codes section up to 0x4FF8 from error-codes. 5523 * @param[out] resp_buffer contains the remote device version information. 5524 * 5525 * 5526 * 5527 */ 5528 typedef void (*rsi_ble_on_remote_device_info_t)(uint16_t status, rsi_ble_event_remote_device_info_t *resp_buffer); 5529 /** 5530 * @file rsi_ble_apis.h 5531 * @brief This file contains the declarations of the BLE API functions. 5532 */ 5533 5534 /** 5535 * @typedef void (*rsi_ble_on_rcp_resp_rcvd_t)(uint16_t status, rsi_ble_event_rcp_rcvd_info_t *resp_buffer); 5536 * @brief Callback function type for receiving RCP response events. 5537 * @param status The status of the RCP response event. 5538 * @param resp_buffer Pointer to the buffer containing the RCP response information. 5539 * 5540 */ 5541 typedef void (*rsi_ble_on_rcp_resp_rcvd_t)(uint16_t status, rsi_ble_event_rcp_rcvd_info_t *resp_buffer); 5542 5543 /** @} */ 5544 5545 /********************************************************************************* 5546 * * BLE L2CAP Credit based flow control(CBFC) Callbacks register function Declarations 5547 * *******************************************************************************/ 5548 5549 /** 5550 * @typedef void (*rsi_ble_on_cbfc_conn_req_event_t)(rsi_ble_event_cbfc_conn_req_t *rsi_ble_cbfc_conn_req); 5551 * @brief Callback function to indicate L2CAP CBFC connection request.This callback function will be called when connected to indicate connection request 5552 * This callback has to be registered using rsi_ble_l2cap_cbfc_callbacks API. 5553 * @param[in] rsi_ble_cbfc_conn_req contains the connection request information 5554 * 5555 * 5556 * 5557 */ 5558 typedef void (*rsi_ble_on_cbfc_conn_req_event_t)(rsi_ble_event_cbfc_conn_req_t *rsi_ble_cbfc_conn_req); 5559 5560 /** 5561 * @typedef void (*rsi_ble_on_cbfc_conn_complete_event_t)(rsi_ble_event_cbfc_conn_complete_t *rsi_ble_cbfc_conn_complete, 5562 * uint16_t status); 5563 * @brief Callback function to indicate L2CAP CBFC connection complete status. This callback function will be called when connected to indicate connection complete status. 5564 * This callback has to be registered using rsi_ble_l2cap_cbfc_callbacks API. 5565 * @param[in] status 5566 * @param[in] rsi_ble_cbfc_conn_complete contains the connection completed information 5567 * 5568 * 5569 * 5570 */ 5571 typedef void (*rsi_ble_on_cbfc_conn_complete_event_t)(rsi_ble_event_cbfc_conn_complete_t *rsi_ble_cbfc_conn_complete, 5572 uint16_t status); 5573 5574 /** 5575 * @typedef void (*rsi_ble_on_cbfc_rx_data_event_t)(rsi_ble_event_cbfc_rx_data_t *rsi_ble_cbfc_rx_data); 5576 * @brief Callback function to indicate L2CAP CBFC RX data event. This callback function will be called when connected to indicate received data. 5577 * This callback has to be registered using rsi_ble_l2cap_cbfc_callbacks API. 5578 * @param[in] rsi_ble_cbfc_rx_data contains the received data information 5579 * 5580 * 5581 * 5582 */ 5583 typedef void (*rsi_ble_on_cbfc_rx_data_event_t)(rsi_ble_event_cbfc_rx_data_t *rsi_ble_cbfc_rx_data); 5584 5585 /** 5586 * @typedef void (*rsi_ble_on_cbfc_disconn_event_t)(rsi_ble_event_cbfc_disconn_t *rsi_ble_cbfc_disconn); 5587 * @brief Callback function to indicate L2CAP CBFC disconnection event. 5588 * This callback function will be called when connected to indicate disconnect l2cap connection. 5589 * This callback has to be registered using rsi_ble_l2cap_cbfc_callbacks API. 5590 * @param[in] rsi_ble_cbfc_disconn contains the disconnect device information 5591 * 5592 * 5593 * 5594 */ 5595 typedef void (*rsi_ble_on_cbfc_disconn_event_t)(rsi_ble_event_cbfc_disconn_t *rsi_ble_cbfc_disconn); 5596 5597 /** 5598 * @fn void rsi_ble_l2cap_cbsc_register_callbacks(rsi_ble_on_cbfc_conn_req_event_t ble_on_cbsc_conn_req, 5599 * rsi_ble_on_cbfc_conn_complete_event_t ble_on_cbsc_conn_complete, 5600 * rsi_ble_on_cbfc_rx_data_event_t ble_on_cbsc_rx_data, 5601 * rsi_ble_on_cbfc_disconn_event_t ble_on_cbsc_disconn); 5602 * @brief Register callbacks for BLE L2CAP Credit Based Flow Control (CBFC) events. 5603 * 5604 * This function is used to register callbacks for various CBFC events in BLE L2CAP. 5605 * The registered callbacks will be invoked when the corresponding events occur. 5606 * 5607 * @param ble_on_cbsc_conn_req Callback function to handle CBFC connection request event. 5608 * @param ble_on_cbsc_conn_complete Callback function to handle CBFC connection complete event. 5609 * @param ble_on_cbsc_rx_data Callback function to handle CBFC receive data event. 5610 * @param ble_on_cbsc_disconn Callback function to handle CBFC disconnection event. 5611 */ 5612 void rsi_ble_l2cap_cbsc_register_callbacks(rsi_ble_on_cbfc_conn_req_event_t ble_on_cbsc_conn_req, 5613 rsi_ble_on_cbfc_conn_complete_event_t ble_on_cbsc_conn_complete, 5614 rsi_ble_on_cbfc_rx_data_event_t ble_on_cbsc_rx_data, 5615 rsi_ble_on_cbfc_disconn_event_t ble_on_cbsc_disconn); 5616 5617 /** 5618 * @typedef void (*chip_ble_buffers_stats_handler_t)(chip_ble_buffers_stats_t *chip_ble_buffers_stats); 5619 * @brief Typedef for the chip_ble_buffers_stats_handler_t function pointer. 5620 * 5621 * This function pointer type is used to define a callback function that handles 5622 * the statistics of the BLE buffers in the chip. 5623 * 5624 * @param chip_ble_buffers_stats Pointer to the chip_ble_buffers_stats_t structure 5625 * that contains the statistics of the BLE buffers. 5626 */ 5627 typedef void (*chip_ble_buffers_stats_handler_t)(chip_ble_buffers_stats_t *chip_ble_buffers_stats); 5628 5629 /** 5630 * @typedef void (*rsi_ble_ae_report_complete_t)(uint16_t resp_status, rsi_ble_ae_adv_report_t *rsi_ble_event_ae_report); 5631 * @brief Callback function to report the AE Advertisements. 5632 * This callback function will be called when AE adv report event is received. 5633 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API. 5634 * @param[out] rsi_ble_event_ae_report contains the controller support AE Adv packets information 5635 * @param[out] resp_status contains the response status (Success or Error code) 5636 * 5637 * 5638 * 5639 */ 5640 typedef void (*rsi_ble_ae_report_complete_t)(uint16_t resp_status, rsi_ble_ae_adv_report_t *rsi_ble_event_ae_report); 5641 5642 /** 5643 * @typedef void (*rsi_ble_ae_per_adv_sync_estbl_t)(uint16_t resp_status, 5644 * rsi_ble_per_adv_sync_estbl_t *rsi_ble_event_per_adv_sync_estbl); 5645 * @brief Callback function to report the AE periodic sync established event. 5646 * This callback function will be called when AE periodic sync established event is received. 5647 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API. 5648 * @param[out] rsi_ble_event_per_adv_sync_estbl contains the controller support AE periodic sync established information 5649 * @param[out] resp_status contains the response status (Success or Error code) 5650 * 5651 * 5652 * 5653 */ 5654 typedef void (*rsi_ble_ae_per_adv_sync_estbl_t)(uint16_t resp_status, 5655 rsi_ble_per_adv_sync_estbl_t *rsi_ble_event_per_adv_sync_estbl); 5656 5657 /** 5658 * @typedef void (*rsi_ble_ae_per_adv_report_t)(uint16_t resp_status, 5659 * rsi_ble_per_adv_report_t *rsi_ble_event_per_adv_report); 5660 * @brief Callback function to report the AE periodic advertisement event 5661 * @param[out] rsi_ble_event_per_adv_report contains the controller support AE periodic advertisement information 5662 * @param[out] resp_status contains the response status (Success or Error code) 5663 * 5664 * This callback function will be called when AE periodic advertisement event is received 5665 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API 5666 */ 5667 typedef void (*rsi_ble_ae_per_adv_report_t)(uint16_t resp_status, 5668 rsi_ble_per_adv_report_t *rsi_ble_event_per_adv_report); 5669 5670 /** 5671 * @typedef void (*rsi_ble_ae_per_adv_sync_lost_t)(uint16_t resp_status, 5672 * rsi_ble_per_adv_sync_lost_t *rsi_ble_event_per_adv_sync_lost); 5673 * @brief Callback function to report the AE periodic sync lost event 5674 * @param[out] rsi_ble_event_per_adv_sync_lost contains the controller support AE periodic sync lost information 5675 * @param[out] resp_status contains the response status (Success or Error code) 5676 * 5677 * This callback function will be called when AE periodic sync lost event is received 5678 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API 5679 */ 5680 typedef void (*rsi_ble_ae_per_adv_sync_lost_t)(uint16_t resp_status, 5681 rsi_ble_per_adv_sync_lost_t *rsi_ble_event_per_adv_sync_lost); 5682 5683 /** 5684 * @typedef void (*rsi_ble_ae_scan_timeout_t)(uint16_t resp_status, rsi_ble_scan_timeout_t *rsi_ble_event_scan_timeout); 5685 * @brief Callback function to report the AE scan timeout event 5686 * @param[out] rsi_ble_event_scan_timeout contains the controller support AE scan timeout information 5687 * @param[out] resp_status contains the response status (Success or Error code) 5688 * 5689 * This callback function will be called when AE scan timeout is received 5690 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API 5691 * 5692 */ 5693 typedef void (*rsi_ble_ae_scan_timeout_t)(uint16_t resp_status, rsi_ble_scan_timeout_t *rsi_ble_event_scan_timeout); 5694 5695 /** 5696 * @typedef void (*rsi_ble_ae_adv_set_terminated_t)(uint16_t resp_status, 5697 * rsi_ble_adv_set_terminated_t *rsi_ble_event_adv_set_terminated); 5698 * @brief Callback function to report the AE advertising set terminated event 5699 * @param[out] rsi_ble_event_adv_set_terminated contains the controller support AE advertising set terminated information 5700 * @param[out] resp_status contains the response status (Success or Error code) 5701 * 5702 * 5703 * This callback function will be called when AE advertising set terminated is received. 5704 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API. 5705 * 5706 */ 5707 typedef void (*rsi_ble_ae_adv_set_terminated_t)(uint16_t resp_status, 5708 rsi_ble_adv_set_terminated_t *rsi_ble_event_adv_set_terminated); 5709 5710 /** 5711 * @typedef void (*rsi_ble_ae_scan_req_recvd_t)(uint16_t resp_status, 5712 * rsi_ble_scan_req_recvd_t *rsi_ble_event_scan_req_recvd); 5713 * @brief Callback function to report the AE scan request received event 5714 * @param[out] rsi_ble_event_scan_req_recvd contains the controller support AE scan request received information 5715 * @param[out] resp_status contains the response status (Success or Error code) 5716 * 5717 * This callback function will be called when AE scan request received is received 5718 * This callback has to be registered using rsi_ble_ae_events_register_callbacks API 5719 */ 5720 typedef void (*rsi_ble_ae_scan_req_recvd_t)(uint16_t resp_status, 5721 rsi_ble_scan_req_recvd_t *rsi_ble_event_scan_req_recvd); 5722 5723 /****************************************************** 5724 * * BLE GATT Callbacks register function Declarations 5725 * ******************************************************/ 5726 /** @addtogroup BT-LOW-ENERGY7 5727 * @{ 5728 */ 5729 /*==============================================*/ 5730 /** 5731 * @brief Register the GATT callbacks. 5732 * @param[in] ble_on_profiles_list_resp - Callback for rsi_ble_get_profiles command. 5733 * @param[in] ble_on_profile_resp - Callback for rsi_ble_get_profile command. 5734 * @param[in] ble_on_char_services_resp - Callback for rsi_ble_get_char_services command. 5735 * @param[in] ble_on_inc_services_resp - Callback for rsi_ble_get_inc_services command. 5736 * @param[in] ble_on_att_desc_resp - Callback for rsi_ble_get_att_descriptors command. 5737 * @param[in] ble_on_read_resp - Callback for all read requests command. 5738 * @param[in] ble_on_write_resp - Callback for all write commands. 5739 * @param[in] ble_on_gatt_event - Callback for all GATT events. 5740 * @param[in] ble_on_gatt_prepare_write_event - Callback for GATT prepare write events. 5741 * @param[in] ble_on_execute_write_event - Callback for GATT execute write events. 5742 * @param[in] ble_on_read_req_event - Callback for read request events. 5743 * @param[in] ble_on_mtu_event - Callback for MTU events. 5744 * @param[in] ble_on_gatt_error_resp_event - Callback for GATT error events. 5745 * @param[in] ble_on_gatt_desc_val_resp_event - Callback for GATT descriptor value events. 5746 * @param[in] ble_on_profiles_list_event - Callback for profiles list events. 5747 * @param[in] ble_on_profile_by_uuid_event - Callback for profile by UUID events. 5748 * @param[in] ble_on_read_by_char_services_event - Callback for read by characteristic services events. 5749 * @param[in] ble_on_read_by_inc_services_event - Callback for read by included services events. 5750 * @param[in] ble_on_read_att_value_event - Callback for read attribute value events. 5751 * @param[in] ble_on_read_resp_event - Callback for read response events. 5752 * @param[in] ble_on_write_resp_event - Callback for write response events. 5753 * @param[in] ble_on_indicate_confirmation_event - Callback for indication confirmation events. 5754 * @param[in] ble_on_prepare_write_resp_event - Callback for prepare write response events. 5755 * 5756 */ 5757 void rsi_ble_gatt_register_callbacks(rsi_ble_on_profiles_list_resp_t ble_on_profiles_list_resp, 5758 rsi_ble_on_profile_resp_t ble_on_profile_resp, 5759 rsi_ble_on_char_services_resp_t ble_on_char_services_resp, 5760 rsi_ble_on_inc_services_resp_t ble_on_inc_services_resp, 5761 rsi_ble_on_att_desc_resp_t ble_on_att_desc_resp, 5762 rsi_ble_on_read_resp_t ble_on_read_resp, 5763 rsi_ble_on_write_resp_t ble_on_write_resp, 5764 rsi_ble_on_gatt_write_event_t ble_on_gatt_event, 5765 rsi_ble_on_gatt_prepare_write_event_t ble_on_gatt_prepare_write_event, 5766 rsi_ble_on_execute_write_event_t ble_on_execute_write_event, 5767 rsi_ble_on_read_req_event_t ble_on_read_req_event, 5768 rsi_ble_on_mtu_event_t ble_on_mtu_event, 5769 rsi_ble_on_gatt_error_resp_t ble_on_gatt_error_resp_event, 5770 rsi_ble_on_gatt_desc_val_event_t ble_on_gatt_desc_val_resp_event, 5771 rsi_ble_on_event_profiles_list_t ble_on_profiles_list_event, 5772 rsi_ble_on_event_profile_by_uuid_t ble_on_profile_by_uuid_event, 5773 rsi_ble_on_event_read_by_char_services_t ble_on_read_by_char_services_event, 5774 rsi_ble_on_event_read_by_inc_services_t ble_on_read_by_inc_services_event, 5775 rsi_ble_on_event_read_att_value_t ble_on_read_att_value_event, 5776 rsi_ble_on_event_read_resp_t ble_on_read_resp_event, 5777 rsi_ble_on_event_write_resp_t ble_on_write_resp_event, 5778 rsi_ble_on_event_indicate_confirmation_t ble_on_indicate_confirmation_event, 5779 rsi_ble_on_event_prepare_write_resp_t ble_on_prepare_write_resp_event); 5780 5781 /*==============================================*/ 5782 /** 5783 * @brief Register the GATT Extended responses/events callbacks. 5784 * @param[in] ble_on_mtu_exchange_info_event ble_on_mtu_exchange_info_event - Call back function for MTU Exchange information Event 5785 * 5786 * 5787 */ 5788 void rsi_ble_gatt_extended_register_callbacks(rsi_ble_on_mtu_exchange_info_t ble_on_mtu_exchange_info_event); 5789 /** @} */ 5790 /** @} */ 5791 5792 #ifdef __cplusplus 5793 } 5794 #endif 5795 #endif