1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /****************************************************************************** 18 * 19 * This file contains constants and definitions that can be used commonly 20 * between JNI and stack layer 21 * 22 ******************************************************************************/ 23 #ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H 24 #define ANDROID_INCLUDE_BT_COMMON_TYPES_H 25 26 #include <vector> 27 28 #include "bluetooth.h" 29 #include "types/bluetooth/uuid.h" 30 #include "types/raw_address.h" 31 32 typedef struct { 33 uint8_t client_if; 34 uint8_t filt_index; 35 uint8_t advertiser_state; 36 uint8_t advertiser_info_present; 37 uint8_t addr_type; 38 uint8_t tx_power; 39 int8_t rssi_value; 40 uint16_t time_stamp; 41 RawAddress bd_addr; 42 uint8_t adv_pkt_len; 43 uint8_t* p_adv_pkt_data; 44 uint8_t scan_rsp_len; 45 uint8_t* p_scan_rsp_data; 46 } btgatt_track_adv_info_t; 47 48 typedef enum { 49 BTGATT_DB_PRIMARY_SERVICE, 50 BTGATT_DB_SECONDARY_SERVICE, 51 BTGATT_DB_INCLUDED_SERVICE, 52 BTGATT_DB_CHARACTERISTIC, 53 BTGATT_DB_DESCRIPTOR, 54 } bt_gatt_db_attribute_type_t; 55 56 typedef struct { 57 uint16_t id; 58 bluetooth::Uuid uuid; 59 bt_gatt_db_attribute_type_t type; 60 uint16_t attribute_handle; 61 62 /* 63 * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or 64 * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute 65 * handles. 66 */ 67 uint16_t start_handle; 68 uint16_t end_handle; 69 70 /* 71 * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of 72 * the characteristic. 73 */ 74 uint8_t properties; 75 uint16_t extended_properties; 76 77 uint16_t permissions; 78 } btgatt_db_element_t; 79 80 typedef struct { 81 uint16_t feat_seln; 82 uint16_t list_logic_type; 83 uint8_t filt_logic_type; 84 uint8_t rssi_high_thres; 85 uint8_t rssi_low_thres; 86 uint8_t dely_mode; 87 uint16_t found_timeout; 88 uint16_t lost_timeout; 89 uint8_t found_timeout_cnt; 90 uint16_t num_of_tracking_entries; 91 } btgatt_filt_param_setup_t; 92 93 // Advertising Packet Content Filter 94 struct ApcfCommand { 95 uint8_t type; 96 RawAddress address; 97 uint8_t addr_type; 98 bluetooth::Uuid uuid; 99 bluetooth::Uuid uuid_mask; 100 std::vector<uint8_t> name; 101 uint16_t company; 102 uint16_t company_mask; 103 uint8_t org_id; 104 uint8_t tds_flags; 105 uint8_t tds_flags_mask; 106 uint8_t meta_data_type; 107 std::vector<uint8_t> meta_data; 108 uint8_t ad_type; 109 std::vector<uint8_t> data; 110 std::vector<uint8_t> data_mask; 111 std::array<uint8_t, 16> irk; // 128 bit/16 octet IRK 112 }; 113 114 typedef enum { 115 MSFT_CONDITION_TYPE_PATTERNS = 0x01, 116 MSFT_CONDITION_TYPE_UUID = 0x02, 117 MSFT_CONDITION_TYPE_IRK_RESOLUTION = 0x03, 118 MSFT_CONDITION_TYPE_ADDRESS = 0x04, 119 } bt_msft_condition_type; 120 121 enum MsftLeMonitorAdvConditionUuidType { 122 MSFT_CONDITION_UUID_TYPE_16_BIT = 0x01, 123 MSFT_CONDITION_UUID_TYPE_32_BIT = 0x02, 124 MSFT_CONDITION_UUID_TYPE_128_BIT = 0x03, 125 }; 126 127 // MSFT scan filter pattern 128 struct MsftAdvMonitorPattern { 129 uint8_t ad_type; 130 uint8_t start_byte; 131 std::vector<uint8_t> pattern; 132 }; 133 134 struct MsftAdvMonitorAddress { 135 uint8_t addr_type; 136 RawAddress bd_addr; 137 }; 138 139 // LE Scan filter defined by MSFT extension. 140 struct MsftAdvMonitor { 141 uint8_t rssi_threshold_high; 142 uint8_t rssi_threshold_low; 143 uint8_t rssi_threshold_low_time_interval; 144 uint8_t rssi_sampling_period; 145 uint8_t condition_type; 146 std::vector<MsftAdvMonitorPattern> patterns; 147 MsftAdvMonitorAddress addr_info; 148 }; 149 150 #if __has_include(<bluetooth/log.h>) 151 #include <bluetooth/log.h> 152 153 namespace std { 154 template <> 155 struct formatter<bt_gatt_db_attribute_type_t> : enum_formatter<bt_gatt_db_attribute_type_t> {}; 156 } // namespace std 157 #endif // __has_include(<bluetooth/log.h>) 158 159 #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ 160