Download WiFly Command Reference, Advanced Features and

Transcript
WiFly Command Reference, Advanced Features & Applications User’s Guide
4.3.4
Using the Backup IP Address/Connect Function
The module contains a feature for auto-retry and redundancy. If the host’s first IP
address connection fails, the module uses the backup IP (if set). If this fails (or is not
set), the module uses the first DNS name. If this fails (or is not set), the module uses
the backup DNS name (if set).
EXAMPLE 4-8:
SET THE BACKUP IP ADDRESS
set ip backup <address>
// Set the backup IP address
EXAMPLE 4-9:
SET THE BACKUP DNS NAME
set dns backup <string>
// Set the backup host name
4.4
USING THE HTML CLIENT FEATURE
The module has a built-in HTML client. When enabled, the module can get or post data
to a web server. For example, you can use the HTML client to post serial and/or sensor
data to the host web server. This feature makes possible to provide Wi-Fi capabilities
to applications such as GPS units, remote sensors, weather stations, etc.
4.4.1
Retrieve Web Server Data
In this example, you want to retrieve data from the web server with the format:
http://www.webserver.com/ob.php?obvar=WEATHER
To perform this function, use the following settings:
set ip proto 18
set dns name www.webserver.com
set ip address 0
set ip remote 80
set com remote 0
// Enable the HTML client
// Set the web server name
// Turn on DNS
// Set the web server port, 80 is standard
// Turn off the REMOTE string so that it
// does not interfere with the post
To make the connection, use the open command or you can use open www.webserver.com 80. The user’s microprocessor writes the following string to the UART:
GET /ob.php?obvar=WEATHER \n\n
Where the \n is the linefeed character (decimal 10 or hex 0xa). Two linefeeds are
required for the web server to know the page is complete.
Note:
DS50002230A-page 74
Some web servers require a carriage return and linefeed to indication the
page is complete. In this case, use \r\n at the end of the string instead of
\n\n.
 2014 Microchip Technology Inc.