29#include "pw_async2/dispatcher.h"
30#include "pw_async2/poll.h"
31#include "pw_channel/channel.h"
32#include "pw_containers/vector.h"
33#include "pw_hdlc/decoder.h"
34#include "pw_multibuf/multibuf.h"
35#include "pw_status/status.h"
58 : io_channel_(io_channel), decoder_(decode_buffer) {}
93 uint64_t receive_address,
94 uint64_t send_address);
104 uint64_t receive_address,
105 uint64_t send_address);
121 constexpr static size_t kSomeNumberOfChannels = 16;
126 uint64_t receive_address_arg,
127 uint64_t send_address_arg)
132 ChannelData(
const ChannelData&) =
delete;
133 ChannelData& operator=(
const ChannelData&) =
delete;
134 ChannelData(ChannelData&&) =
default;
135 ChannelData& operator=(ChannelData&&) =
default;
150 ChannelData* FindChannelForReceiveAddress(uint64_t receive_address);
172 void RemoveClosedChannels();
190 pw::multibuf::MultiBuf incoming_data_;
196 std::optional<pw::hdlc::Frame> decoded_frame_;
202 struct OutgoingBuffer {
203 pw::multibuf::MultiBuf buffer;
204 size_t hdlc_encoded_size;
205 uint64_t target_address;
209 std::optional<OutgoingBuffer> buffer_to_encode_and_send_;
214 size_t next_first_read_index_ = 0;
pw::async2::Poll PendClose(pw::async2::Context &cx)
Closes all underlying channels, attempting to flush any data.
pw::channel::DatagramReaderWriter * channel
A channel which reads and writes datagrams.
Definition: router.h:138
Status AddChannel(pw::channel::DatagramReaderWriter &channel, uint64_t receive_address, uint64_t send_address)
Router(pw::channel::ByteReaderWriter &io_channel, ByteSpan decode_buffer)
Definition: router.h:57
uint64_t receive_address
Data received over HDLC with this address will be sent to channel.
Definition: router.h:141
Status RemoveChannel(pw::channel::DatagramReaderWriter &channel, uint64_t receive_address, uint64_t send_address)
uint64_t send_address
Definition: router.h:145
pw::async2::Poll Pend(pw::async2::Context &cx)