1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-01 23:29:28 +01:00

Updated Wifi Connect with WEP example to explain 40- vs 128-bit

This commit is contained in:
Tom Igoe 2012-03-04 15:14:12 -05:00
parent 15d7873d24
commit 0ddbfd0e95

View File

@ -1,21 +1,31 @@
/*
This example connects to an unencrypted Wifi network.
This example connects to a WEP-encrypted Wifi network.
Then it prints the MAC address of the Wifi shield,
the IP address obtained, and other network details.
If you use 40-bit WEP, you need a key that is 10 characters long,
and the characters must be hexadecimal (0-9 or A-F).
e.g. for 40-bit, ABBADEAF01 will work, but ABBADEAF won't work
(too short) and ABBAISDEAF won't work (I and S are not
hexadecimal characters).
For 128-bit, you need a string that is 26 characters long.
D0D0DEADF00DABBADEAFBEADED will work because it's 26 characters,
all in the 0-9, A-F range.
Circuit:
* WiFi shield attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 29 Feb 2012
by Scott Fitzgerald
modified 4 Mar 2012
by Tom Igoe
*/
#include <WiFi.h>
char ssid[] = "YourNetwork"; // your network SSID (name)
char key[] = "725d223132"; // your network key
char ssid[] = "yourNetwork"; // your network SSID (name)
char key[] = "D0D0DEADF00DABBADEAFBEADED"; // your network key
int keyIndex = 0; // your network key Index number
int status = WL_IDLE_STATUS; // the Wifi radio's status
@ -26,7 +36,7 @@ void setup() {
// attempt to connect to an open network:
Serial.print("Attempting to connect to WEP network: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass, key);
status = WiFi.begin(ssid, keyIndex, key);
// if you're not connected, stop here:
if ( status != WL_CONNECTED) {
@ -103,3 +113,4 @@ void printCurrentNet() {
Serial.println();
}