9 static const char *
const TAG =
"e131";
10 static 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;
61 ssize_t
len = this->
socket_->read(buf,
sizeof(buf));
66 memmove(&payload[0], buf, len);
68 if (!this->
packet_(payload, universe, packet)) {
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;
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...
bool packet_(const std::vector< uint8_t > &data, int &universe, E131Packet &packet)
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().
bool process_(int universe, const E131Packet &packet)
std::unique_ptr< socket::Socket > socket_
int get_last_universe() const
const std::string & get_name()
void leave_(int universe)
std::set< E131AddressableLightEffect * > light_effects_
int get_first_universe() const
void add_effect(E131AddressableLightEffect *light_effect)
void remove_effect(E131AddressableLightEffect *light_effect)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.