32 bool sent_(
bool sent,
bool busy);
39 void receive_(std::span<const uint8_t> packet,
float rssi,
float snr);
60template<
typename Listener>
62 static_cast<void (Listener::*)(
const std::vector<uint8_t> &,
float,
float)
>(&Listener::on_packet);
67 void on_packet(
const std::vector<uint8_t> &packet,
float rssi,
float snr)
final {
68 static_cast<Listener *
>(
this)->on_packet(std::span<const uint8_t>(packet), rssi, snr);
72template<
typename Radio,
typename Listener,
typename Error,
size_t MaxPacketSize>
79 this->
radio_->register_listener(
this);
85 if (!this->
radio_->is_ready() || !this->radio_->is_receiving())
91 if (!this->
radio_->is_ready()) {
98 bool busy = this->
radio_->is_receiving();
101 if (data.is_contiguous()) {
102 auto span = data.as_span();
103 return this->
sent_(this->
radio_->transmit_packet(span.data(), span.size()) == Error{}, busy);
105 uint8_t buf[MaxPacketSize];
106 data.copy_to(buf,
size);
107 return this->
sent_(this->
radio_->transmit_packet(buf,
size) == Error{}, busy);
110 void on_packet(std::span<const uint8_t> packet,
float rssi,
float snr)
override { this->
receive_(packet, rssi, snr); }
void disable_loop()
Disable this component's loop.
Decides whether a half-duplex radio link may send while its radio reports that it is receiving a pack...
void set_turnaround(uint32_t turnaround_ms)
void set_max_busy(uint32_t max_busy_ms)
A buffer class that efficiently represents a composite buffer with three sections:
size_t size() const
Get the total size of the buffer.
A class that will transport data to and from an abstract channel.
The parts of RadioLink that do not depend on the radio.
void receive_(std::span< const uint8_t > packet, float rssi, float snr)
void radio_not_ready_(bool failed)
Warns once when a send finds the radio failed; until its setup has run, sends are refused quietly.
void set_max_busy(uint32_t max_busy_ms)
RadioLinkBase(size_t max_packet_size)
bool skip_empty_() const
Returns true for an empty packet, which the radios cannot send, so there is nothing to retry.
bool sent_(bool sent, bool busy)
Returns sent, after ending the busy period and warning if the packet was sent over a radio that seeme...
bool check_size_(size_t size) const
False if a packet of this size is too large.
ListenBeforeTalk listen_before_talk_
bool may_send_(bool busy)
False if sending must wait, as the radio is busy or the peer may be about to reply; starts loop() to ...
void radio_free_()
Ends the busy period when loop() finds the radio free.
virtual uint32_t current_time_ms() const
The time now, not the loop's start: earlier sends in the same loop pass may have waited seconds for t...
void set_turnaround(uint32_t turnaround_ms)
bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override
RadioLink(Radio *radio, size_t max_packet_size)
void on_packet(std::span< const uint8_t > packet, float rssi, float snr) override
void on_packet(const std::vector< uint8_t > &packet, float rssi, float snr) final
A packet interface link over a packet radio: each packet is one radio packet, with the RSSI and SNR o...
uint32_t IRAM_ATTR HOT millis()