ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
udp
packet_transport
udp_transport.cpp
Go to the documentation of this file.
1
#include "
esphome/core/log.h
"
2
#include "
esphome/core/application.h
"
3
#include "
esphome/components/network/util.h
"
4
#include "
udp_transport.h
"
5
6
namespace
esphome::udp
{
7
8
static
const
char
*
const
TAG
=
"udp_transport"
;
9
10
bool
UDPTransport::should_send
() {
return
network::is_connected
(); }
11
void
UDPTransport::setup
() {
12
PacketTransport::setup();
13
if
(!this->
providers_
.empty() || this->is_encrypted_()) {
14
this->
parent_
->add_listener([
this
](std::span<const uint8_t> data) { this->
process_
(data); });
15
}
16
}
17
18
void
UDPTransport::send_packet
(
const
std::vector<uint8_t> &buf)
const
{ this->
parent_
->send_packet(buf); }
19
}
// namespace esphome::udp
application.h
esphome::Parented< UDPComponent >::parent_
UDPComponent * parent_
Definition
helpers.h:1872
esphome::packet_transport::PacketTransport::providers_
string_map_t< Provider > providers_
Definition
packet_transport.h:158
esphome::packet_transport::PacketTransport::process_
void process_(std::span< const uint8_t > data)
Process a received packet.
Definition
packet_transport.cpp:420
esphome::udp::UDPTransport::send_packet
void send_packet(const std::vector< uint8_t > &buf) const override
Definition
udp_transport.cpp:18
esphome::udp::UDPTransport::setup
void setup() override
Definition
udp_transport.cpp:11
esphome::udp::UDPTransport::should_send
bool should_send() override
Definition
udp_transport.cpp:10
util.h
log.h
esphome::network::is_connected
ESPHOME_ALWAYS_INLINE bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
Definition
util.h:27
esphome::spi::TAG
const char *const TAG
Definition
spi.cpp:7
esphome::udp
Definition
automation.h:9
udp_transport.h
Generated by
1.12.0