mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Modified Pachube examples to use manual Ethernet config if DCHP fails.
This commit is contained in:
parent
6a68361a14
commit
d16eeb0af3
@ -11,7 +11,7 @@
|
||||
* Ethernet shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 15 March 2010
|
||||
updated 4 Sep 2010
|
||||
updated 26 Oct 2011
|
||||
by Tom Igoe
|
||||
|
||||
http://www.tigoe.net/pcomp/code/category/arduinowiring/873
|
||||
@ -28,6 +28,9 @@
|
||||
byte mac[] = {
|
||||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
|
||||
// fill in an available IP address on your network here,
|
||||
// for manual configuration:
|
||||
IPAddress ip(10,0,1,20);
|
||||
// initialize the library instance:
|
||||
EthernetClient client;
|
||||
|
||||
@ -38,15 +41,14 @@ const int postingInterval = 10000; //delay between updates to Pachube.com
|
||||
void setup() {
|
||||
// start serial port:
|
||||
Serial.begin(9600);
|
||||
// give the ethernet module time to boot up:
|
||||
delay(1000);
|
||||
// start the Ethernet connection:
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// no point in carrying on, so do nothing forevermore:
|
||||
for(;;)
|
||||
;
|
||||
// Configure manually:
|
||||
Ethernet.begin(mac, ip);
|
||||
}
|
||||
// give the ethernet module time to boot up:
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Ethernet shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 15 March 2010
|
||||
updated 4 Sep 2010
|
||||
updated 26 Oct 2011
|
||||
by Tom Igoe
|
||||
|
||||
This code is in the public domain.
|
||||
@ -28,6 +28,9 @@
|
||||
// fill in your address here:
|
||||
byte mac[] = {
|
||||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
// fill in an available IP address on your network here,
|
||||
// for manual configuration:
|
||||
IPAddress ip(10,0,1,20);
|
||||
|
||||
// initialize the library instance:
|
||||
EthernetClient client;
|
||||
@ -37,16 +40,16 @@ boolean lastConnected = false; // state of the connection last time through
|
||||
const int postingInterval = 10000; //delay between updates to Pachube.com
|
||||
|
||||
void setup() {
|
||||
// start the ethernet connection and serial port:
|
||||
// start serial port:
|
||||
Serial.begin(9600);
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// no point in carrying on, so do nothing forevermore:
|
||||
for(;;)
|
||||
;
|
||||
}
|
||||
// give the ethernet module time to boot up:
|
||||
delay(1000);
|
||||
// start the Ethernet connection:
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// Configure manually:
|
||||
Ethernet.begin(mac, ip);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user