• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "pw_bluetooth_sapphire/internal/host/gap/android_vendor_capabilities.h"
16 
17 #include "pw_bluetooth_sapphire/internal/host/common/log.h"
18 #include "pw_bluetooth_sapphire/internal/host/hci-spec/constants.h"
19 
20 namespace bt::gap {
21 
Initialize(const pw::bluetooth::vendor::android_hci::LEGetVendorCapabilitiesCommandCompleteEventView & c)22 void AndroidVendorCapabilities::Initialize(
23     const pw::bluetooth::vendor::android_hci::
24         LEGetVendorCapabilitiesCommandCompleteEventView& c) {
25   initialized_ = false;
26 
27   if (c.status().Read() != pw::bluetooth::emboss::StatusCode::SUCCESS) {
28     bt_log(INFO,
29            "android_vendor_extensions",
30            "refusing to parse non-success vendor capabilities");
31     return;
32   }
33 
34   max_simultaneous_advertisement_ = c.max_advt_instances().Read();
35   supports_offloaded_rpa_ =
36       static_cast<bool>(c.offloaded_resolution_of_private_address().Read());
37   scan_results_storage_bytes_ = c.total_scan_results_storage().Read();
38   irk_list_size_ = c.max_irk_list_sz().Read();
39   supports_filtering_ = static_cast<bool>(c.filtering_support().Read());
40   max_filters_ = c.max_filter().Read();
41   supports_activity_energy_info_ =
42       static_cast<bool>(c.activity_energy_info_support().Read());
43   version_minor_ = c.version_supported().minor_number().Read();
44   version_major_ = c.version_supported().major_number().Read();
45   max_advertisers_tracked_ = c.total_num_of_advt_tracked().Read();
46   supports_extended_scan_ = static_cast<bool>(c.extended_scan_support().Read());
47   supports_debug_logging_ =
48       static_cast<bool>(c.debug_logging_supported().Read());
49   supports_offloading_le_address_generation_ =
50       static_cast<bool>(c.le_address_generation_offloading_support().Read());
51   a2dp_source_offload_capability_mask_ =
52       c.a2dp_source_offload_capability_mask().BackingStorage().ReadUInt();
53   supports_bluetooth_quality_report_ =
54       static_cast<bool>(c.bluetooth_quality_report_support().Read());
55   supports_dynamic_audio_buffer_ =
56       c.dynamic_audio_buffer_support().BackingStorage().ReadUInt();
57 
58   initialized_ = true;
59 }
60 
61 }  // namespace bt::gap
62