1 /****************************************************************************** 2 * 3 * Copyright (C) 2014 Broadcom Corporation 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 20 #ifndef BTIF_GATT_MULTI_ADV_UTIL_H 21 #define BTIF_GATT_MULTI_ADV_UTIL_H 22 23 #include <hardware/bluetooth.h> 24 #include "bta_api.h" 25 26 #define CLNT_IF_IDX 0 27 #define INST_ID_IDX 1 28 #define INST_ID_IDX_MAX INST_ID_IDX + 1 29 #define INVALID_ADV_INST -1 30 #define STD_ADV_INSTID 0 31 32 /* Default ADV flags for general and limited discoverability */ 33 #define ADV_FLAGS_LIMITED BTA_DM_LIMITED_DISC 34 #define ADV_FLAGS_GENERAL BTA_DM_GENERAL_DISC 35 36 typedef struct 37 { 38 int client_if; 39 BOOLEAN set_scan_rsp; 40 BOOLEAN include_name; 41 BOOLEAN include_txpower; 42 int min_interval; 43 int max_interval; 44 int appearance; 45 uint16_t manufacturer_len; 46 uint8_t* p_manufacturer_data; 47 uint16_t service_data_len; 48 uint8_t* p_service_data; 49 uint16_t service_uuid_len; 50 uint8_t* p_service_uuid; 51 } btif_adv_data_t; 52 53 typedef struct 54 { 55 UINT8 inst_id; 56 BOOLEAN is_scan_rsp; 57 UINT8 client_if; 58 UINT16 service_uuid_len; 59 tBTA_BLE_AD_MASK mask; 60 tBTA_BLE_ADV_DATA data; 61 tBTA_BLE_ADV_PARAMS param; 62 TIMER_LIST_ENT tle_limited_timer; 63 int timeout_s; 64 }btgatt_multi_adv_inst_cb; 65 66 typedef struct 67 { 68 INT8 *clntif_map; 69 // Includes the stored data for standard LE instance 70 btgatt_multi_adv_inst_cb *inst_cb; 71 72 } btgatt_multi_adv_common_data; 73 74 extern btgatt_multi_adv_common_data *btif_obtain_multi_adv_data_cb(); 75 extern void btif_gattc_init_multi_adv_cb(void); 76 extern void btif_gattc_destroy_multi_adv_cb(); 77 extern int btif_multi_adv_add_instid_map(int client_if, int inst_id, 78 BOOLEAN gen_temp_instid); 79 extern int btif_multi_adv_instid_for_clientif(int client_if); 80 extern int btif_gattc_obtain_idx_for_datacb(int value, int clnt_inst_index); 81 extern void btif_gattc_clear_clientif(int client_if); 82 extern void btif_gattc_cleanup_inst_cb(int inst_id); 83 extern void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_inst_cb); 84 extern BOOLEAN btif_gattc_copy_datacb(int arrindex, btif_adv_data_t *p_adv_data, 85 BOOLEAN bInstData); 86 extern void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp, 87 bool include_name, bool include_txpower, int min_interval, int max_interval, 88 int appearance, int manufacturer_len, char* manufacturer_data, 89 int service_data_len, char* service_data, int service_uuid_len, 90 char* service_uuid, btif_adv_data_t *p_multi_adv_inst); 91 void btif_multi_adv_timer_ctrl(int client_if, TIMER_CBACK cb); 92 #endif 93 94 95