WiSnap User Manual 2.21 04112011-JF
Page
40
of
66
11
Sending data using UDP
11.1
Overview
UDP is a connectionless protocol. There is no initial handshaking between the hosts to set up the UDP
connection. There are no acknowledgements sent by the receiver for UDP packets that it receives.
This makes UDP an unreliable protocol, as there is no guarantee that the data will be correctly
delivered. However, due to its connectionless nature, UDP is suited for applications that cannot
tolerate too much latency but can tolerate some errors in data. Transmission of video would be a
good example of UDP application.
To use UDP on the WiSnap module, you will need to enable the UDP protocol using the command
“set ip proto 1”. You will also need to specify the remote host IP address and the local and remote
port number that you will use for UDP communications.
The commands to enable UDP data transfer are:
Associate to a network:
set wlan ssid <string>
// set the network name
set wlan phrase <string>
// set the passphrase for WPA and WPA2 modes
Set up the protocol and port number
set ip proto 1
// enable UDP as the protocol
set ip host <ip address>
// set the IP address of remote host
set ip remote <port>
// set the remote port number on which the host is
listening
set ip local <port>
// set the port number on which the WiSnap module will listen
save
// saves the settings in config file
reboot
// reboots the module so that the above settings take effect
NOTE:
If you attempt to send data by physically typing characters on the keyboard or if your
microcontroller is not sending data fast enough, the WiSnap module will send out packets with less
data bytes. To avoid this, set the flush timer to a higher value. By default, it is set to 10
milliseconds. You can choose to either disable forwarding based on flush timer (use “set comm. time
0”) or set it to a higher value (e.g. set comm. time 2000)
Since UDP is a connectionless protocol, data will start flowing as soon as the module is rebooted.
Unlike TCP, it is not required to do an “OPEN” for the connection to be established. The WiSnap
module acts like a data-pipe, so the UART data will be sent over the Wi-Fi link via the UDP protocol
(in this case) and the data coming over the Wi-Fi link (via UDP protocol in this case) will be sent to
the UART.
11.2
UDP Auto Pairing
UDP auto pairing feature temporarily stores the Host IP address of the first remote device that send
a UDP packet into the module. This host IP address is stored in the RAM which will not survive a
sleep or power cycle.
This feature allows the WiSnap module to echo back to any client that sends a UDP packet. To use
this feature, the host IP addresses and set the ip flags.
set ip host 0.0.0.0
set ip flags 0x80