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 {
64 uint16_t le_acl_credits_to_reserve,
65 uint16_t br_edr_acl_credits_to_reserve,
200 MultiBufAllocator& rx_multibuf_allocator,
201 uint16_t connection_handle,
202 L2capCoc::CocConfig rx_config,
203 L2capCoc::CocConfig tx_config,
204 Function<
void(FlatConstMultiBuf&& payload)>&& receive_fn,
205 ChannelEventCallback&& event_fn);
257 MultiBufAllocator& rx_multibuf_allocator,
258 uint16_t connection_handle,
261 AclTransportType transport,
262 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
263 OptionalPayloadReceiveCallback&& payload_from_host_fn,
264 ChannelEventCallback&& event_fn);
286 int16_t connection_handle,
287 uint16_t attribute_handle,
288 ChannelEventCallback&& event_fn);
310 return AclDataChannel::GetMaxNumAclConnections();
314 friend class internal::ProxyHostImpl;
326 void DoRegisterL2capStatusDelegate(L2capStatusDelegate& delegate);
329 void DoUnregisterL2capStatusDelegate(L2capStatusDelegate& delegate);
333 MultiBufAllocator& rx_multibuf_allocator,
334 uint16_t connection_handle,
335 L2capCoc::CocConfig rx_config,
336 L2capCoc::CocConfig tx_config,
337 Function<
void(FlatConstMultiBuf&& payload)>&& receive_fn,
338 ChannelEventCallback&& event_fn);
342 MultiBufAllocator& rx_multibuf_allocator,
343 uint16_t connection_handle,
346 AclTransportType transport,
347 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
348 OptionalPayloadReceiveCallback&& payload_from_host_fn,
349 ChannelEventCallback&& event_fn);
353 int16_t connection_handle,
354 uint16_t attribute_handle,
355 ChannelEventCallback&& event_fn);
358 bool DoHasSendLeAclCapability()
const;
361 bool DoHasSendBrEdrAclCapability()
const;
364 uint16_t DoGetNumFreeLeAclPackets()
const;
367 uint16_t DoGetNumFreeBrEdrAclPackets()
const;
391 void OnConnectionCompleteSuccess(uint16_t connection_handle,
392 AclTransportType transport);
396 void OnAclTxCredits();
400 ConnectionHandle connection_handle,
401 uint16_t local_channel_id,
402 uint16_t remote_channel_id,
403 AclTransportType transport,
404 BufferReceiveFunction&& payload_from_controller_fn,
405 BufferReceiveFunction&& payload_from_host_fn,
406 ChannelEventCallback&& event_fn)
override;
409 ConnectionHandle connection_handle,
410 uint16_t local_channel_id,
411 uint16_t remote_channel_id,
412 AclTransportType transport,
413 BufferReceiveFunction&& payload_from_controller_fn,
414 BufferReceiveFunction&& payload_from_host_fn,
415 ChannelEventCallback&& event_fn);
418 ConnectionHandle connection_handle,
419 ConnectionOrientedChannelConfig rx_config,
420 ConnectionOrientedChannelConfig tx_config,
421 MultiBufReceiveFunction&& receive_fn,
422 ChannelEventCallback&& event_fn)
override;
425 internal::ProxyHostImpl impl_;
429 HciTransport hci_transport_;
432 AclDataChannel acl_data_channel_;
435 L2capChannelManager l2cap_channel_manager_;
Definition: allocator.h:45
Definition: dispatcher.h:46
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:309
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)
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)
Status SetDispatcher(async2::Dispatcher &dispatcher)
uint16_t GetNumFreeLeAclPackets() const
uint16_t GetNumFreeBrEdrAclPackets() const
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