11/*
2-
3- This example connects to a WEP-encrypted Wifi network.
2+
3+ This example connects to a WEP-encrypted Wifi network.
44 Then it prints the MAC address of the Wifi shield,
55 the IP address obtained, and other network details.
6-
7- If you use 40-bit WEP, you need a key that is 10 characters long,
8- and the characters must be hexadecimal (0-9 or A-F).
9- e.g. for 40-bit, ABBADEAF01 will work, but ABBADEAF won't work
10- (too short) and ABBAISDEAF won't work (I and S are not
11- hexadecimal characters).
12-
13- For 128-bit, you need a string that is 26 characters long.
14- D0D0DEADF00DABBADEAFBEADED will work because it's 26 characters,
6+
7+ If you use 40-bit WEP, you need a key that is 10 characters long,
8+ and the characters must be hexadecimal (0-9 or A-F).
9+ e.g. for 40-bit, ABBADEAF01 will work, but ABBADEAF won't work
10+ (too short) and ABBAISDEAF won't work (I and S are not
11+ hexadecimal characters).
12+
13+ For 128-bit, you need a string that is 26 characters long.
14+ D0D0DEADF00DABBADEAFBEADED will work because it's 26 characters,
1515 all in the 0-9, A-F range.
16-
16+
1717 Circuit:
1818 * WiFi shield attached
19-
19+
2020 created 13 July 2010
2121 by dlf (Metodo2 srl)
2222 modified 31 May 2012
2323 by Tom Igoe
2424 */
25+ #include < SPI.h>
2526#include < WiFi.h>
2627
27- char ssid[] = " yourNetwork" ; // your network SSID (name)
28+ char ssid[] = " yourNetwork" ; // your network SSID (name)
2829char key[] = " D0D0DEADF00DABBADEAFBEADED" ; // your network key
2930int keyIndex = 0 ; // your network key Index number
3031int status = WL_IDLE_STATUS; // the Wifi radio's status
3132
3233void setup () {
3334 // Initialize serial and wait for port to open:
34- Serial.begin (9600 );
35+ Serial.begin (9600 );
3536 while (!Serial) {
3637 ; // wait for serial port to connect. Needed for Leonardo only
3738 }
3839
3940 // check for the presence of the shield:
4041 if (WiFi.status () == WL_NO_SHIELD) {
41- Serial.println (" WiFi shield not present" );
42+ Serial.println (" WiFi shield not present" );
4243 // don't continue:
43- while (true );
44- }
44+ while (true );
45+ }
46+
47+ String fv = WiFi.firmwareVersion ();
48+ if ( fv != " 1.1.0" )
49+ Serial.println (" Please upgrade the firmware" );
4550
4651 // attempt to connect to Wifi network:
47- while ( status != WL_CONNECTED) {
52+ while ( status != WL_CONNECTED) {
4853 Serial.print (" Attempting to connect to WEP network, SSID: " );
4954 Serial.println (ssid);
5055 status = WiFi.begin (ssid, keyIndex, key);
@@ -73,20 +78,20 @@ void printWifiData() {
7378 Serial.println (ip);
7479
7580 // print your MAC address:
76- byte mac[6 ];
81+ byte mac[6 ];
7782 WiFi.macAddress (mac);
7883 Serial.print (" MAC address: " );
79- Serial.print (mac[5 ],HEX);
84+ Serial.print (mac[5 ], HEX);
8085 Serial.print (" :" );
81- Serial.print (mac[4 ],HEX);
86+ Serial.print (mac[4 ], HEX);
8287 Serial.print (" :" );
83- Serial.print (mac[3 ],HEX);
88+ Serial.print (mac[3 ], HEX);
8489 Serial.print (" :" );
85- Serial.print (mac[2 ],HEX);
90+ Serial.print (mac[2 ], HEX);
8691 Serial.print (" :" );
87- Serial.print (mac[1 ],HEX);
92+ Serial.print (mac[1 ], HEX);
8893 Serial.print (" :" );
89- Serial.println (mac[0 ],HEX);
94+ Serial.println (mac[0 ], HEX);
9095}
9196
9297void printCurrentNet () {
@@ -96,19 +101,19 @@ void printCurrentNet() {
96101
97102 // print the MAC address of the router you're attached to:
98103 byte bssid[6 ];
99- WiFi.BSSID (bssid);
104+ WiFi.BSSID (bssid);
100105 Serial.print (" BSSID: " );
101- Serial.print (bssid[5 ],HEX);
106+ Serial.print (bssid[5 ], HEX);
102107 Serial.print (" :" );
103- Serial.print (bssid[4 ],HEX);
108+ Serial.print (bssid[4 ], HEX);
104109 Serial.print (" :" );
105- Serial.print (bssid[3 ],HEX);
110+ Serial.print (bssid[3 ], HEX);
106111 Serial.print (" :" );
107- Serial.print (bssid[2 ],HEX);
112+ Serial.print (bssid[2 ], HEX);
108113 Serial.print (" :" );
109- Serial.print (bssid[1 ],HEX);
114+ Serial.print (bssid[1 ], HEX);
110115 Serial.print (" :" );
111- Serial.println (bssid[0 ],HEX);
116+ Serial.println (bssid[0 ], HEX);
112117
113118 // print the received signal strength:
114119 long rssi = WiFi.RSSI ();
@@ -118,7 +123,7 @@ void printCurrentNet() {
118123 // print the encryption type:
119124 byte encryption = WiFi.encryptionType ();
120125 Serial.print (" Encryption Type:" );
121- Serial.println (encryption,HEX);
126+ Serial.println (encryption, HEX);
122127 Serial.println ();
123128}
124129
0 commit comments