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/l2cap_channel_common.h"
22#include "pw_bluetooth_proxy/l2cap_coc.h"
23#include "pw_bluetooth_proxy/l2cap_status_delegate.h"
24#include "pw_function/function.h"
25#include "pw_multibuf/multibuf.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 {
92 uint16_t le_acl_credits_to_reserve,
93 uint16_t br_edr_acl_credits_to_reserve,
228 multibuf::MultiBufAllocator& rx_multibuf_allocator,
229 uint16_t connection_handle,
230 L2capCoc::CocConfig rx_config,
231 L2capCoc::CocConfig tx_config,
232 Function<
void(multibuf::MultiBuf&& payload)>&& receive_fn,
233 ChannelEventCallback&& event_fn);
285 multibuf::MultiBufAllocator& rx_multibuf_allocator,
286 uint16_t connection_handle,
289 AclTransportType transport,
290 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
291 OptionalPayloadReceiveCallback&& payload_from_host_fn,
292 ChannelEventCallback&& event_fn);
314 int16_t connection_handle,
315 uint16_t attribute_handle,
316 ChannelEventCallback&& event_fn);
338 return AclDataChannel::GetMaxNumAclConnections();
342 friend class internal::ProxyHostImpl;
354 void DoRegisterL2capStatusDelegate(L2capStatusDelegate& delegate);
357 void DoUnregisterL2capStatusDelegate(L2capStatusDelegate& delegate);
361 multibuf::MultiBufAllocator& rx_multibuf_allocator,
362 uint16_t connection_handle,
363 L2capCoc::CocConfig rx_config,
364 L2capCoc::CocConfig tx_config,
365 Function<
void(multibuf::MultiBuf&& payload)>&& receive_fn,
366 ChannelEventCallback&& event_fn);
370 multibuf::MultiBufAllocator& rx_multibuf_allocator,
371 uint16_t connection_handle,
374 AclTransportType transport,
375 OptionalPayloadReceiveCallback&& payload_from_controller_fn,
376 OptionalPayloadReceiveCallback&& payload_from_host_fn,
377 ChannelEventCallback&& event_fn);
381 int16_t connection_handle,
382 uint16_t attribute_handle,
383 ChannelEventCallback&& event_fn);
386 bool DoHasSendLeAclCapability()
const;
389 bool DoHasSendBrEdrAclCapability()
const;
392 uint16_t DoGetNumFreeLeAclPackets()
const;
395 uint16_t DoGetNumFreeBrEdrAclPackets()
const;
419 void OnConnectionCompleteSuccess(uint16_t connection_handle,
420 AclTransportType transport);
424 void OnAclTxCredits();
428 ConnectionHandle connection_handle,
429 uint16_t local_channel_id,
430 uint16_t remote_channel_id,
431 AclTransportType transport,
432 BufferReceiveFunction&& payload_from_controller_fn,
433 BufferReceiveFunction&& payload_from_host_fn,
434 ChannelEventCallback&& event_fn)
override;
437 ConnectionHandle connection_handle,
438 uint16_t local_channel_id,
439 uint16_t remote_channel_id,
440 AclTransportType transport,
441 BufferReceiveFunction&& payload_from_controller_fn,
442 BufferReceiveFunction&& payload_from_host_fn,
443 ChannelEventCallback&& event_fn);
446 ConnectionHandle connection_handle,
447 ConnectionOrientedChannelConfig rx_config,
448 ConnectionOrientedChannelConfig tx_config,
449 MultiBufReceiveFunction&& receive_fn,
450 ChannelEventCallback&& event_fn)
override;
453 internal::ProxyHostImpl impl_;
457 HciTransport hci_transport_;
460 AclDataChannel acl_data_channel_;
463 L2capChannelManager l2cap_channel_manager_;
Definition: allocator.h:42
Definition: dispatcher.h:74
H4PacketWithH4 is an H4Packet backed by an H4 buffer.
Definition: h4_packet.h:173
H4PacketWithHci is an H4Packet backed by an HCI buffer.
Definition: h4_packet.h:138
Definition: proxy_host.h:48
static constexpr size_t GetMaxNumAclConnections()
Returns the max number of simultaneous LE ACL connections supported.
Definition: proxy_host.h:337
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
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
pw::Result< BasicL2capChannel > AcquireBasicL2capChannel(multibuf::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)
uint16_t GetNumFreeBrEdrAclPackets() const
pw::Result< L2capCoc > AcquireL2capCoc(multibuf::MultiBufAllocator &rx_multibuf_allocator, uint16_t connection_handle, L2capCoc::CocConfig rx_config, L2capCoc::CocConfig tx_config, Function< void(multibuf::MultiBuf &&payload)> &&receive_fn, ChannelEventCallback &&event_fn)
void UnregisterL2capStatusDelegate(L2capStatusDelegate &delegate)
ProxyHost(pw::Function< void(H4PacketWithHci &&packet)> &&send_to_host_fn, pw::Function< void(H4PacketWithH4 &&packet)> &&send_to_controller_fn, pw::Allocator &allocator)
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:27