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 <cstdint>
17 
18 #include "pw_bluetooth_sapphire/internal/host/hci-spec/constants.h"
19 #include "pw_bluetooth_sapphire/internal/host/transport/data_buffer_info.h"
20 
21 namespace bt::gap {
22 
23 // Stores Bluetooth Low Energy settings and state information.
24 class LowEnergyState final {
25  public:
26   // Returns true if |feature_bit| is set as supported in the local LE features
27   // list.
IsFeatureSupported(hci_spec::LESupportedFeature feature_bit)28   inline bool IsFeatureSupported(
29       hci_spec::LESupportedFeature feature_bit) const {
30     return supported_features_ & static_cast<uint64_t>(feature_bit);
31   }
32 
supported_features()33   uint64_t supported_features() const { return supported_features_; }
34 
35   // Returns the LE ACL data buffer capacity.
acl_data_buffer_info()36   const hci::DataBufferInfo& acl_data_buffer_info() const {
37     return acl_data_buffer_info_;
38   }
39 
40   // Returns the ISO data buffer capacity.
iso_data_buffer_info()41   const hci::DataBufferInfo& iso_data_buffer_info() const {
42     return iso_data_buffer_info_;
43   }
44 
max_advertising_data_length()45   uint16_t max_advertising_data_length() const {
46     return max_advertising_data_length_;
47   }
48 
49  private:
50   friend class Adapter;
51   friend class AdapterImpl;
52 
53   // Storage capacity information about the controller's internal ACL data
54   // buffers.
55   hci::DataBufferInfo acl_data_buffer_info_;
56 
57   // Storage capacity information about the controller's internal ISO data
58   // buffers.
59   hci::DataBufferInfo iso_data_buffer_info_;
60 
61   // Local supported LE Features reported by the controller.
62   uint64_t supported_features_ = 0;
63 
64   // Local supported LE states reported by the controller.
65   uint64_t supported_states_ = 0;
66 
67   // Maximum length of data supported by the Controller for use as advertisement
68   // data or scan response data in an advertising event or as periodic
69   // advertisement data
70   uint16_t max_advertising_data_length_ = 0;
71 };
72 
73 }  // namespace bt::gap
74