diff --git a/Artnet.cpp b/Artnet.cpp index 419819c..1a6e32b 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -35,6 +35,28 @@ void Artnet::begin(byte mac[], byte ip[]) Udp.begin(ART_NET_PORT); } +void Artnet::begin(byte mac[],bool setBroadcast) +{ + + #if !defined(ARDUINO_SAMD_ZERO) && !defined(ESP8266) && !defined(ESP32) + Serial.println("Attempt to assign IP by DHCP"); + if(Ethernet.begin(mac)!=0){ + Serial.print(" DHCP assigned IP "); + Serial.println(Ethernet.localIP()); + // Artnet Begin + Udp.begin(ART_NET_PORT); + if(setBroadcast){ + setBroadcastAuto(Ethernet.localIP(),Ethernet.subnetMask()); + Serial.print(" Broadcast IP "); + Serial.println(getBroadcastIP()); + + } + }else{ + Serial.println("Failed to assign ip through DHCP"); + } + #endif + +} void Artnet::begin() { Udp.begin(ART_NET_PORT); diff --git a/Artnet.h b/Artnet.h index 8ccea96..ce31d4e 100755 --- a/Artnet.h +++ b/Artnet.h @@ -37,6 +37,9 @@ THE SOFTWARE. #include #include #else + #ifdef ARDUINO_ARCH_RP2040 + #include + #endif #include #include #endif @@ -98,6 +101,7 @@ class Artnet Artnet(); void begin(byte mac[], byte ip[]); + void begin(byte mac[],bool setBroadcast); void begin(); void setBroadcastAuto(IPAddress ip, IPAddress sn); void setBroadcast(byte bc[]); @@ -147,6 +151,11 @@ class Artnet artSyncCallback = fptr; } + inline IPAddress getBroadcastIP(void) + { + return broadcast; + } + private: uint8_t node_ip_address[4]; uint8_t id[8];