WiSnap User Manual 2.21 04112011-JF
Page
12
of
66
set wlan join 1
// Auto join upon power up
set wlan chan 0
// Scan all channels
set wlan ssid my_network
// Network name
set wlan phrase my_secret_code
// Pass phrase
The
join 1
setting ensures that when the module wakes up, it tries to join the access point that matches the stored
SSID, passkey and channel. Channel =0 (the default) will force auto-scanning. Setting the channel will reduce the
time it takes the WiSnap to find and associate.
Step 2: Set up the
IP address and port number of the remote server, so the WiSnap can connect when it wakes up.
set ip host 10.20.20.75
// Set the host IP address
set ip remote 3000
// Set the remote port
set sys autoconn 2
// Try to connect to the host every 2 seconds
save
// Save configuration>
Note: If autoconn = 1, the WiSnap will only make one attempt to auto connect.
Step 3: Set the
wake up and sleep conditions. By default the adapter will wake whenever there is
data written to the serial interface. You can also configure the device to wake up on CTS, on a PIO or
timer. See the command reference for details. We are going to set this up to wake on a timer then
sleep after 2 minutes if there is no connection or if connected and no data has been transferred for
30 seconds.
set sys sleep 120
// sleep after 2 minutes if no connection
set sys trigger 2
// wake on CTS
set conn idle 30
// disconnect after 30 seconds of no data
save
// save all the settings to the config file
reboot
// use the new settings
This setup can be tested using TCP server application that opens a socket on port 3000. Port Peeker
is a free application that you can download off the web.
It is available at
http://www.linklogger.com/portpeeker.htm
Waiting for the remote host to connect to the serial adapter (listen mode)
In this example we are using a static IP so that the remote host knows where the WiSnap Serial adapter is on the
network. Alternatively you can write your application software to listen for the broadcast UDP packet (automatically
sent by WiSnap by default) to identify the WiSnap Serial adapter and get the IP address and TCP port number that
the WiSnap is listening on.
Step 1: Set up the wlan properties so the device will connect to the network automatically upon power up. In this
example we want to connect to the wireless network my_network.
set wlan join 1
// Auto join upon power up
set wlan chan 1
// only look on channel 1
set wlan ssid my_network
// Network name
set wlan phrase my_secret_code
// Pass phrase
Step 2: Configure the WiSnap static IP address so the remote application can connect,
turn off DHCP and set the IP
address and netmask.