12
12
#include < ZephyrClient.h>
13
13
#include " ZephyrEthernet.h"
14
14
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
+
15
21
// Set the static IP address to use if the DHCP fails to assign
16
22
IPAddress ip (192 , 168 , 0 , 177 );
17
23
IPAddress myDns (192 , 168 , 0 , 1 );
@@ -42,7 +48,7 @@ void setup() {
42
48
43
49
// start the Ethernet connection:
44
50
Serial.println (" Initialize Ethernet with DHCP:" );
45
- if (Ethernet.begin () == 0 ) {
51
+ if (Ethernet.begin (mac ) == 0 ) {
46
52
Serial.println (" Failed to configure Ethernet using DHCP" );
47
53
// Check for Ethernet hardware present
48
54
if (Ethernet.hardwareStatus () == EthernetNoHardware) {
@@ -54,8 +60,8 @@ void setup() {
54
60
if (Ethernet.linkStatus () == LinkOFF) {
55
61
Serial.println (" Ethernet cable is not connected." );
56
62
}
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);
59
65
Serial.print (" My IP address: " );
60
66
Serial.println (Ethernet.localIP ());
61
67
} else {
@@ -86,7 +92,7 @@ void loop() {
86
92
// this method makes a HTTP connection to the server:
87
93
void httpRequest () {
88
94
// 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
90
96
client.stop ();
91
97
92
98
// if there's a successful connection:
@@ -105,8 +111,4 @@ void httpRequest() {
105
111
// if you couldn't make a connection:
106
112
Serial.println (" connection failed" );
107
113
}
108
- }
109
-
110
-
111
-
112
-
114
+ }
0 commit comments