User`s guide
RN-WIFLYCR-UG
www.rovingnetworks.com Version 1.2r 4/30/13 page 71
Chapter 4. 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 fea-
ture, upgrading the firmware over FTP, etc.
4.1 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 connection-
less, UDP is suited for applications that cannot tolerate too much latency but can toler-
ate 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 4-1: ASSOCIATE WITH A NETWORK
EXAMPLE 4-2: SET UP THE PROTOCOL & PORT NUMBER
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.
set wlan ssid <string> // Set the network name
set wlan phrase <string> // Set the passphrase for WPA and WPA2 modes
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 remote port on which host listens
set ip local <value> // Set port number on which module listens
save // Save 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).