wln.associate on WA2000

The WA2000 can only associate with access points (infrastructure networks) and cannot associate with other wireless devices (stations) running ad hoc networks.

Prior to associating, you will need to set the WEP or WPA security (if required).


The wln.associate method will be rejected (return 1 — REJECTED) if:


As with the GA1000, you can associate with a wireless network by providing the precise parameters of this network:


Normally, the SSID is known, but the BSSID, channel, and BSS mode require some digging. The easiest way to sniff out the correct values of these parameters is through scanning. The wln.scan or wln.activescan methods will fill the wln.scanresultbssid and wln.scanresultchannel read-only properties with the correct data. The example below shows how to put them to good use.

After the association task is completed, you need to check the association result. This can be done through the wln.associationstate property.

Tibbo BASIC
'connect to the access point named TIBBO.
wln.scan("TIBBO") 'scanning for a specific network will give us necessary parameters (you can also use wln.activescan)
While wln.task<>PL_WLN_TASK_IDLE
Wend
If wln.scanresultssid<>"" Then
   'wireless network not found
End If
 
'now can associate: 'wln.scanresult...' properties contain necessary data after the scanning
wln.associate(wln.scanresultbssid, wln.scanresultssid, wln.scanresultchannel, PL_WLN_BSS_MODE_ADHOC)
While wln.task<>PL_WLN_TASK_IDLE
Wend
If wln.associationstate=PL_WLN_ASSOCIATED Then
   'successful association!
   ...
End If

Unline the GA1000, WA2000 also offers a "wildcard" association: Instead of specifying all parameters, provide only the SSID (name) of the target network. Set the bssid argument to "" or "0.0.0.0.0.0" — this will instruct the module to associate with any access point with the matching name. To allow the WA2000 to associate on any channel, set the channel to 0. These allow your app to bypass scanning for the network parameters of the target network and proceed directly to associating:

Tibbo BASIC
...
wln.associate("","Tibbo1",0,PL_WLN_BSS_MODE_INFRASTRUCTURE)
...

Now, what will happen if you use this "wildcard" association while there are several access points with the same SSID in your device's range? The WA2000 will automatically select the one with the strongest signal!


The WA2000 has another advantage over the GA1000 — it handles WPA and WPA2 security completely by itself and requires no help from the application, like the GA1000 does. When WPA or WPA2 is enabled, the WA2000 performs the requires "WPA handshake" as soon as it associates with an access point. If this fails, you application will quickly receive an on_wln_event(PL_WLN_EVENT_DISASSOCIATED) event.