Hardware Reference
In-Depth Information
To connect to an open SSID (one that does not require a password), use only
the ssid parameter:
WiFi.begin(ssid);
To connect to a WPA-2 Personal protected network, specify the SSID and the
password:
WiFi.begin(ssid, password);
To connect to a WEP protected network, another parameter is required. WEP
protected networks can have up to four keys, and you must specify which one
to use:
WiFi.begin(ssid, keyIndex, key);
Both keys and SSIDs can be written as an array of chars :
char ssid[] = "yourNetworkSSID";
char password[] = "MySuperSecretPassword";
Status
Of course, initialization presumes that a WiFi shield is present and correctly
connected, which might not always be the case. To test for a WiFi shield, use
the status() function:
result = WiFi.status();
This function takes no parameters and returns one of several constants, as
shown in Table 10-1.
Table 10-1: Status Update Return Codes
CONSTANT
MEANING
WL_IDLE_STATUS
The WiFi shield is idle, without any instructions.
WL_NO_SSID_AVAIL
There are no networks to connect to.
WL_SCAN_
COMPLETED
An initial SSID scan has been completed, and the WiFi shield
knows about available SSIDs.
WL_CONNECTED
The WiFi shield has successfully connected to an SSID.
WL_CONNECT_
FAILED
The WiFi shield was unable to connect; either the encryption key
is wrong, or the connection was refused by the access point.
WL_CONNECTION_
LOST
The WiFi shield was previously connected, but that connection
has been lost (either out of range, or interference).
Continues
 
Search WWH ::




Custom Search