forkineye / ESPAsyncE131

Asynchronous E1.31 (sACN) library for Arduino ESP8266 and ESP32
123 stars 28 forks source link

Adding non-sequential universes in multicast #10

Open TyIsI opened 4 years ago

TyIsI commented 4 years ago

Hi,

I'm currently working on functionality to add additional universes at runtime. Would you be interested in receiving a PR for this and if so, do you have preference for a particular naming convention?

Cheers

push-pop commented 3 years ago

hi @TyIsI I am currently working on trying to add multi-universe multicast support for my WLED setup. Wondering if your code is somewhere I could look at? Or have any tips?

TyIsI commented 2 years ago

This is what I've added:

/////////////////////////////////////////////////////////
//
// Add and remove additional universes - Public
//
/////////////////////////////////////////////////////////

void ESPAsyncE131::addUniverse(uint16_t universe)
{
    delay(100);

    ip4_addr_t ifaddr;
    ip4_addr_t multicast_addr;

    ifaddr.addr = static_cast<uint32_t>(WiFi.localIP());
    multicast_addr.addr = static_cast<uint32_t>(IPAddress(239, 255,
                                                          ((universe >> 8) & 0xff), ((universe >> 0) & 0xff)));
    igmp_joingroup(&ifaddr, &multicast_addr);
}

void ESPAsyncE131::removeUniverse(uint16_t universe)
{
    delay(100);

    ip4_addr_t ifaddr;
    ip4_addr_t multicast_addr;

    ifaddr.addr = static_cast<uint32_t>(WiFi.localIP());
    multicast_addr.addr = static_cast<uint32_t>(IPAddress(239, 255,
                                                          ((universe >> 8) & 0xff), ((universe >> 0) & 0xff)));
    igmp_leavegroup(&ifaddr, &multicast_addr);
}