Pigweed
 
Loading...
Searching...
No Matches
controller2.h
1// Copyright 2024 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
17#include "pw_async2/dispatcher.h"
18#include "pw_async2/once_sender.h"
19#include "pw_bluetooth/vendor.h"
20#include "pw_channel/channel.h"
21#include "pw_function/function.h"
22#include "pw_result/result.h"
23#include "pw_status/status.h"
24
25namespace pw::bluetooth {
26
32 : public pw::channel::Implement<pw::channel::ReliableDatagramReaderWriter> {
33 public:
35 enum class FeaturesBits : uint32_t {
39 kHciSco = (1 << 0),
41 kSetAclPriorityCommand = (1 << 1),
46 kAndroidVendorExtensions = (1 << 2),
48 };
49
50 enum class ScoCodingFormat : uint8_t {
51 kCvsd,
52 kMsbc,
53 };
54
55 enum class ScoEncoding : uint8_t {
56 k8Bits,
57 k16Bits,
58 };
59
60 enum class ScoSampleRate : uint8_t {
61 k8Khz,
62 k16Khz,
63 };
64
68
74
83 ScoCodingFormat coding_format,
84 ScoEncoding encoding,
85 ScoSampleRate sample_rate) = 0;
86
95
98
105 VendorCommandParameters parameters) = 0;
106};
107
108inline constexpr bool operator&(Controller2::FeaturesBits left,
110 return static_cast<bool>(
111 static_cast<std::underlying_type_t<Controller2::FeaturesBits>>(left) &
112 static_cast<std::underlying_type_t<Controller2::FeaturesBits>>(right));
113}
114
115inline constexpr Controller2::FeaturesBits operator|(
117 return static_cast<Controller2::FeaturesBits>(
118 static_cast<std::underlying_type_t<Controller2::FeaturesBits>>(left) |
119 static_cast<std::underlying_type_t<Controller2::FeaturesBits>>(right));
120}
121
122inline constexpr Controller2::FeaturesBits& operator|=(
124 return left = left | right;
125}
126
127} // namespace pw::bluetooth
Definition: dispatcher_base.h:52
Definition: once_sender.h:41
Definition: poll.h:54
Definition: controller2.h:32
virtual async2::Poll< Status > PendError(async2::Context &cx)=0
virtual async2::OnceReceiver< Status > ResetSco()=0
virtual async2::OnceReceiver< FeaturesBits > GetFeatures()=0
virtual async2::OnceReceiver< Result< multibuf::MultiBuf > > EncodeVendorCommand(VendorCommandParameters parameters)=0
FeaturesBits
Bitmask of features the controller supports.
Definition: controller2.h:35
@ kSetAclPriorityCommand
Indicates support for the Set Acl Priority command.
virtual async2::OnceReceiver< Status > ConfigureSco(ScoCodingFormat coding_format, ScoEncoding encoding, ScoSampleRate sample_rate)=0
virtual async2::OnceReceiver< Status > Initialize()=0
Definition: channel.h:583