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