1
1
/*
2
-
3
- This example connects to a WEP-encrypted Wifi network.
2
+
3
+ This example connects to a WEP-encrypted Wifi network.
4
4
Then it prints the MAC address of the Wifi shield,
5
5
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,
15
15
all in the 0-9, A-F range.
16
-
16
+
17
17
Circuit:
18
18
* WiFi shield attached
19
-
19
+
20
20
created 13 July 2010
21
21
by dlf (Metodo2 srl)
22
22
modified 31 May 2012
23
23
by Tom Igoe
24
24
*/
25
+ #include < SPI.h>
25
26
#include < WiFi.h>
26
27
27
- char ssid[] = " yourNetwork" ; // your network SSID (name)
28
+ char ssid[] = " yourNetwork" ; // your network SSID (name)
28
29
char key[] = " D0D0DEADF00DABBADEAFBEADED" ; // your network key
29
30
int keyIndex = 0 ; // your network key Index number
30
31
int status = WL_IDLE_STATUS; // the Wifi radio's status
31
32
32
33
void setup () {
33
34
// Initialize serial and wait for port to open:
34
- Serial.begin (9600 );
35
+ Serial.begin (9600 );
35
36
while (!Serial) {
36
37
; // wait for serial port to connect. Needed for Leonardo only
37
38
}
38
39
39
40
// check for the presence of the shield:
40
41
if (WiFi.status () == WL_NO_SHIELD) {
41
- Serial.println (" WiFi shield not present" );
42
+ Serial.println (" WiFi shield not present" );
42
43
// 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" );
45
50
46
51
// attempt to connect to Wifi network:
47
- while ( status != WL_CONNECTED) {
52
+ while ( status != WL_CONNECTED) {
48
53
Serial.print (" Attempting to connect to WEP network, SSID: " );
49
54
Serial.println (ssid);
50
55
status = WiFi.begin (ssid, keyIndex, key);
@@ -73,20 +78,20 @@ void printWifiData() {
73
78
Serial.println (ip);
74
79
75
80
// print your MAC address:
76
- byte mac[6 ];
81
+ byte mac[6 ];
77
82
WiFi.macAddress (mac);
78
83
Serial.print (" MAC address: " );
79
- Serial.print (mac[5 ],HEX);
84
+ Serial.print (mac[5 ], HEX);
80
85
Serial.print (" :" );
81
- Serial.print (mac[4 ],HEX);
86
+ Serial.print (mac[4 ], HEX);
82
87
Serial.print (" :" );
83
- Serial.print (mac[3 ],HEX);
88
+ Serial.print (mac[3 ], HEX);
84
89
Serial.print (" :" );
85
- Serial.print (mac[2 ],HEX);
90
+ Serial.print (mac[2 ], HEX);
86
91
Serial.print (" :" );
87
- Serial.print (mac[1 ],HEX);
92
+ Serial.print (mac[1 ], HEX);
88
93
Serial.print (" :" );
89
- Serial.println (mac[0 ],HEX);
94
+ Serial.println (mac[0 ], HEX);
90
95
}
91
96
92
97
void printCurrentNet () {
@@ -96,19 +101,19 @@ void printCurrentNet() {
96
101
97
102
// print the MAC address of the router you're attached to:
98
103
byte bssid[6 ];
99
- WiFi.BSSID (bssid);
104
+ WiFi.BSSID (bssid);
100
105
Serial.print (" BSSID: " );
101
- Serial.print (bssid[5 ],HEX);
106
+ Serial.print (bssid[5 ], HEX);
102
107
Serial.print (" :" );
103
- Serial.print (bssid[4 ],HEX);
108
+ Serial.print (bssid[4 ], HEX);
104
109
Serial.print (" :" );
105
- Serial.print (bssid[3 ],HEX);
110
+ Serial.print (bssid[3 ], HEX);
106
111
Serial.print (" :" );
107
- Serial.print (bssid[2 ],HEX);
112
+ Serial.print (bssid[2 ], HEX);
108
113
Serial.print (" :" );
109
- Serial.print (bssid[1 ],HEX);
114
+ Serial.print (bssid[1 ], HEX);
110
115
Serial.print (" :" );
111
- Serial.println (bssid[0 ],HEX);
116
+ Serial.println (bssid[0 ], HEX);
112
117
113
118
// print the received signal strength:
114
119
long rssi = WiFi.RSSI ();
@@ -118,7 +123,7 @@ void printCurrentNet() {
118
123
// print the encryption type:
119
124
byte encryption = WiFi.encryptionType ();
120
125
Serial.print (" Encryption Type:" );
121
- Serial.println (encryption,HEX);
126
+ Serial.println (encryption, HEX);
122
127
Serial.println ();
123
128
}
124
129
0 commit comments