From d16eeb0af3eb3e23202de663a09ca44434c738e9 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 26 Oct 2011 13:22:30 -0400 Subject: [PATCH] Modified Pachube examples to use manual Ethernet config if DCHP fails. --- .../examples/PachubeClient/PachubeClient.ino | 14 ++++++++------ .../PachubeClientString.ino | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino index e626113b0..8f405e7af 100644 --- a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino +++ b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino @@ -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() { diff --git a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino index 4b97c4175..4a03100f2 100644 --- a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino +++ b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino @@ -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() {