BL4S200 User’s Manual
150
•
WIFISCAN.C
—initializes the BL5S220 and scans for other Wi-Fi devices that are
operating in either the ad-hoc mode or through access points in the infrastructure mode.
No network parameter settings are needed since the BL5S220 does not actually join an
802.11 network. This program outputs the results of the scan to the Dynamic C
STDIO
window.
•
WIFISCANASSOCIATE.C
— demostrates how to scan Wi-Fi channels for SSIDs using
ifconfig IFS_WIFI_SCAN
. This takes a while to complete, so
ifconfig()
calls a
callback function when it is done. The callback function is specified using
ifconfig
IFS_WIFI_SCAN
.
Before you run this sample program, configure the Dynamic C
TCP_CONFIG.LIB
library and your
TCPCONFIG
macro.
1. Use macro definitions in the “Defines” tab in the Dynamic C
Options > Project
Options
menu to modify any parameter settings.
If you are not using DHCP, set the IP parameters to values appropriate to your network.
Set
IFS_WIFI_SSID
to an appropriate value. To connect to a specific BSS, set
IFS_
WIFI_SSID
to the SSID of your access point as a C-style string, for example,
or use an empty string,
""
, to associate with the strongest BSS available.
Alternatively, you may create your own
CUSTOM_CONFIG.LIB
library modeled on the
Dynamic C
TCP_CONFIG.LIB
library. Then use a
TCPCONFIG
macro greater than or
equal to 100, which will invoke your
CUSTOM_CONFIG.LIB
library to be used.
Remember to add the
CUSTOM_CONFIG.LIB
library to
LIB.DIR
.
2. If you are using DHCP, change the definition of the
TCPCONFIG
macro to 5. The default
value of 1 indicates Wi-Fi with a static IP address.
Now compile and run the sample program. Follow the menu options displayed in the
Dynamic C
STDIO
window.
Note that
ifconfig IFS_WIFI_SCAN
function calls do not return data directly since
the scan takes a fair amount of time. Instead, callback functions are used. The callback
function is passed to
ifconfig()
as the only parameter to
IFS_WIFI_SCAN
.
ifconfig(IF_WIFI0, IFS_WIFI_SCAN, scan_callback, IFS_END);
_PRIMARY_STATIC_IP = "10.10.6.100"
_PRIMARY_NETMASK = "255.255.255.0"
MY_NAMESERVER = "10.10.6.1"
MY_GATEWAY = "10.10.6.1"
IFS_WIFI_SSID = "My Access Point"
s - scan for BSS's,
a - scan and associate
m - dump MAC state information
t - dump tx information
electronic components distributor