Associating With Selected Network
|Top Previous Next|
Association is a process by which your Wi-Fi device establishes a link with an access point or another wireless station running an ad-hoc network.
The association process is initiated using the wln.associate method. Association is a required step before you will be able to send and receive the data over the Wi-Fi. Note that wln.associate is a wln task and there is a certain correct way of handling tasks.
Wln.associate will be rejected (return 1- REJECTED) if:
The method will return 0- ACCEPTED if the task is accepted for processing.
Normally, the SSID is known, but BSSID, channel, and BSS mode require some digging. The easiest way to sniff out correct values of these parameters is through scanning. Wln.scan or wln.activescan will fill out wln.scanresultbssid, wln.scanresultchannel, and wln.scanresultbssmode R/O properties. You only need to put them to good use, as shown in the example below.
Before you look at the example, consider this: you may be able to discover the network with wln.scan, yet unable to associate with it because this network is operating on a channel which is disallowed in a currently selected domain.
After the association task is completed you have to check the association result. Mere task completion does not indicate success! The wln.associationstate will provide the indication.
If you are running with no security or WEP security, you can start communicating over the Wi-Fi interface as soon as you are done associating. If it is WPA you are dealing with, completing wln.associate is really just a first step. There is a lengthy and laborious message exchange to follow. It is best to delegate this to our WLN library!
When the wln. object is in the associated state, wln.rssi read-only property is constantly updated with the strength of the signal coming from the access point. Do not confuse this with the wln.scanresultrssi property which returns the signal strength of a particular network obtained during scanning.