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_bluetooth_proxy/l2cap_coc.h"
18 
19 namespace pw::bluetooth::proxy {
20 
21 class L2capCocInternal final : public L2capCoc {
22  public:
23   // Should only be created by `ProxyHost` and tests.
Create(L2capChannelManager & l2cap_channel_manager,uint16_t connection_handle,CocConfig rx_config,CocConfig tx_config,pw::Function<void (pw::span<uint8_t> payload)> && receive_fn,pw::Function<void (Event event)> && event_fn)24   static pw::Result<L2capCoc> Create(
25       L2capChannelManager& l2cap_channel_manager,
26       uint16_t connection_handle,
27       CocConfig rx_config,
28       CocConfig tx_config,
29       pw::Function<void(pw::span<uint8_t> payload)>&& receive_fn,
30       pw::Function<void(Event event)>&& event_fn) {
31     return L2capCoc::Create(l2cap_channel_manager,
32                             connection_handle,
33                             rx_config,
34                             tx_config,
35                             std::move(receive_fn),
36                             std::move(event_fn));
37   }
38 
39   // Increment L2CAP credits. This should be called by signaling channels in
40   // response to L2CAP_FLOW_CONTROL_CREDIT_IND packets.
AddCredits(uint16_t credits)41   void AddCredits(uint16_t credits) { L2capCoc::AddCredits(credits); }
42 };
43 
44 }  // namespace pw::bluetooth::proxy
45