1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __ESP_GAP_BLE_API_H__ 8 #define __ESP_GAP_BLE_API_H__ 9 10 #include <stdint.h> 11 #include <stdbool.h> 12 13 #include "esp_err.h" 14 #include "esp_bt_defs.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 /** 21 * @brief BLE_ADV_DATA_FLAG data flag bit definition used for advertising data flag 22 */ 23 #define ESP_BLE_ADV_FLAG_LIMIT_DISC (0x01 << 0) 24 #define ESP_BLE_ADV_FLAG_GEN_DISC (0x01 << 1) 25 #define ESP_BLE_ADV_FLAG_BREDR_NOT_SPT (0x01 << 2) 26 #define ESP_BLE_ADV_FLAG_DMT_CONTROLLER_SPT (0x01 << 3) 27 #define ESP_BLE_ADV_FLAG_DMT_HOST_SPT (0x01 << 4) 28 #define ESP_BLE_ADV_FLAG_NON_LIMIT_DISC (0x00 ) 29 30 31 /// relate to BTM_LE_KEY_xxx in stack/btm_api.h 32 #define ESP_LE_KEY_NONE 0 /*!< No encryption key */ 33 #define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */ 34 #define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */ 35 #define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */ 36 #define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/ 37 #define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4) /*!< peer link key*/ 38 #define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */ 39 #define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */ 40 #define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */ 41 typedef uint8_t esp_ble_key_type_t; 42 43 /// relate to BTM_LE_AUTH_xxx in stack/btm_api.h 44 #define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0 no bondingv*/ 45 #define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 device in the bonding with peer */ 46 #define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 man in the middle attack */ 47 #define ESP_LE_AUTH_REQ_BOND_MITM (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_MITM) /*!< 0101 banding with man in the middle attack */ 48 #define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 secure connection */ 49 #define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 secure connection with band*/ 50 #define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 secure conn with MITM */ 51 #define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 SC with MITM and Bonding*/ 52 typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */ 53 54 #define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_DISABLE 0 /*!< authentication disable*/ 55 #define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE 1 /*!< authentication enable*/ 56 57 #define ESP_BLE_OOB_DISABLE 0 /*!< disbale the out of bond*/ 58 #define ESP_BLE_OOB_ENABLE 1 /*!< enable the out of bond*/ 59 60 /// relate to BTM_IO_CAP_xxx in stack/btm_api.h 61 #define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ 62 #define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ 63 #define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ 64 #define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ 65 #define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ 66 67 #define ESP_BLE_APPEARANCE_UNKNOWN 0x0000 /*!< relate to BTM_BLE_APPEARANCE_UNKNOWN in stack/btm_ble_api.h */ 68 #define ESP_BLE_APPEARANCE_GENERIC_PHONE 0x0040 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_PHONE in stack/btm_ble_api.h */ 69 #define ESP_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_COMPUTER in stack/btm_ble_api.h */ 70 #define ESP_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_WATCH in stack/btm_ble_api.h */ 71 #define ESP_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 /*!< relate to BTM_BLE_APPEARANCE_SPORTS_WATCH in stack/btm_ble_api.h */ 72 #define ESP_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_CLOCK in stack/btm_ble_api.h */ 73 #define ESP_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_DISPLAY in stack/btm_ble_api.h */ 74 #define ESP_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_REMOTE in stack/btm_ble_api.h */ 75 #define ESP_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES in stack/btm_ble_api.h */ 76 #define ESP_BLE_APPEARANCE_GENERIC_TAG 0x0200 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_TAG in stack/btm_ble_api.h */ 77 #define ESP_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_KEYRING in stack/btm_ble_api.h */ 78 #define ESP_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER in stack/btm_ble_api.h */ 79 #define ESP_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER in stack/btm_ble_api.h */ 80 #define ESP_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_THERMOMETER in stack/btm_ble_api.h */ 81 #define ESP_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 /*!< relate to BTM_BLE_APPEARANCE_THERMOMETER_EAR in stack/btm_ble_api.h */ 82 #define ESP_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_HEART_RATE in stack/btm_ble_api.h */ 83 #define ESP_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 /*!< relate to BTM_BLE_APPEARANCE_HEART_RATE_BELT in stack/btm_ble_api.h */ 84 #define ESP_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE in stack/btm_ble_api.h */ 85 #define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 /*!< relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM in stack/btm_ble_api.h */ 86 #define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 /*!< relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST in stack/btm_ble_api.h */ 87 #define ESP_BLE_APPEARANCE_GENERIC_HID 0x03C0 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_HID in stack/btm_ble_api.h */ 88 #define ESP_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 /*!< relate to BTM_BLE_APPEARANCE_HID_KEYBOARD in stack/btm_ble_api.h */ 89 #define ESP_BLE_APPEARANCE_HID_MOUSE 0x03C2 /*!< relate to BTM_BLE_APPEARANCE_HID_MOUSE in stack/btm_ble_api.h */ 90 #define ESP_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 /*!< relate to BTM_BLE_APPEARANCE_HID_JOYSTICK in stack/btm_ble_api.h */ 91 #define ESP_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 /*!< relate to BTM_BLE_APPEARANCE_HID_GAMEPAD in stack/btm_ble_api.h */ 92 #define ESP_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 /*!< relate to BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET in stack/btm_ble_api.h */ 93 #define ESP_BLE_APPEARANCE_HID_CARD_READER 0x03C6 /*!< relate to BTM_BLE_APPEARANCE_HID_CARD_READER in stack/btm_ble_api.h */ 94 #define ESP_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 /*!< relate to BTM_BLE_APPEARANCE_HID_DIGITAL_PEN in stack/btm_ble_api.h */ 95 #define ESP_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 /*!< relate to BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER in stack/btm_ble_api.h */ 96 #define ESP_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_GLUCOSE in stack/btm_ble_api.h */ 97 #define ESP_BLE_APPEARANCE_GENERIC_WALKING 0x0440 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_WALKING in stack/btm_ble_api.h */ 98 #define ESP_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 /*!< relate to BTM_BLE_APPEARANCE_WALKING_IN_SHOE in stack/btm_ble_api.h */ 99 #define ESP_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 /*!< relate to BTM_BLE_APPEARANCE_WALKING_ON_SHOE in stack/btm_ble_api.h */ 100 #define ESP_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 /*!< relate to BTM_BLE_APPEARANCE_WALKING_ON_HIP in stack/btm_ble_api.h */ 101 #define ESP_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_CYCLING in stack/btm_ble_api.h */ 102 #define ESP_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_COMPUTER in stack/btm_ble_api.h */ 103 #define ESP_BLE_APPEARANCE_CYCLING_SPEED 0x0482 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_SPEED in stack/btm_ble_api.h */ 104 #define ESP_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_CADENCE in stack/btm_ble_api.h */ 105 #define ESP_BLE_APPEARANCE_CYCLING_POWER 0x0484 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_POWER in stack/btm_ble_api.h */ 106 #define ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE in stack/btm_ble_api.h */ 107 #define ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER in stack/btm_ble_api.h */ 108 #define ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP in stack/btm_ble_api.h */ 109 #define ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST in stack/btm_ble_api.h */ 110 #define ESP_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_WEIGHT in stack/btm_ble_api.h */ 111 #define ESP_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE in stack/btm_ble_api.h */ 112 #define ESP_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1 /*!< relate to BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR in stack/btm_ble_api.h */ 113 #define ESP_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2 /*!< relate to BTM_BLE_APPEARANCE_MOBILITY_SCOOTER in stack/btm_ble_api.h */ 114 #define ESP_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR in stack/btm_ble_api.h */ 115 #define ESP_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP in stack/btm_ble_api.h */ 116 #define ESP_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41 /*!< relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP in stack/btm_ble_api.h */ 117 #define ESP_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44 /*!< relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP in stack/btm_ble_api.h */ 118 #define ESP_BLE_APPEARANCE_INSULIN_PEN 0x0D48 /*!< relate to BTM_BLE_APPEARANCE_INSULIN_PEN in stack/btm_ble_api.h */ 119 #define ESP_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY in stack/btm_ble_api.h */ 120 #define ESP_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS in stack/btm_ble_api.h */ 121 #define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 /*!< relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION in stack/btm_ble_api.h */ 122 #define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 /*!< relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV in stack/btm_ble_api.h */ 123 #define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 /*!< relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD in stack/btm_ble_api.h */ 124 #define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 /*!< relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV in stack/btm_ble_api.h */ 125 126 typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */ 127 128 /// GAP BLE callback event type 129 typedef enum { 130 //BLE_42_FEATURE_SUPPORT 131 ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */ 132 ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< When scan response data set complete, the event comes */ 133 ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT, /*!< When scan parameters set complete, the event comes */ 134 ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */ 135 ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */ 136 ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */ 137 ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */ 138 ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */ 139 //BLE_INCLUDED 140 ESP_GAP_BLE_AUTH_CMPL_EVT = 8, /*!< Authentication complete indication. */ 141 ESP_GAP_BLE_KEY_EVT, /*!< BLE key event for peer device keys */ 142 ESP_GAP_BLE_SEC_REQ_EVT, /*!< BLE security request */ 143 ESP_GAP_BLE_PASSKEY_NOTIF_EVT, /*!< passkey notification event */ 144 ESP_GAP_BLE_PASSKEY_REQ_EVT, /*!< passkey request event */ 145 ESP_GAP_BLE_OOB_REQ_EVT, /*!< OOB request event */ 146 ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR (identity Root 128-bit random static value used to generate Long Term Key) event */ 147 ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root vakue used to genrate identity resolving key) event */ 148 ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */ 149 //BLE_42_FEATURE_SUPPORT 150 ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */ 151 ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */ 152 //BLE_INCLUDED 153 ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT = 19, /*!< When set the static rand address complete, the event comes */ 154 ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */ 155 ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt length complete, the event comes */ 156 ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */ 157 ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */ 158 ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */ 159 ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */ 160 ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */ 161 ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */ 162 //BLE_42_FEATURE_SUPPORT 163 ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT, /*!< When update duplicate exceptional list complete, the event comes */ 164 //BLE_INCLUDED 165 ESP_GAP_BLE_SET_CHANNELS_EVT = 29, /*!< When setting BLE channels complete, the event comes */ 166 //BLE_50_FEATURE_SUPPORT 167 ESP_GAP_BLE_READ_PHY_COMPLETE_EVT, /*!< when reading phy complete, this event comes */ 168 ESP_GAP_BLE_SET_PREFERRED_DEFAULT_PHY_COMPLETE_EVT, /*!< when preferred default phy complete, this event comes */ 169 ESP_GAP_BLE_SET_PREFERRED_PHY_COMPLETE_EVT, /*!< when preferred phy complete , this event comes */ 170 ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT, /*!< when extended set random address complete, the event comes */ 171 ESP_GAP_BLE_EXT_ADV_SET_PARAMS_COMPLETE_EVT, /*!< when extended advertising parameter complete, the event comes */ 172 ESP_GAP_BLE_EXT_ADV_DATA_SET_COMPLETE_EVT, /*!< when extended advertising data complete, the event comes */ 173 ESP_GAP_BLE_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< when extended scan response data complete, the event comes */ 174 ESP_GAP_BLE_EXT_ADV_START_COMPLETE_EVT, /*!< when extended advertising start complete, the event comes */ 175 ESP_GAP_BLE_EXT_ADV_STOP_COMPLETE_EVT, /*!< when extended advertising stop complete, the event comes */ 176 ESP_GAP_BLE_EXT_ADV_SET_REMOVE_COMPLETE_EVT, /*!< when extended advertising set remove complete, the event comes */ 177 ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT, /*!< when extended advertising set clear complete, the event comes */ 178 ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT, /*!< when periodic advertising parameter complete, the event comes */ 179 ESP_GAP_BLE_PERIODIC_ADV_DATA_SET_COMPLETE_EVT, /*!< when periodic advertising data complete, the event comes */ 180 ESP_GAP_BLE_PERIODIC_ADV_START_COMPLETE_EVT, /*!< when periodic advertising start complete, the event comes */ 181 ESP_GAP_BLE_PERIODIC_ADV_STOP_COMPLETE_EVT, /*!< when periodic advertising stop complete, the event comes */ 182 ESP_GAP_BLE_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT, /*!< when periodic advertising create sync complete, the event comes */ 183 ESP_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT, /*!< when extended advertising sync cancel complete, the event comes */ 184 ESP_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT, /*!< when extended advertising sync terminate complete, the event comes */ 185 ESP_GAP_BLE_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT, /*!< when extended advertising add device complete , the event comes */ 186 ESP_GAP_BLE_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT, /*!< when extended advertising remove device complete, the event comes */ 187 ESP_GAP_BLE_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT, /*!< when extended advertising clear device, the event comes */ 188 ESP_GAP_BLE_SET_EXT_SCAN_PARAMS_COMPLETE_EVT, /*!< when extended scan parameter complete, the event comes */ 189 ESP_GAP_BLE_EXT_SCAN_START_COMPLETE_EVT, /*!< when extended scan start complete, the event comes */ 190 ESP_GAP_BLE_EXT_SCAN_STOP_COMPLETE_EVT, /*!< when extended scan stop complete, the event comes */ 191 ESP_GAP_BLE_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT, /*!< when extended prefer connection parameter set complete, the event comes */ 192 ESP_GAP_BLE_PHY_UPDATE_COMPLETE_EVT, /*!< when ble phy update complete, the event comes */ 193 ESP_GAP_BLE_EXT_ADV_REPORT_EVT, /*!< when extended advertising report complete, the event comes */ 194 ESP_GAP_BLE_SCAN_TIMEOUT_EVT, /*!< when scan timeout complete, the event comes */ 195 ESP_GAP_BLE_ADV_TERMINATED_EVT, /*!< when advertising terminate data complete, the event comes */ 196 ESP_GAP_BLE_SCAN_REQ_RECEIVED_EVT, /*!< when scan req received complete, the event comes */ 197 ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT, /*!< when channel select algorithm complete, the event comes */ 198 ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT, /*!< when periodic report advertising complete, the event comes */ 199 ESP_GAP_BLE_PERIODIC_ADV_SYNC_LOST_EVT, /*!< when periodic advertising sync lost complete, the event comes */ 200 ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT, /*!< when periodic advertising sync establish complete, the event comes */ 201 //BLE_INCLUDED 202 ESP_GAP_BLE_SC_OOB_REQ_EVT, /*!< Secure Connection OOB request event */ 203 ESP_GAP_BLE_SC_CR_LOC_OOB_EVT, /*!< Secure Connection create OOB data complete event */ 204 ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT, /*!< When getting BT device name complete, the event comes */ 205 ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */ 206 } esp_gap_ble_cb_event_t; 207 208 #define ESP_GAP_BLE_CHANNELS_LEN 5 /*!< channel length*/ 209 typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN]; 210 211 /// This is the old name, just for backwards compatibility 212 #define ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT 213 214 /// Advertising data maximum length 215 #define ESP_BLE_ADV_DATA_LEN_MAX 31 216 /// Scan response data maximum length 217 #define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31 218 219 /* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */ 220 /// The type of advertising data(not adv_type) 221 typedef enum { 222 ESP_BLE_AD_TYPE_FLAG = 0x01, /* relate to BTM_BLE_AD_TYPE_FLAG in stack/btm_ble_api.h */ 223 ESP_BLE_AD_TYPE_16SRV_PART = 0x02, /* relate to BTM_BLE_AD_TYPE_16SRV_PART in stack/btm_ble_api.h */ 224 ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03, /* relate to BTM_BLE_AD_TYPE_16SRV_CMPL in stack/btm_ble_api.h */ 225 ESP_BLE_AD_TYPE_32SRV_PART = 0x04, /* relate to BTM_BLE_AD_TYPE_32SRV_PART in stack/btm_ble_api.h */ 226 ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05, /* relate to BTM_BLE_AD_TYPE_32SRV_CMPL in stack/btm_ble_api.h */ 227 ESP_BLE_AD_TYPE_128SRV_PART = 0x06, /* relate to BTM_BLE_AD_TYPE_128SRV_PART in stack/btm_ble_api.h */ 228 ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07, /* relate to BTM_BLE_AD_TYPE_128SRV_CMPL in stack/btm_ble_api.h */ 229 ESP_BLE_AD_TYPE_NAME_SHORT = 0x08, /* relate to BTM_BLE_AD_TYPE_NAME_SHORT in stack/btm_ble_api.h */ 230 ESP_BLE_AD_TYPE_NAME_CMPL = 0x09, /* relate to BTM_BLE_AD_TYPE_NAME_CMPL in stack/btm_ble_api.h */ 231 ESP_BLE_AD_TYPE_TX_PWR = 0x0A, /* relate to BTM_BLE_AD_TYPE_TX_PWR in stack/btm_ble_api.h */ 232 ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D, /* relate to BTM_BLE_AD_TYPE_DEV_CLASS in stack/btm_ble_api.h */ 233 ESP_BLE_AD_TYPE_SM_TK = 0x10, /* relate to BTM_BLE_AD_TYPE_SM_TK in stack/btm_ble_api.h */ 234 ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11, /* relate to BTM_BLE_AD_TYPE_SM_OOB_FLAG in stack/btm_ble_api.h */ 235 ESP_BLE_AD_TYPE_INT_RANGE = 0x12, /* relate to BTM_BLE_AD_TYPE_INT_RANGE in stack/btm_ble_api.h */ 236 ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14, /* relate to BTM_BLE_AD_TYPE_SOL_SRV_UUID in stack/btm_ble_api.h */ 237 ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15, /* relate to BTM_BLE_AD_TYPE_128SOL_SRV_UUID in stack/btm_ble_api.h */ 238 ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16, /* relate to BTM_BLE_AD_TYPE_SERVICE_DATA in stack/btm_ble_api.h */ 239 ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17, /* relate to BTM_BLE_AD_TYPE_PUBLIC_TARGET in stack/btm_ble_api.h */ 240 ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18, /* relate to BTM_BLE_AD_TYPE_RANDOM_TARGET in stack/btm_ble_api.h */ 241 ESP_BLE_AD_TYPE_APPEARANCE = 0x19, /* relate to BTM_BLE_AD_TYPE_APPEARANCE in stack/btm_ble_api.h */ 242 ESP_BLE_AD_TYPE_ADV_INT = 0x1A, /* relate to BTM_BLE_AD_TYPE_ADV_INT in stack/btm_ble_api.h */ 243 ESP_BLE_AD_TYPE_LE_DEV_ADDR = 0x1b, /* relate to BTM_BLE_AD_TYPE_LE_DEV_ADDR in stack/btm_ble_api.h */ 244 ESP_BLE_AD_TYPE_LE_ROLE = 0x1c, /* relate to BTM_BLE_AD_TYPE_LE_ROLE in stack/btm_ble_api.h */ 245 ESP_BLE_AD_TYPE_SPAIR_C256 = 0x1d, /* relate to BTM_BLE_AD_TYPE_SPAIR_C256 in stack/btm_ble_api.h */ 246 ESP_BLE_AD_TYPE_SPAIR_R256 = 0x1e, /* relate to BTM_BLE_AD_TYPE_SPAIR_R256 in stack/btm_ble_api.h */ 247 ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1f, /* relate to BTM_BLE_AD_TYPE_32SOL_SRV_UUID in stack/btm_ble_api.h */ 248 ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x20, /* relate to BTM_BLE_AD_TYPE_32SERVICE_DATA in stack/btm_ble_api.h */ 249 ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x21, /* relate to BTM_BLE_AD_TYPE_128SERVICE_DATA in stack/btm_ble_api.h */ 250 ESP_BLE_AD_TYPE_LE_SECURE_CONFIRM = 0x22, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM in stack/btm_ble_api.h */ 251 ESP_BLE_AD_TYPE_LE_SECURE_RANDOM = 0x23, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_RANDOM in stack/btm_ble_api.h */ 252 ESP_BLE_AD_TYPE_URI = 0x24, /* relate to BTM_BLE_AD_TYPE_URI in stack/btm_ble_api.h */ 253 ESP_BLE_AD_TYPE_INDOOR_POSITION = 0x25, /* relate to BTM_BLE_AD_TYPE_INDOOR_POSITION in stack/btm_ble_api.h */ 254 ESP_BLE_AD_TYPE_TRANS_DISC_DATA = 0x26, /* relate to BTM_BLE_AD_TYPE_TRANS_DISC_DATA in stack/btm_ble_api.h */ 255 ESP_BLE_AD_TYPE_LE_SUPPORT_FEATURE = 0x27, /* relate to BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE in stack/btm_ble_api.h */ 256 ESP_BLE_AD_TYPE_CHAN_MAP_UPDATE = 0x28, /* relate to BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE in stack/btm_ble_api.h */ 257 ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF, /* relate to BTM_BLE_AD_MANUFACTURER_SPECIFIC_TYPE in stack/btm_ble_api.h */ 258 } esp_ble_adv_data_type; 259 260 /// Advertising mode 261 typedef enum { 262 ADV_TYPE_IND = 0x00, 263 ADV_TYPE_DIRECT_IND_HIGH = 0x01, 264 ADV_TYPE_SCAN_IND = 0x02, 265 ADV_TYPE_NONCONN_IND = 0x03, 266 ADV_TYPE_DIRECT_IND_LOW = 0x04, 267 } esp_ble_adv_type_t; 268 269 /// Advertising channel mask 270 typedef enum { 271 ADV_CHNL_37 = 0x01, 272 ADV_CHNL_38 = 0x02, 273 ADV_CHNL_39 = 0x04, 274 ADV_CHNL_ALL = 0x07, 275 } esp_ble_adv_channel_t; 276 277 typedef enum { 278 ///Allow both scan and connection requests from anyone 279 ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY = 0x00, 280 ///Allow both scan req from White List devices only and connection req from anyone 281 ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY, 282 ///Allow both scan req from anyone and connection req from White List devices only 283 ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST, 284 ///Allow scan and connection requests from White List devices only 285 ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST, 286 ///Enumeration end value for advertising filter policy value check 287 } esp_ble_adv_filter_t; 288 289 290 /* relate to BTA_DM_BLE_SEC_xxx in bta/bta_api.h */ 291 typedef enum { 292 ESP_BLE_SEC_ENCRYPT = 1, /*!< relate to BTA_DM_BLE_SEC_ENCRYPT in bta/bta_api.h. If the device has already 293 bonded, the stack will used Long Term Key (LTK) to encrypt with the remote device directly. 294 Else if the device hasn't bonded, the stack will used the default authentication request 295 used the esp_ble_gap_set_security_param function set by the user. */ 296 ESP_BLE_SEC_ENCRYPT_NO_MITM, /*!< relate to BTA_DM_BLE_SEC_ENCRYPT_NO_MITM in bta/bta_api.h. If the device has been already 297 bonded, the stack will check the LTK (Long Term Key) Whether the authentication request has been met, and if met, use the LTK 298 to encrypt with the remote device directly, else re-pair with the remote device. 299 Else if the device hasn't been bonded, the stack will use NO MITM authentication request in the current link instead of 300 using the authreq in the esp_ble_gap_set_security_param function set by the user. */ 301 ESP_BLE_SEC_ENCRYPT_MITM, /*!< relate to BTA_DM_BLE_SEC_ENCRYPT_MITM in bta/bta_api.h. If the device has been already 302 bonded, the stack will check the LTK (Long Term Key) whether the authentication request has been met, and if met, use the LTK 303 to encrypt with the remote device directly, else re-pair with the remote device. 304 Else if the device hasn't been bonded, the stack will use MITM authentication request in the current link instead of 305 using the authreq in the esp_ble_gap_set_security_param function set by the user. */ 306 }esp_ble_sec_act_t; 307 308 typedef enum { 309 ESP_BLE_SM_PASSKEY = 0, 310 /*!< Authentication requirements of local device */ 311 ESP_BLE_SM_AUTHEN_REQ_MODE, 312 /*!< The IO capability of local device */ 313 ESP_BLE_SM_IOCAP_MODE, 314 /*!< Initiator Key Distribution/Generation */ 315 ESP_BLE_SM_SET_INIT_KEY, 316 /*!< Responder Key Distribution/Generation */ 317 ESP_BLE_SM_SET_RSP_KEY, 318 /*!< Maximum Encryption key size to support */ 319 ESP_BLE_SM_MAX_KEY_SIZE, 320 /*!< Minimum Encryption key size requirement from Peer */ 321 ESP_BLE_SM_MIN_KEY_SIZE, 322 /*!< Set static Passkey */ 323 ESP_BLE_SM_SET_STATIC_PASSKEY, 324 /*!< Reset static Passkey */ 325 ESP_BLE_SM_CLEAR_STATIC_PASSKEY, 326 /*!< Accept only specified SMP Authentication requirement */ 327 ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH, 328 /*!< Enable/Disable OOB support */ 329 ESP_BLE_SM_OOB_SUPPORT, 330 /*!< Appl encryption key size */ 331 ESP_BLE_APP_ENC_KEY_SIZE, 332 /*!< authentication max param */ 333 ESP_BLE_SM_MAX_PARAM, 334 } esp_ble_sm_param_t; 335 336 #if (BLE_42_FEATURE_SUPPORT == TRUE) 337 /// Advertising parameters 338 typedef struct { 339 uint16_t adv_int_min; /*!< Minimum advertising interval for 340 undirected and low duty cycle directed advertising. 341 Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second) 342 Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec */ 343 uint16_t adv_int_max; /*!< Maximum advertising interval for 344 undirected and low duty cycle directed advertising. 345 Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second) 346 Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec Advertising max interval */ 347 esp_ble_adv_type_t adv_type; /*!< Advertising type */ 348 esp_ble_addr_type_t own_addr_type; /*!< Owner bluetooth device address type */ 349 esp_bd_addr_t peer_addr; /*!< Peer device bluetooth device address */ 350 esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type, only support public address type and random address type */ 351 esp_ble_adv_channel_t channel_map; /*!< Advertising channel map */ 352 esp_ble_adv_filter_t adv_filter_policy; /*!< Advertising filter policy */ 353 } esp_ble_adv_params_t; 354 355 /// Advertising data content, according to "Supplement to the Bluetooth Core Specification" 356 typedef struct { 357 bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/ 358 bool include_name; /*!< Advertising data include device name or not */ 359 bool include_txpower; /*!< Advertising data include TX power */ 360 int min_interval; /*!< Advertising data show slave preferred connection min interval. 361 The connection interval in the following manner: 362 connIntervalmin = Conn_Interval_Min * 1.25 ms 363 Conn_Interval_Min range: 0x0006 to 0x0C80 364 Value of 0xFFFF indicates no specific minimum. 365 Values not defined above are reserved for future use.*/ 366 367 int max_interval; /*!< Advertising data show slave preferred connection max interval. 368 The connection interval in the following manner: 369 connIntervalmax = Conn_Interval_Max * 1.25 ms 370 Conn_Interval_Max range: 0x0006 to 0x0C80 371 Conn_Interval_Max shall be equal to or greater than the Conn_Interval_Min. 372 Value of 0xFFFF indicates no specific maximum. 373 Values not defined above are reserved for future use.*/ 374 375 int appearance; /*!< External appearance of device */ 376 uint16_t manufacturer_len; /*!< Manufacturer data length */ 377 uint8_t *p_manufacturer_data; /*!< Manufacturer data point */ 378 uint16_t service_data_len; /*!< Service data length */ 379 uint8_t *p_service_data; /*!< Service data point */ 380 uint16_t service_uuid_len; /*!< Service uuid length */ 381 uint8_t *p_service_uuid; /*!< Service uuid array point */ 382 uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */ 383 } esp_ble_adv_data_t; 384 385 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 386 387 /// Ble scan type 388 typedef enum { 389 BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */ 390 BLE_SCAN_TYPE_ACTIVE = 0x1, /*!< Active scan */ 391 } esp_ble_scan_type_t; 392 393 /// Ble scan filter type 394 typedef enum { 395 BLE_SCAN_FILTER_ALLOW_ALL = 0x0, /*!< Accept all : 396 1. advertisement packets except directed advertising packets not addressed to this device (default). */ 397 BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only : 398 1. advertisement packets from devices where the advertiser’s address is in the White list. 399 2. Directed advertising packets which are not addressed for this device shall be ignored. */ 400 BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2, /*!< Accept all : 401 1. undirected advertisement packets, and 402 2. directed advertising packets where the initiator address is a resolvable private address, and 403 3. directed advertising packets addressed to this device. */ 404 BLE_SCAN_FILTER_ALLOW_WLIST_RPA_DIR = 0x3, /*!< Accept all : 405 1. advertisement packets from devices where the advertiser’s address is in the White list, and 406 2. directed advertising packets where the initiator address is a resolvable private address, and 407 3. directed advertising packets addressed to this device.*/ 408 } esp_ble_scan_filter_t; 409 410 /// Ble scan duplicate type 411 typedef enum { 412 BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */ 413 BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */ 414 BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */ 415 } esp_ble_scan_duplicate_t; 416 #if (BLE_42_FEATURE_SUPPORT == TRUE) 417 /// Ble scan parameters 418 typedef struct { 419 esp_ble_scan_type_t scan_type; /*!< Scan type */ 420 esp_ble_addr_type_t own_addr_type; /*!< Owner address type */ 421 esp_ble_scan_filter_t scan_filter_policy; /*!< Scan filter policy */ 422 uint16_t scan_interval; /*!< Scan interval. This is defined as the time interval from 423 when the Controller started its last LE scan until it begins the subsequent LE scan. 424 Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms) 425 Time = N * 0.625 msec 426 Time Range: 2.5 msec to 10.24 seconds*/ 427 uint16_t scan_window; /*!< Scan window. The duration of the LE scan. LE_Scan_Window 428 shall be less than or equal to LE_Scan_Interval 429 Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms) 430 Time = N * 0.625 msec 431 Time Range: 2.5 msec to 10240 msec */ 432 esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out 433 duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate 434 advertising reports for each packet received */ 435 } esp_ble_scan_params_t; 436 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 437 /// connection parameters information 438 typedef struct { 439 uint16_t interval; /*!< connection interval */ 440 uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */ 441 uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. 442 Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec 443 Time Range: 100 msec to 32 seconds */ 444 } esp_gap_conn_params_t; 445 446 /// Connection update parameters 447 typedef struct { 448 esp_bd_addr_t bda; /*!< Bluetooth device address */ 449 uint16_t min_int; /*!< Min connection interval */ 450 uint16_t max_int; /*!< Max connection interval */ 451 uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */ 452 uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. 453 Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec 454 Time Range: 100 msec to 32 seconds */ 455 } esp_ble_conn_update_params_t; 456 457 /** 458 * @brief BLE pkt date length keys 459 */ 460 typedef struct 461 { 462 uint16_t rx_len; /*!< pkt rx data length value */ 463 uint16_t tx_len; /*!< pkt tx data length value */ 464 } esp_ble_pkt_data_length_params_t; 465 466 /** 467 * @brief BLE encryption keys 468 */ 469 typedef struct 470 { 471 esp_bt_octet16_t ltk; /*!< The long term key*/ 472 esp_bt_octet8_t rand; /*!< The random number*/ 473 uint16_t ediv; /*!< The ediv value*/ 474 uint8_t sec_level; /*!< The security level of the security link*/ 475 uint8_t key_size; /*!< The key size(7~16) of the security link*/ 476 } esp_ble_penc_keys_t; /*!< The key type*/ 477 478 /** 479 * @brief BLE CSRK keys 480 */ 481 typedef struct 482 { 483 uint32_t counter; /*!< The counter */ 484 esp_bt_octet16_t csrk; /*!< The csrk key */ 485 uint8_t sec_level; /*!< The security level */ 486 } esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */ 487 488 /** 489 * @brief BLE pid keys 490 */ 491 typedef struct 492 { 493 esp_bt_octet16_t irk; /*!< The irk value */ 494 esp_ble_addr_type_t addr_type; /*!< The address type */ 495 esp_bd_addr_t static_addr; /*!< The static address */ 496 } esp_ble_pid_keys_t; /*!< The pid key type */ 497 498 /** 499 * @brief BLE Encryption reproduction keys 500 */ 501 typedef struct 502 { 503 esp_bt_octet16_t ltk; /*!< The long term key */ 504 uint16_t div; /*!< The div value */ 505 uint8_t key_size; /*!< The key size of the security link */ 506 uint8_t sec_level; /*!< The security level of the security link */ 507 } esp_ble_lenc_keys_t; /*!< The key type */ 508 509 /** 510 * @brief BLE SRK keys 511 */ 512 typedef struct 513 { 514 uint32_t counter; /*!< The counter value */ 515 uint16_t div; /*!< The div value */ 516 uint8_t sec_level; /*!< The security level of the security link */ 517 esp_bt_octet16_t csrk; /*!< The csrk key value */ 518 } esp_ble_lcsrk_keys; /*!< The csrk key type */ 519 520 /** 521 * @brief Structure associated with ESP_KEY_NOTIF_EVT 522 */ 523 typedef struct 524 { 525 esp_bd_addr_t bd_addr; /*!< peer address */ 526 uint32_t passkey; /*!< the numeric value for comparison. If just_works, do not show this number to UI */ 527 } esp_ble_sec_key_notif_t; /*!< BLE key notify type*/ 528 529 /** 530 * @brief Structure of the security request 531 */ 532 typedef struct 533 { 534 esp_bd_addr_t bd_addr; /*!< peer address */ 535 } esp_ble_sec_req_t; /*!< BLE security request type*/ 536 537 /** 538 * @brief union type of the security key value 539 */ 540 typedef union 541 { 542 esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */ 543 esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */ 544 esp_ble_pid_keys_t pid_key; /*!< peer device ID key */ 545 esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/ 546 esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/ 547 } esp_ble_key_value_t; /*!< ble key value type*/ 548 549 /** 550 * @brief struct type of the bond key information value 551 */ 552 typedef struct 553 { 554 esp_ble_key_mask_t key_mask; /*!< the key mask to indicate witch key is present */ 555 esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */ 556 esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */ 557 esp_ble_pid_keys_t pid_key; /*!< peer device ID key */ 558 } esp_ble_bond_key_info_t; /*!< ble bond key information value type */ 559 560 /** 561 * @brief struct type of the bond device value 562 */ 563 typedef struct 564 { 565 esp_bd_addr_t bd_addr; /*!< peer address */ 566 esp_ble_bond_key_info_t bond_key; /*!< the bond key information */ 567 } esp_ble_bond_dev_t; /*!< the ble bond device type */ 568 569 570 /** 571 * @brief union type of the security key value 572 */ 573 typedef struct 574 { 575 esp_bd_addr_t bd_addr; /*!< peer address */ 576 esp_ble_key_type_t key_type; /*!< key type of the security link */ 577 esp_ble_key_value_t p_key_value; /*!< the pointer to the key value */ 578 } esp_ble_key_t; /*!< the union to the ble key value type*/ 579 580 /** 581 * @brief structure type of the ble local id keys value 582 */ 583 typedef struct { 584 esp_bt_octet16_t ir; /*!< the 16 bits of the ir value */ 585 esp_bt_octet16_t irk; /*!< the 16 bits of the ir key value */ 586 esp_bt_octet16_t dhk; /*!< the 16 bits of the dh key value */ 587 } esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/ 588 589 /** 590 * @brief structure type of the ble local oob data value 591 */ 592 typedef struct { 593 esp_bt_octet16_t oob_c; /*!< the 128 bits of confirmation value */ 594 esp_bt_octet16_t oob_r; /*!< the 128 bits of randomizer value */ 595 } esp_ble_local_oob_data_t; 596 597 /** 598 * @brief Structure associated with ESP_AUTH_CMPL_EVT 599 */ 600 typedef struct 601 { 602 esp_bd_addr_t bd_addr; /*!< BD address peer device. */ 603 bool key_present; /*!< Valid link key value in key element */ 604 esp_link_key key; /*!< Link key associated with peer device. */ 605 uint8_t key_type; /*!< The type of Link Key */ 606 bool success; /*!< TRUE of authentication succeeded, FALSE if failed. */ 607 uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */ 608 esp_ble_addr_type_t addr_type; /*!< Peer device address type */ 609 esp_bt_dev_type_t dev_type; /*!< Device type */ 610 esp_ble_auth_req_t auth_mode; /*!< authentication mode */ 611 } esp_ble_auth_cmpl_t; /*!< The ble authentication complete cb type */ 612 613 /** 614 * @brief union associated with ble security 615 */ 616 typedef union 617 { 618 esp_ble_sec_key_notif_t key_notif; /*!< passkey notification */ 619 esp_ble_sec_req_t ble_req; /*!< BLE SMP related request */ 620 esp_ble_key_t ble_key; /*!< BLE SMP keys used when pairing */ 621 esp_ble_local_id_keys_t ble_id_keys; /*!< BLE IR event */ 622 esp_ble_local_oob_data_t oob_data; /*!< BLE SMP secure connection OOB data */ 623 esp_ble_auth_cmpl_t auth_cmpl; /*!< Authentication complete indication. */ 624 } esp_ble_sec_t; /*!< BLE security type */ 625 #if (BLE_42_FEATURE_SUPPORT == TRUE) 626 /// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT 627 typedef enum { 628 ESP_GAP_SEARCH_INQ_RES_EVT = 0, /*!< Inquiry result for a peer device. */ 629 ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /*!< Inquiry complete. */ 630 ESP_GAP_SEARCH_DISC_RES_EVT = 2, /*!< Discovery result for a peer device. */ 631 ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /*!< Discovery result for BLE GATT based service on a peer device. */ 632 ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */ 633 ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */ 634 ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */ 635 ESP_GAP_SEARCH_INQ_DISCARD_NUM_EVT = 7, /*!< The number of pkt discarded by flow control */ 636 } esp_gap_search_evt_t; 637 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 638 /** 639 * @brief Ble scan result event type, to indicate the 640 * result is scan response or advertising data or other 641 */ 642 typedef enum { 643 ESP_BLE_EVT_CONN_ADV = 0x00, /*!< Connectable undirected advertising (ADV_IND) */ 644 ESP_BLE_EVT_CONN_DIR_ADV = 0x01, /*!< Connectable directed advertising (ADV_DIRECT_IND) */ 645 ESP_BLE_EVT_DISC_ADV = 0x02, /*!< Scannable undirected advertising (ADV_SCAN_IND) */ 646 ESP_BLE_EVT_NON_CONN_ADV = 0x03, /*!< Non connectable undirected advertising (ADV_NONCONN_IND) */ 647 ESP_BLE_EVT_SCAN_RSP = 0x04, /*!< Scan Response (SCAN_RSP) */ 648 } esp_ble_evt_type_t; 649 650 typedef enum{ 651 ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */ 652 ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */ 653 ESP_BLE_WHITELIST_CLEAR = 0x02, /*!< clear all device in whitelist */ 654 } esp_ble_wl_operation_t; 655 #if (BLE_42_FEATURE_SUPPORT == TRUE) 656 typedef enum { 657 ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD = 0, /*!< Add device info into duplicate scan exceptional list */ 658 ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_REMOVE, /*!< Remove device info from duplicate scan exceptional list */ 659 ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, /*!< Clean duplicate scan exceptional list */ 660 } esp_bt_duplicate_exceptional_subcode_type_t; 661 #endif //#if (BLE_42_FEATURE_SUPPORT == TRUE) 662 663 #define BLE_BIT(n) (1UL<<(n)) 664 #if (BLE_42_FEATURE_SUPPORT == TRUE) 665 typedef enum { 666 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR = 0, /*!< BLE advertising address , device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST */ 667 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID, /*!< BLE mesh link ID, it is for BLE mesh, device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST */ 668 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */ 669 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */ 670 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */ 671 } esp_ble_duplicate_exceptional_info_type_t; 672 673 typedef enum { 674 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */ 675 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */ 676 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */ 677 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */ 678 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */ 679 ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */ 680 } esp_duplicate_scan_exceptional_list_type_t; 681 682 typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN]; 683 684 #endif //#if (BLE_42_FEATURE_SUPPORT == TRUE) 685 686 #if (BLE_50_FEATURE_SUPPORT == TRUE) 687 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED (0 << 0) /*!< Non-Connectable and Non-Scannable Undirected advertising */ 688 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0) /*!< Connectable advertising */ 689 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1) /*!< Scannable advertising */ 690 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2) /*!< Directed advertising */ 691 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3) /*!< High Duty Cycle Directed Connectable advertising (<= 3.75 ms Advertising Interval) */ 692 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4) /*!< Use legacy advertising PDUs */ 693 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5) /*!< Omit advertiser's address from all PDUs ("anonymous advertising") */ 694 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6) /*!< Include TxPower in the extended header of the advertising PDU */ 695 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F) /*!< Reserved for future use */ 696 697 /*!< If extended advertising PDU types are being used (bit 4 = 0) then: 698 The advertisement shall not be both connectable and scannable. 699 High duty cycle directed connectable advertising (<= 3.75 ms advertising interval) shall not be used (bit 3 = 0) 700 */ 701 /*!< ADV_IND */ 702 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 703 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 704 ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) 705 /*!< ADV_DIRECT_IND (low duty cycle) */ 706 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 707 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 708 ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED) 709 /*!< ADV_DIRECT_IND (high duty cycle) */ 710 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 711 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 712 ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED) 713 /*!< ADV_SCAN_IND */ 714 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 715 ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) 716 /*!< ADV_NONCONN_IND */ 717 #define ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY) 718 typedef uint16_t esp_ble_ext_adv_type_mask_t; 719 720 #define ESP_BLE_GAP_PHY_1M 1 /*!< Secondery Advertisement PHY is LE1M */ 721 #define ESP_BLE_GAP_PHY_2M 2 /*!< Secondery Advertisement PHY is LE2M */ 722 #define ESP_BLE_GAP_PHY_CODED 3 /*!< Secondery Advertisement PHY is LE Coded */ 723 typedef uint8_t esp_ble_gap_phy_t; 724 725 #define ESP_BLE_GAP_NO_PREFER_TRANSMIT_PHY (1<<0) /*!< No Prefer TX PHY supported by controller */ 726 #define ESP_BLE_GAP_NO_PREFER_RECEIVE_PHY (1<<1) /*!< No Prefer RX PHY supported by controller */ 727 typedef uint8_t esp_ble_gap_all_phys_t; 728 729 /// Primary phy only support 1M and LE coded phy 730 #define ESP_BLE_GAP_PRI_PHY_1M ESP_BLE_GAP_PHY_1M /*!< Primary Phy is LE1M */ 731 #define ESP_BLE_GAP_PRI_PHY_CODED ESP_BLE_GAP_PHY_CODED /*!< Primary Phy is LE CODED */ 732 typedef uint8_t esp_ble_gap_pri_phy_t; // primary phy 733 734 #define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or reciever PHY */ 735 #define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or reciever PHY */ 736 #define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or reciever PHY */ 737 typedef uint8_t esp_ble_gap_phy_mask_t; 738 739 #define ESP_BLE_GAP_PHY_OPTIONS_NO_PREF 0 /*!< The Host has no preferred coding when transmitting on the LE Coded PHY */ 740 #define ESP_BLE_GAP_PHY_OPTIONS_PREF_S2_CODING 1 /*!< The Host prefers that S=2 coding be used when transmitting on the LE Coded PHY */ 741 #define ESP_BLE_GAP_PHY_OPTIONS_PREF_S8_CODING 2 /*!< The Host prefers that S=8 coding be used when transmitting on the LE Coded PHY */ 742 typedef uint16_t esp_ble_gap_prefer_phy_options_t; 743 744 #define ESP_BLE_GAP_EXT_SCAN_CFG_UNCODE_MASK 0x01 /*!< Scan Advertisements on the LE1M PHY */ 745 #define ESP_BLE_GAP_EXT_SCAN_CFG_CODE_MASK 0x02 /*!< Scan advertisements on the LE coded PHY */ 746 typedef uint8_t esp_ble_ext_scan_cfg_mask_t; 747 748 /// Advertising data 749 #define ESP_BLE_GAP_EXT_ADV_DATA_COMPLETE 0x00 /*!< extended advertising data compete */ 750 #define ESP_BLE_GAP_EXT_ADV_DATA_INCOMPLETE 0x01 /*!< extended advertising data incomplete */ 751 #define ESP_BLE_GAP_EXT_ADV_DATA_TRUNCATED 0x02 /*!< extended advertising data truncated mode */ 752 typedef uint8_t esp_ble_gap_ext_adv_data_status_t; 753 754 /// Advertising SYNC policy 755 #define ESP_BLE_GAP_SYNC_POLICY_BY_ADV_INFO 0 /*!< sync policy by advertising info */ 756 #define ESP_BLE_GAP_SYNC_POLICY_BY_PERIODIC_LIST 1 /*!< periodic advertising sync policy */ 757 typedef uint8_t esp_ble_gap_sync_t; 758 759 /// Advertising report 760 #define ESP_BLE_ADV_REPORT_EXT_ADV_IND (1<<0) /*!< advertising report with extended advertising indication type */ 761 #define ESP_BLE_ADV_REPORT_EXT_SCAN_IND (1<<1) /*!< advertising report with extended scan indication type */ 762 #define ESP_BLE_ADV_REPORT_EXT_DIRECT_ADV (1<<2) /*!< advertising report with extended direct advertising indication type */ 763 #define ESP_BLE_ADV_REPORT_EXT_SCAN_RSP (1<<3) /*!< advertising report with extended scan response indication type */ 764 765 /*!< Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */ 766 #define ESP_BLE_LEGACY_ADV_TYPE_IND (0x13) /*!< advertising report with legacy advertising indication type */ 767 #define ESP_BLE_LEGACY_ADV_TYPE_DIRECT_IND (0x15) /*!< advertising report with legacy direct indication type */ 768 #define ESP_BLE_LEGACY_ADV_TYPE_SCAN_IND (0x12) /*!< advertising report with legacy scan indication type */ 769 #define ESP_BLE_LEGACY_ADV_TYPE_NONCON_IND (0x10) /*!< advertising report with legacy non connectable indication type */ 770 #define ESP_BLE_LEGACY_ADV_TYPE_SCAN_RSP_TO_ADV_IND (0x1b) /*!< advertising report with legacy scan response indication type */ 771 #define ESP_BLE_LEGACY_ADV_TYPE_SCAN_RSP_TO_ADV_SCAN_IND (0x1a) /*!< advertising report with legacy advertising with scan response indication type */ 772 773 typedef uint8_t esp_ble_gap_adv_type_t; 774 775 /// Extend advertising tx power, range: [-127, +126] dBm 776 #define EXT_ADV_TX_PWR_NO_PREFERENCE (127) /*!< host has no preference for tx power */ 777 778 /** 779 * @brief ext adv parameters 780 */ 781 typedef struct { 782 esp_ble_ext_adv_type_mask_t type; /*!< ext adv type */ 783 uint32_t interval_min; /*!< ext adv minimum interval */ 784 uint32_t interval_max; /*!< ext adv maximum interval */ 785 esp_ble_adv_channel_t channel_map; /*!< ext adv channel map */ 786 esp_ble_addr_type_t own_addr_type; /*!< ext adv own address type */ 787 esp_ble_addr_type_t peer_addr_type; /*!< ext adv peer address type */ 788 esp_bd_addr_t peer_addr; /*!< ext adv peer address */ 789 esp_ble_adv_filter_t filter_policy; /*!< ext adv filter policy */ 790 int8_t tx_power; /*!< ext adv tx power */ 791 esp_ble_gap_pri_phy_t primary_phy; /*!< ext adv primary phy */ 792 uint8_t max_skip; /*!< ext adv maximum skip */ 793 esp_ble_gap_phy_t secondary_phy; /*!< ext adv secondary phy */ 794 uint8_t sid; /*!< ext adv sid */ 795 bool scan_req_notif; /*!< ext adv scan request event notify */ 796 } esp_ble_gap_ext_adv_params_t; 797 798 /** 799 * @brief ext scan config 800 */ 801 typedef struct { 802 esp_ble_scan_type_t scan_type; /*!< ext scan type */ 803 uint16_t scan_interval; /*!< ext scan interval */ 804 uint16_t scan_window; /*!< ext scan window */ 805 } esp_ble_ext_scan_cfg_t; 806 807 /** 808 * @brief ext scan parameters 809 */ 810 typedef struct { 811 esp_ble_addr_type_t own_addr_type; /*!< ext scan own address type */ 812 esp_ble_scan_filter_t filter_policy; /*!< ext scan filter policy */ 813 esp_ble_scan_duplicate_t scan_duplicate; /*!< ext scan duplicate scan */ 814 esp_ble_ext_scan_cfg_mask_t cfg_mask; /*!< ext scan config mask */ 815 esp_ble_ext_scan_cfg_t uncoded_cfg; /*!< ext scan uncoded config parameters */ 816 esp_ble_ext_scan_cfg_t coded_cfg; /*!< ext scan coded config parameters */ 817 } esp_ble_ext_scan_params_t; 818 819 /** 820 * @brief create extend connection parameters 821 */ 822 typedef struct { 823 uint16_t scan_interval; /*!< init scan interval */ 824 uint16_t scan_window; /*!< init scan window */ 825 uint16_t interval_min; /*!< minimum interval */ 826 uint16_t interval_max; /*!< maximum interval */ 827 uint16_t latency; /*!< ext scan type */ 828 uint16_t supervision_timeout; /*!< connection supervision timeout */ 829 uint16_t min_ce_len; /*!< minimum ce length */ 830 uint16_t max_ce_len; /*!< maximum ce length */ 831 } esp_ble_gap_conn_params_t; 832 833 /** 834 * @brief extend adv enable parameters 835 */ 836 typedef struct { 837 uint8_t instance; /*!< advertising handle */ 838 int duration; /*!< advertising duration */ 839 int max_events; /*!< maximum number of extended advertising events */ 840 } esp_ble_gap_ext_adv_t; 841 842 /** 843 * @brief periodic adv parameters 844 */ 845 typedef struct { 846 uint16_t interval_min; /*!< periodic advertising minimum interval */ 847 uint16_t interval_max; /*!< periodic advertising maximum interval */ 848 uint8_t properties; /*!< periodic advertising properties */ 849 } esp_ble_gap_periodic_adv_params_t; 850 851 /** 852 * @brief periodic adv sync parameters 853 */ 854 typedef struct { 855 esp_ble_gap_sync_t filter_policy; /*!< periodic advertising sync filter policy */ 856 uint8_t sid; /*!< periodic advertising sid */ 857 esp_ble_addr_type_t addr_type; /*!< periodic advertising address type */ 858 esp_bd_addr_t addr; /*!< periodic advertising address */ 859 uint16_t skip; /*!< the maximum number of periodic advertising events that can be skipped */ 860 uint16_t sync_timeout; /*!< synchronization timeout */ 861 } esp_ble_gap_periodic_adv_sync_params_t; 862 863 /** 864 * @brief extend adv report parameters 865 */ 866 typedef struct { 867 // uint8_t props; 868 // uint8_t legacy_event_type; 869 esp_ble_gap_adv_type_t event_type; /*!< extend advertising type */ 870 uint8_t addr_type; /*!< extend advertising address type */ 871 esp_bd_addr_t addr; /*!< extend advertising address */ 872 esp_ble_gap_pri_phy_t primary_phy; /*!< extend advertising primary phy */ 873 esp_ble_gap_phy_t secondly_phy; /*!< extend advertising secondary phy */ 874 uint8_t sid; /*!< extend advertising sid */ 875 uint8_t tx_power; /*!< extend advertising tx power */ 876 int8_t rssi; /*!< extend advertising rssi */ 877 uint16_t per_adv_interval; /*!< periodic advertising interval */ 878 uint8_t dir_addr_type; /*!< direct address type */ 879 esp_bd_addr_t dir_addr; /*!< direct address */ 880 esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */ 881 uint8_t adv_data_len; /*!< extend advertising data length */ 882 uint8_t adv_data[251]; /*!< extend advertising data */ 883 } esp_ble_gap_ext_adv_reprot_t; 884 885 /** 886 * @brief periodic adv report parameters 887 */ 888 typedef struct { 889 uint16_t sync_handle; /*!< periodic advertising train handle */ 890 uint8_t tx_power; /*!< periodic advertising tx power*/ 891 int8_t rssi; /*!< periodic advertising rssi */ 892 esp_ble_gap_ext_adv_data_status_t data_status; /*!< periodic advertising data type*/ 893 uint8_t data_length; /*!< periodic advertising data length */ 894 uint8_t data[251]; /*!< periodic advertising data */ 895 } esp_ble_gap_periodic_adv_report_t; 896 897 /** 898 * @brief perodic adv sync establish parameters 899 */ 900 typedef struct { 901 uint8_t status; /*!< periodic advertising sync status */ 902 uint16_t sync_handle; /*!< periodic advertising train handle */ 903 uint8_t sid; /*!< periodic advertising sid */ 904 esp_ble_addr_type_t addr_type; /*!< periodic advertising address type */ 905 esp_bd_addr_t adv_addr; /*!< periodic advertising address */ 906 esp_ble_gap_phy_t adv_phy; /*!< periodic advertising adv phy type */ 907 uint16_t period_adv_interval; /*!< periodic advertising interval */ 908 uint8_t adv_clk_accuracy; /*!< periodic advertising clock accuracy */ 909 } esp_ble_gap_periodic_adv_sync_estab_t; 910 911 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) 912 913 /** 914 * @brief Gap callback parameters union 915 */ 916 typedef union { 917 /** 918 * @brief ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT 919 */ 920 struct ble_get_dev_name_cmpl_evt_param { 921 esp_bt_status_t status; /*!< Indicate the get device name success status */ 922 char *name; /*!< Name of bluetooth device */ 923 } get_dev_name_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT */ 924 #if (BLE_42_FEATURE_SUPPORT == TRUE) 925 /** 926 * @brief ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 927 */ 928 struct ble_adv_data_cmpl_evt_param { 929 esp_bt_status_t status; /*!< Indicate the set advertising data operation success status */ 930 } adv_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT */ 931 /** 932 * @brief ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 933 */ 934 struct ble_scan_rsp_data_cmpl_evt_param { 935 esp_bt_status_t status; /*!< Indicate the set scan response data operation success status */ 936 } scan_rsp_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT */ 937 /** 938 * @brief ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 939 */ 940 struct ble_scan_param_cmpl_evt_param { 941 esp_bt_status_t status; /*!< Indicate the set scan param operation success status */ 942 } scan_param_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT */ 943 /** 944 * @brief ESP_GAP_BLE_SCAN_RESULT_EVT 945 */ 946 struct ble_scan_result_evt_param { 947 esp_gap_search_evt_t search_evt; /*!< Search event type */ 948 esp_bd_addr_t bda; /*!< Bluetooth device address which has been searched */ 949 esp_bt_dev_type_t dev_type; /*!< Device type */ 950 esp_ble_addr_type_t ble_addr_type; /*!< Ble device address type */ 951 esp_ble_evt_type_t ble_evt_type; /*!< Ble scan result event type */ 952 int rssi; /*!< Searched device's RSSI */ 953 uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX]; /*!< Received EIR */ 954 int flag; /*!< Advertising data flag bit */ 955 int num_resps; /*!< Scan result number */ 956 uint8_t adv_data_len; /*!< Adv data length */ 957 uint8_t scan_rsp_len; /*!< Scan response length */ 958 uint32_t num_dis; /*!< The number of discard packets */ 959 } scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */ 960 /** 961 * @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT 962 */ 963 struct ble_adv_data_raw_cmpl_evt_param { 964 esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */ 965 } adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */ 966 /** 967 * @brief ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT 968 */ 969 struct ble_scan_rsp_data_raw_cmpl_evt_param { 970 esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */ 971 } scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */ 972 /** 973 * @brief ESP_GAP_BLE_ADV_START_COMPLETE_EVT 974 */ 975 struct ble_adv_start_cmpl_evt_param { 976 esp_bt_status_t status; /*!< Indicate advertising start operation success status */ 977 } adv_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_START_COMPLETE_EVT */ 978 /** 979 * @brief ESP_GAP_BLE_SCAN_START_COMPLETE_EVT 980 */ 981 struct ble_scan_start_cmpl_evt_param { 982 esp_bt_status_t status; /*!< Indicate scan start operation success status */ 983 } scan_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_START_COMPLETE_EVT */ 984 #endif //#if (BLE_42_FEATURE_SUPPORT == TRUE) 985 esp_ble_sec_t ble_security; /*!< ble gap security union type */ 986 #if (BLE_42_FEATURE_SUPPORT == TRUE) 987 /** 988 * @brief ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT 989 */ 990 struct ble_scan_stop_cmpl_evt_param { 991 esp_bt_status_t status; /*!< Indicate scan stop operation success status */ 992 } scan_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT */ 993 /** 994 * @brief ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT 995 */ 996 struct ble_adv_stop_cmpl_evt_param { 997 esp_bt_status_t status; /*!< Indicate adv stop operation success status */ 998 } adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */ 999 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1000 /** 1001 * @brief ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT 1002 */ 1003 struct ble_set_rand_cmpl_evt_param { 1004 esp_bt_status_t status; /*!< Indicate set static rand address operation success status */ 1005 } set_rand_addr_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT */ 1006 /** 1007 * @brief ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT 1008 */ 1009 struct ble_update_conn_params_evt_param { 1010 esp_bt_status_t status; /*!< Indicate update connection parameters success status */ 1011 esp_bd_addr_t bda; /*!< Bluetooth device address */ 1012 uint16_t min_int; /*!< Min connection interval */ 1013 uint16_t max_int; /*!< Max connection interval */ 1014 uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */ 1015 uint16_t conn_int; /*!< Current connection interval */ 1016 uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. 1017 Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */ 1018 } update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */ 1019 /** 1020 * @brief ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT 1021 */ 1022 struct ble_pkt_data_length_cmpl_evt_param { 1023 esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */ 1024 esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */ 1025 } pkt_data_length_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */ 1026 /** 1027 * @brief ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT 1028 */ 1029 struct ble_local_privacy_cmpl_evt_param { 1030 esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */ 1031 } local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */ 1032 /** 1033 * @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT 1034 */ 1035 struct ble_remove_bond_dev_cmpl_evt_param { 1036 esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */ 1037 esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */ 1038 } remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ 1039 /** 1040 * @brief ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT 1041 */ 1042 struct ble_clear_bond_dev_cmpl_evt_param { 1043 esp_bt_status_t status; /*!< Indicate the clear bond device operation success status */ 1044 } clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ 1045 /** 1046 * @brief ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT 1047 */ 1048 struct ble_get_bond_dev_cmpl_evt_param { 1049 esp_bt_status_t status; /*!< Indicate the get bond device operation success status */ 1050 uint8_t dev_num; /*!< Indicate the get number device in the bond list */ 1051 esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */ 1052 } get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ 1053 /** 1054 * @brief ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT 1055 */ 1056 struct ble_read_rssi_cmpl_evt_param { 1057 esp_bt_status_t status; /*!< Indicate the read adv tx power operation success status */ 1058 int8_t rssi; /*!< The ble remote device rssi value, the range is from -127 to 20, the unit is dbm, 1059 if the RSSI cannot be read, the RSSI metric shall be set to 127. */ 1060 esp_bd_addr_t remote_addr; /*!< The remote device address */ 1061 } read_rssi_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */ 1062 /** 1063 * @brief ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT 1064 */ 1065 struct ble_update_whitelist_cmpl_evt_param { 1066 esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */ 1067 esp_ble_wl_operation_t wl_operation; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */ 1068 } update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */ 1069 #if (BLE_42_FEATURE_SUPPORT == TRUE) 1070 /** 1071 * @brief ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT 1072 */ 1073 struct ble_update_duplicate_exceptional_list_cmpl_evt_param { 1074 esp_bt_status_t status; /*!< Indicate update duplicate scan exceptional list operation success status */ 1075 uint8_t subcode; /*!< Define in esp_bt_duplicate_exceptional_subcode_type_t */ 1076 uint16_t length; /*!< The length of device_info */ 1077 esp_duplicate_info_t device_info; /*!< device information, when subcode is ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, the value is invalid */ 1078 } update_duplicate_exceptional_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT */ 1079 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1080 /** 1081 * @brief ESP_GAP_BLE_SET_CHANNELS_EVT 1082 */ 1083 struct ble_set_channels_evt_param { 1084 esp_bt_status_t stat; /*!< BLE set channel status */ 1085 } ble_set_channels; /*!< Event parameter of ESP_GAP_BLE_SET_CHANNELS_EVT */ 1086 1087 #if (BLE_50_FEATURE_SUPPORT == TRUE) 1088 /** 1089 * @brief ESP_GAP_BLE_READ_PHY_COMPLETE_EVT 1090 */ 1091 struct ble_read_phy_cmpl_evt_param { 1092 esp_bt_status_t status; /*!< read phy complete status */ 1093 esp_bd_addr_t bda; /*!< read phy address */ 1094 esp_ble_gap_phy_t tx_phy; /*!< tx phy type */ 1095 esp_ble_gap_phy_t rx_phy; /*!< rx phy type */ 1096 } read_phy; /*!< Event parameter of ESP_GAP_BLE_READ_PHY_COMPLETE_EVT */ 1097 /** 1098 * @brief ESP_GAP_BLE_SET_PREFERRED_DEFAULT_PHY_COMPLETE_EVT 1099 */ 1100 struct ble_set_perf_def_phy_cmpl_evt_param { 1101 esp_bt_status_t status; /*!< Indicate perf default phy set status */ 1102 } set_perf_def_phy; /*!< Event parameter of ESP_GAP_BLE_SET_PREFERRED_DEFAULT_PHY_COMPLETE_EVT */ 1103 /** 1104 * @brief ESP_GAP_BLE_SET_PREFERRED_PHY_COMPLETE_EVT 1105 */ 1106 struct ble_set_perf_phy_cmpl_evt_param { 1107 esp_bt_status_t status; /*!< Indicate perf phy set status */ 1108 } set_perf_phy; /*!< Event parameter of ESP_GAP_BLE_SET_PREFERRED_PHY_COMPLETE_EVT */ 1109 /** 1110 * @brief ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 1111 */ 1112 struct ble_ext_adv_set_rand_addr_cmpl_evt_param { 1113 esp_bt_status_t status; /*!< Indicate extend advertising random address set status */ 1114 } ext_adv_set_rand_addr; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT */ 1115 /** 1116 * @brief ESP_GAP_BLE_EXT_ADV_SET_PARAMS_COMPLETE_EVT 1117 */ 1118 struct ble_ext_adv_set_params_cmpl_evt_param { 1119 esp_bt_status_t status; /*!< Indicate extend advertising parameters set status */ 1120 } ext_adv_set_params; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_PARAMS_COMPLETE_EVT */ 1121 /** 1122 * @brief ESP_GAP_BLE_EXT_ADV_DATA_SET_COMPLETE_EVT 1123 */ 1124 struct ble_ext_adv_data_set_cmpl_evt_param { 1125 esp_bt_status_t status; /*!< Indicate extend advertising data set status */ 1126 } ext_adv_data_set; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_DATA_SET_COMPLETE_EVT */ 1127 /** 1128 * @brief ESP_GAP_BLE_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT 1129 */ 1130 struct ble_ext_adv_scan_rsp_set_cmpl_evt_param { 1131 esp_bt_status_t status; /*!< Indicate extend advertising scan response data set status */ 1132 } scan_rsp_set; /*!< Event parameter of ESP_GAP_BLE_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT */ 1133 /** 1134 * @brief ESP_GAP_BLE_EXT_ADV_START_COMPLETE_EVT 1135 */ 1136 struct ble_ext_adv_start_cmpl_evt_param { 1137 esp_bt_status_t status; /*!< Indicate advertising start operation success status */ 1138 } ext_adv_start; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_START_COMPLETE_EVT */ 1139 /** 1140 * @brief ESP_GAP_BLE_EXT_ADV_STOP_COMPLETE_EVT 1141 */ 1142 struct ble_ext_adv_stop_cmpl_evt_param { 1143 esp_bt_status_t status; /*!< Indicate advertising stop operation success status */ 1144 } ext_adv_stop; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_STOP_COMPLETE_EVT */ 1145 /** 1146 * @brief ESP_GAP_BLE_EXT_ADV_SET_REMOVE_COMPLETE_EVT 1147 */ 1148 struct ble_ext_adv_set_remove_cmpl_evt_param { 1149 esp_bt_status_t status; /*!< Indicate advertising stop operation success status */ 1150 } ext_adv_remove; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_REMOVE_COMPLETE_EVT */ 1151 /** 1152 * @brief ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT 1153 */ 1154 struct ble_ext_adv_set_clear_cmpl_evt_param { 1155 esp_bt_status_t status; /*!< Indicate advertising stop operation success status */ 1156 } ext_adv_clear; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT */ 1157 /** 1158 * @brief ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 1159 */ 1160 struct ble_periodic_adv_set_params_cmpl_param { 1161 esp_bt_status_t status; /*!< Indicate periodic advertisingparameters set status */ 1162 } peroid_adv_set_params; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT */ 1163 /** 1164 * @brief ESP_GAP_BLE_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 1165 */ 1166 struct ble_periodic_adv_data_set_cmpl_param { 1167 esp_bt_status_t status; /*!< Indicate periodic advertising data set status */ 1168 } period_adv_data_set; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_DATA_SET_COMPLETE_EVT */ 1169 /** 1170 * @brief ESP_GAP_BLE_PERIODIC_ADV_START_COMPLETE_EVT 1171 */ 1172 struct ble_periodic_adv_start_cmpl_param { 1173 esp_bt_status_t status; /*!< Indicate periodic advertising start status */ 1174 } period_adv_start; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_START_COMPLETE_EVT */ 1175 /** 1176 * @brief ESP_GAP_BLE_PERIODIC_ADV_STOP_COMPLETE_EVT 1177 */ 1178 struct ble_periodic_adv_stop_cmpl_param { 1179 esp_bt_status_t status; /*!< Indicate periodic advertising stop status */ 1180 } period_adv_stop; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_STOP_COMPLETE_EVT */ 1181 /** 1182 * @brief ESP_GAP_BLE_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT 1183 */ 1184 struct ble_period_adv_create_sync_cmpl_param { 1185 esp_bt_status_t status; /*!< Indicate periodic advertising create sync status */ 1186 } period_adv_create_sync; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT */ 1187 /** 1188 * @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT 1189 */ 1190 struct ble_period_adv_sync_cancel_cmpl_param { 1191 esp_bt_status_t status; /*!< Indicate periodic advertising sync cancel status */ 1192 } period_adv_sync_cancel; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT */ 1193 /** 1194 * @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT 1195 */ 1196 struct ble_period_adv_sync_terminate_cmpl_param { 1197 esp_bt_status_t status; /*!< Indicate periodic advertising sync terminate status */ 1198 } period_adv_sync_term; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT */ 1199 /** 1200 * @brief ESP_GAP_BLE_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 1201 */ 1202 struct ble_period_adv_add_dev_cmpl_param { 1203 esp_bt_status_t status; /*!< Indicate periodic advertising device list add status */ 1204 } period_adv_add_dev; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT */ 1205 /** 1206 * @brief ESP_GAP_BLE_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 1207 */ 1208 struct ble_period_adv_remove_dev_cmpl_param { 1209 esp_bt_status_t status; /*!< Indicate periodic advertising device list remove status */ 1210 } period_adv_remove_dev; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT */ 1211 /** 1212 * @brief ESP_GAP_BLE_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 1213 */ 1214 struct ble_period_adv_clear_dev_cmpl_param { 1215 esp_bt_status_t status; /*!< Indicate periodic advertising device list clean status */ 1216 } period_adv_clear_dev; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT */ 1217 /** 1218 * @brief ESP_GAP_BLE_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 1219 */ 1220 struct ble_set_ext_scan_params_cmpl_param { 1221 esp_bt_status_t status; /*!< Indicate extend advertising parameters set status */ 1222 } set_ext_scan_params; /*!< Event parameter of ESP_GAP_BLE_SET_EXT_SCAN_PARAMS_COMPLETE_EVT */ 1223 /** 1224 * @brief ESP_GAP_BLE_EXT_SCAN_START_COMPLETE_EVT 1225 */ 1226 struct ble_ext_scan_start_cmpl_param { 1227 esp_bt_status_t status; /*!< Indicate extend advertising start status */ 1228 } ext_scan_start; /*!< Event parameter of ESP_GAP_BLE_EXT_SCAN_START_COMPLETE_EVT */ 1229 /** 1230 * @brief ESP_GAP_BLE_EXT_SCAN_STOP_COMPLETE_EVT 1231 */ 1232 struct ble_ext_scan_stop_cmpl_param { 1233 esp_bt_status_t status; /*!< Indicate extend advertising stop status */ 1234 } ext_scan_stop; /*!< Event parameter of ESP_GAP_BLE_EXT_SCAN_STOP_COMPLETE_EVT */ 1235 /** 1236 * @brief ESP_GAP_BLE_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 1237 */ 1238 struct ble_ext_conn_params_set_cmpl_param { 1239 esp_bt_status_t status; /*!< Indicate extend connection parameters set status */ 1240 } ext_conn_params_set; /*!< Event parameter of ESP_GAP_BLE_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT */ 1241 /** 1242 * @brief ESP_GAP_BLE_ADV_TERMINATED_EVT 1243 */ 1244 struct ble_adv_terminate_param { 1245 uint8_t status; /*!< Indicate adv terminate status */ 1246 /* status 0x3c indicates that advertising for a fixed duration completed or, 1247 for directed advertising, that advertising completed without a connection 1248 being created; 1249 status 0x00 indicates that advertising successfully ended with a connection being created. 1250 */ 1251 uint8_t adv_instance; /*!< extend advertising handle */ 1252 uint16_t conn_idx; /*!< connection index */ 1253 uint8_t completed_event; /*!< the number of completed extend advertising events */ 1254 } adv_terminate; /*!< Event parameter of ESP_GAP_BLE_ADV_TERMINATED_EVT */ 1255 /** 1256 * @brief ESP_GAP_BLE_SCAN_REQ_RECEIVED_EVT 1257 */ 1258 struct ble_scan_req_received_param { 1259 uint8_t adv_instance; /*!< extend advertising handle */ 1260 esp_ble_addr_type_t scan_addr_type; /*!< scanner address type */ 1261 esp_bd_addr_t scan_addr; /*!< scanner address */ 1262 } scan_req_received; /*!< Event parameter of ESP_GAP_BLE_SCAN_REQ_RECEIVED_EVT */ 1263 /** 1264 * @brief ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT 1265 */ 1266 struct ble_channel_sel_alg_param { 1267 uint16_t conn_handle; /*!< connection handle */ 1268 uint8_t channel_sel_alg; /*!< channel selection algorithm */ 1269 } channel_sel_alg; /*!< Event parameter of ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT */ 1270 /** 1271 * @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_LOST_EVT 1272 */ 1273 struct ble_periodic_adv_sync_lost_param { 1274 uint16_t sync_handle; /*!< sync handle */ 1275 } periodic_adv_sync_lost; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_LOST_EVT */ 1276 /** 1277 * @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT 1278 */ 1279 struct ble_periodic_adv_sync_estab_param { 1280 uint8_t status; /*!< periodic advertising sync status */ 1281 uint16_t sync_handle; /*!< periodic advertising sync handle */ 1282 uint8_t sid; /*!< periodic advertising sid */ 1283 esp_ble_addr_type_t adv_addr_type; /*!< periodic advertising address type */ 1284 esp_bd_addr_t adv_addr; /*!< periodic advertising address */ 1285 esp_ble_gap_phy_t adv_phy; /*!< periodic advertising phy type */ 1286 uint16_t period_adv_interval; /*!< periodic advertising interval */ 1287 uint8_t adv_clk_accuracy; /*!< periodic advertising clock accuracy */ 1288 } periodic_adv_sync_estab; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT */ 1289 /** 1290 * @brief ESP_GAP_BLE_PHY_UPDATE_COMPLETE_EVT 1291 */ 1292 struct ble_phy_update_cmpl_param { 1293 esp_bt_status_t status; /*!< phy update status */ 1294 esp_bd_addr_t bda; /*!< address */ 1295 esp_ble_gap_phy_t tx_phy; /*!< tx phy type */ 1296 esp_ble_gap_phy_t rx_phy; /*!< rx phy type */ 1297 } phy_update; /*!< Event parameter of ESP_GAP_BLE_PHY_UPDATE_COMPLETE_EVT */ 1298 /** 1299 * @brief ESP_GAP_BLE_EXT_ADV_REPORT_EVT 1300 */ 1301 struct ble_ext_adv_report_param { 1302 esp_ble_gap_ext_adv_reprot_t params; /*!< extend advertising report parameters */ 1303 } ext_adv_report; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_REPORT_EVT */ 1304 /** 1305 * @brief ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT 1306 */ 1307 struct ble_periodic_adv_report_param { 1308 esp_ble_gap_periodic_adv_report_t params; /*!< periodic advertising report parameters */ 1309 } period_adv_report; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT */ 1310 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) 1311 } esp_ble_gap_cb_param_t; 1312 1313 /** 1314 * @brief GAP callback function type 1315 * @param event : Event type 1316 * @param param : Point to callback parameter, currently is union type 1317 */ 1318 typedef void (* esp_gap_ble_cb_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param); 1319 1320 /** 1321 * @brief This function is called to occur gap event, such as scan result 1322 * 1323 * @param[in] callback: callback function 1324 * 1325 * @return 1326 * - ESP_OK : success 1327 * - other : failed 1328 * 1329 */ 1330 esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback); 1331 1332 #if (BLE_42_FEATURE_SUPPORT == TRUE) 1333 /** 1334 * @brief This function is called to override the BTA default ADV parameters. 1335 * 1336 * @param[in] adv_data: Pointer to User defined ADV data structure. This 1337 * memory space can not be freed until callback of config_adv_data 1338 * is received. 1339 * 1340 * @return 1341 * - ESP_OK : success 1342 * - other : failed 1343 * 1344 */ 1345 esp_err_t esp_ble_gap_config_adv_data (esp_ble_adv_data_t *adv_data); 1346 1347 1348 1349 /** 1350 * @brief This function is called to set scan parameters 1351 * 1352 * @param[in] scan_params: Pointer to User defined scan_params data structure. This 1353 * memory space can not be freed until callback of set_scan_params 1354 * 1355 * @return 1356 * - ESP_OK : success 1357 * - other : failed 1358 * 1359 */ 1360 esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params); 1361 1362 1363 /** 1364 * @brief This procedure keep the device scanning the peer device which advertising on the air 1365 * 1366 * @param[in] duration: Keeping the scanning time, the unit is second. 1367 * 1368 * @return 1369 * - ESP_OK : success 1370 * - other : failed 1371 * 1372 */ 1373 esp_err_t esp_ble_gap_start_scanning(uint32_t duration); 1374 1375 1376 /** 1377 * @brief This function call to stop the device scanning the peer device which advertising on the air 1378 * @return 1379 * - ESP_OK : success 1380 * - other : failed 1381 * 1382 */ 1383 esp_err_t esp_ble_gap_stop_scanning(void); 1384 1385 /** 1386 * @brief This function is called to start advertising. 1387 * 1388 * @param[in] adv_params: pointer to User defined adv_params data structure. 1389 1390 * @return 1391 * - ESP_OK : success 1392 * - other : failed 1393 * 1394 */ 1395 esp_err_t esp_ble_gap_start_advertising (esp_ble_adv_params_t *adv_params); 1396 1397 1398 1399 /** 1400 * @brief This function is called to stop advertising. 1401 * 1402 * @return 1403 * - ESP_OK : success 1404 * - other : failed 1405 * 1406 */ 1407 esp_err_t esp_ble_gap_stop_advertising(void); 1408 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1409 1410 1411 /** 1412 * @brief Update connection parameters, can only be used when connection is up. 1413 * 1414 * @param[in] params - connection update parameters 1415 * 1416 * @return 1417 * - ESP_OK : success 1418 * - other : failed 1419 * 1420 */ 1421 esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params); 1422 1423 1424 /** 1425 * @brief This function is to set maximum LE data packet size 1426 * 1427 * @return 1428 * - ESP_OK : success 1429 * - other : failed 1430 * 1431 */ 1432 esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length); 1433 1434 /** 1435 * @brief This function sets the static Random Address and Non-Resolvable Private Address for the application 1436 * 1437 * @param[in] rand_addr: the random address which should be setting 1438 * 1439 * @return 1440 * - ESP_OK : success 1441 * - other : failed 1442 * 1443 */ 1444 esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr); 1445 1446 /** 1447 * @brief This function clears the random address for the application 1448 * 1449 * @return 1450 * - ESP_OK : success 1451 * - other : failed 1452 * 1453 */ 1454 esp_err_t esp_ble_gap_clear_rand_addr(void); 1455 1456 1457 1458 /** 1459 * @brief Enable/disable privacy on the local device 1460 * 1461 * @param[in] privacy_enable - enable/disable privacy on remote device. 1462 * 1463 * @return 1464 * - ESP_OK : success 1465 * - other : failed 1466 * 1467 */ 1468 esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable); 1469 1470 /** 1471 * @brief set local gap appearance icon 1472 * 1473 * 1474 * @param[in] icon - External appearance value, these values are defined by the Bluetooth SIG, please refer to 1475 * https://www.bluetooth.com/specifications/assigned-numbers/ 1476 * 1477 * @return 1478 * - ESP_OK : success 1479 * - other : failed 1480 * 1481 */ 1482 esp_err_t esp_ble_gap_config_local_icon (uint16_t icon); 1483 1484 /** 1485 * @brief Add or remove device from white list 1486 * 1487 * @param[in] add_remove: the value is true if added the ble device to the white list, and false remove to the white list. 1488 * @param[in] remote_bda: the remote device address add/remove from the white list. 1489 * @param[in] wl_addr_type: whitelist address type 1490 * @return 1491 * - ESP_OK : success 1492 * - other : failed 1493 * 1494 */ 1495 esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda, esp_ble_wl_addr_type_t wl_addr_type); 1496 1497 /** 1498 * @brief Clear all white list 1499 * 1500 * @return 1501 * - ESP_OK : success 1502 * - other : failed 1503 * 1504 */ 1505 esp_err_t esp_ble_gap_clear_whitelist(void); 1506 1507 /** 1508 * @brief Get the whitelist size in the controller 1509 * 1510 * @param[out] length: the white list length. 1511 * @return 1512 * - ESP_OK : success 1513 * - other : failed 1514 * 1515 */ 1516 esp_err_t esp_ble_gap_get_whitelist_size(uint16_t *length); 1517 #if (BLE_42_FEATURE_SUPPORT == TRUE) 1518 /** 1519 * @brief This function is called to set the preferred connection 1520 * parameters when default connection parameter is not desired before connecting. 1521 * This API can only be used in the master role. 1522 * 1523 * @param[in] bd_addr: BD address of the peripheral 1524 * @param[in] min_conn_int: minimum preferred connection interval 1525 * @param[in] max_conn_int: maximum preferred connection interval 1526 * @param[in] slave_latency: preferred slave latency 1527 * @param[in] supervision_tout: preferred supervision timeout 1528 * 1529 * @return 1530 * - ESP_OK : success 1531 * - other : failed 1532 * 1533 */ 1534 esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr, 1535 uint16_t min_conn_int, uint16_t max_conn_int, 1536 uint16_t slave_latency, uint16_t supervision_tout); 1537 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1538 /** 1539 * @brief Set device name to the local device 1540 * 1541 * @param[in] name - device name. 1542 * 1543 * @return 1544 * - ESP_OK : success 1545 * - other : failed 1546 * 1547 */ 1548 esp_err_t esp_ble_gap_set_device_name(const char *name); 1549 1550 /** 1551 * @brief Get device name of the local device 1552 * 1553 * @return 1554 * - ESP_OK : success 1555 * - other : failed 1556 * 1557 */ 1558 esp_err_t esp_ble_gap_get_device_name(void); 1559 1560 /** 1561 * @brief This function is called to get local used address and address type. 1562 * uint8_t *esp_bt_dev_get_address(void) get the public address 1563 * 1564 * @param[in] local_used_addr - current local used ble address (six bytes) 1565 * @param[in] addr_type - ble address type 1566 * 1567 * @return - ESP_OK : success 1568 * - other : failed 1569 * 1570 */ 1571 esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type); 1572 /** 1573 * @brief This function is called to get ADV data for a specific type. 1574 * 1575 * @param[in] adv_data - pointer of ADV data which to be resolved 1576 * @param[in] type - finding ADV data type 1577 * @param[out] length - return the length of ADV data not including type 1578 * 1579 * @return pointer of ADV data 1580 * 1581 */ 1582 uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length); 1583 #if (BLE_42_FEATURE_SUPPORT == TRUE) 1584 /** 1585 * @brief This function is called to set raw advertising data. User need to fill 1586 * ADV data by self. 1587 * 1588 * @param[in] raw_data : raw advertising data 1589 * @param[in] raw_data_len : raw advertising data length , less than 31 bytes 1590 * 1591 * @return 1592 * - ESP_OK : success 1593 * - other : failed 1594 * 1595 */ 1596 esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len); 1597 1598 /** 1599 * @brief This function is called to set raw scan response data. User need to fill 1600 * scan response data by self. 1601 * 1602 * @param[in] raw_data : raw scan response data 1603 * @param[in] raw_data_len : raw scan response data length , less than 31 bytes 1604 * 1605 * @return 1606 * - ESP_OK : success 1607 * - other : failed 1608 */ 1609 esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len); 1610 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1611 1612 /** 1613 * @brief This function is called to read the RSSI of remote device. 1614 * The address of link policy results are returned in the gap callback function with 1615 * ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT event. 1616 * 1617 * @param[in] remote_addr : The remote connection device address. 1618 * 1619 * @return 1620 * - ESP_OK : success 1621 * - other : failed 1622 */ 1623 esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr); 1624 #if (BLE_42_FEATURE_SUPPORT == TRUE) 1625 /** 1626 * @brief This function is called to add a device info into the duplicate scan exceptional list. 1627 * 1628 * 1629 * @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t 1630 * when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid. 1631 * @param[in] device_info: the device information. 1632 * @return 1633 * - ESP_OK : success 1634 * - other : failed 1635 */ 1636 esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info); 1637 1638 /** 1639 * @brief This function is called to remove a device info from the duplicate scan exceptional list. 1640 * 1641 * 1642 * @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t 1643 * when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid. 1644 * @param[in] device_info: the device information. 1645 * @return 1646 * - ESP_OK : success 1647 * - other : failed 1648 */ 1649 esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info); 1650 1651 /** 1652 * @brief This function is called to clean the duplicate scan exceptional list. 1653 * This API will delete all device information in the duplicate scan exceptional list. 1654 * 1655 * 1656 * @param[in] list_type: duplicate scan exceptional list type, the value can be one or more of esp_duplicate_scan_exceptional_list_type_t. 1657 * 1658 * @return 1659 * - ESP_OK : success 1660 * - other : failed 1661 */ 1662 esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_exceptional_list_type_t list_type); 1663 #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) 1664 1665 #if (SMP_INCLUDED == TRUE) 1666 /** 1667 * @brief Set a GAP security parameter value. Overrides the default value. 1668 * 1669 * Secure connection is highly recommended to avoid some major 1670 * vulnerabilities like 'Impersonation in the Pin Pairing Protocol' 1671 * (CVE-2020-26555) and 'Authentication of the LE Legacy Pairing 1672 * Protocol'. 1673 * 1674 * To accept only `secure connection mode`, it is necessary do as following: 1675 * 1676 * 1. Set bit `ESP_LE_AUTH_REQ_SC_ONLY` (`param_type` is 1677 * `ESP_BLE_SM_AUTHEN_REQ_MODE`), bit `ESP_LE_AUTH_BOND` and bit 1678 * `ESP_LE_AUTH_REQ_MITM` is optional as required. 1679 * 1680 * 2. Set to `ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE` (`param_type` is 1681 * `ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH`). 1682 * 1683 * @param[in] param_type : the type of the param which to be set 1684 * @param[in] value : the param value 1685 * @param[in] len : the length of the param value 1686 * 1687 * @return - ESP_OK : success 1688 * - other : failed 1689 * 1690 */ 1691 esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type, 1692 void *value, uint8_t len); 1693 1694 /** 1695 * @brief Grant security request access. 1696 * 1697 * @param[in] bd_addr : BD address of the peer 1698 * @param[in] accept : accept the security request or not 1699 * 1700 * @return - ESP_OK : success 1701 * - other : failed 1702 * 1703 */ 1704 esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept); 1705 1706 1707 /** 1708 * @brief Set a gap parameter value. Use this function to change 1709 * the default GAP parameter values. 1710 * 1711 * @param[in] bd_addr : the address of the peer device need to encryption 1712 * @param[in] sec_act : This is the security action to indicate 1713 * what kind of BLE security level is required for 1714 * the BLE link if the BLE is supported 1715 * 1716 * @return - ESP_OK : success 1717 * - other : failed 1718 * 1719 */ 1720 esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_act); 1721 1722 /** 1723 * @brief Reply the key value to the peer device in the legacy connection stage. 1724 * 1725 * @param[in] bd_addr : BD address of the peer 1726 * @param[in] accept : passkey entry successful or declined. 1727 * @param[in] passkey : passkey value, must be a 6 digit number, 1728 * can be lead by 0. 1729 * 1730 * @return - ESP_OK : success 1731 * - other : failed 1732 * 1733 */ 1734 esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey); 1735 1736 1737 /** 1738 * @brief Reply the confirm value to the peer device in the secure connection stage. 1739 * 1740 * @param[in] bd_addr : BD address of the peer device 1741 * @param[in] accept : numbers to compare are the same or different. 1742 * 1743 * @return - ESP_OK : success 1744 * - other : failed 1745 * 1746 */ 1747 esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept); 1748 1749 /** 1750 * @brief Removes a device from the security database list of 1751 * peer device. It manages unpairing event while connected. 1752 * 1753 * @param[in] bd_addr : BD address of the peer device 1754 * 1755 * @return - ESP_OK : success 1756 * - other : failed 1757 * 1758 */ 1759 esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr); 1760 1761 /** 1762 * @brief Get the device number from the security database list of peer device. 1763 * It will return the device bonded number immediately. 1764 * 1765 * @return - >= 0 : bonded devices number. 1766 * - ESP_FAIL : failed 1767 * 1768 */ 1769 int esp_ble_get_bond_device_num(void); 1770 1771 1772 /** 1773 * @brief Get the device from the security database list of peer device. 1774 * It will return the device bonded information immediately. 1775 * @param[inout] dev_num: Indicate the dev_list array(buffer) size as input. 1776 * If dev_num is large enough, it means the actual number as output. 1777 * Suggest that dev_num value equal to esp_ble_get_bond_device_num(). 1778 * 1779 * @param[out] dev_list: an array(buffer) of `esp_ble_bond_dev_t` type. Use for storing the bonded devices address. 1780 * The dev_list should be allocated by who call this API. 1781 * @return - ESP_OK : success 1782 * - other : failed 1783 * 1784 */ 1785 esp_err_t esp_ble_get_bond_device_list(int *dev_num, esp_ble_bond_dev_t *dev_list); 1786 1787 /** 1788 * @brief This function is called to provide the OOB data for 1789 * SMP in response to ESP_GAP_BLE_OOB_REQ_EVT 1790 * 1791 * @param[in] bd_addr: BD address of the peer device. 1792 * @param[in] TK: Temporary Key value, the TK value shall be a 128-bit random number 1793 * @param[in] len: length of temporary key, should always be 128-bit 1794 * 1795 * @return - ESP_OK : success 1796 * - other : failed 1797 * 1798 */ 1799 esp_err_t esp_ble_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t *TK, uint8_t len); 1800 1801 /** 1802 * @brief This function is called to provide the OOB data for 1803 * SMP in response to ESP_GAP_BLE_SC_OOB_REQ_EVT 1804 * 1805 * @param[in] bd_addr: BD address of the peer device. 1806 * @param[in] p_c: Confirmation value, it shall be a 128-bit random number 1807 * @param[in] p_r: Randomizer value, it should be a 128-bit random number 1808 * 1809 * @return - ESP_OK : success 1810 * - other : failed 1811 * 1812 */ 1813 esp_err_t esp_ble_sc_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t p_c[16], uint8_t p_r[16]); 1814 1815 /** 1816 * @brief This function is called to create the OOB data for 1817 * SMP when secure connection 1818 * 1819 * @return - ESP_OK : success 1820 * - other : failed 1821 * 1822 */ 1823 esp_err_t esp_ble_create_sc_oob_data(void); 1824 #endif /* #if (SMP_INCLUDED == TRUE) */ 1825 1826 /** 1827 * @brief This function is to disconnect the physical connection of the peer device 1828 * gattc may have multiple virtual GATT server connections when multiple app_id registered. 1829 * esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id) only close one virtual GATT server connection. 1830 * if there exist other virtual GATT server connections, it does not disconnect the physical connection. 1831 * esp_ble_gap_disconnect(esp_bd_addr_t remote_device) disconnect the physical connection directly. 1832 * 1833 * 1834 * 1835 * @param[in] remote_device : BD address of the peer device 1836 * 1837 * @return - ESP_OK : success 1838 * - other : failed 1839 * 1840 */ 1841 esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device); 1842 1843 /** 1844 * @brief This function is called to read the connection 1845 * parameters information of the device 1846 * 1847 * @param[in] bd_addr: BD address of the peer device. 1848 * @param[out] conn_params: the connection parameters information 1849 * 1850 * @return - ESP_OK : success 1851 * - other : failed 1852 * 1853 */ 1854 esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_params_t *conn_params); 1855 1856 /** 1857 * @brief BLE set channels 1858 * 1859 * @param[in] channels : The n th such field (in the range 0 to 36) contains the value for the link layer channel index n. 1860 * 0 means channel n is bad. 1861 * 1 means channel n is unknown. 1862 * The most significant bits are reserved and shall be set to 0. 1863 * At least one channel shall be marked as unknown. 1864 * 1865 * @return - ESP_OK : success 1866 * - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled 1867 * - other : failed 1868 * 1869 */ 1870 esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels); 1871 1872 /** 1873 * @brief This function is called to authorized a link after Authentication(MITM protection) 1874 * 1875 * @param[in] bd_addr: BD address of the peer device. 1876 * @param[out] authorize: Authorized the link or not. 1877 * 1878 * @return - ESP_OK : success 1879 * - other : failed 1880 * 1881 */ 1882 esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize); 1883 1884 #if (BLE_50_FEATURE_SUPPORT == TRUE) 1885 1886 /** 1887 * @brief This function is used to read the current transmitter PHY 1888 * and receiver PHY on the connection identified by remote address. 1889 * 1890 * @param[in] bd_addr : BD address of the peer device 1891 * 1892 * @return - ESP_OK : success 1893 * - other : failed 1894 * 1895 */ 1896 esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr); 1897 1898 /** 1899 * @brief This function is used to allows the Host to specify its preferred values 1900 * for the transmitter PHY and receiver PHY to be used for all subsequent connections 1901 * over the LE transport. 1902 * 1903 * @param[in] tx_phy_mask : indicates the transmitter PHYs that the Host prefers the Controller to use 1904 * @param[in] rx_phy_mask : indicates the receiver PHYs that the Host prefers the Controller to use 1905 * 1906 * @return - ESP_OK : success 1907 * - other : failed 1908 * 1909 */ 1910 esp_err_t esp_ble_gap_set_preferred_default_phy(esp_ble_gap_phy_mask_t tx_phy_mask, esp_ble_gap_phy_mask_t rx_phy_mask); 1911 /** 1912 * @brief This function is used to set the PHY preferences for the connection identified by the remote address. 1913 * The Controller might not be able to make the change (e.g. because the peer does not support the requested PHY) 1914 * or may decide that the current PHY is preferable. 1915 * 1916 * @param[in] bd_addr : remote address 1917 * @param[in] all_phys_mask : a bit field that allows the Host to specify 1918 * @param[in] tx_phy_mask : a bit field that indicates the transmitter PHYs that the Host prefers the Controller to use 1919 * @param[in] rx_phy_mask : a bit field that indicates the receiver PHYs that the Host prefers the Controller to use 1920 * @param[in] phy_options : a bit field that allows the Host to specify options for PHYs 1921 * 1922 * @return - ESP_OK : success 1923 * - other : failed 1924 * 1925 */ 1926 esp_err_t esp_ble_gap_set_preferred_phy(esp_bd_addr_t bd_addr, 1927 esp_ble_gap_all_phys_t all_phys_mask, 1928 esp_ble_gap_phy_mask_t tx_phy_mask, 1929 esp_ble_gap_phy_mask_t rx_phy_mask, 1930 esp_ble_gap_prefer_phy_options_t phy_options); 1931 1932 /** 1933 * @brief This function is used by the Host to set the random device address specified by the Random_Address parameter. 1934 * 1935 * @param[in] instance : Used to identify an advertising set 1936 * @param[in] rand_addr : Random Device Address 1937 * 1938 * @return - ESP_OK : success 1939 * - other : failed 1940 * 1941 */ 1942 esp_err_t esp_ble_gap_ext_adv_set_rand_addr(uint8_t instance, esp_bd_addr_t rand_addr); 1943 1944 /** 1945 * @brief This function is used by the Host to set the advertising parameters. 1946 * 1947 * @param[in] instance : identifies the advertising set whose parameters are being configured. 1948 * @param[in] params : advertising parameters 1949 * 1950 * @return - ESP_OK : success 1951 * - other : failed 1952 * 1953 */ 1954 esp_err_t esp_ble_gap_ext_adv_set_params(uint8_t instance, const esp_ble_gap_ext_adv_params_t *params); 1955 1956 /** 1957 * @brief This function is used to set the data used in advertising PDUs that have a data field 1958 * 1959 * @param[in] instance : identifies the advertising set whose data are being configured 1960 * @param[in] length : data length 1961 * @param[in] data : data information 1962 * 1963 * @return - ESP_OK : success 1964 * - other : failed 1965 * 1966 */ 1967 esp_err_t esp_ble_gap_config_ext_adv_data_raw(uint8_t instance, uint16_t length, const uint8_t *data); 1968 1969 /** 1970 * @brief This function is used to provide scan response data used in scanning response PDUs 1971 * 1972 * @param[in] instance : identifies the advertising set whose response data are being configured. 1973 * @param[in] length : responsedata length 1974 * @param[in] scan_rsp_data : response data information 1975 * 1976 * @return - ESP_OK : success 1977 * - other : failed 1978 * 1979 */ 1980 esp_err_t esp_ble_gap_config_ext_scan_rsp_data_raw(uint8_t instance, uint16_t length, 1981 const uint8_t *scan_rsp_data); 1982 /** 1983 * @brief This function is used to request the Controller to enable one or more 1984 * advertising sets using the advertising sets identified by the instance parameter. 1985 * 1986 * @param[in] num_adv : Number of advertising sets to enable or disable 1987 * @param[in] ext_adv : adv parameters 1988 * 1989 * @return - ESP_OK : success 1990 * - other : failed 1991 * 1992 */ 1993 esp_err_t esp_ble_gap_ext_adv_start(uint8_t num_adv, const esp_ble_gap_ext_adv_t *ext_adv); 1994 1995 /** 1996 * @brief This function is used to request the Controller to disable one or more 1997 * advertising sets using the advertising sets identified by the instance parameter. 1998 * 1999 * @param[in] num_adv : Number of advertising sets to enable or disable 2000 * @param[in] ext_adv_inst : ext adv instance 2001 * 2002 * @return - ESP_OK : success 2003 * - other : failed 2004 * 2005 */ 2006 esp_err_t esp_ble_gap_ext_adv_stop(uint8_t num_adv, const uint8_t *ext_adv_inst); 2007 2008 /** 2009 * @brief This function is used to remove an advertising set from the Controller. 2010 * 2011 * @param[in] instance : Used to identify an advertising set 2012 * 2013 * @return - ESP_OK : success 2014 * - other : failed 2015 * 2016 */ 2017 esp_err_t esp_ble_gap_ext_adv_set_remove(uint8_t instance); 2018 2019 /** 2020 * @brief This function is used to remove all existing advertising sets from the Controller. 2021 * 2022 * 2023 * @return - ESP_OK : success 2024 * - other : failed 2025 * 2026 */ 2027 esp_err_t esp_ble_gap_ext_adv_set_clear(void); 2028 2029 /** 2030 * @brief This function is used by the Host to set the parameters for periodic advertising. 2031 * 2032 * @param[in] instance : identifies the advertising set whose periodic advertising parameters are being configured. 2033 * @param[in] params : periodic adv parameters 2034 * 2035 * @return - ESP_OK : success 2036 * - other : failed 2037 * 2038 */ 2039 esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_gap_periodic_adv_params_t *params); 2040 2041 /** 2042 * @brief This function is used to set the data used in periodic advertising PDUs. 2043 * 2044 * @param[in] instance : identifies the advertising set whose periodic advertising parameters are being configured. 2045 * @param[in] length : the length of periodic data 2046 * @param[in] data : periodic data information 2047 * 2048 * @return - ESP_OK : success 2049 * - other : failed 2050 * 2051 */ 2052 esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length, 2053 const uint8_t *data); 2054 /** 2055 * @brief This function is used to request the Controller to enable the periodic advertising for the advertising set specified 2056 * 2057 * @param[in] instance : Used to identify an advertising set 2058 * 2059 * @return - ESP_OK : success 2060 * - other : failed 2061 * 2062 */ 2063 esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance); 2064 2065 /** 2066 * @brief This function is used to request the Controller to disable the periodic advertising for the advertising set specified 2067 * 2068 * @param[in] instance : Used to identify an advertising set 2069 * 2070 * @return - ESP_OK : success 2071 * - other : failed 2072 * 2073 */ 2074 esp_err_t esp_ble_gap_periodic_adv_stop(uint8_t instance); 2075 2076 /** 2077 * @brief This function is used to set the extended scan parameters to be used on the advertising channels. 2078 * 2079 * @param[in] params : scan parameters 2080 * 2081 * @return - ESP_OK : success 2082 * - other : failed 2083 * 2084 */ 2085 esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *params); 2086 2087 /** 2088 * @brief This function is used to enable scanning. 2089 * 2090 * @param[in] duration : Scan duration 2091 * @param[in] period : Time interval from when the Controller started its last Scan Duration until it begins the subsequent Scan Duration. 2092 * 2093 * @return - ESP_OK : success 2094 * - other : failed 2095 * 2096 */ 2097 esp_err_t esp_ble_gap_start_ext_scan(uint32_t duration, uint16_t period); 2098 2099 /** 2100 * @brief This function is used to disable scanning. 2101 * 2102 * @return - ESP_OK : success 2103 * - other : failed 2104 * 2105 */ 2106 esp_err_t esp_ble_gap_stop_ext_scan(void); 2107 2108 /** 2109 * @brief This function is used to synchronize with periodic advertising from an advertiser and begin receiving periodic advertising packets. 2110 * 2111 * @param[in] params : sync parameters 2112 * 2113 * @return - ESP_OK : success 2114 * - other : failed 2115 * 2116 */ 2117 esp_err_t esp_ble_gap_periodic_adv_create_sync(const esp_ble_gap_periodic_adv_sync_params_t *params); 2118 2119 /** 2120 * @brief This function is used to cancel the LE_Periodic_Advertising_Create_Sync command while it is pending. 2121 * 2122 * 2123 * @return - ESP_OK : success 2124 * - other : failed 2125 * 2126 */ 2127 esp_err_t esp_ble_gap_periodic_adv_sync_cancel(void); 2128 2129 /** 2130 * @brief This function is used to stop reception of the periodic advertising identified by the Sync Handle parameter. 2131 * 2132 * @param[in] sync_handle : identify the periodic advertiser 2133 * 2134 * @return - ESP_OK : success 2135 * - other : failed 2136 * 2137 */ 2138 esp_err_t esp_ble_gap_periodic_adv_sync_terminate(uint16_t sync_handle); 2139 2140 /** 2141 * @brief This function is used to add a single device to the Periodic Advertiser list stored in the Controller 2142 * 2143 * @param[in] addr_type : address type 2144 * @param[in] addr : Device Address 2145 * @param[in] sid : Advertising SID subfield in the ADI field used to identify the Periodic Advertising 2146 * 2147 * @return - ESP_OK : success 2148 * - other : failed 2149 * 2150 */ 2151 esp_err_t esp_ble_gap_periodic_adv_add_dev_to_list(esp_ble_addr_type_t addr_type, 2152 esp_bd_addr_t addr, 2153 uint8_t sid); 2154 2155 /** 2156 * @brief This function is used to remove one device from the list of Periodic Advertisers stored in the Controller. 2157 * Removals from the Periodic Advertisers List take effect immediately. 2158 * 2159 * @param[in] addr_type : address type 2160 * @param[in] addr : Device Address 2161 * @param[in] sid : Advertising SID subfield in the ADI field used to identify the Periodic Advertising 2162 * 2163 * @return - ESP_OK : success 2164 * - other : failed 2165 * 2166 */ 2167 esp_err_t esp_ble_gap_periodic_adv_remove_dev_from_list(esp_ble_addr_type_t addr_type, 2168 esp_bd_addr_t addr, 2169 uint8_t sid); 2170 /** 2171 * @brief This function is used to remove all devices from the list of Periodic Advertisers in the Controller. 2172 * 2173 * @return - ESP_OK : success 2174 * - other : failed 2175 * 2176 */ 2177 esp_err_t esp_ble_gap_periodic_adv_clear_dev(void); 2178 2179 /** 2180 * @brief This function is used to set aux connection parameters 2181 * 2182 * @param[in] addr : device address 2183 * @param[in] phy_mask : indicates the PHY(s) on which the advertising packets should be received on the primary advertising channel and the PHYs for which connection parameters have been specified. 2184 * @param[in] phy_1m_conn_params : Scan connectable advertisements on the LE 1M PHY. Connection parameters for the LE 1M PHY are provided. 2185 * @param[in] phy_2m_conn_params : Connection parameters for the LE 2M PHY are provided. 2186 * @param[in] phy_coded_conn_params : Scan connectable advertisements on the LE Coded PHY. Connection parameters for the LE Coded PHY are provided. 2187 * 2188 * @return - ESP_OK : success 2189 * - other : failed 2190 * 2191 */ 2192 esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, 2193 esp_ble_gap_phy_mask_t phy_mask, 2194 const esp_ble_gap_conn_params_t *phy_1m_conn_params, 2195 const esp_ble_gap_conn_params_t *phy_2m_conn_params, 2196 const esp_ble_gap_conn_params_t *phy_coded_conn_params); 2197 2198 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) 2199 2200 #ifdef __cplusplus 2201 } 2202 #endif 2203 2204 #endif /* __ESP_GAP_BLE_API_H__ */ 2205