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