Hardware Reference
In-Depth Information
This function does not take any parameters and does not return any
information. It immediately disconnects from the current network.
By default, the WiFi shield uses DHCP to obtain an IP address and network
settings. When begin() is called, DHCP negotiations begin after connecting to
the network. While some wireless networks provide DHCP, others do not and
require manual coni guration. To perform manual coni guration, use config() .
This function can be called in four ways:
WiFi.config(ip);
WiFi.config(ip, dns);
WiFi.config(ip, dns, gateway);
WiFi.config(ip, dns, gateway, subnet);
In its most basic form, config() requires one parameter: the IP address to
use, expressed as an array of 4 bytes, or optionally, using an IPAddress object.
This object takes 4 bytes; the 4 bytes of an IP Address:
IPAddress ip(192.168.0.10);
To translate human-readable text into IP addresses, a Domain Name Server
must be specii ed as the dns parameter, again, as an array of 4 bytes, or IPAddress .
For packets to leave the current network to another network, a gateway IP must
be specii ed with gateway . Finally, to change subnet, you must specify the sub-
net IP (by default: 255.255.255.0).
Calling config() before begin() forces the WiFi shield to use the settings
specii ed. Calling config() after begin() again forces the WiFi shield to use
the settings that were specii ed, but the begin() function will attempt to contact
a DHCP server beforehand, resulting in a possible IP change.
The downside to this is that to use a specii c DNS, you must specify the IP
address. Some computers prefer to use an external DNS. (For example, Google
allows users to use their DNS instead of their Internet provider's DNS.) To
remedy this, the setDNS() function can be used.
WiFi.setDNS(dns_server1);
WiFi.setDNS(dns_server1, dns_server2);
This function requires either one or two DNS server addresses. It returns
no data and immediately sets the DNS server values without changing the IP
address.
Wireless Client
Just like with the Ethernet library, the WiFi library has its own client class.
Remember, a client is a device that connects to a server on a specii ed port. A
server is always on listening for client connections.
Before connecting to a server, the client must i rst create a client object; for
the WiFi library, this is called WiFiClient .
 
Search WWH ::




Custom Search