Skip to content

Commit 277948c

Browse files
ethernet lib: restore default WebClientRepeating.ino example
1 parent f82e0bc commit 277948c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

libraries/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#include <ZephyrClient.h>
1313
#include "ZephyrEthernet.h"
1414

15+
// assign a MAC address for the Ethernet controller.
16+
// fill in your address here:
17+
byte mac[] = {
18+
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
19+
};
20+
1521
// Set the static IP address to use if the DHCP fails to assign
1622
IPAddress ip(192, 168, 0, 177);
1723
IPAddress myDns(192, 168, 0, 1);
@@ -42,7 +48,7 @@ void setup() {
4248

4349
// start the Ethernet connection:
4450
Serial.println("Initialize Ethernet with DHCP:");
45-
if (Ethernet.begin() == 0) {
51+
if (Ethernet.begin(mac) == 0) {
4652
Serial.println("Failed to configure Ethernet using DHCP");
4753
// Check for Ethernet hardware present
4854
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
@@ -54,8 +60,8 @@ void setup() {
5460
if (Ethernet.linkStatus() == LinkOFF) {
5561
Serial.println("Ethernet cable is not connected.");
5662
}
57-
// try to congifure using IP address instead of DHCP:
58-
Ethernet.begin(ip, myDns);
63+
// try to configure using IP address instead of DHCP:
64+
Ethernet.begin(mac, ip, myDns);
5965
Serial.print("My IP address: ");
6066
Serial.println(Ethernet.localIP());
6167
} else {
@@ -86,7 +92,7 @@ void loop() {
8692
// this method makes a HTTP connection to the server:
8793
void httpRequest() {
8894
// close any connection before send a new request.
89-
// This will free the socket on the WiFi shield
95+
// This will free the socket on the Ethernet shield
9096
client.stop();
9197

9298
// if there's a successful connection:
@@ -105,8 +111,4 @@ void httpRequest() {
105111
// if you couldn't make a connection:
106112
Serial.println("connection failed");
107113
}
108-
}
109-
110-
111-
112-
114+
}

0 commit comments

Comments
 (0)