• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_channel_common.h"
18 #include "pw_bluetooth_proxy/l2cap_coc.h"
19 
20 namespace pw::bluetooth::proxy {
21 
22 class L2capCocInternal final : public L2capCoc {
23  public:
24   // Should only be created by `ProxyHost` and tests.
Create(pw::multibuf::MultiBufAllocator & rx_multibuf_allocator,L2capChannelManager & l2cap_channel_manager,L2capSignalingChannel * signaling_channel,uint16_t connection_handle,CocConfig rx_config,CocConfig tx_config,ChannelEventCallback && event_fn,Function<void (multibuf::MultiBuf && payload)> && receive_fn)25   static pw::Result<L2capCoc> Create(
26       pw::multibuf::MultiBufAllocator& rx_multibuf_allocator,
27       L2capChannelManager& l2cap_channel_manager,
28       L2capSignalingChannel* signaling_channel,
29       uint16_t connection_handle,
30       CocConfig rx_config,
31       CocConfig tx_config,
32       ChannelEventCallback&& event_fn,
33       Function<void(multibuf::MultiBuf&& payload)>&& receive_fn) {
34     return L2capCoc::Create(rx_multibuf_allocator,
35                             l2cap_channel_manager,
36                             signaling_channel,
37                             connection_handle,
38                             rx_config,
39                             tx_config,
40                             std::move(event_fn),
41                             std::move(receive_fn));
42   }
43 
44   // Increment L2CAP credits. This should be called by signaling channels in
45   // response to L2CAP_FLOW_CONTROL_CREDIT_IND packets.
AddTxCredits(uint16_t credits)46   void AddTxCredits(uint16_t credits) { L2capCoc::AddTxCredits(credits); }
47 };
48 
49 }  // namespace pw::bluetooth::proxy
50