wln.associate on GA1000

The GA1000 can associate with access points, as well as 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:


Before your device can successfully associate, it will need to know several key parameters of the target 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, wln.scanresultchannel, and wln.scanresultbssmode 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, wln.scanresultbssmode)
While wln.task<>PL_WLN_TASK_IDLE
Wend
If wln.associationstate=PL_WLN_ASSOCIATED Then
   'successful association!
   ...
End If

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 you're dealing with WPA or WPA2, completing wln.associate is really just the first step. There is a lengthy message exchange to follow. It is best to delegate this to our WLN library!