13#include <lwip/ip4_addr.h>
14#include <lwip/ip_addr.h>
20static const uint8_t ACN_ID[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00};
23static const uint8_t VECTOR_DMP = 2;
29 uint16_t preamble_size;
30 uint16_t postamble_size;
32 uint16_t root_flength;
37 uint16_t frame_flength;
39 uint8_t source_name[64];
42 uint8_t sequence_number;
50 uint16_t first_address;
51 uint16_t address_increment;
52 uint16_t property_value_count;
84 err = igmp_joingroup(IP4_ADDR_ANY4, &multicast_addr);
88 ESP_LOGW(TAG,
"IGMP join for %d universe of E1.31 failed. Multicast might not work.",
universe);
90 ESP_LOGD(TAG,
"Joined %d universe for E1.31.",
universe);
105 if (consumer !=
nullptr) {
106 if (consumer->consumers++ > 0) {
117 ESP_LOGD(TAG,
"IGMP join for %d universe of E1.31 deferred until the network is up.",
universe);
126 if (consumer ==
nullptr)
129 if (--consumer->consumers > 0) {
137 igmp_leavegroup(IP4_ADDR_ANY4, &multicast_addr);
140 ESP_LOGD(TAG,
"Left %d universe for E1.31.",
universe);
147 auto *sbuff =
reinterpret_cast<const E131RawPacket *
>(data);
149 if (memcmp(sbuff->acn_id, ACN_ID,
sizeof(sbuff->acn_id)) != 0)
151 if (htonl(sbuff->root_vector) != VECTOR_ROOT)
153 if (htonl(sbuff->frame_vector) != VECTOR_FRAME)
155 if (sbuff->dmp_vector != VECTOR_DMP)
157 if (sbuff->property_values[0] != 0)
161 packet.
count = htons(sbuff->property_value_count);
165 memcpy(packet.
values, sbuff->property_values, packet.
count);
Helper class to lock the lwIP TCPIP core when making lwIP API calls from non-TCPIP threads.
void join_universe_(uint16_t universe)
void leave_(int universe)
E131ListenMethod listen_method_
bool packet_(const uint8_t *data, size_t len, int &universe, E131Packet &packet)
std::unique_ptr< socket::UDPSocket > socket_
UniverseConsumer * find_universe_(int universe)
std::vector< UniverseConsumer > universe_consumers_
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
uint8_t property_values[E131_MAX_PROPERTY_VALUES_COUNT]
struct in_addr ip4_addr_t
const int E131_MAX_PROPERTY_VALUES_COUNT
const size_t E131_MIN_PACKET_SIZE
ESPHOME_LOG_TAG(TAG, "e131")
ESPHOME_ALWAYS_INLINE bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
uint8_t values[E131_MAX_PROPERTY_VALUES_COUNT]