Skip to content

Commit 3ad4f98

Browse files
committed
Merge branch 'hd_2.7' of github.com:arduino/wifishield into hd_2.7
2 parents a5c38d1 + b2a8a47 commit 3ad4f98

File tree

13 files changed

+160
-94
lines changed

13 files changed

+160
-94
lines changed

WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
1010
created 13 July 2010
1111
by dlf (Metodo2 srl)
12-
modified 29 Feb 2012
13-
by Scott Fitzgerald
12+
modified 31 May 2012
13+
by Tom Igoe
1414
*/
1515
#include <WiFi.h>
1616

@@ -20,23 +20,28 @@ int status = WL_IDLE_STATUS; // the Wifi radio's status
2020
void setup() {
2121
// initialize serial:
2222
Serial.begin(9600);
23-
24-
// attempt to connect to an open network:
25-
Serial.print("Attempting to connect to open network: ");
26-
Serial.println(ssid);
27-
status = WiFi.begin(ssid);
28-
29-
// if you're not connected, stop here:
30-
if ( status != WL_CONNECTED) {
31-
Serial.println("Couldn't get a wifi connection");
23+
24+
// check for the presence of the shield:
25+
if (WiFi.status() == WL_NO_SHIELD) {
26+
Serial.println("WiFi shield not present");
27+
// don't continue:
3228
while(true);
3329
}
34-
// if you are connected :
35-
else {
36-
Serial.print("You're connected to the network");
37-
printCurrentNet();
38-
printWifiData();
30+
31+
// attempt to connect to Wifi network:
32+
while ( status != WL_CONNECTED) {
33+
Serial.print("Attempting to connect to open SSID: ");
34+
Serial.println(ssid);
35+
status = WiFi.begin(ssid);
36+
37+
// wait 10 seconds for connection:
38+
delay(10000);
3939
}
40+
41+
// you're connected now, so print out the data:
42+
Serial.print("You're connected to the network");
43+
printCurrentNet();
44+
printWifiData();
4045
}
4146

4247
void loop() {

WiFi/examples/ConnectWithWEP/ConnectWithWEP.ino

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
created 13 July 2010
2121
by dlf (Metodo2 srl)
22-
modified 4 Mar 2012
22+
modified 31 May 2012
2323
by Tom Igoe
2424
*/
2525
#include <WiFi.h>
@@ -33,22 +33,27 @@ void setup() {
3333
// initialize serial:
3434
Serial.begin(9600);
3535

36-
// attempt to connect to an open network:
37-
Serial.print("Attempting to connect to WEP network: ");
38-
Serial.println(ssid);
39-
status = WiFi.begin(ssid, keyIndex, key);
40-
41-
// if you're not connected, stop here:
42-
if ( status != WL_CONNECTED) {
43-
Serial.println("Couldn't get a wifi connection");
36+
// check for the presence of the shield:
37+
if (WiFi.status() == WL_NO_SHIELD) {
38+
Serial.println("WiFi shield not present");
39+
// don't continue:
4440
while(true);
4541
}
46-
// if you are connected :
47-
else {
48-
Serial.print("You're connected to the network");
49-
printCurrentNet();
50-
printWifiData();
42+
43+
// attempt to connect to Wifi network:
44+
while ( status != WL_CONNECTED) {
45+
Serial.print("Attempting to connect to WEP network, SSID: ");
46+
Serial.println(ssid);
47+
status = WiFi.begin(ssid, keyIndex, key);
48+
49+
// wait 10 seconds for connection:
50+
delay(10000);
5151
}
52+
53+
// once you are connected :
54+
Serial.print("You're connected to the network");
55+
printCurrentNet();
56+
printWifiData();
5257
}
5358

5459
void loop() {
@@ -60,7 +65,7 @@ void loop() {
6065
void printWifiData() {
6166
// print your WiFi shield's IP address:
6267
IPAddress ip = WiFi.localIP();
63-
Serial.print("IP Address: ");
68+
Serial.print("IP Address: ");
6469
Serial.println(ip);
6570
Serial.println(ip);
6671

@@ -115,3 +120,4 @@ void printCurrentNet() {
115120
}
116121

117122

123+

WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,42 @@
99
1010
created 13 July 2010
1111
by dlf (Metodo2 srl)
12-
modified 29 Feb 2012
13-
by Scott Fitzgerald
12+
modified 31 May 2012
13+
by Tom Igoe
1414
*/
1515
#include <WiFi.h>
1616

17-
char ssid[] = "networkName"; // your network SSID (name)
18-
char pass[] = "yourPassword"; // your network password
17+
char ssid[] = "yourNetwork"; // your network SSID (name)
18+
char pass[] = "secretPassword"; // your network password
1919
int status = WL_IDLE_STATUS; // the Wifi radio's status
2020

2121
void setup() {
2222
// initialize serial:
2323
Serial.begin(9600);
24-
25-
// attempt to connect to an open network:
26-
Serial.print("Attempting to connect to WPA network: ");
27-
Serial.println(ssid);
28-
status = WiFi.begin(ssid, pass);
2924

30-
// if you're not connected, stop here:
31-
if ( status != WL_CONNECTED) {
32-
Serial.println("Couldn't get a wifi connection");
25+
// check for the presence of the shield:
26+
if (WiFi.status() == WL_NO_SHIELD) {
27+
Serial.println("WiFi shield not present");
28+
// don't continue:
3329
while(true);
3430
}
35-
// if you are connected :
36-
else {
37-
Serial.print("You're connected to the network");
38-
printCurrentNet();
39-
printWifiData();
31+
32+
// attempt to connect to Wifi network:
33+
while ( status != WL_CONNECTED) {
34+
Serial.print("Attempting to connect to WPA SSID: ");
35+
Serial.println(ssid);
36+
// Connect to WPA/WPA2 network:
37+
status = WiFi.begin(ssid, pass);
38+
39+
// wait 10 seconds for connection:
40+
delay(10000);
4041
}
42+
43+
// you're connected now, so print out the data:
44+
Serial.print("You're connected to the network");
45+
printCurrentNet();
46+
printWifiData();
47+
4148
}
4249

4350
void loop() {

WiFi/examples/ScanNetworks/ScanNetworks.ino

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
created 13 July 2010
1212
by dlf (Metodo2 srl)
13-
modified 22 April 2012
13+
modified 31 May 2012
1414
by Tom Igoe
1515
*/
1616

@@ -21,9 +21,15 @@
2121
void setup() {
2222
// initialize serial and wait for the port to open:
2323
Serial.begin(9600);
24-
25-
// attempt to connect using WEP encryption:
26-
Serial.println("Initializing Wifi...");
24+
25+
// check for the presence of the shield:
26+
if (WiFi.status() == WL_NO_SHIELD) {
27+
Serial.println("WiFi shield not present");
28+
// don't continue:
29+
while(true);
30+
}
31+
32+
// Print WiFi MAC address:
2733
printMacAddress();
2834

2935
// scan for existing networks:

WiFi/examples/WifiChatServer/WifiChatServer.ino

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
1515
created 18 Dec 2009
1616
by David A. Mellis
17-
modified 23 Apr 2012
17+
modified 31 May 2012
1818
by Tom Igoe
1919
2020
*/
2121

2222
#include <SPI.h>
2323
#include <WiFi.h>
2424

25-
char ssid[] = "YourNetwork"; // your network SSID (name)
26-
char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)
25+
char ssid[] = "yourNetwork"; // your network SSID (name)
26+
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
2727

2828
int keyIndex = 0; // your network key Index number (needed only for WEP)
2929

@@ -36,16 +36,21 @@ boolean alreadyConnected = false; // whether or not the client was connected pre
3636
void setup() {
3737
// start serial port:
3838
Serial.begin(9600);
39-
39+
40+
// check for the presence of the shield:
41+
if (WiFi.status() == WL_NO_SHIELD) {
42+
Serial.println("WiFi shield not present");
43+
// don't continue:
44+
while(true);
45+
}
46+
4047
// attempt to connect to Wifi network:
4148
while ( status != WL_CONNECTED) {
4249
Serial.print("Attempting to connect to SSID: ");
4350
Serial.println(ssid);
51+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
4452
status = WiFi.begin(ssid, pass);
45-
if ( status != WL_CONNECTED) {
46-
Serial.println("Couldn't get a wifi connection");
47-
while(true);
48-
}
53+
4954
// wait 10 seconds for connection:
5055
delay(10000);
5156
}

WiFi/examples/WifiCosmClient/WifiCosmClient.ino

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Wifi shield attached to pins 10, 11, 12, 13
1717
1818
created 13 Mar 2012
19-
modified 14 May 2012
19+
modified 31 May 2012
2020
by Tom Igoe
2121
2222
This code is in the public domain.
@@ -49,15 +49,20 @@ void setup() {
4949
// start serial port:
5050
Serial.begin(9600);
5151

52+
// check for the presence of the shield:
53+
if (WiFi.status() == WL_NO_SHIELD) {
54+
Serial.println("WiFi shield not present");
55+
// don't continue:
56+
while(true);
57+
}
58+
5259
// attempt to connect to Wifi network:
5360
while ( status != WL_CONNECTED) {
5461
Serial.print("Attempting to connect to SSID: ");
5562
Serial.println(ssid);
63+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
5664
status = WiFi.begin(ssid, pass);
57-
if ( status != WL_CONNECTED) {
58-
Serial.println("Couldn't get a wifi connection");
59-
while(true);
60-
}
65+
6166
// wait 10 seconds for connection:
6267
delay(10000);
6368
}

WiFi/examples/WifiCosmClientString/WifiCosmClientString.ino

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Wifi shield attached to pins 10, 11, 12, 13
2020
2121
created 16 Mar 2012
22-
modified 14 May 2012
22+
modified 31 May 2012
2323
by Tom Igoe
2424
2525
This code is in the public domain.
@@ -53,16 +53,21 @@ const unsigned long postingInterval = 10*1000; //delay between updates to cosm.
5353
void setup() {
5454
// start serial port:
5555
Serial.begin(9600);
56-
56+
57+
// check for the presence of the shield:
58+
if (WiFi.status() == WL_NO_SHIELD) {
59+
Serial.println("WiFi shield not present");
60+
// don't continue:
61+
while(true);
62+
}
63+
5764
// attempt to connect to Wifi network:
5865
while ( status != WL_CONNECTED) {
5966
Serial.print("Attempting to connect to SSID: ");
6067
Serial.println(ssid);
68+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
6169
status = WiFi.begin(ssid, pass);
62-
if ( status != WL_CONNECTED) {
63-
Serial.println("Couldn't get a wifi connection");
64-
while(true);
65-
}
70+
6671
// wait 10 seconds for connection:
6772
delay(10000);
6873
}

WiFi/examples/WifiTwitterClient/WifiTwitterClient.ino

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* WiFi shield attached to pins 10, 11, 12, 13
1515
1616
created 23 apr 2012
17+
modified 31 May 2012
1718
by Tom Igoe
1819
1920
This code is in the public domain.
@@ -22,7 +23,7 @@
2223
#include <SPI.h>
2324
#include <WiFi.h>
2425

25-
char ssid[] = "YourNetwork"; // your network SSID (name)
26+
char ssid[] = "yourNetwork"; // your network SSID (name)
2627
char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)
2728
int keyIndex = 0; // your network key Index number (needed only for WEP)
2829

@@ -51,16 +52,21 @@ void setup() {
5152
tweet.reserve(150);
5253
// start serial port:
5354
Serial.begin(9600);
54-
55+
56+
// check for the presence of the shield:
57+
if (WiFi.status() == WL_NO_SHIELD) {
58+
Serial.println("WiFi shield not present");
59+
// don't continue:
60+
while(true);
61+
}
62+
5563
// attempt to connect to Wifi network:
5664
while ( status != WL_CONNECTED) {
5765
Serial.print("Attempting to connect to SSID: ");
5866
Serial.println(ssid);
59-
status = WiFi.begin(ssid, pass);
60-
if ( status != WL_CONNECTED) {
61-
Serial.println("Couldn't get a wifi connection");
62-
while(true);
63-
}
67+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
68+
status = WiFi.begin(ssid, pass);
69+
6470
// wait 10 seconds for connection:
6571
delay(10000);
6672
}

0 commit comments

Comments
 (0)