BLE shield
Fork of X_NUCLEO_IDB0XA1 by
Embed:
(wiki syntax)
Show/hide line numbers
bluenrg_gap_aci.h
00001 /******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** 00002 * File Name : bluenrg_gap_aci.h 00003 * Author : AMS - AAS 00004 * Version : V1.0.0 00005 * Date : 26-Jun-2014 00006 * Description : Header file with GAP commands for BlueNRG FW6.3. 00007 ******************************************************************************** 00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00014 *******************************************************************************/ 00015 00016 #ifndef __BLUENRG_GAP_ACI_H__ 00017 #define __BLUENRG_GAP_ACI_H__ 00018 00019 /** 00020 *@addtogroup GAP GAP 00021 *@brief GAP layer. 00022 *@{ 00023 */ 00024 00025 /** 00026 *@defgroup GAP_Functions GAP functions 00027 *@brief API for GAP layer. 00028 *@{ 00029 */ 00030 00031 /** 00032 * @brief Initialize the GAP layer. 00033 * @note Register the GAP service with the GATT. 00034 * All the standard GAP characteristics will also be added: 00035 * @li Device Name 00036 * @li Appearance 00037 * @li Peripheral Preferred Connection Parameters (peripheral role only) 00038 * @code 00039 00040 tBleStatus ret; 00041 uint16_t service_handle, dev_name_char_handle, appearance_char_handle; 00042 00043 ret = aci_gap_init_IDB05A1(1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle); 00044 if(ret){ 00045 PRINTF("GAP_Init failed.\n"); 00046 reboot(); 00047 } 00048 const char *name = "BlueNRG"; 00049 ret = aci_gatt_update_char_value(service_handle, dev_name_char_handle, 0, strlen(name), (uint8_t *)name); 00050 if(ret){ 00051 PRINTF("aci_gatt_update_char_value failed.\n"); 00052 } 00053 * @endcode 00054 * @param role Bitmap of allowed roles: see @ref gap_roles "GAP roles". 00055 * @param privacy_enabled Enable (1) or disable (0) privacy. 00056 * @param device_name_char_len Length of the device name characteristic 00057 * @param[out] service_handle Handle of the GAP service. 00058 * @param[out] dev_name_char_handle Device Name Characteristic handle 00059 * @param[out] appearance_char_handle Appearance Characteristic handle 00060 * @retval tBleStatus Value indicating success or error code. 00061 */ 00062 tBleStatus aci_gap_init_IDB05A1(uint8_t role, uint8_t privacy_enabled, 00063 uint8_t device_name_char_len, 00064 uint16_t* service_handle, 00065 uint16_t* dev_name_char_handle, 00066 uint16_t* appearance_char_handle); 00067 /** 00068 * @brief Initialize the GAP layer. 00069 * @note Register the GAP service with the GATT. 00070 * All the standard GAP characteristics will also be added: 00071 * @li Device Name 00072 * @li Appearance 00073 * @li Peripheral Privacy Flag (peripheral role only) 00074 * @li Reconnection Address (peripheral role only) 00075 * @li Peripheral Preferred Connection Parameters (peripheral role only) 00076 * @code 00077 00078 tBleStatus ret; 00079 uint16_t service_handle, dev_name_char_handle, appearance_char_handle; 00080 00081 ret = aci_gap_init_IDB04A1(1, &service_handle, &dev_name_char_handle, &appearance_char_handle); 00082 if(ret){ 00083 PRINTF("GAP_Init failed.\n"); 00084 reboot(); 00085 } 00086 const char *name = "BlueNRG"; 00087 ret = aci_gatt_update_char_value(service_handle, dev_name_char_handle, 0, strlen(name), (uint8_t *)name); 00088 if(ret){ 00089 PRINTF("aci_gatt_update_char_value failed.\n"); 00090 } 00091 * @endcode 00092 * @param role One of the allowed roles: @ref GAP_PERIPHERAL_ROLE or @ref GAP_CENTRAL_ROLE. See @ref gap_roles "GAP roles". 00093 * @param[out] service_handle Handle of the GAP service. 00094 * @param[out] dev_name_char_handle Device Name Characteristic handle 00095 * @param[out] appearance_char_handle Appearance Characteristic handle 00096 * @retval tBleStatus Value indicating success or error code. 00097 */ 00098 tBleStatus aci_gap_init_IDB04A1(uint8_t role, 00099 uint16_t* service_handle, 00100 uint16_t* dev_name_char_handle, 00101 uint16_t* appearance_char_handle); 00102 00103 /** 00104 * @brief Set the Device in non-discoverable mode. 00105 * @note This command will disable the LL advertising. 00106 * @retval tBleStatus Value indicating success or error code. 00107 */ 00108 tBleStatus aci_gap_set_non_discoverable(void); 00109 00110 /** 00111 * @brief Put the device in limited discoverable mode 00112 * (as defined in GAP specification volume 3, section 9.2.3). 00113 * @note The device will be discoverable for TGAP (lim_adv_timeout) = 180 seconds. 00114 * The advertising can be disabled at any time by issuing 00115 * aci_gap_set_non_discoverable() command. 00116 * The AdvIntervMin and AdvIntervMax parameters are optional. If both 00117 * are set to 0, the GAP will use default values (250 ms and 500 ms respectively). 00118 * Host can set the Local Name, a Service UUID list and the Slave Connection 00119 * Minimum and Maximum. If provided, these data will be inserted into the 00120 * advertising packet payload as AD data. These parameters are optional 00121 * in this command. These values can be also set using aci_gap_update_adv_data() 00122 * separately. 00123 * The total size of data in advertising packet cannot exceed 31 bytes. 00124 * With this command, the BLE Stack will also add automatically the following 00125 * standard AD types: 00126 * @li AD Flags 00127 * @li TX Power Level 00128 * 00129 * When advertising timeout happens (i.e. limited discovery period has elapsed), controller generates 00130 * @ref EVT_BLUE_GAP_LIMITED_DISCOVERABLE event. 00131 * 00132 * Example: 00133 * @code 00134 * 00135 * #define ADV_INTERVAL_MIN_MS 100 00136 * #define ADV_INTERVAL_MAX_MS 200 00137 * 00138 * tBleStatus ret; 00139 * 00140 * const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; 00141 * const uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID,0x34,0x12}; 00142 * 00143 * ret = aci_gap_set_limited_discoverable(ADV_IND, (ADV_INTERVAL_MIN_MS*1000)/0.625, 00144 * (ADV_INTERVAL_MAX_MS*1000)/0.625, 00145 * STATIC_RANDOM_ADDR, NO_WHITE_LIST_USE, 00146 * sizeof(local_name), local_name, 00147 * sizeof(serviceUUIDList), serviceUUIDList, 00148 * 0, 0); 00149 * @endcode 00150 * 00151 * @param AdvType One of the advertising types: 00152 * @arg @ref ADV_IND Connectable undirected advertising 00153 * @arg @ref ADV_SCAN_IND Scannable undirected advertising 00154 * @arg @ref ADV_NONCONN_IND Non connectable undirected advertising 00155 * @param AdvIntervMin Minimum advertising interval. 00156 * Range: 0x0020 to 0x4000 00157 * Default: 250 ms 00158 * Time = N * 0.625 msec 00159 * Time Range: 20 ms to 10.24 sec (minimum 100 ms for ADV_SCAN_IND or ADV_NONCONN_IND). 00160 * @param AdvIntervMax Maximum advertising interval. 00161 * Range: 0x0020 to 0x4000 00162 * Default: 500 ms 00163 * Time = N * 0.625 msec 00164 * Time Range: 20 ms to 10.24 sec (minimum 100 ms for ADV_SCAN_IND or ADV_NONCONN_IND). 00165 * @param OwnAddrType Type of our address used during advertising 00166 * (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00167 * @param AdvFilterPolicy Filter policy: 00168 * @arg NO_WHITE_LIST_USE 00169 * @arg WHITE_LIST_FOR_ONLY_SCAN 00170 * @arg WHITE_LIST_FOR_ONLY_CONN 00171 * @arg WHITE_LIST_FOR_ALL 00172 * @param LocalNameLen Length of LocalName array. 00173 * @param LocalName Array containing the Local Name AD data. First byte is the AD type: 00174 * @ref AD_TYPE_SHORTENED_LOCAL_NAME or @ref AD_TYPE_COMPLETE_LOCAL_NAME. 00175 * @param ServiceUUIDLen Length of ServiceUUIDList array. 00176 * @param ServiceUUIDList This is the list of the UUIDs AD Types as defined in Volume 3, 00177 * Section 11.1.1 of GAP Specification. First byte is the AD Type. 00178 * @arg @ref AD_TYPE_16_BIT_SERV_UUID 00179 * @arg @ref AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST 00180 * @arg @ref AD_TYPE_128_BIT_SERV_UUID 00181 * @arg @ref AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST 00182 * @param SlaveConnIntervMin Slave connection interval minimum value suggested by Peripheral. 00183 * If SlaveConnIntervMin and SlaveConnIntervMax are not 0x0000, 00184 * Slave Connection Interval Range AD structure will be added in advertising 00185 * data. 00186 * Connection interval is defined in the following manner: 00187 * connIntervalmin = Slave_Conn_Interval_Min x 1.25ms 00188 * Slave_Conn_Interval_Min range: 0x0006 to 0x0C80 00189 * Value of 0xFFFF indicates no specific minimum. 00190 * @param SlaveConnIntervMax Slave connection interval maximum value suggested by Peripheral. 00191 * If SlaveConnIntervMin and SlaveConnIntervMax are not 0x0000, 00192 * Slave Connection Interval Range AD structure will be added in advertising 00193 * data. 00194 * ConnIntervalmax = Slave_Conn_Interval_Max x 1.25ms 00195 * Slave_Conn_Interval_Max range: 0x0006 to 0x0C80 00196 * Slave_ Conn_Interval_Max shall be equal to or greater than the Slave_Conn_Interval_Min. 00197 * Value of 0xFFFF indicates no specific maximum. 00198 * 00199 * @retval tBleStatus Value indicating success or error code. 00200 */ 00201 tBleStatus aci_gap_set_limited_discoverable(uint8_t AdvType, uint16_t AdvIntervMin, uint16_t AdvIntervMax, 00202 uint8_t OwnAddrType, uint8_t AdvFilterPolicy, uint8_t LocalNameLen, 00203 const char *LocalName, uint8_t ServiceUUIDLen, uint8_t* ServiceUUIDList, 00204 uint16_t SlaveConnIntervMin, uint16_t SlaveConnIntervMax); 00205 /** 00206 * @brief Put the Device in general discoverable mode (as defined in GAP specification volume 3, section 9.2.4). 00207 * @note The device will be discoverable until the Host issue Bluehci_Gap_Set_Non_Discoverable command. 00208 * The Adv_Interval_Min and Adv_Interval_Max parameters are optional. If both are set to 0, the GAP uses 00209 * the default values for advertising intervals (1.28 s and 2.56 s respectively). 00210 * Host can set the Local Name, a Service UUID list and the Slave Connection Interval Range. If provided, 00211 * these data will be inserted into the advertising packet payload as AD data. These parameters are optional 00212 * in this command. These values can be also set using aci_gap_update_adv_data() separately. 00213 * The total size of data in advertising packet cannot exceed 31 bytes. 00214 * With this command, the BLE Stack will also add automatically the following standard AD types: 00215 * @li AD Flags 00216 * @li TX Power Level 00217 * 00218 * Usage example: 00219 * 00220 * @code 00221 * 00222 * #define ADV_INTERVAL_MIN_MS 800 00223 * #define ADV_INTERVAL_MAX_MS 900 00224 * #define CONN_INTERVAL_MIN_MS 100 00225 * #define CONN_INTERVAL_MAX_MS 300 00226 * 00227 * tBleStatus ret; 00228 * 00229 * const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; 00230 * const uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID,0x34,0x12}; 00231 * 00232 * ret = aci_gap_set_discoverable(ADV_IND, (ADV_INTERVAL_MIN_MS*1000)/0.625, 00233 * (ADV_INTERVAL_MAX_MS*1000)/0.625, 00234 * STATIC_RANDOM_ADDR, NO_WHITE_LIST_USE, 00235 * sizeof(local_name), local_name, 00236 * 0, NULL, 00237 * (CONN_INTERVAL_MIN_MS*1000)/1250, 00238 * (CONN_INTERVAL_MAX_MS*1000)/1250); 00239 * @endcode 00240 * 00241 * @param AdvType One of the advertising types: 00242 * @arg @ref ADV_IND Connectable undirected advertising 00243 * @arg @ref ADV_SCAN_IND Scannable undirected advertising 00244 * @arg @ref ADV_NONCONN_IND Non connectable undirected advertising 00245 * @param AdvIntervMin Minimum advertising interval. 00246 * Range: 0x0020 to 0x4000 00247 * Default: 1.28 s 00248 * Time = N * 0.625 msec 00249 * Time Range: 20 ms to 10.24 sec (minimum 100 ms for ADV_SCAN_IND or ADV_NONCONN_IND). 00250 * @param AdvIntervMax Maximum advertising interval. 00251 * Range: 0x0020 to 0x4000 00252 * Default: 2.56 s 00253 * Time = N * 0.625 msec 00254 * Time Range: 20 ms to 10.24 sec (minimum 100 ms for ADV_SCAN_IND or ADV_NONCONN_IND). 00255 * @param OwnAddrType Type of our address used during advertising 00256 * (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00257 * @param AdvFilterPolicy Filter policy: 00258 * @arg @ref NO_WHITE_LIST_USE 00259 * @arg @ref WHITE_LIST_FOR_ONLY_SCAN 00260 * @arg @ref WHITE_LIST_FOR_ONLY_CONN 00261 * @arg @ref WHITE_LIST_FOR_ALL 00262 * @param LocalNameLen Length of LocalName array. 00263 * @param LocalName Array containing the Local Name AD data. First byte is the AD type: 00264 * @ref AD_TYPE_SHORTENED_LOCAL_NAME or @ref AD_TYPE_COMPLETE_LOCAL_NAME. 00265 * @param ServiceUUIDLen Length of ServiceUUIDList array. 00266 * @param ServiceUUIDList This is the list of the UUIDs AD Types as defined in Volume 3, 00267 * Section 11.1.1 of GAP Specification. First byte is the AD Type. 00268 * @arg @ref AD_TYPE_16_BIT_SERV_UUID 00269 * @arg @ref AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST 00270 * @arg @ref AD_TYPE_128_BIT_SERV_UUID 00271 * @arg @ref AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST 00272 * @param SlaveConnIntervMin Slave connection interval minimum value suggested by Peripheral. 00273 * If SlaveConnIntervMin and SlaveConnIntervMax are not 0x0000, 00274 * Slave Connection Interval Range AD structure will be added in advertising 00275 * data. 00276 * Connection interval is defined in the following manner: 00277 * connIntervalmin = Slave_Conn_Interval_Min x 1.25ms 00278 * Slave_Conn_Interval_Min range: 0x0006 to 0x0C80 00279 * Value of 0xFFFF indicates no specific minimum. 00280 * @param SlaveConnIntervMax Slave connection interval maximum value suggested by Peripheral. 00281 * If SlaveConnIntervMin and SlaveConnIntervMax are not 0x0000, 00282 * Slave Connection Interval Range AD structure will be added in advertising 00283 * data. 00284 * ConnIntervalmax = Slave_Conn_Interval_Max x 1.25ms 00285 * Slave_Conn_Interval_Max range: 0x0006 to 0x0C80 00286 * Slave_ Conn_Interval_Max shall be equal to or greater than the Slave_Conn_Interval_Min. 00287 * Value of 0xFFFF indicates no specific maximum. 00288 * 00289 * @retval tBleStatus Value indicating success or error code. 00290 */ 00291 tBleStatus aci_gap_set_discoverable(uint8_t AdvType, uint16_t AdvIntervMin, uint16_t AdvIntervMax, 00292 uint8_t OwnAddrType, uint8_t AdvFilterPolicy, uint8_t LocalNameLen, 00293 const char *LocalName, uint8_t ServiceUUIDLen, uint8_t* ServiceUUIDList, 00294 uint16_t SlaveConnIntervMin, uint16_t SlaveConnIntervMax); 00295 00296 /** 00297 * @brief Set the Device in direct connectable mode (as defined in GAP specification Volume 3, Section 9.3.3). 00298 * @note If the privacy is enabled, the reconnection address is used for advertising, otherwise the address 00299 * of the type specified in OwnAddrType is used. The device will be in directed connectable mode only 00300 * for 1.28 seconds. If no connection is established within this duration, the device enters non 00301 * discoverable mode and advertising will have to be again enabled explicitly. 00302 * The controller generates a @ref EVT_LE_CONN_COMPLETE event with the status set to @ref HCI_DIRECTED_ADV_TIMEOUT 00303 * if the connection was not established and 0x00 if the connection was successfully established. 00304 * 00305 * Usage example: 00306 * @code 00307 * 00308 * tBleStatus ret; 00309 * 00310 * const uint8_t central_address[] = {0x43,0x27,0x84,0xE1,0x80,0x02}; 00311 * ret = aci_gap_set_direct_connectable_IDB05A1(PUBLIC_ADDR, HIGH_DUTY_CYCLE_DIRECTED_ADV, PUBLIC_ADDR, central_address); 00312 * @endcode 00313 * 00314 * 00315 * 00316 * @param OwnAddrType Type of our address used during advertising (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00317 * @param directed_adv_type Type of directed advertising (@ref HIGH_DUTY_CYCLE_DIRECTED_ADV, @ref LOW_DUTY_CYCLE_DIRECTED_ADV). 00318 * @param InitiatorAddrType Type of peer address (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00319 * @param InitiatorAddr Initiator's address (Little Endian). 00320 * @return Value indicating success or error code. 00321 */ 00322 tBleStatus aci_gap_set_direct_connectable_IDB05A1(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); 00323 /** 00324 * @brief Set the Device in direct connectable mode (as defined in GAP specification Volume 3, Section 9.3.3). 00325 * @note If the privacy is enabled, the reconnection address is used for advertising, otherwise the address 00326 * of the type specified in OwnAddrType is used. The device will be in directed connectable mode only 00327 * for 1.28 seconds. If no connection is established within this duration, the device enters non 00328 * discoverable mode and advertising will have to be again enabled explicitly. 00329 * The controller generates a @ref EVT_LE_CONN_COMPLETE event with the status set to @ref HCI_DIRECTED_ADV_TIMEOUT 00330 * if the connection was not established and 0x00 if the connection was successfully established. 00331 * 00332 * Usage example: 00333 * @code 00334 * 00335 * tBleStatus ret; 00336 * 00337 * const uint8_t central_address = {0x43,0x27,0x84,0xE1,0x80,0x02}; 00338 * ret = aci_gap_set_direct_connectable_IDB04A1(PUBLIC_ADDR, PUBLIC_ADDR, central_address); 00339 * @endcode 00340 * 00341 * 00342 * 00343 * @param OwnAddrType Type of our address used during advertising (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00344 * @param InitiatorAddrType Type of peer address (@ref PUBLIC_ADDR,@ref STATIC_RANDOM_ADDR). 00345 * @param InitiatorAddr Initiator's address (Little Endian). 00346 * @return Value indicating success or error code. 00347 */ 00348 tBleStatus aci_gap_set_direct_connectable_IDB04A1(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); 00349 00350 /** 00351 * @brief Set the IO capabilities of the device. 00352 * @note This command has to be given only when the device is not in a connected state. 00353 * @param io_capability One of the allowed codes for IO Capability: 00354 * @arg @ref IO_CAP_DISPLAY_ONLY 00355 * @arg @ref IO_CAP_DISPLAY_YES_NO 00356 * @arg @ref IO_CAP_KEYBOARD_ONLY 00357 * @arg @ref IO_CAP_NO_INPUT_NO_OUTPUT 00358 * @arg @ref IO_CAP_KEYBOARD_DISPLAY 00359 * @return Value indicating success or error code. 00360 */ 00361 tBleStatus aci_gap_set_io_capability(uint8_t io_capability); 00362 00363 /** 00364 * @brief Set the authentication requirements for the device. 00365 * @note If the oob_enable is set to 0, oob_data will be ignored. 00366 * This command has to be given only when the device is not in a connected state. 00367 * @param mitm_mode MITM mode: 00368 * @arg @ref MITM_PROTECTION_NOT_REQUIRED 00369 * @arg @ref MITM_PROTECTION_REQUIRED 00370 * @param oob_enable If OOB data are present or not: 00371 * @arg @ref OOB_AUTH_DATA_ABSENT 00372 * @arg @ref OOB_AUTH_DATA_PRESENT 00373 * @param oob_data Out-Of-Band data 00374 * @param min_encryption_key_size Minimum size of the encryption key to be used during the pairing process 00375 * @param max_encryption_key_size Maximum size of the encryption key to be used during the pairing process 00376 * @param use_fixed_pin If application wants to use a fixed pin or not: 00377 * @arg @ref USE_FIXED_PIN_FOR_PAIRING 00378 * @arg @ref DONOT_USE_FIXED_PIN_FOR_PAIRING 00379 * If a fixed pin is not used, it has to be provided by the application with 00380 * aci_gap_pass_key_response() after @ref EVT_BLUE_GAP_PASS_KEY_REQUEST event. 00381 * @param fixed_pin If use_fixed_pin is USE_FIXED_PIN_FOR_PAIRING, this is the value of the pin that will 00382 * be used during pairing if MIMT protection is enabled. Any value between 0 to 999999 is 00383 * accepted. 00384 * @param bonding_mode One of the bonding modes: 00385 * @arg @ref BONDING 00386 * @arg @ref NO_BONDING 00387 * @return Value indicating success or error code. 00388 */ 00389 tBleStatus aci_gap_set_auth_requirement(uint8_t mitm_mode, 00390 uint8_t oob_enable, 00391 uint8_t oob_data[16], 00392 uint8_t min_encryption_key_size, 00393 uint8_t max_encryption_key_size, 00394 uint8_t use_fixed_pin, 00395 uint32_t fixed_pin, 00396 uint8_t bonding_mode); 00397 /** 00398 * @brief Set the authorization requirements of the device. 00399 * @note This command has to be given only when the device is not in a connected state. 00400 * @param conn_handle Handle of the connection in case BlueNRG is configured as a master (otherwise it can be also 0). 00401 * @param authorization_enable @arg @ref AUTHORIZATION_NOT_REQUIRED : Authorization not required 00402 * @arg @ref AUTHORIZATION_REQUIRED : Authorization required. This enables 00403 * the authorization requirement in the device and when a remote device 00404 * tries to connect to GATT server, @ref EVT_BLUE_GAP_AUTHORIZATION_REQUEST event 00405 * will be sent to the Host. 00406 * 00407 * @return Value indicating success or error code. 00408 */ 00409 tBleStatus aci_gap_set_author_requirement(uint16_t conn_handle, uint8_t authorization_enable); 00410 00411 /** 00412 * @brief Provide the pass key that will be used during pairing. 00413 * @note This command should be sent by the Host in response to @ref EVT_BLUE_GAP_PASS_KEY_REQUEST event. 00414 * @param conn_handle Connection handle 00415 * @param passkey Pass key that will be used during the pairing process. Must be a number between 00416 * 0 and 999999. 00417 * @return Value indicating success or error code. 00418 */ 00419 tBleStatus aci_gap_pass_key_response(uint16_t conn_handle, uint32_t passkey); 00420 00421 /** 00422 * @brief Authorize a device to access attributes. 00423 * @note Application should send this command after it has received a @ref EVT_BLUE_GAP_AUTHORIZATION_REQUEST. 00424 * 00425 * @param conn_handle Connection handle 00426 * @param authorize @arg @ref CONNECTION_AUTHORIZED : Authorize (accept connection) 00427 * @arg @ref CONNECTION_REJECTED : Reject (reject connection) 00428 * @return Value indicating success or error code. 00429 */ 00430 tBleStatus aci_gap_authorization_response(uint16_t conn_handle, uint8_t authorize); 00431 00432 /** 00433 * @brief Put the device into non-connectable mode. 00434 * @param adv_type One of the allowed advertising types: 00435 * @arg @ref ADV_SCAN_IND : Scannable undirected advertising 00436 * @arg @ref ADV_NONCONN_IND : Non-connectable undirected advertising 00437 * @param own_address_type If Privacy is disabled, then the peripheral address can be 00438 * @arg @ref PUBLIC_ADDR. 00439 * @arg @ref STATIC_RANDOM_ADDR. 00440 * If Privacy is enabled, then the peripheral address can be 00441 * @arg @ref RESOLVABLE_PRIVATE_ADDR 00442 * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR 00443 * @return Value indicating success or error code. 00444 */ 00445 tBleStatus aci_gap_set_non_connectable_IDB05A1(uint8_t adv_type, uint8_t own_address_type); 00446 /** 00447 * @brief Put the device into non-connectable mode. 00448 * @param adv_type One of the allowed advertising types: 00449 * @arg @ref ADV_SCAN_IND : Scannable undirected advertising 00450 * @arg @ref ADV_NONCONN_IND : Non-connectable undirected advertising 00451 * @return Value indicating success or error code. 00452 */ 00453 tBleStatus aci_gap_set_non_connectable_IDB04A1(uint8_t adv_type); 00454 00455 /** 00456 * @brief Put the device into undirected connectable mode. 00457 * @note If privacy is enabled in the device, a resolvable private address is generated and used 00458 * as the advertiser's address. If not, the address of the type specified in own_addr_type 00459 * is used for advertising. 00460 * @param own_addr_type Type of our address used during advertising: 00461 * if BLUENRG (IDB04A1) 00462 * @arg @ref PUBLIC_ADDR. 00463 * @arg @ref STATIC_RANDOM_ADDR. 00464 * else if BLUENRG_MS (IDB05A1) 00465 * If Privacy is disabled: 00466 * @arg @ref PUBLIC_ADDR. 00467 * @arg @ref STATIC_RANDOM_ADDR. 00468 * If Privacy is enabled: 00469 * @arg @ref RESOLVABLE_PRIVATE_ADDR 00470 * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR 00471 * @param adv_filter_policy Filter policy: 00472 * @arg @ref NO_WHITE_LIST_USE 00473 * @arg @ref WHITE_LIST_FOR_ALL 00474 * @return Value indicating success or error code. 00475 */ 00476 tBleStatus aci_gap_set_undirected_connectable(uint8_t own_addr_type, uint8_t adv_filter_policy); 00477 00478 /** 00479 * @brief Send a slave security request to the master. 00480 * @note This command has to be issued to notify the master of the security requirements of the slave. 00481 * The master may encrypt the link, initiate the pairing procedure, or reject the request. 00482 * @param conn_handle Connection handle 00483 * @param bonding One of the bonding modes: 00484 * @arg @ref BONDING 00485 * @arg @ref NO_BONDING 00486 * @param mitm_protection If MITM protection is required or not: 00487 * @arg @ref MITM_PROTECTION_NOT_REQUIRED 00488 * @arg @ref MITM_PROTECTION_REQUIRED 00489 * @return Value indicating success or error code. 00490 */ 00491 tBleStatus aci_gap_slave_security_request(uint16_t conn_handle, uint8_t bonding, uint8_t mitm_protection); 00492 00493 /** 00494 * @brief Update advertising data. 00495 * @note This command can be used to update the advertising data for a particular AD type. 00496 * If the AD type specified does not exist, then it is added to the advertising data. 00497 * If the overall advertising data length is more than 31 octets after the update, then 00498 * the command is rejected and the old data is retained. 00499 * @param AdvLen Length of AdvData array 00500 * @param AdvData Advertisement Data, formatted as specified in Bluetooth specification 00501 * (Volume 3, Part C, 11), including data length. It can contain more than one AD type. 00502 * Example 00503 * @code 00504 * tBleStatus ret; 00505 * const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; 00506 * const uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID,0x34,0x12}; 00507 * const uint8_t manuf_data[] = {4, AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0x05, 0x02, 0x01}; 00508 * 00509 * ret = aci_gap_set_discoverable(ADV_IND, 0, 0, STATIC_RANDOM_ADDR, NO_WHITE_LIST_USE, 00510 * 8, local_name, 3, serviceUUIDList, 0, 0); 00511 * ret = aci_gap_update_adv_data(5, manuf_data); 00512 * @endcode 00513 * 00514 * @return Value indicating success or error code. 00515 */ 00516 tBleStatus aci_gap_update_adv_data(uint8_t AdvLen, const uint8_t *AdvData); 00517 00518 /** 00519 * @brief Delete an AD Type 00520 * @note This command can be used to delete the specified AD type from the advertisement data if 00521 * present. 00522 * @param ad_type One of the allowed AD types (see @ref AD_Types) 00523 * @return Value indicating success or error code. 00524 */ 00525 tBleStatus aci_gap_delete_ad_type(uint8_t ad_type); 00526 00527 /** 00528 * @brief Get the current security settings 00529 * @note This command can be used to get the current security settings of the device. 00530 * @param mitm_protection @arg 0: Not required 00531 * @arg 1: Required 00532 * @param bonding @arg 0: No bonding mode 00533 * @arg 1: Bonding mode 00534 * @param oob_data @arg 0: Data absent 00535 * @arg 1: Data present 00536 * @param passkey_required @arg 0: Not required 00537 * @arg 1: Fixed pin is present which is being used 00538 * @arg 2: Passkey required for pairing. An event will be generated 00539 * when required. 00540 * @return Value indicating success or error code. 00541 */ 00542 tBleStatus aci_gap_get_security_level(uint8_t* mitm_protection, uint8_t* bonding, 00543 uint8_t* oob_data, uint8_t* passkey_required); 00544 00545 /** 00546 * @brief Add addresses of bonded devices into the controller's whitelist. 00547 * @note The command will return an error if there are no devices in the database or if it was unable 00548 * to add the device into the whitelist. 00549 * @return Value indicating success or error code. 00550 */ 00551 tBleStatus aci_gap_configure_whitelist(void); 00552 00553 /** 00554 * @brief Terminate a connection. 00555 * @note A @ref EVT_DISCONN_COMPLETE event will be generated when the link is disconnected. 00556 * @param conn_handle Connection handle 00557 * @param reason Reason for requesting disconnection. The error code can be any of ones as specified 00558 * for the disconnected command in the HCI specification (See @ref HCI_Error_codes). 00559 * @return Value indicating success or error code. 00560 */ 00561 tBleStatus aci_gap_terminate(uint16_t conn_handle, uint8_t reason); 00562 00563 /** 00564 * @brief Clear the security database. 00565 * @note All the devices in the security database will be removed. 00566 * @return Value indicating success or error code. 00567 */ 00568 tBleStatus aci_gap_clear_security_database(void); 00569 00570 /** 00571 * @brief Allows the security manager to complete the pairing procedure and re-bond with the master. 00572 * @note This command can be issued by the application if a @ref EVT_BLUE_GAP_BOND_LOST event is generated. 00573 * @param conn_handle 00574 * @return Value indicating success or error code. 00575 */ 00576 tBleStatus aci_gap_allow_rebond_IDB05A1(uint16_t conn_handle); 00577 /** 00578 * @brief Allows the security manager to complete the pairing procedure and re-bond with the master. 00579 * @note This command can be issued by the application if a @ref EVT_BLUE_GAP_BOND_LOST event is generated. 00580 * @return Value indicating success or error code. 00581 */ 00582 tBleStatus aci_gap_allow_rebond_IDB04A1(void); 00583 00584 /** 00585 * @brief Start the limited discovery procedure. 00586 * @note The controller is commanded to start active scanning. When this procedure is started, 00587 * only the devices in limited discoverable mode are returned to the upper layers. 00588 * The procedure is terminated when either the upper layers issue a command to terminate the 00589 * procedure by issuing the command aci_gap_terminate_gap_procedure() with the procedure code 00590 * set to @ref GAP_LIMITED_DISCOVERY_PROC or a timeout happens. When the procedure is terminated 00591 * due to any of the above reasons, @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is returned with 00592 * the procedure code set to @ref GAP_LIMITED_DISCOVERY_PROC. 00593 * The device found when the procedure is ongoing is returned to the upper layers through the 00594 * event @ref EVT_BLUE_GAP_DEVICE_FOUND. 00595 * @param scanInterval Time interval from when the Controller started its last LE scan until it begins 00596 * the subsequent LE scan. The scan interval should be a number in the range 00597 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00598 * For a number N, Time = N x 0.625 msec. 00599 * @param scanWindow Amount of time for the duration of the LE scan. Scan_Window shall be less than 00600 * or equal to Scan_Interval. The scan window should be a number in the range 00601 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00602 * For a number N, Time = N x 0.625 msec. 00603 * @param own_address_type Type of our address used during advertising (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00604 * @param filterDuplicates Duplicate filtering enabled or not. 00605 * @arg 0x00: Do not filter the duplicates 00606 * @arg 0x01: Filter duplicates 00607 * 00608 * @return Value indicating success or error code. 00609 */ 00610 tBleStatus aci_gap_start_limited_discovery_proc(uint16_t scanInterval, uint16_t scanWindow, 00611 uint8_t own_address_type, uint8_t filterDuplicates); 00612 00613 /** 00614 * @brief Start the general discovery procedure. 00615 * @note The controller is commanded to start active scanning. The procedure is terminated when 00616 * either the upper layers issue a command to terminate the procedure by issuing the command 00617 * aci_gap_terminate_gap_procedure() with the procedure code set to GAP_GENERAL_DISCOVERY_PROC 00618 * or a timeout happens. When the procedure is terminated due to any of the above reasons, 00619 * @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is returned with the procedure code set to 00620 * @ref GAP_GENERAL_DISCOVERY_PROC. The device found when the procedure is ongoing is returned to 00621 * the upper layers through the event @ref EVT_BLUE_GAP_DEVICE_FOUND. 00622 * @param scanInterval Time interval from when the Controller started its last LE scan until it begins 00623 * the subsequent LE scan. The scan interval should be a number in the range 00624 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00625 * For a number N, Time = N x 0.625 msec. 00626 * @param scanWindow Amount of time for the duration of the LE scan. Scan_Window shall be less than 00627 * or equal to Scan_Interval. The scan window should be a number in the range 00628 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00629 * For a number N, Time = N x 0.625 msec. 00630 * @param own_address_type Type of our address used during advertising (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00631 * @param filterDuplicates Duplicate filtering enabled or not. 00632 * @arg 0x00: Do not filter the duplicates 00633 * @arg 0x01: Filter duplicates 00634 * 00635 * @return Value indicating success or error code. 00636 */ 00637 tBleStatus aci_gap_start_general_discovery_proc(uint16_t scanInterval, uint16_t scanWindow, 00638 uint8_t own_address_type, uint8_t filterDuplicates); 00639 00640 /** 00641 * @brief Start the name discovery procedure. 00642 * @note A LE_Create_Connection call will be made to the controller by GAP with the initiator filter 00643 * policy set to ignore whitelist and process connectable advertising packets only for the 00644 * specified device. Once a connection is established, GATT procedure is started to read the 00645 * device name characteristic. When the read is completed (successfully or unsuccessfully), 00646 * a @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is given to the upper layer. The event also 00647 * contains the name of the device if the device name was read successfully. 00648 * @param scanInterval Time interval from when the Controller started its last LE scan until it begins 00649 * the subsequent LE scan. The scan interval should be a number in the range 00650 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00651 * For a number N, Time = N x 0.625 msec. 00652 * @param scanWindow Amount of time for the duration of the LE scan. Scan_Window shall be less than 00653 * or equal to Scan_Interval. The scan window should be a number in the range 00654 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00655 * For a number N, Time = N x 0.625 msec. 00656 * @param peer_bdaddr_type Type of the peer address (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00657 * @param peer_bdaddr Address of the peer device with which a connection has to be established. 00658 * @param own_bdaddr_type Type of our address used during advertising (PUBLIC_ADDR,STATIC_RANDOM_ADDR). 00659 * @param conn_min_interval Minimum value for the connection event interval. This shall be less than or 00660 * equal to Conn_Interval_Max.\n 00661 * Range: 0x0006 to 0x0C80\n 00662 * Time = N x 1.25 msec\n 00663 * Time Range: 7.5 msec to 4 seconds 00664 * @param conn_max_interval Maximum value for the connection event interval. This shall be greater than or 00665 * equal to Conn_Interval_Min.\n 00666 * Range: 0x0006 to 0x0C80\n 00667 * Time = N x 1.25 msec\n 00668 * Time Range: 7.5 msec to 4 seconds 00669 * @param conn_latency Slave latency for the connection in number of connection events.\n 00670 * Range: 0x0000 to 0x01F4 00671 * @param supervision_timeout Supervision timeout for the LE Link.\n 00672 * Range: 0x000A to 0x0C80\n 00673 * Time = N x 10 msec\n 00674 * Time Range: 100 msec to 32 seconds 00675 * @param min_conn_length Minimum length of connection needed for the LE connection.\n 00676 * Range: 0x0000 - 0xFFFF\n 00677 * Time = N x 0.625 msec. 00678 * @param max_conn_length Maximum length of connection needed for the LE connection.\n 00679 * Range: 0x0000 - 0xFFFF\n 00680 * Time = N x 0.625 msec. 00681 * @return Value indicating success or error code. 00682 */ 00683 tBleStatus aci_gap_start_name_discovery_proc(uint16_t scanInterval, uint16_t scanWindow, 00684 uint8_t peer_bdaddr_type, tBDAddr peer_bdaddr, 00685 uint8_t own_bdaddr_type, uint16_t conn_min_interval, 00686 uint16_t conn_max_interval, uint16_t conn_latency, 00687 uint16_t supervision_timeout, uint16_t min_conn_length, 00688 uint16_t max_conn_length); 00689 00690 /** 00691 * @brief Start the auto connection establishment procedure. 00692 * @note The devices specified are added to the white list of the controller and a LE_Create_Connection 00693 * call will be made to the controller by GAP with the initiator filter policy set to 00694 * use whitelist to determine which advertiser to connect to. When a command is issued to 00695 * terminate the procedure by upper layer, a LE_Create_Connection_Cancel call will be made to the 00696 * controller by GAP. 00697 * The procedure is terminated when either a connection is successfully established with one of 00698 * the specified devices in the white list or the procedure is explicitly terminated by issuing 00699 * the command aci_gap_terminate_gap_procedure() with the procedure code set to 00700 * @ref GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC. A @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is returned with 00701 * the procedure code set to @ref GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC. 00702 * @param scanInterval Time interval from when the Controller started its last LE scan until it begins 00703 * the subsequent LE scan. The scan interval should be a number in the range 00704 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00705 * For a number N, Time = N x 0.625 msec. 00706 * @param scanWindow Amount of time for the duration of the LE scan. Scan_Window shall be less than 00707 * or equal to Scan_Interval. The scan window should be a number in the range 00708 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00709 * For a number N, Time = N x 0.625 msec. 00710 * @param own_bdaddr_type Type of our address used during advertising (PUBLIC_ADDR,STATIC_RANDOM_ADDR). 00711 * @param conn_min_interval Minimum value for the connection event interval. This shall be less than or 00712 * equal to Conn_Interval_Max.\n 00713 * Range: 0x0006 to 0x0C80\n 00714 * Time = N x 1.25 msec\n 00715 * Time Range: 7.5 msec to 4 seconds 00716 * @param conn_max_interval Maximum value for the connection event interval. This shall be greater than or 00717 * equal to Conn_Interval_Min.\n 00718 * Range: 0x0006 to 0x0C80\n 00719 * Time = N x 1.25 msec\n 00720 * Time Range: 7.5 msec to 4 seconds 00721 * @param conn_latency Slave latency for the connection in number of connection events.\n 00722 * Range: 0x0000 to 0x01F4 00723 * @param supervision_timeout Supervision timeout for the LE Link.\n 00724 * Range: 0x000A to 0x0C80\n 00725 * Time = N x 10 msec\n 00726 * Time Range: 100 msec to 32 seconds 00727 * @param min_conn_length Minimum length of connection needed for the LE connection.\n 00728 * Range: 0x0000 - 0xFFFF\n 00729 * Time = N x 0.625 msec. 00730 * @param max_conn_length Maximum length of connection needed for the LE connection.\n 00731 * Range: 0x0000 - 0xFFFF\n 00732 * Time = N x 0.625 msec. 00733 * @cond BLUENRG 00734 * @param use_reconn_addr If 1, the provided reconnection address is used as our address during the procedure (the address 00735 * has been previously notified to the application through @ref EVT_BLUE_GAP_RECONNECTION_ADDRESS event).\n 00736 * @param reconn_addr Reconnection address used if use_reconn_addr is 1. 00737 * @endcond 00738 * @param num_whitelist_entries Number of devices that have to be added to the whitelist. 00739 * @param addr_array addr_array will contain the addresses that have to be added into the whitelist. The 00740 * format of the addr_array should be: address type followed by address. 00741 * Example: 00742 * @code 00743 * uint8_t addr_array[] = {PUBLIC_ADDR,0x01,0x00,0x00,0xe1,0x80,0x02, 00744 * PUBLIC_ADDR,0x02,0x00,0x00,0xe1,0x80,0x02}; 00745 * @endcode 00746 * @return Value indicating success or error code. 00747 */ 00748 tBleStatus aci_gap_start_auto_conn_establish_proc_IDB05A1(uint16_t scanInterval, uint16_t scanWindow, 00749 uint8_t own_bdaddr_type, uint16_t conn_min_interval, 00750 uint16_t conn_max_interval, uint16_t conn_latency, 00751 uint16_t supervision_timeout, uint16_t min_conn_length, 00752 uint16_t max_conn_length, 00753 uint8_t num_whitelist_entries, 00754 const uint8_t *addr_array); 00755 tBleStatus aci_gap_start_auto_conn_establish_proc_IDB04A1(uint16_t scanInterval, uint16_t scanWindow, 00756 uint8_t own_bdaddr_type, uint16_t conn_min_interval, 00757 uint16_t conn_max_interval, uint16_t conn_latency, 00758 uint16_t supervision_timeout, uint16_t min_conn_length, 00759 uint16_t max_conn_length, 00760 uint8_t use_reconn_addr, 00761 const tBDAddr reconn_addr, 00762 uint8_t num_whitelist_entries, 00763 const uint8_t *addr_array); 00764 00765 /** 00766 * @brief Start a general connection establishment procedure. 00767 * @note The host enables scanning in the controller with the scanner filter policy set 00768 * to accept all advertising packets and from the scanning results all the devices 00769 * are sent to the upper layer using the event @ref EVT_BLUE_GAP_DEVICE_FOUND. 00770 * The upper layer then has to select one of the devices to which it wants to connect 00771 * by issuing the command aci_gap_create_connection(). The procedure is terminated 00772 * when a connection is established or the upper layer terminates the procedure by 00773 * issuing the command aci_gap_terminate_gap_procedure() with the procedure code set to 00774 * @ref GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC. On completion of the procedure a 00775 * @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is generated with the procedure code set to 00776 * @ref GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC. 00777 * @param scan_type Passive or active scanning (@ref PASSIVE_SCAN, @ref ACTIVE_SCAN) 00778 * @param scan_interval Time interval from when the Controller started its last LE scan until it begins 00779 * the subsequent LE scan. The scan interval should be a number in the range 00780 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00781 * For a number N, Time = N x 0.625 msec. 00782 * @param scan_window Amount of time for the duration of the LE scan. Scan_Window shall be less than 00783 * or equal to Scan_Interval. The scan window should be a number in the range 00784 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00785 * For a number N, Time = N x 0.625 msec. 00786 * @param own_address_type Type of our address used during active scanning (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00787 * @param filter_duplicates Duplicate filtering enabled or not. 00788 * @arg 0x00: Do not filter the duplicates 00789 * @arg 0x01: Filter duplicates 00790 * @cond BLUENRG 00791 * @param use_reconn_addr If 1, the provided reconnection address is used as our address during the procedure (the address 00792 * has been previously notified to the application through @ref EVT_BLUE_GAP_RECONNECTION_ADDRESS event).\n 00793 * @param reconn_addr Reconnection address used if use_reconn_addr is 1. 00794 * @endcond 00795 * 00796 * @return Value indicating success or error code. 00797 */ 00798 tBleStatus aci_gap_start_general_conn_establish_proc_IDB05A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, 00799 uint8_t own_address_type, uint8_t filter_duplicates); 00800 tBleStatus aci_gap_start_general_conn_establish_proc_IDB04A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, 00801 uint8_t own_address_type, uint8_t filter_duplicates, uint8_t use_reconn_addr, const tBDAddr reconn_addr); 00802 00803 /** 00804 * @brief Start a selective connection establishment procedure. 00805 * @note The GAP adds the specified device addresses into white list and enables scanning in 00806 * the controller with the scanner filter policy set to accept packets only from 00807 * devices in whitelist. All the devices found are sent to the upper layer by the 00808 * event @ref EVT_BLUE_GAP_DEVICE_FOUND. The upper layer then has to select one of the 00809 * devices to which it wants to connect by issuing the command aci_gap_create_connection(). 00810 * On completion of the procedure a @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is generated 00811 * with the procedure code set to @ref GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC. 00812 * The procedure is terminated when a connection is established or the upper layer terminates 00813 * the procedure by issuing the command aci_gap_terminate_gap_procedure with the procedure 00814 * code set to @ref GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC. 00815 * @param scan_type Passive or active scanning (@ref PASSIVE_SCAN, @ref ACTIVE_SCAN) 00816 * @param scan_interval Time interval from when the Controller started its last LE scan until it begins 00817 * the subsequent LE scan. The scan interval should be a number in the range 00818 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00819 * For a number N, Time = N x 0.625 msec. 00820 * @param scan_window Amount of time for the duration of the LE scan. Scan_Window shall be less than 00821 * or equal to Scan_Interval. The scan window should be a number in the range 00822 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00823 * For a number N, Time = N x 0.625 msec. 00824 * @param own_address_type Type of our address used during active scanning (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00825 * @param filter_duplicates Duplicate filtering enabled or not. 00826 * @arg 0x00: Do not filter the duplicates 00827 * @arg 0x01: Filter duplicates 00828 * @param num_whitelist_entries Number of devices that have to be added to the whitelist. 00829 * @param addr_array addr_array will contain the addresses that have to be added into the whitelist. The 00830 * format of the addr_array should be: address type followed by address. 00831 * Example: 00832 * @code 00833 * uint8_t addr_array[] = {PUBLIC_ADDR,0x01,0x00,0x00,0xe1,0x80,0x02, 00834 * PUBLIC_ADDR,0x02,0x00,0x00,0xe1,0x80,0x02}; 00835 * @endcode 00836 * 00837 * @return Value indicating success or error code. 00838 */ 00839 tBleStatus aci_gap_start_selective_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, 00840 uint8_t own_address_type, uint8_t filter_duplicates, uint8_t num_whitelist_entries, 00841 const uint8_t *addr_array); 00842 00843 /** 00844 * @brief Start the direct connection establishment procedure. 00845 * @note A LE_Create_Connection call will be made to the controller by GAP with the initiator filter 00846 * policy set to ignore whitelist and process connectable advertising packets only for the 00847 * specified device. The procedure can be terminated explicitly by the upper layer by issuing 00848 * the command aci_gap_terminate_gap_procedure(). When a command is issued to terminate the 00849 * procedure by upper layer, a LE_Create_Connection_Cancel call will be made to the controller 00850 * by GAP. 00851 * On termination of the procedure, a @ref EVT_LE_CONN_COMPLETE event is returned. The procedure can 00852 * be explicitly terminated by the upper layer by issuing the command 00853 * aci_gap_terminate_gap_procedure() with the procedure_code set to @ref GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC. 00854 * @param scanInterval Time interval from when the Controller started its last LE scan until it begins 00855 * the subsequent LE scan. The scan interval should be a number in the range 00856 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00857 * For a number N, Time = N x 0.625 msec. 00858 * @param scanWindow Amount of time for the duration of the LE scan. Scan_Window shall be less than 00859 * or equal to Scan_Interval. The scan window should be a number in the range 00860 * 0x0004 to 0x4000. This corresponds to a time range 2.5 msec to 10240 msec. 00861 * For a number N, Time = N x 0.625 msec. 00862 * @param peer_bdaddr_type Type of the peer address (@ref PUBLIC_ADDR, @ref STATIC_RANDOM_ADDR). 00863 * @param peer_bdaddr Address of the peer device with which a connection has to be established. 00864 * @param own_bdaddr_type Type of our address used during advertising (PUBLIC_ADDR,STATIC_RANDOM_ADDR). 00865 * @param conn_min_interval Minimum value for the connection event interval. This shall be less than or 00866 * equal to Conn_Interval_Max.\n 00867 * Range: 0x0006 to 0x0C80\n 00868 * Time = N x 1.25 msec\n 00869 * Time Range: 7.5 msec to 4 seconds 00870 * @param conn_max_interval Maximum value for the connection event interval. This shall be greater than or 00871 * equal to Conn_Interval_Min.\n 00872 * Range: 0x0006 to 0x0C80\n 00873 * Time = N x 1.25 msec\n 00874 * Time Range: 7.5 msec to 4 seconds 00875 * @param conn_latency Slave latency for the connection in number of connection events.\n 00876 * Range: 0x0000 to 0x01F4 00877 * @param supervision_timeout Supervision timeout for the LE Link.\n 00878 * Range: 0x000A to 0x0C80\n 00879 * Time = N x 10 msec\n 00880 * Time Range: 100 msec to 32 seconds 00881 * @param min_conn_length Minimum length of connection needed for the LE connection.\n 00882 * Range: 0x0000 - 0xFFFF\n 00883 * Time = N x 0.625 msec. 00884 * @param max_conn_length Maximum length of connection needed for the LE connection.\n 00885 * Range: 0x0000 - 0xFFFF\n 00886 * Time = N x 0.625 msec. 00887 * @return Value indicating success or error code. 00888 */ 00889 tBleStatus aci_gap_create_connection(uint16_t scanInterval, uint16_t scanWindow, 00890 uint8_t peer_bdaddr_type, tBDAddr peer_bdaddr, 00891 uint8_t own_bdaddr_type, uint16_t conn_min_interval, 00892 uint16_t conn_max_interval, uint16_t conn_latency, 00893 uint16_t supervision_timeout, uint16_t min_conn_length, 00894 uint16_t max_conn_length); 00895 00896 /** 00897 * @brief Terminate the specified GATT procedure. @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is 00898 * returned with the procedure code set to the corresponding procedure. 00899 * @param procedure_code One of the procedure codes (@ref gap_procedure_codes "GAP procedure codes"). 00900 * @return Value indicating success or error code. 00901 */ 00902 tBleStatus aci_gap_terminate_gap_procedure(uint8_t procedure_code); 00903 00904 /** 00905 * @brief Start the connection parameter update procedure. 00906 * @note Allowed by the Central to update the connection parameter of the specified connection. 00907 * A Link Layer Connection Update procedure is started on the controller. 00908 * On completion of the procedure, a @ref EVT_LE_CONN_UPDATE_COMPLETE event is returned to 00909 * the upper layer. 00910 * @param conn_handle Handle of the connection for which the update procedure has to be started. 00911 * @param conn_min_interval Minimum value for the connection event interval. This shall be less than or 00912 * equal to Conn_Interval_Max.\n 00913 * Range: 0x0006 to 0x0C80\n 00914 * Time = N x 1.25 msec\n 00915 * Time Range: 7.5 msec to 4 seconds 00916 * @param conn_max_interval Maximum value for the connection event interval. This shall be greater than or 00917 * equal to Conn_Interval_Min.\n 00918 * Range: 0x0006 to 0x0C80\n 00919 * Time = N x 1.25 msec\n 00920 * Time Range: 7.5 msec to 4 seconds 00921 * @param conn_latency Slave latency for the connection in number of connection events.\n 00922 * Range: 0x0000 to 0x01F4 00923 * @param supervision_timeout Supervision timeout for the LE Link.\n 00924 * Range: 0x000A to 0x0C80\n 00925 * Time = N x 10 msec\n 00926 * Time Range: 100 msec to 32 seconds 00927 * @param min_conn_length Minimum length of connection needed for the LE connection.\n 00928 * Range: 0x0000 - 0xFFFF\n 00929 * Time = N x 0.625 msec. 00930 * @param max_conn_length Maximum length of connection needed for the LE connection.\n 00931 * Range: 0x0000 - 0xFFFF\n 00932 * Time = N x 0.625 msec. 00933 * @return Value indicating success or error code. 00934 */ 00935 tBleStatus aci_gap_start_connection_update(uint16_t conn_handle, uint16_t conn_min_interval, 00936 uint16_t conn_max_interval, uint16_t conn_latency, 00937 uint16_t supervision_timeout, uint16_t min_conn_length, 00938 uint16_t max_conn_length); 00939 00940 /** 00941 * @brief Send a pairing request. 00942 * @note Send the SM pairing request to start a pairing process from a Central. The authentication 00943 * requirements and IO capabilities should be set before issuing this command using 00944 * aci_gap_set_io_capability() and aci_gap_set_auth_requirement(). 00945 * A @ref EVT_BLUE_GAP_PAIRING_CMPLT event is returned after the pairing process is completed. 00946 * @param conn_handle Handle of the connection for which the pairing request has to be sent. 00947 * @param force_rebond @arg 0x00: Pairing request is sent only if the device has not previously bonded 00948 * @arg 0x01: Pairing request will be sent even if the device was previously bonded 00949 * @return Value indicating success or error code. 00950 */ 00951 tBleStatus aci_gap_send_pairing_request(uint16_t conn_handle, uint8_t force_rebond); 00952 00953 /** 00954 * @brief Resolve a private address. 00955 * @note This command tries to resolve the address provided with the IRKs present in its database. If 00956 * the address is resolved successfully with any one of the IRKs present in the database, it 00957 * returns success. 00958 * @param address Address to be resolved. 00959 * @param[in] actual_address The public or static random address of the peer device, distributed during pairing phase. 00960 * @return Value indicating success or error code. 00961 */ 00962 tBleStatus aci_gap_resolve_private_address_IDB05A1(const tBDAddr private_address, tBDAddr actual_address); 00963 00964 /** 00965 * @brief Resolve a private address. 00966 * @note This command tries to resolve the address provided with the IRKs present in its database. If 00967 * the address is resolved successfully with any one of the IRKs present in the database, it 00968 * returns success. 00969 * @param address Address to be resolved. 00970 * @return Value indicating success or error code. 00971 */ 00972 tBleStatus aci_gap_resolve_private_address_IDB04A1(const tBDAddr private_address); 00973 00974 /** 00975 * @brief This command gets the list of bonded devices. 00976 * @note It returns the number of addresses and the corresponding address types and values. 00977 * Example: 00978 * @code 00979 * tBleStatus ret; 00980 * uint8_t num_devices = 0; 00981 * uint8_t device_list[12*7]; 00982 * ret = aci_gap_get_bonded_devices(&num_devices, device_list, sizeof(device_list)); 00983 * for(int i = 0; i < num_devices; i+=7){ 00984 * uint8_t addr_type = device_list[i]; 00985 * uint8_t addr = device_list[i+1]; 00986 * printf("Type: %d, Addr: %02X%02X%02X%02X%02X%02X\n",addr_type,addr[5],addr[4],addr[3],addr[2],addr[1],addr[0]); 00987 * } 00988 * @endcode 00989 * 00990 * @param[in] num_devices The number of bonded devices. 00991 * @param[in] device_list List of addresses. It contains a sequence of [address type, address] pairs, where address 00992 * type can be @ref PUBLIC_ADDR or @arg @ref STATIC_RANDOM_ADDR. 00993 * @param device_list_size Maximum size of the device_list buffer used to return the device list. 00994 * @return Value indicating success or error code. 00995 */ 00996 tBleStatus aci_gap_get_bonded_devices(uint8_t *num_devices, uint8_t *device_list, uint8_t device_list_size); 00997 00998 /** 00999 * @brief Puts the device into broadcast mode 01000 * @note A privacy enabled device uses either a resolvable private address or a non-resolvable private address 01001 * as specified in the own_addr_type parameter of the command. 01002 * @param adv_interv_min Minimum advertising interval. 01003 * Range: 0x00A0 to 0x4000 01004 * Time = N * 0.625 msec 01005 * Time Range: 100 ms to 10.24 sec 01006 * @param adv_interv_max Maximum advertising interval. 01007 * Range: 0x00A0 to 0x4000 01008 * Time = N * 0.625 msec 01009 * Time Range: 100 ms to 10.24 sec 01010 * @param adv_type One of the allowed advertising types: 01011 * @arg @ref ADV_SCAN_IND Scannable undirected advertising 01012 * @arg @ref ADV_NONCONN_IND Non connectable undirected advertising 01013 * @param own_address_type If Privacy is disabled, the broadcaster address can be 01014 * @arg @ref PUBLIC_ADDR. 01015 * @arg @ref STATIC_RANDOM_ADDR. 01016 * If Privacy is enabled, then the broadcaster address can be 01017 * @arg @ref RESOLVABLE_PRIVATE_ADDR 01018 * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR 01019 * @param adv_data_length Length of the advertising data in the advertising packet 01020 * @param adv_data Advertising data used by the device while advertising 01021 * @param num_whitelist_entries Number of devices to be added to whitelist 01022 * @param addr_array It will contain the addresses that have to be added into the whitelist. The 01023 * format of the addr_array should be: address type followed by address. 01024 * Example: 01025 * @code 01026 * uint8_t addr_array[] = {PUBLIC_ADDR,0x01,0x00,0x00,0xe1,0x80,0x02, 01027 * PUBLIC_ADDR,0x02,0x00,0x00,0xe1,0x80,0x02}; 01028 * @endcode 01029 * @return Value indicating success or error code. 01030 */ 01031 tBleStatus aci_gap_set_broadcast_mode_IDB05A1(uint16_t adv_interv_min, uint16_t adv_interv_max, uint8_t adv_type, 01032 uint8_t own_addr_type, uint8_t adv_data_length, const uint8_t *adv_data, uint8_t num_whitelist_entries, 01033 const uint8_t *addr_array); 01034 01035 /** 01036 * @brief Starts an observation procedure, when the device is in Observer role. 01037 * @note The host enables scanning in the controller. The advertising reports are sent to the upper layer 01038 * using standard @ref EVT_LE_ADVERTISING_REPORT subevent in @ref EVT_LE_META_EVENT. See Bluetooth 01039 * Core v4.0, Vol. 2, part E, Ch. 7.7.65.2, LE Advertising Report Event. 01040 * @param scan_interval Time interval from when the Controller started its last LE scan until it begins the subsequent LE scan. 01041 * The scan interval should be a number in the range 0x0004 to 0x4000. This corresponds to a time range from 2.5 msec 01042 * to 10240 msec. For a number N, Time = N * 0.625 msec. 01043 * @param scan_window Amount of time for the duration of the LE scan. scan_window shall be less than or equal to scan_interval. 01044 * The scan window should be a number in the range 0x0004 to 0x4000. This corresponds to a time range from 2.5 msec 01045 * to 10240 msec. For a number N, Time = N * 0.625 msec. 01046 * @param scan_type Passive or active scanning (@ref PASSIVE_SCAN, @ref ACTIVE_SCAN) 01047 * @param own_address_type If Privacy is disabled, then the scanner address can be 01048 * @arg @ref PUBLIC_ADDR. 01049 * @arg @ref STATIC_RANDOM_ADDR. 01050 * If Privacy is enabled, then the scanner address can be 01051 * @arg @ref RESOLVABLE_PRIVATE_ADDR 01052 * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR 01053 * @param filter_duplicates Duplicate filtering enabled or not. 01054 * @arg 0x00: Do not filter the duplicates 01055 * @arg 0x01: Filter duplicates 01056 * @return Value indicating success or error code. 01057 */ 01058 tBleStatus aci_gap_start_observation_procedure_IDB05A1(uint16_t scan_interval, uint16_t scan_window, uint8_t scan_type, 01059 uint8_t own_address_type, uint8_t filter_duplicates); 01060 01061 /** 01062 * @brief The command finds whether a device is bonded. 01063 * @note If the device is using a resolvable private address and it has been bonded, then the command will return 01064 * BLE_STATUS_SUCCESS. 01065 * @param peer_address_type The address type of the peer device 01066 * @arg @ref PUBLIC_ADDR. 01067 * @arg @ref RANDOM_ADDR. 01068 * @param peer_address Address used by the peer device while advertising. 01069 * @return Value indicating success or error code. 01070 */ 01071 tBleStatus aci_gap_is_device_bonded_IDB05A1(uint8_t peer_address_type, const tBDAddr peer_address); 01072 01073 01074 /** 01075 * @} 01076 */ 01077 01078 /** 01079 * @defgroup GAP_Events GAP events 01080 * @{ 01081 */ 01082 01083 /** 01084 * This event is generated by the controller when the limited discoverable 01085 * mode ends due to timeout (180 seconds). No parameters in the event. 01086 */ 01087 #define EVT_BLUE_GAP_LIMITED_DISCOVERABLE (0x0400) 01088 01089 01090 /** 01091 * This event is generated when the pairing process has completed successfully 01092 * or a pairing procedure timeout has occurred or the pairing has failed. 01093 * This is to notify the application that we have paired with a remote device 01094 * so that it can take further actions or to notify that a timeout has occurred 01095 * so that the upper layer can decide to disconnect the link. See @ref _evt_gap_pairing_cmplt. 01096 */ 01097 #define EVT_BLUE_GAP_PAIRING_CMPLT (0x0401) 01098 typedef __packed struct _evt_gap_pairing_cmplt{ 01099 uint16_t conn_handle; /**< Connection handle on which the pairing procedure completed */ 01100 /** 01101 * 0x00: Pairing Success. Pairing with a remote device was successful\n 01102 * 0x01: Pairing Timeout. The SMP timeout has elapsed and no further SMP commands will be processed until reconnection\n 01103 * 0x02: Pairing Failed. The pairing failed with the remote device. 01104 */ 01105 uint8_t status; 01106 } PACKED evt_gap_pairing_cmplt; 01107 01108 01109 /** 01110 * This event is generated by the Security manager to the application when a pass key is required for pairing. 01111 * When this event is received, the application has to respond with the aci_gap_pass_key_response() command. 01112 * See @ref _evt_gap_pass_key_req. 01113 */ 01114 #define EVT_BLUE_GAP_PASS_KEY_REQUEST (0x0402) 01115 typedef __packed struct _evt_gap_pass_key_req{ 01116 uint16_t conn_handle; /**< Connection handle for which the passkey has been requested. */ 01117 } PACKED evt_gap_pass_key_req; 01118 01119 01120 /** 01121 * This event is generated by the Security manager to the application when the application 01122 * has set that authorization is required for reading/writing of attributes. This event will 01123 * be generated as soon as the pairing is complete. When this event is received, 01124 * aci_gap_authorization_response() command should be used by the application. 01125 * See @ref _evt_gap_author_req. 01126 */ 01127 #define EVT_BLUE_GAP_AUTHORIZATION_REQUEST (0x0403) 01128 typedef __packed struct _evt_gap_author_req{ 01129 uint16_t conn_handle; /**< Connection handle for which authorization has been requested. */ 01130 } PACKED evt_gap_author_req; 01131 01132 /** 01133 * This event is generated when the slave security request is successfully sent to the master. 01134 * No parameters for this event. 01135 */ 01136 #define EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED (0X0404) 01137 01138 /** 01139 * This event is generated when a pairing request is issued in response to a slave security 01140 * request from a master which has previously bonded with the slave. When this event is received, 01141 * the upper layer has to issue the command aci_gap_allow_rebond() in order to allow the slave 01142 * to continue the pairing process with the master. No parameters for this event 01143 */ 01144 #define EVT_BLUE_GAP_BOND_LOST (0X0405) 01145 01146 /** 01147 * The event is given by the GAP layer to the upper layers when a device is discovered during scanning 01148 * as a consequence of one of the GAP procedures started by the upper layers. See @ref _evt_gap_device_found. 01149 */ 01150 #define EVT_BLUE_GAP_DEVICE_FOUND (0x0406) 01151 typedef __packed struct _evt_gap_device_found{ 01152 uint8_t evt_type; /**< Type of event (@ref ADV_IND, @ref ADV_DIRECT_IND, @ref ADV_SCAN_IND, @ref ADV_NONCONN_IND, @ref SCAN_RSP) */ 01153 uint8_t bdaddr_type; /**< Type of the peer address (@ref PUBLIC_ADDR, @ref RANDOM_ADDR). */ 01154 tBDAddr bdaddr; /**< Address of the peer device found during scanning. */ 01155 uint8_t data_length; /**< Length of advertising or scan response data. */ 01156 uint8_t data_RSSI[VARIABLE_SIZE]; /**< Advertising or scan response data + RSSI. RSSI is last octect (signed integer). */ 01157 } PACKED evt_gap_device_found; 01158 01159 /** 01160 * This event is sent by the GAP to the upper layers when a procedure previously started has been terminated 01161 * by the upper layer or has completed for any other reason. See @ref _evt_gap_procedure_complete. 01162 */ 01163 #define EVT_BLUE_GAP_PROCEDURE_COMPLETE (0x0407) 01164 typedef __packed struct _evt_gap_procedure_complete{ 01165 uint8_t procedure_code; /**< Terminated procedure. See @ref gap_procedure_codes "GAP procedure codes". */ 01166 /** 01167 * @ref BLE_STATUS_SUCCESS, @ref BLE_STATUS_FAILED or @ref ERR_AUTH_FAILURE (procedure failed 01168 * due to authentication requirements). 01169 */ 01170 uint8_t status; 01171 /** 01172 * Procedure specific data.\n 01173 * @li For Name Discovery Procedure:\n 01174 * the name of the peer device if the procedure completed successfully. 01175 * @li For General Connection Establishment Procedure:\n 01176 * The reconnection address written to the peripheral device if the peripheral is privacy enabled 01177 */ 01178 uint8_t data[VARIABLE_SIZE]; 01179 } PACKED evt_gap_procedure_complete; 01180 01181 /** 01182 * This event is sent only by a privacy enabled Peripheral. The event is sent to the upper layers when the peripheral 01183 * is not able to resolve the private address of the peer device after connecting to it. 01184 */ 01185 #define EVT_BLUE_GAP_ADDR_NOT_RESOLVED_IDB05A1 (0x0408) 01186 typedef __packed struct _evt_gap_addr_not_resolved_IDB05A1{ 01187 uint16_t conn_handle; /**< Connection handle for which the private address could not be resolved with any of the stored IRK's. */ 01188 } PACKED evt_gap_addr_not_resolved_IDB05A1; 01189 /** 01190 * This event is raised when the reconnection address is generated during the general connection 01191 * establishment procedure. The same address is set into the peer device also as a part of the general 01192 * connection establishment procedure. In order to make use of the reconnection address the next time 01193 * while connecting to the bonded peripheral, the application needs to use this reconnection address 01194 * as its own address as well as the peer address to which it wants to connect. See aci_gap_start_general_conn_establish_proc() 01195 * and aci_gap_start_auto_conn_establish_proc(). 01196 */ 01197 #define EVT_BLUE_GAP_RECONNECTION_ADDRESS_IDB04A1 (0x0408) 01198 typedef __packed struct _evt_gap_reconnection_addr_IDB04A1{ 01199 uint8_t reconnection_address[6]; /**< 6 bytes of reconnection address that has been generated */ 01200 } PACKED evt_gap_reconnection_addr_IDB04A1; 01201 01202 /** 01203 * @} 01204 */ 01205 01206 /** 01207 * @} 01208 */ 01209 01210 01211 #endif /* __BLUENRG_GAP_ACI_H__ */
Generated on Tue Jul 12 2022 19:27:28 by 1.7.2