Wln.associate on GA1000
GA1000 devices 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).
Wln.associate will be rejected (return 1- REJECTED) if:
• Another task is currently in progress.
• The Wi-Fi add-on module is not booted property (wln.enabled = 0- NO).
• The Wi-Fi interface is already either associated or is running its own ad-hoc network (wln.associationstate <>0- PL_WLN_NOT_ASSOCIATED).
Befor your device can successfully associate, it will need to know several key parameters of the target network:
• The SSID (name) of this network;
• The BSSID (MAC address) of this network;
• The channel on which this network operates;
• The BSS mode of this network, i.e. whether this network is an infrastructure network created by an access point or an ad-hoc network created by another station.
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 the wln.scanresultbssid , wln.scanresultchannel , and wln.scanresultbssmode read-only properties with correct data. 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 it is WPA or WPA2 you are dealing with, 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 !