Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dhcp support and rp2040 support #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Artnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions Artnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ THE SOFTWARE.
#include <WiFi.h>
#include <WiFiUdp.h>
#else
#ifdef ARDUINO_ARCH_RP2040
#include <EthernetClient.h>
#endif
#include <Ethernet.h>
#include <EthernetUdp.h>
#endif
Expand Down Expand Up @@ -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[]);
Expand Down Expand Up @@ -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];
Expand Down