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 19 #ifndef STACK_BLE_CONTROLLER_LL_PRDADV_PRD_ADV_H_ 20 #define STACK_BLE_CONTROLLER_LL_PRDADV_PRD_ADV_H_ 21 22 /* maximum number of periodic advertising this SDK can support */ 23 #define PERIODIC_ADV_NUMBER_MAX 2 24 25 #define PERD_ADV_PARAM_LENGTH (476) // Note: user can't modify this value,and this value must 4 byte aligned 26 27 /** 28 * @brief for user to initialize periodic advertising module 29 * @param none 30 * @return none 31 */ 32 void blc_ll_initPeriodicAdvertising_module(void); 33 34 /** 35 * @brief for user to allocate periodic advertising parameters buffer 36 * notice that: this API must used after "blc_ll_initPeriodicAdvertising_module", 37 * and before any other periodic ADV initialization APIs. 38 * @param[in] pBuff - global buffer allocated by application layer. 39 * @param[in] num_periodic_adv - number of application adv_sets 40 * @return Status - 0x00: command succeeded; 41 * 0x12: num_periodic_adv exceed maximum number of supported periodic advertising. 42 */ 43 ble_sts_t blc_ll_initPeriodicAdvParamBuffer(u8 *pBuff, int num_periodic_adv); 44 45 /** 46 * @brief This function is used by the Host to set the parameters for periodic advertising. 47 * @param[in] adv_handle - - Used to identify a periodic advertising train 48 * @param[in] advInter_min - Periodic_Advertising_Interval_Min 49 * (Range: 0x0006 to 0xFFFF, Time = N * 1.25 ms Time Range: 7.5 ms to 81.91875 s) 50 * @param[in] advInter_max - Periodic_Advertising_Interval_Max 51 * @param[in] property - Periodic_Advertising_Properties 52 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 53 */ 54 ble_sts_t blc_ll_setPeriodicAdvParam(adv_handle_t adv_handle, u16 advInter_min, u16 advInter_max, 55 perd_adv_prop_t property); 56 57 /** 58 * @brief initialize Periodic Advertising Data buffer for all adv_set 59 * @param[in] perdAdvData - 60 * @param[in] max_len_perdAdvData - 61 * @return none 62 */ 63 void blc_ll_initPeriodicAdvDataBuffer(u8 *perdAdvData, int max_len_perdAdvData); 64 65 /** 66 * @brief initialize Periodic Advertising Data buffer for specific adv_set. 67 * notice that: 68 * @param[in] adv_handle - equal to adv_set index here. So if using single adv_set, adv_handle can only be 0x00; 69 * if using multiple adv_set, for example 3, adv_handle can be 0x00,0x01 and 0x02 70 * @param[in] perdAdvData - 71 * @param[in] max_len_perdAdvData - 72 * @return Status - 0x00: succeed. 73 * 0x12: adv_handle out of range. 74 */ 75 ble_sts_t blc_ll_initPeriodicAdvDataBuffer_by_advHandle(u8 adv_handle, u8 *perdAdvData, int max_len_perdAdvData); 76 77 /** 78 * @brief This function is used to set the data used in periodic advertising PDUs. 79 * @param[in] adv_handle - - equal to adv_set index here. 80 * @param[in] advData_len - 81 * @param[in] *advdata - 82 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 83 */ 84 ble_sts_t blc_ll_setPeriodicAdvData(adv_handle_t adv_handle, u16 advData_len, u8 *advdata); 85 86 /** 87 * @brief This function is used to enable or disable the periodic advertising for the advertising 88 * set specified by the Advertising_Handle parameter 89 * @param[in] adv_enable - Advertising_Enable 90 * @param[in] adv_handle - Used to identify an advertising set. 91 * @return Status - 0x00: command succeeded; 0x01-0xFF: command failed 92 */ 93 ble_sts_t blc_ll_setPeriodicAdvEnable(adv_en_t per_adv_enable, adv_handle_t adv_handle); 94 95 #endif /* STACK_BLE_CONTROLLER_LL_PRDADV_PRD_ADV_H_ */ 96