diff --git a/.github/workflows/PlatformIO.yml b/.github/workflows/PlatformIO.yml index ded4276..cb86c1f 100644 --- a/.github/workflows/PlatformIO.yml +++ b/.github/workflows/PlatformIO.yml @@ -24,6 +24,6 @@ jobs: run: pip install --upgrade platformio - name: Build examples - run: pio ci --lib="." --board=${{ matrix.example[0] }} + run: pio ci --lib="." --lib="Ethernet" --board=${{ matrix.example[0] }} env: PLATFORMIO_CI_SRC: ${{ matrix.example[1] }} diff --git a/examples/WakeOnLan-ESP32-Ethernet/WakeOnLan-ESP32-Ethernet.ino b/examples/WakeOnLan-ESP32-Ethernet/WakeOnLan-ESP32-Ethernet.ino index 4095ffe..354d76f 100644 --- a/examples/WakeOnLan-ESP32-Ethernet/WakeOnLan-ESP32-Ethernet.ino +++ b/examples/WakeOnLan-ESP32-Ethernet/WakeOnLan-ESP32-Ethernet.ino @@ -1,4 +1,5 @@ -#include +#include +#include #include #include @@ -6,9 +7,6 @@ EthernetUdp UDP; WakeOnLan WOL(UDP); -const char* ssid = "your-ssid"; -const char* password = "your-password"; - void wakeMyPC() { const char *MACAddress = "01:23:45:67:89:AB"; @@ -24,19 +22,19 @@ void wakeOfficePC() { // WOL.sendSecureMagicPacket(MACAddress, secureOn, 7); // Change the port number } -void setup() -{ +void setup() { WOL.setRepeat(3, 100); // Optional, repeat the packet three times with 100ms between. WARNING delay() is used between send packet function. - WiFi.mode(WIFI_STA); - WiFi.begin(ssid, password); + // the media access control (ethernet hardware) address for the shield: + byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; + Ethernet.begin(mac); - while (WiFi.status() != WL_CONNECTED) { + while (Ethernet.linkStatus() != LinkON) { delay(500); Serial.print("."); } - WOL.calculateBroadcastAddress(WiFi.localIP(), WiFi.subnetMask()); // Optional => To calculate the broadcast address, otherwise 255.255.255.255 is used (which is denied in some networks). + WOL.calculateBroadcastAddress(Ethernet.localIP(), Ethernet.subnetMask()); // Optional => To calculate the broadcast address, otherwise 255.255.255.255 is used (which is denied in some networks). wakeMyPC(); wakeOfficePC(); @@ -45,4 +43,5 @@ void setup() void loop() { + Ethernet.maintain(); }