1 /* 2 * Copyright 2022 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 #pragma once 17 18 #include <memory> 19 #include <vector> 20 21 #include "common/callback.h" 22 #include "hci/address_with_type.h" 23 #include "hci/hci_packets.h" 24 #include "hci/uuid.h" 25 26 namespace bluetooth { 27 namespace hci { 28 29 using ScannerId = uint8_t; 30 31 class AdvertisingFilterOnFoundOnLostInfo { 32 public: 33 // For MSFT-based advertisement events, the monitor handle associates every event with the monitor 34 // filter this event comes from. 35 uint8_t monitor_handle; 36 uint8_t scanner_id; 37 uint8_t filter_index; 38 uint8_t advertiser_state; 39 AdvtInfoPresent advertiser_info_present; 40 Address advertiser_address; 41 uint8_t advertiser_address_type; 42 uint8_t tx_power; 43 int8_t rssi; 44 uint16_t time_stamp; 45 std::vector<uint8_t> adv_packet; 46 std::vector<uint8_t> scan_response; 47 }; 48 49 class ScanningCallback { 50 public: 51 enum ScanningStatus { 52 SUCCESS, 53 NO_RESOURCES = 0x80, 54 INTERNAL_ERROR = 0x85, 55 ILLEGAL_PARAMETER = 0x87, 56 }; 57 58 virtual ~ScanningCallback() = default; 59 virtual void OnScannerRegistered( 60 const bluetooth::hci::Uuid app_uuid, ScannerId scanner_id, ScanningStatus status) = 0; 61 virtual void OnSetScannerParameterComplete(ScannerId scanner_id, ScanningStatus status) = 0; 62 virtual void OnScanResult( 63 uint16_t event_type, 64 uint8_t address_type, 65 Address address, 66 uint8_t primary_phy, 67 uint8_t secondary_phy, 68 uint8_t advertising_sid, 69 int8_t tx_power, 70 int8_t rssi, 71 uint16_t periodic_advertising_interval, 72 std::vector<uint8_t> advertising_data) = 0; 73 virtual void OnTrackAdvFoundLost(AdvertisingFilterOnFoundOnLostInfo on_found_on_lost_info) = 0; 74 virtual void OnBatchScanReports( 75 int client_if, int status, int report_format, int num_records, std::vector<uint8_t> data) = 0; 76 virtual void OnBatchScanThresholdCrossed(int client_if) = 0; 77 virtual void OnTimeout() = 0; 78 virtual void OnFilterEnable(Enable enable, uint8_t status) = 0; 79 virtual void OnFilterParamSetup(uint8_t available_spaces, ApcfAction action, uint8_t status) = 0; 80 virtual void OnFilterConfigCallback( 81 ApcfFilterType filter_type, uint8_t available_spaces, ApcfAction action, uint8_t status) = 0; 82 virtual void OnPeriodicSyncStarted( 83 int request_id, 84 uint8_t status, 85 uint16_t sync_handle, 86 uint8_t advertising_sid, 87 AddressWithType address_with_type, 88 uint8_t phy, 89 uint16_t interval) = 0; 90 virtual void OnPeriodicSyncReport( 91 uint16_t sync_handle, int8_t tx_power, int8_t rssi, uint8_t status, std::vector<uint8_t> data) = 0; 92 virtual void OnPeriodicSyncLost(uint16_t sync_handle) = 0; 93 virtual void OnPeriodicSyncTransferred(int pa_source, uint8_t status, Address address) = 0; 94 virtual void OnBigInfoReport(uint16_t sync_handle, bool encrypted) = 0; 95 }; 96 97 class AdvertisingPacketContentFilterCommand { 98 public: 99 ApcfFilterType filter_type; 100 Address address; 101 ApcfApplicationAddressType application_address_type; 102 Uuid uuid; 103 Uuid uuid_mask; 104 std::vector<uint8_t> name; 105 uint16_t company; 106 uint16_t company_mask; 107 uint8_t org_id; 108 uint8_t tds_flags; 109 uint8_t tds_flags_mask; 110 ApcfMetaDataType meta_data_type; 111 std::vector<uint8_t> meta_data; 112 uint8_t ad_type; 113 std::vector<uint8_t> data; 114 std::vector<uint8_t> data_mask; 115 std::array<uint8_t, 16> irk; 116 }; 117 118 class AdvertisingFilterParameter { 119 public: 120 uint16_t feature_selection; 121 uint16_t list_logic_type; 122 uint8_t filter_logic_type; 123 uint8_t rssi_high_thresh; 124 DeliveryMode delivery_mode; 125 uint16_t onfound_timeout; 126 uint8_t onfound_timeout_cnt; 127 uint8_t rssi_low_thresh; 128 uint16_t onlost_timeout; 129 uint16_t num_of_tracking_entries; 130 }; 131 132 } // namespace hci 133 } // namespace bluetooth 134