10 #include <lwip/ip4_addr.h> 11 #include <lwip/ip_addr.h> 16 static const char *
const TAG =
"e131";
18 static const uint8_t ACN_ID[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00};
19 static const uint32_t VECTOR_ROOT = 4;
20 static const uint32_t VECTOR_FRAME = 2;
21 static const uint8_t VECTOR_DMP = 2;
59 const size_t E131_MIN_PACKET_SIZE =
reinterpret_cast<size_t>(&((E131RawPacket *)
nullptr)->property_values[1]);
64 if (this->socket_ ==
nullptr)
67 for (
auto universe : universe_consumers_) {
74 auto err = igmp_joingroup(IP4_ADDR_ANY4, &multicast_addr);
77 ESP_LOGW(TAG,
"IGMP join for %d universe of E1.31 failed. Multicast might not work.",
universe.first);
86 auto consumers = ++universe_consumers_[
universe];
92 if (join_igmp_groups_()) {
93 ESP_LOGD(TAG,
"Joined %d universe for E1.31.", universe);
98 auto consumers = --universe_consumers_[
universe];
107 igmp_leavegroup(IP4_ADDR_ANY4, &multicast_addr);
110 ESP_LOGD(TAG,
"Left %d universe for E1.31.", universe);
117 auto *sbuff =
reinterpret_cast<const E131RawPacket *
>(&data[0]);
119 if (memcmp(sbuff->acn_id, ACN_ID,
sizeof(sbuff->acn_id)) != 0)
121 if (htonl(sbuff->root_vector) != VECTOR_ROOT)
123 if (htonl(sbuff->frame_vector) != VECTOR_FRAME)
125 if (sbuff->dmp_vector != VECTOR_DMP)
127 if (sbuff->property_values[0] != 0)
130 universe = htons(sbuff->universe);
131 packet.
count = htons(sbuff->property_value_count);
bool packet_(const std::vector< uint8_t > &data, int &universe, E131Packet &packet)
uint8_t values[E131_MAX_PROPERTY_VALUES_COUNT]
uint16_t address_increment
const int E131_MAX_PROPERTY_VALUES_COUNT
enum esphome::EntityCategory __attribute__
uint16_t property_value_count
uint8_t property_values[E131_MAX_PROPERTY_VALUES_COUNT]
void leave_(int universe)
Implementation of SPI Controller mode.
const size_t E131_MIN_PACKET_SIZE