ESPHome 2025.5.0
Loading...
Searching...
No Matches
udp_transport.cpp
Go to the documentation of this file.
1#include "esphome/core/log.h"
4#include "udp_transport.h"
5
6namespace esphome {
7namespace udp {
8
9static const char *const TAG = "udp_transport";
10
13 PacketTransport::setup();
15#ifdef USE_SENSOR
16 this->should_broadcast_ |= !this->sensors_.empty();
17#endif
18#ifdef USE_BINARY_SENSOR
19 this->should_broadcast_ |= !this->binary_sensors_.empty();
20#endif
21 if (this->should_broadcast_)
22 this->parent_->set_should_broadcast();
23 if (!this->providers_.empty() || this->is_encrypted_()) {
24 this->parent_->add_listener([this](std::vector<uint8_t> &buf) { this->process_(buf); });
25 }
26}
27
29 PacketTransport::update();
30 this->updated_ = true;
31 this->resend_data_ = this->should_broadcast_;
32}
33
34void UDPTransport::send_packet(const std::vector<uint8_t> &buf) const { this->parent_->send_packet(buf); }
35} // namespace udp
36} // namespace esphome
std::vector< BinarySensor > binary_sensors_
void process_(const std::vector< uint8_t > &data)
Process a received packet.
std::map< std::string, Provider > providers_
void send_packet(const std::vector< uint8_t > &buf) const override
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
Definition util.cpp:15
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7