17#include "pw_bluetooth_proxy/gatt_notify_channel.h"
18#include "pw_bluetooth_proxy/internal/acl_data_channel.h"
19#include "pw_bluetooth_proxy/internal/hci_transport.h"
20#include "pw_bluetooth_proxy/internal/l2cap_channel_manager.h"
21#include "pw_bluetooth_proxy/internal/multibuf.h"
22#include "pw_bluetooth_proxy/l2cap_channel_common.h"
23#include "pw_bluetooth_proxy/l2cap_coc.h"
24#include "pw_bluetooth_proxy/l2cap_status_delegate.h"
25#include "pw_function/function.h"
26#include "pw_status/status.h"
28#if PW_BLUETOOTH_PROXY_ASYNC == 0
29#include "pw_bluetooth_proxy/internal/proxy_host_sync.h"
37#include "pw_async2/dispatcher.h"
38#include "pw_bluetooth_proxy/internal/proxy_host_async.h"
48class ProxyHost :
public L2capChannelManagerInterface {
65 uint16_t le_acl_credits_to_reserve,
66 uint16_t br_edr_acl_credits_to_reserve,
199 MultiBufAllocator& rx_multibuf_allocator,
200 uint16_t connection_handle,
201 L2capCoc::CocConfig rx_config,
202 L2capCoc::CocConfig tx_config,
204 ChannelEventCallback&& event_fn);
254 MultiBufAllocator& rx_multibuf_allocator,
255 uint16_t connection_handle,
258 AclTransportType transport,
259 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
260 OptionalPayloadReceiveCallback&& payload_from_host_fn,
261 ChannelEventCallback&& event_fn);
283 int16_t connection_handle,
284 uint16_t attribute_handle,
285 ChannelEventCallback&& event_fn);
307 return AclDataChannel::GetMaxNumAclConnections();
311 friend class internal::ProxyHostImpl;
323 void DoRegisterL2capStatusDelegate(L2capStatusDelegate& delegate);
326 void DoUnregisterL2capStatusDelegate(L2capStatusDelegate& delegate);
330 MultiBufAllocator& rx_multibuf_allocator,
331 uint16_t connection_handle,
332 L2capCoc::CocConfig rx_config,
333 L2capCoc::CocConfig tx_config,
335 ChannelEventCallback&& event_fn);
339 MultiBufAllocator& rx_multibuf_allocator,
340 uint16_t connection_handle,
343 AclTransportType transport,
344 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
345 OptionalPayloadReceiveCallback&& payload_from_host_fn,
346 ChannelEventCallback&& event_fn);
350 int16_t connection_handle,
351 uint16_t attribute_handle,
352 ChannelEventCallback&& event_fn);
355 bool DoHasSendLeAclCapability()
const;
358 bool DoHasSendBrEdrAclCapability()
const;
361 uint16_t DoGetNumFreeLeAclPackets()
const;
364 uint16_t DoGetNumFreeBrEdrAclPackets()
const;
388 void OnConnectionCompleteSuccess(uint16_t connection_handle,
389 AclTransportType transport);
393 void OnAclTxCredits();
397 ConnectionHandle connection_handle,
398 uint16_t local_channel_id,
399 uint16_t remote_channel_id,
400 AclTransportType transport,
401 BufferReceiveFunction&& payload_from_controller_fn,
402 BufferReceiveFunction&& payload_from_host_fn,
403 ChannelEventCallback&& event_fn)
override;
406 ConnectionHandle connection_handle,
407 uint16_t local_channel_id,
408 uint16_t remote_channel_id,
409 AclTransportType transport,
410 BufferReceiveFunction&& payload_from_controller_fn,
411 BufferReceiveFunction&& payload_from_host_fn,
412 ChannelEventCallback&& event_fn);
415 internal::ProxyHostImpl impl_;
419 HciTransport hci_transport_;
422 AclDataChannel acl_data_channel_;
425 L2capChannelManager l2cap_channel_manager_;
Definition: allocator.h:45
Definition: multibuf_v2.h:185
Definition: dispatcher.h:53
H4PacketWithH4 is an H4Packet backed by an H4 buffer.
Definition: h4_packet.h:141
H4PacketWithHci is an H4Packet backed by an HCI buffer.
Definition: h4_packet.h:113
Definition: proxy_host.h:48
static constexpr size_t GetMaxNumAclConnections()
Returns the max number of simultaneous LE ACL connections supported.
Definition: proxy_host.h:306
pw::Result< GattNotifyChannel > AcquireGattNotifyChannel(int16_t connection_handle, uint16_t attribute_handle, ChannelEventCallback &&event_fn)
void HandleH4HciFromHost(H4PacketWithH4 &&h4_packet)
void RegisterL2capStatusDelegate(L2capStatusDelegate &delegate)
bool HasSendLeAclCapability() const
pw::Result< BasicL2capChannel > AcquireBasicL2capChannel(MultiBufAllocator &rx_multibuf_allocator, uint16_t connection_handle, uint16_t local_cid, uint16_t remote_cid, AclTransportType transport, OptionalPayloadReceiveCallback &&payload_from_controller_fn, OptionalPayloadReceiveCallback &&payload_from_host_fn, ChannelEventCallback &&event_fn)
Status SetDispatcher(async2::Dispatcher &dispatcher)
uint16_t GetNumFreeLeAclPackets() const
uint16_t GetNumFreeBrEdrAclPackets() const
ProxyHost(pw::Function< void(H4PacketWithHci &&packet)> &&send_to_host_fn, pw::Function< void(H4PacketWithH4 &&packet)> &&send_to_controller_fn, uint16_t le_acl_credits_to_reserve, uint16_t br_edr_acl_credits_to_reserve, pw::Allocator *allocator=nullptr)
void UnregisterL2capStatusDelegate(L2capStatusDelegate &delegate)
pw::Result< L2capCoc > AcquireL2capCoc(MultiBufAllocator &rx_multibuf_allocator, uint16_t connection_handle, L2capCoc::CocConfig rx_config, L2capCoc::CocConfig tx_config, Function< void(FlatConstMultiBuf &&payload)> &&receive_fn, ChannelEventCallback &&event_fn)
bool HasSendBrEdrAclCapability() const
void HandleH4HciFromController(H4PacketWithHci &&h4_packet)
fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Function
Definition: function.h:73
Lightweight proxy for augmenting Bluetooth functionality.
Definition: h4_packet.h:24