• 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 #pragma once
16 #include "pw_bluetooth_sapphire/internal/host/transport/sco_data_channel.h"
17 
18 namespace bt::hci {
19 
20 class FakeScoDataChannel final : public ScoDataChannel {
21  public:
22   struct RegisteredConnection {
23     WeakPtr<ConnectionInterface> connection;
24   };
25 
FakeScoDataChannel(uint16_t max_data_length)26   explicit FakeScoDataChannel(uint16_t max_data_length)
27       : max_data_length_(max_data_length) {}
28 
29   ~FakeScoDataChannel() override = default;
30 
connections()31   const auto& connections() { return connections_; }
32 
readable_count()33   uint16_t readable_count() const { return readable_count_; }
34 
35   // ScoDataChannel overrides:
36   void RegisterConnection(WeakPtr<ConnectionInterface> connection) override;
37   void UnregisterConnection(hci_spec::ConnectionHandle handle) override;
38   void OnOutboundPacketReadable() override;
ClearControllerPacketCount(hci_spec::ConnectionHandle handle)39   void ClearControllerPacketCount(hci_spec::ConnectionHandle handle) override {}
max_data_length()40   uint16_t max_data_length() const override { return max_data_length_; }
41 
42  private:
43   uint16_t max_data_length_;
44   uint16_t readable_count_ = 0;
45   std::unordered_map<hci_spec::ConnectionHandle, RegisteredConnection>
46       connections_;
47 };
48 
49 }  // namespace bt::hci
50