Setting WEP Mode and Keys

Top  Previous  Next

If the network you are associating with (creating) uses (is supposed to be using) WEP, then you need to set the WEP prior to associating with (creating) the network. The wln.wepmode method specifies whether your Wi-Fi interface will operate with WEP off, with 64-bit WEP, or 128-bit WEP. When WEP-64 and WEP-128 modes are selected, you need to also set four WEP keys using wln.wepkey1 ... wln.wepkey4 properties. This done, invoke the wln.setwep method to "send" the keys into the Wi-Fi hardware. Please, note that wln.setwep is a wln task, and your application should wait for this task to complete before issuing another task.

WEP keys are entered as HEX strings, not ASCII strings. Each character in a string represents one HEX digit and, hence, can be 0..9 or A..F (a..f). The keys have a fixed length: 10 HEX digits for WEP-64 or 26 HEX digits for WEP-128. If your key is too short, it will be padded with zeroes, if the key is too large it will be truncated.

Here is the code example that sets the Wi-Fi to WEP-128 mode:

 

 

'set WEP-128

wln.wepmode=PL_WLN_WEP_MODE_128

wln.wepkey1="11111111111111111111111111"

wln.wepkey2="22222222222222222222222222"

wln.wepkey3="33333333333333333333333333"

wln.wepkey4="44444444444444444444444444"

wln.setwep

While wln.task<>PL_WLN_TASK_IDLE

Wend

 

 

Note that the WEP mode and keys can't be changed while the Wi-Fi interface is in the associated state (wln.associationstate= 1- PL_WLN_ASSOCIATED).