1 // Copyright 2023 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 #include "pw_bluetooth_sapphire/internal/host/hci-spec/vendor_protocol.h" 17 18 namespace bt::gap { 19 20 class AndroidVendorCapabilities final { 21 public: 22 static AndroidVendorCapabilities New( 23 const pw::bluetooth::vendor::android_hci:: 24 LEGetVendorCapabilitiesCommandCompleteEventView& c); 25 26 // Number of advertisement instances supported. 27 // 28 // This parameter is deprecated in the Google feature spec v0.98 and higher in 29 // favor of the LE Extended Advertising available in the BT spec version 5.0 30 // and higher. max_simultaneous_advertisements()31 uint8_t max_simultaneous_advertisements() const { 32 return max_simultaneous_advertisement_; 33 } 34 35 // BT chip capability of resolution of private addresses. If supported by a 36 // chip, it needs enablement by the host. 37 // 38 // This parameter is deprecated in the Google feature spec v0.98 and higher in 39 // favor of the Privacy feature available in the BT spec version 4.2 and 40 // higher. supports_offloaded_rpa()41 bool supports_offloaded_rpa() const { return supports_offloaded_rpa_; } 42 43 // Storage for scan results in bytes scan_results_storage_bytes()44 uint16_t scan_results_storage_bytes() const { 45 return scan_results_storage_bytes_; 46 } 47 48 // Number of IRK entries supported in the firmware irk_list_size()49 uint8_t irk_list_size() const { return irk_list_size_; } 50 51 // Support for filtering in the controller supports_filtering()52 bool supports_filtering() const { return supports_filtering_; } 53 54 // Number of filters supported max_filters()55 uint8_t max_filters() const { return max_filters_; } 56 57 // Supports reporting of activity and energy information supports_activity_energy_info()58 bool supports_activity_energy_info() const { 59 return supports_activity_energy_info_; 60 } 61 62 // Specifies the minor version of the Google feature spec supported version_minor()63 uint8_t version_minor() const { return version_minor_; } 64 65 // Specifies the major version of the Google feature spec supported version_major()66 uint8_t version_major() const { return version_major_; } 67 68 // Total number of advertisers tracked for OnLost/OnFound purposes max_advertisers_tracked()69 uint16_t max_advertisers_tracked() const { return max_advertisers_tracked_; } 70 71 // Supports extended scan window and interval supports_extended_scan()72 bool supports_extended_scan() const { return supports_extended_scan_; } 73 74 // Supports logging of binary debug information from controller supports_debug_logging()75 bool supports_debug_logging() const { return supports_debug_logging_; } 76 77 // This parameter is deprecated in the Google feature spec v0.98 and higher in 78 // favor of the Privacy feature available in the BT spec version 4.2 and 79 // higher. supports_offloading_le_address_generation()80 bool supports_offloading_le_address_generation() const { 81 return supports_offloading_le_address_generation_; 82 } 83 84 // Get a bitmask of the codec types supported for A2DP source offload. See 85 // A2dpCodecType in 86 // pw_bluetooth_sapphire/internal/host/hci_spec/vendor_protocol.h. a2dp_source_offload_capability_mask()87 uint32_t a2dp_source_offload_capability_mask() const { 88 return a2dp_source_offload_capability_mask_; 89 } 90 91 // Supports reporting of Bluetooth Quality events supports_bluetooth_quality_report()92 bool supports_bluetooth_quality_report() const { 93 return supports_bluetooth_quality_report_; 94 } 95 96 // Get a bitmask of the codec types where dynamic audio buffering in the 97 // Bluetooth controller is supported. See A2dpCodecType in 98 // pw_bluetooth_sapphire/internal/host/hci_spec/vendor_protocol.h. supports_dynamic_audio_buffer()99 uint32_t supports_dynamic_audio_buffer() const { 100 return supports_dynamic_audio_buffer_; 101 } 102 103 // Supports A2DP offloading with version 2 commands supports_a2dp_offload_v2()104 bool supports_a2dp_offload_v2() const { return a2dp_offload_v2_support_; } 105 106 private: 107 AndroidVendorCapabilities() = default; 108 109 // Determines if the currently configured version is less than or equal to the 110 // given version's major and minor. 111 bool SupportsVersion(uint8_t major, uint8_t minor) const; 112 113 uint8_t max_simultaneous_advertisement_ = 0; 114 bool supports_offloaded_rpa_ = false; 115 uint16_t scan_results_storage_bytes_ = 0; 116 uint8_t irk_list_size_ = 0; 117 bool supports_filtering_ = false; 118 uint8_t max_filters_ = 0; 119 bool supports_activity_energy_info_ = false; 120 uint8_t version_major_ = 0; 121 uint8_t version_minor_ = 0; 122 uint16_t max_advertisers_tracked_ = 0; 123 bool supports_extended_scan_ = false; 124 bool supports_debug_logging_ = false; 125 bool supports_offloading_le_address_generation_ = false; 126 uint32_t a2dp_source_offload_capability_mask_ = 0; 127 bool supports_bluetooth_quality_report_ = false; 128 uint32_t supports_dynamic_audio_buffer_ = 0; 129 bool a2dp_offload_v2_support_ = false; 130 }; 131 } // namespace bt::gap 132