Skip to content

Commit 8ffa971

Browse files
committed
Merge branch 'new-extension' of github.com:arduino/Arduino into diskloader_reboot
Conflicts: hardware/arduino/variants/mega/pins_arduino.h libraries/Ethernet/examples/PachubeClient/PachubeClient.ino libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
2 parents fee7de8 + 7eddea6 commit 8ffa971

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

examples/PachubeClient/PachubeClient.ino

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Ethernet shield attached to pins 10, 11, 12, 13
1212
1313
created 15 March 2010
14-
updated 4 Sep 2010
14+
updated 26 Oct 2011
1515
by Tom Igoe
1616
1717
http://www.tigoe.net/pcomp/code/category/arduinowiring/873
@@ -23,34 +23,32 @@
2323
#include <Ethernet.h>
2424

2525
// assign a MAC address for the ethernet controller.
26+
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
2627
// fill in your address here:
2728
byte mac[] = {
2829
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
29-
// assign an IP address for the controller:
30-
byte ip[] = {
31-
192,168,1,20 };
32-
byte gateway[] = {
33-
192,168,1,1};
34-
byte subnet[] = {
35-
255, 255, 255, 0 };
36-
37-
// The address of the server you want to connect to (pachube.com):
38-
byte server[] = {
39-
173,203,98,29 };
4030

31+
// fill in an available IP address on your network here,
32+
// for manual configuration:
33+
IPAddress ip(10,0,1,20);
4134
// initialize the library instance:
42-
Client client(server, 80);
35+
EthernetClient client;
4336

4437
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
4538
boolean lastConnected = false; // state of the connection last time through the main loop
4639
const int postingInterval = 10000; //delay between updates to Pachube.com
4740

4841
void setup() {
49-
// start the ethernet connection and serial port:
50-
Ethernet.begin(mac, ip);
42+
// start serial port:
5143
Serial.begin(9600);
5244
// give the ethernet module time to boot up:
5345
delay(1000);
46+
// start the Ethernet connection:
47+
if (Ethernet.begin(mac) == 0) {
48+
Serial.println("Failed to configure Ethernet using DHCP");
49+
// Configure manually:
50+
Ethernet.begin(mac, ip);
51+
}
5452
}
5553

5654
void loop() {
@@ -86,7 +84,7 @@ void loop() {
8684
// this method makes a HTTP connection to the server:
8785
void sendData(int thisData) {
8886
// if there's a successful connection:
89-
if (client.connect()) {
87+
if (client.connect("www.pachube.com", 80)) {
9088
Serial.println("connecting...");
9189
// send the HTTP PUT request.
9290
// fill in your feed address here:

examples/PachubeClientString/PachubeClientString.ino

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Ethernet shield attached to pins 10, 11, 12, 13
1515
1616
created 15 March 2010
17-
updated 4 Sep 2010
17+
updated 26 Oct 2011
1818
by Tom Igoe
1919
2020
This code is in the public domain.
@@ -28,31 +28,28 @@
2828
// fill in your address here:
2929
byte mac[] = {
3030
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
31-
// assign an IP address for the controller:
32-
byte ip[] = {
33-
192,168,1,20 };
34-
byte gateway[] = {
35-
192,168,1,1};
36-
byte subnet[] = {
37-
255, 255, 255, 0 };
38-
39-
// The address of the server you want to connect to (pachube.com):
40-
byte server[] = {
41-
173,203,98,29 };
31+
// fill in an available IP address on your network here,
32+
// for manual configuration:
33+
IPAddress ip(10,0,1,20);
4234

4335
// initialize the library instance:
44-
Client client(server, 80);
36+
EthernetClient client;
4537

4638
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
4739
boolean lastConnected = false; // state of the connection last time through the main loop
4840
const int postingInterval = 10000; //delay between updates to Pachube.com
4941

5042
void setup() {
51-
// start the ethernet connection and serial port:
52-
Ethernet.begin(mac, ip);
43+
// start serial port:
5344
Serial.begin(9600);
5445
// give the ethernet module time to boot up:
5546
delay(1000);
47+
// start the Ethernet connection:
48+
if (Ethernet.begin(mac) == 0) {
49+
Serial.println("Failed to configure Ethernet using DHCP");
50+
// Configure manually:
51+
Ethernet.begin(mac, ip);
52+
}
5653
}
5754

5855
void loop() {
@@ -96,7 +93,7 @@ void loop() {
9693
// this method makes a HTTP connection to the server:
9794
void sendData(String thisData) {
9895
// if there's a successful connection:
99-
if (client.connect()) {
96+
if (client.connect("www.pachube.com", 80)) {
10097
Serial.println("connecting...");
10198
// send the HTTP PUT request.
10299
// fill in your feed address here:

0 commit comments

Comments
 (0)