Scanning for Wi-Fi Networks

Top  Previous  Next

Scanning allows you to discover all networks in your device's "neighborhood" and also learn about their operating parameters, such as the name, RF channel, etc. The wln.scan method is provided for this purpose. Please, note that scanning is a wln task, and your application should wait for this task to complete before issuing another task.

The wln.task accepts a single argument of string type. Presence or absence of this argument defines the "operating mode" of the method.

When called with an empty string, the wln.task will attempt to find all available wireless networks. After the task completes, a wln.scanresultssid property will contain a comma-separated list of network names:

 

 

'scan for available network

Dim s As String

...

wln.scan("")

While wln.task<>PL_WLN_TASK_IDLE

Wend

s=wln.scanresultssid 'the list of networks will be copied into s

 

 

After the execution of the above, s string may contain something like this: "TIBBO,c1100_1,WNET2".

When called with the argument set to the name of a particular network, the wln.scan method will return additional data on this network:

Wln.scanresultssid R/O property will contain the name of the specified network, or nothing if the network wasn't found). If the network was found, the following four properties will have additional data on this network:
Wln.scanresultbssid R/O property will contain the BSSID of the specified network.
Wln.scanresultbssmode R/O property will contain the BSS mode of the network.
Wln.scanresultchannel R/O property will return the number of the RF channel on which the network operates.
Wln.scanresultRSSI R/O property will contain the strength of the RF signal received from the specified network.

 

The scanning cannot be performed while the Wi-Fi interface is in the associated state (wln.associationstate= 1- PL_WLN_ASSOCIATED). Scanning is not required for successful association -- if you know the name of the network you wish to connect to, you can proceed to associating with this network directly.

 

note_tip-wt

Don't know what SSID in wln.scanresult means? How about BSSID or RSSI? The Wi-Fi Parlance Primer will tell you what it all means!