9static const char *
const TAG =
"e131";
10static const int PORT = 5568;
24 int err = this->
socket_->setsockopt(SOL_SOCKET, SO_REUSEADDR, &enable,
sizeof(
int));
26 ESP_LOGW(TAG,
"Socket unable to set reuseaddr: errno %d", err);
29 err = this->
socket_->setblocking(
false);
31 ESP_LOGW(TAG,
"Socket unable to set nonblocking mode: errno %d", err);
40 ESP_LOGW(TAG,
"Socket unable to set sockaddr: errno %d", errno);
47 ESP_LOGW(TAG,
"Socket unable to bind: errno %d", errno);
56 std::vector<uint8_t> payload;
66 memmove(&payload[0], buf,
len);
69 ESP_LOGV(TAG,
"Invalid packet received of size %zu.", payload.size());
73 if (!this->
process_(universe, packet)) {
74 ESP_LOGV(TAG,
"Ignored packet for %d universe of size %d.",
universe, packet.
count);
83 ESP_LOGD(TAG,
"Registering '%s' for universes %d-%d.", light_effect->
get_name().c_str(),
98 ESP_LOGD(TAG,
"Unregistering '%s' for universes %d-%d.", light_effect->
get_name().c_str(),
109 bool handled =
false;
111 ESP_LOGV(TAG,
"Received E1.31 packet for %d universe, with %d bytes",
universe, packet.
count);
114 handled = light_effect->process_(
universe, packet) || handled;
virtual void mark_failed()
Mark this component as failed.
int get_first_universe() const
int get_last_universe() const
void leave_(int universe)
void add_effect(E131AddressableLightEffect *light_effect)
void remove_effect(E131AddressableLightEffect *light_effect)
bool process_(int universe, const E131Packet &packet)
std::unique_ptr< socket::Socket > socket_
std::set< E131AddressableLightEffect * > light_effects_
bool packet_(const std::vector< uint8_t > &data, int &universe, E131Packet &packet)
const std::string & get_name()
std::unique_ptr< Socket > socket_ip(int type, int protocol)
Create a socket in the newest available IP domain (IPv6 or IPv4) of the given type and protocol.
socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t port)
Set a sockaddr to the any address and specified port for the IP version used by socket_ip().
Providing packet encoding functions for exchanging data with a remote host.