Scanning for Wi-Fi Networks
Scanning allows you to discover the wireless networks (access points) in your device's range and also learn about their operating parameters, such as the name, RF channel, signal strength, etc. Two methods — wln.scan and wln.activescan — are provided for this purpose. Both methods are tasks and there is a certain correct way of executing tasks.
Wln.scan or wln.activescan will be rejected (return 1- REJECTED) if:
Another task is currently in progress.
Wln.scan performs a passive detection of Wi-Fi networks. During the passive detection, the Wi-Fi module intercepts "beacons" transmitted by wireless networks and extracts the network information from these beacon packets. This method can't collect the network information of "hidden" wireless networks that do not broadcast their SSIDs (names).
Passive scanning is performed on all frequency bands and in all modes allowed by the current value of wln.band, regardless of the value of wln.domain. This is not in violation of any regulations because passive scanning does not involve transmitting any data out of the device.
Wln.activescan actively "probes" the environment around the device by sending — you guessed it — "probe" packets. This method can find all the wireless networks that wln.scan would find, plus it can discover hidden networks, but only if you knew their names in advance.
Active scanning (sending of "probe" packets) is performed on frequency bands and in modes allowed by the current value of wln.band, and is also limited to channels allowed by wln.domain.
Scanning can be performed at any time, even when the Wi-Fi interface is in the associated state (wln.associationstate= 1- PL_WLN_ASSOCIATED) or running its own network (wln.associationstate= 2- PL_WLN_OWN_NETWORK). Keep in mind, however, that scanning temporarily disrupts Wi-Fi communications. This is because scanning involves checking for available access points on all (allowed) frequencies. Obviously, the radio can't keep communicating while jumping from channel to channel.
Note that on the WA2000, the time it takes to scan for available networks depends on the wln.band. For more information see Selecting Allowed Bands.
You can choose to discover all networks, or limit the scan result to only infrastructure or only ad-hoc networks. This is controlled by the wln.scanfilter property.
Both wln.scan and wln.activescan accept a single string argument. Presence or absence of this argument defines the "operating mode" of these methods. You can either discover all (non-hidden) wireless networks in range, or try to collect information about the specified network.