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(const bluetooth::hci::Uuid app_uuid, ScannerId scanner_id, 60 ScanningStatus status) = 0; 61 virtual void OnSetScannerParameterComplete(ScannerId scanner_id, ScanningStatus status) = 0; 62 virtual void OnScanResult(uint16_t event_type, uint8_t address_type, Address address, 63 uint8_t primary_phy, uint8_t secondary_phy, uint8_t advertising_sid, 64 int8_t tx_power, int8_t rssi, uint16_t periodic_advertising_interval, 65 std::vector<uint8_t> advertising_data) = 0; 66 virtual void OnTrackAdvFoundLost(AdvertisingFilterOnFoundOnLostInfo on_found_on_lost_info) = 0; 67 virtual void OnBatchScanReports(int client_if, int status, int report_format, int num_records, 68 std::vector<uint8_t> data) = 0; 69 virtual void OnBatchScanThresholdCrossed(int client_if) = 0; 70 virtual void OnTimeout() = 0; 71 virtual void OnFilterEnable(Enable enable, uint8_t status) = 0; 72 virtual void OnFilterParamSetup(uint8_t available_spaces, ApcfAction action, uint8_t status) = 0; 73 virtual void OnFilterConfigCallback(ApcfFilterType filter_type, uint8_t available_spaces, 74 ApcfAction action, uint8_t status) = 0; 75 virtual void OnPeriodicSyncStarted(int request_id, uint8_t status, uint16_t sync_handle, 76 uint8_t advertising_sid, AddressWithType address_with_type, 77 uint8_t phy, uint16_t interval) = 0; 78 virtual void OnPeriodicSyncReport(uint16_t sync_handle, int8_t tx_power, int8_t rssi, 79 uint8_t status, std::vector<uint8_t> data) = 0; 80 virtual void OnPeriodicSyncLost(uint16_t sync_handle) = 0; 81 virtual void OnPeriodicSyncTransferred(int pa_source, uint8_t status, Address address) = 0; 82 virtual void OnBigInfoReport(uint16_t sync_handle, bool encrypted) = 0; 83 }; 84 85 class AdvertisingPacketContentFilterCommand { 86 public: 87 ApcfFilterType filter_type; 88 Address address; 89 ApcfApplicationAddressType application_address_type; 90 Uuid uuid; 91 Uuid uuid_mask; 92 std::vector<uint8_t> name; 93 uint16_t company; 94 uint16_t company_mask; 95 uint8_t org_id; 96 uint8_t tds_flags; 97 uint8_t tds_flags_mask; 98 ApcfMetaDataType meta_data_type; 99 std::vector<uint8_t> meta_data; 100 uint8_t ad_type; 101 std::vector<uint8_t> data; 102 std::vector<uint8_t> data_mask; 103 std::array<uint8_t, 16> irk; 104 }; 105 106 class AdvertisingFilterParameter { 107 public: 108 uint16_t feature_selection; 109 uint16_t list_logic_type; 110 uint8_t filter_logic_type; 111 uint8_t rssi_high_thresh; 112 DeliveryMode delivery_mode; 113 uint16_t onfound_timeout; 114 uint8_t onfound_timeout_cnt; 115 uint8_t rssi_low_thresh; 116 uint16_t onlost_timeout; 117 uint16_t num_of_tracking_entries; 118 }; 119 120 } // namespace hci 121 } // namespace bluetooth 122