www.rovingnetworks.com
Version 1.0r 9/21/2012
61
RN -W IFLYCR -U M
ADVANCED APPLICATIONS
This section describes a variety of advanced applications for the WiFly module, such as sending data using UDP,
associating with access points, using the HTML client feature, upgrading the firmware over FTP, etc.
SENDING DATA USING UDP
UDP is a connectionless protocol: there is no initial handshaking between the hosts to set up the UDP connection and the
receiver does not send an acknowledgement when it receives UDP packets. Therefore, UDP is an unreliable protocol
because there is no guarantee that the data will be delivered correctly. However, because it is connectionless, UDP is
suited for applications that cannot tolerate too much latency but can tolerate some errors in the data, e.g., video
transmission.
To use UDP with the module, you must enable the UDP protocol using the
set ip proto 1
command. You must also specify
the remote host’s IP address and the local and remote port number that you will use for UDP communications. The
following example shows the commands you use to enable UDP data transfer.
Example: Associate with a Network
set wlan ssid
<
string
>
// Set the network name
set wlan phrase
<
string
>
// Set the passphrase for WPA and WPA2 modes
Example: Set Up the Protocol & Port Number
set ip proto 1
// Enable UDP as the protocol
set ip host
<
address
>
// Set the remote host’s IP address
set ip remote
<
value
>
// Set the remote port on which the host listens
set ip local
<
value
>
// Set the port number on which the module listens
save
// Save the settings in the configuration file
reboot
// Reboot the module
NOTE:
If you attempt to send data by typing characters on the keyboard or if your microcontroller is not sending
data fast enough, the module sends out packets with fewer data bytes. To avoid this issue, set the flush
timer to a higher value. By default, it is set to 10 ms. You can disable forwarding based on the flush timer
(
set comm time 0
) or set it to a higher value (e.g.,
set comm time 2000
).
Because UDP is a connectionless protocol, data begins flowing as soon as you reboot the module. Unlike TCP, you do not
need to send an open command to establish the connection. The module acts like a data pipe: the UART data is sent over
the Wi-Fi link via the UDP protocol (in this case) and the data coming from the Wi-Fi link (via UDP protocol in this case) is
sent to the UART.