Wln.associate on WA2000
WA2000 devices 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).
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).
• If the bssmode argument was set to PL_WLN_BSS_MODE_ADHOC. This will only work on the GA1000 .
As with GA1000 , you can associate with a wireless network by providing precise parameters of this network:
• The SSID (name) of this network;
• The BSSID (MAC address) of this network;
• The channel on which this network operates.
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 and wln.scanresultchannel 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, 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 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 a matching name. To allow the WA2000 associate on any channel, set the channel to 0. These allows 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 app, like the GA1000 does. When WPA or WAP2 is enabled, the WA2000 performs the requires "WPA handshake" as soon as it associates with an access point. If this fails, you app will quickly receive an on_wln_event (PL_WLN_EVENT_DISASSOCIATED) event.