1 /****************************************************************************** 2 * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") 3 * All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *****************************************************************************/ 18 #ifndef LL_EXT_ADV_H_ 19 #define LL_EXT_ADV_H_ 20 21 #include "stack/ble/hci/hci_cmd.h" 22 23 /* maximum number of advertising sets this SDK can support, periodic advertising is included. */ 24 #define ADV_SETS_NUMBER_MAX 4 25 26 /* Note: user can't modify this value,and this value must 4 byte aligned 27 * if use BLUETOOTH_VER_5_2 this value is 680 other than 572 28 */ 29 #define ADV_SET_PARAM_LENGTH 680 // 572 30 31 /** 32 * @brief for user to initialize extended advertising module 33 * notice that: 1. only one module can be selected between 34 * legacy advertising module and extended advertising module 35 * 2. this API must be used before any other extended ADV initialization APIs. 36 * @param none 37 * @return none 38 */ 39 void blc_ll_initExtendedAdvertising_module(void); 40 41 /** 42 * @brief for user to allocate single or multiple advertising sets buffer 43 * notice that: this API must used after "blc_ll_initExtendedAdvertising_module", 44 * and before any other extended ADV initialization APIs. 45 * @param[in] pBuff_advSets - global buffer allocated by application layer. 46 * @param[in] num_advSets - number of application adv_sets 47 * @return Status - 0x00: command succeeded; 48 * 0x12: num_advSets exceed maximum number of supported adv_sets. 49 */ 50 ble_sts_t blc_ll_initExtendedAdvSetBuffer(u8 *pBuff_advSets, int num_advSets); 51 52 /** 53 * @brief initialize Advertising Data buffer for all adv_set 54 * @param[in] pExtAdvData - 55 * @param[in] max_len_advData - 56 * @return none 57 */ 58 void blc_ll_initExtAdvDataBuffer(u8 *pExtAdvData, int max_len_advData); 59 60 /** 61 * @brief initialize Advertising Data buffer for specific adv_set. 62 * @param[in] adv_handle - Used to identify an advertising set 63 * @param[in] pExtAdvData - 64 * @param[in] max_len_advData - 65 * @return Status - 0x00: succeed. 66 * 0x12: adv_handle out of range. 67 */ 68 ble_sts_t blc_ll_initExtAdvDataBuffer_by_advHandle(u8 adv_handle, u8 *pExtAdvData, int max_len_advData); 69 70 /** 71 * @brief initialize Scan Response Data Buffer for all adv_set 72 * @param[in] pScanRspData - 73 * @param[in] max_len_scanRspData - 74 * @return none 75 */ 76 void blc_ll_initExtScanRspDataBuffer(u8 *pScanRspData, int max_len_scanRspData); 77 78 /** 79 * @brief initialize Scan Response Data Buffer buffer for specific adv_set. 80 * @param[in] adv_handle - Used to identify an advertising set 81 * @param[in] pScanRspData - 82 * @param[in] max_len_scanRspData - 83 * @return Status - 0x00: succeed. 84 * 0x12: adv_handle out of range. 85 */ 86 ble_sts_t blc_ll_initExtScanRspDataBuffer_by_advHandle(u8 adv_handle, u8 *pScanRspData, int max_len_scanRspData); 87 88 /** 89 * @brief This function is used to set the advertising parameters 90 * @param[in] adv_handle - Used to identify an advertising set 91 * @param[in] adv_evt_prop - 92 * @param[in] pri_advInter_min & pri_advInter_max 93 * @param[in] 94 * @param[in] 95 * @param[in] 96 * @param[in] 97 * @return Status - 0x00: command succeeded; 98 * 0x12: 1. adv_handle out of range; 99 * 2. pri_advChnMap out of range 100 * 0x0C: advertising is enabled for the specified advertising set 101 */ 102 ble_sts_t blc_ll_setExtAdvParam(u8 adv_handle, advEvtProp_type_t adv_evt_prop, u32 pri_advInter_min, 103 u32 pri_advInter_max, adv_chn_map_t pri_advChnMap, own_addr_type_t ownAddrType, 104 u8 peerAddrType, u8 *peerAddr, adv_fp_type_t advFilterPolicy, tx_power_t adv_tx_pow, 105 le_phy_type_t pri_adv_phy, u8 sec_adv_max_skip, le_phy_type_t sec_adv_phy, u8 adv_sid, 106 u8 scan_req_noti_en); 107 108 /** 109 * @brief This function is used to set the data used in advertising PDU that have a data field 110 * notice that: setting legacy ADV data also use this API, data length can not exceed 31 111 * @param[in] adv_handle - Used to identify an advertising set 112 * @param[in] *advData - 113 * @param[in] advData_len - 114 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 115 */ 116 ble_sts_t blc_ll_setExtAdvData(u8 adv_handle, int advData_len, u8 *advData); 117 118 /** 119 * @brief This function is used to provide scan response data used in scanning response PDUs. 120 * notice that: setting legacy scan response data also use this API, data length can not exceed 31 121 * @param[in] adv_handle - Used to identify an advertising set 122 * @param[in] scanRspData_len - 123 * @param[in] *scanRspData - 124 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 125 */ 126 ble_sts_t blc_ll_setExtScanRspData(u8 adv_handle, int scanRspData_len, u8 *scanRspData); 127 128 /** 129 * @brief This function is used to request the Controller to enable or disable one or more advertising sets 130 * using the advertising sets identified by the adv_handle 131 * @param[in] enable - 132 * @param[in] adv_handle - Used to identify an advertising set 133 * @param[in] duration - the duration for which that advertising set is enabled 134 * Range: 0x0001 to 0xFFFF, Time = N * 10 ms, Time Range: 10 ms to 655,350 ms 135 * @param[in] max_extAdvEvt - Maximum number of extended advertising events the Controller shall 136 * attempt to send prior to terminating the extended advertising 137 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 138 */ 139 ble_sts_t blc_ll_setExtAdvEnable(adv_en_t enable, u8 adv_handle, u16 duration, u8 max_extAdvEvt); 140 141 /** 142 * @brief This function is used by the Host to set the random device address specified by the Random_Address 143 parameter 144 * @param[in] adv_handle - Used to identify an advertising set 145 * @param[in] *rand_addr - Random Device Address 146 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 147 */ 148 ble_sts_t blc_ll_setAdvRandomAddr(u8 adv_handle, u8 *rand_addr); 149 150 /** 151 * @brief This function is is used to remove an advertising set from the Controller. 152 * @param[in] adv_handle - Used to identify an advertising set 153 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 154 */ 155 ble_sts_t blc_ll_removeAdvSet(u8 adv_handle); 156 157 /** 158 * @brief This function is used to remove all existing advertising sets from the Controller. 159 * @param[in] none. 160 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 161 */ 162 ble_sts_t blc_ll_clearAdvSets(void); 163 164 // only for Debug 165 ble_sts_t blc_ll_setAuxAdvChnIdxByCustomers(u8 aux_chn); 166 167 #endif /* LL_EXT_ADV_H_ */ 168