@@ -312,14 +312,22 @@ For example::
312312 Constructors
313313 ------------
314314
315- .. class :: WLAN(..)
315+ .. class :: WLAN(id=0, . ..)
316316
317317 Create a WLAN object, and optionally configure it. See ``init `` for params of configuration.
318318
319+ .. note ::
320+
321+ The ``WLAN `` constructor is special in the sense that if no arguments besides the id are given,
322+ it will return the already exisiting ``WLAN `` instance without re-configuring it. This is
323+ because ``WLAN `` is a system feature of the WiPy. If the already existing instance is not
324+ initialized it will do the same as the other constructors an will initialize it with default
325+ values.
326+
319327 Methods
320328 -------
321329
322- .. method :: wlan.init(mode, \*, ssid, security, key , channel, antenna)
330+ .. method :: wlan.init(mode, \*, ssid, auth , channel, antenna)
323331
324332 Set or get the WiFi network processor configuration.
325333
@@ -329,34 +337,33 @@ For example::
329337 - ``ssid `` is a string with the ssid name. Only needed when mode is ``WLAN.AP ``.
330338 - ``auth `` is a tuple with (sec, key). Security can be ``None ``, ``WLAN.WEP ``,
331339 ``WLAN.WPA `` or ``WLAN.WPA2 ``. The key is a string with the network password.
332- If ``security `` is ``WLAN.WEP `` the key must be a string representing hexadecimal
340+ If ``sec `` is ``WLAN.WEP `` the key must be a string representing hexadecimal
333341 values (e.g. 'ABC1DE45BF'). Only needed when mode is ``WLAN.AP ``.
334342 - ``channel `` a number in the range 1-11. Only needed when mode is ``WLAN.AP ``.
335343 - ``antenna `` selects between the internal and the external antenna. Can be either
336- ``WLAN.INT_ANT `` or ``WLAN.EXTERNAL ``.
344+ ``WLAN.INT_ANT `` or ``WLAN.EXT_ANT ``.
337345
338346 For example, you can do::
339347
340348 # create and configure as an access point
341- nic.iwconfig (mode=WLAN.AP, ssid='wipy-wlan', security= WLAN.WPA2, key= 'www.wipy.io', channel=7, antenna=WLAN.INTERNAL )
349+ wlan.init (mode=WLAN.AP, ssid='wipy-wlan', auth=( WLAN.WPA2,'www.wipy.io') , channel=7, antenna=WLAN.INT_ANT )
342350
343351 or::
344352
345353 # configure as an station
346- nic.iwconfig(mode=WLAN.STA)
347-
348- With no arguments given, the current configuration is returned as a namedtuple that looks like this:
349- ``(mode=2, ssid='wipy-wlan', security=2, key='www.wipy.io', channel=5, antenna=0) ``
354+ wlan.init(mode=WLAN.STA)
350355
351- .. method :: wlan.connect(ssid, \*, auth=None, key=None, bssid=None, timeout=5000)
356+ .. method :: wlan.connect(ssid, \*, auth=None, bssid=None, timeout=5000)
352357
353358 Connect to a wifi access point using the given SSID, and other security
354359 parameters.
355360
356- - ``key `` is always a string, but if ``security `` is ``WLAN.WEP `` the key must be a string
357- representing hexadecimal values (e.g. 'ABC1DE45BF').
358- - ``bssid `` is the MAC address of the AP to connect to. Useful when there are several APs
359- with the same ssid.
361+ - ``auth `` is a tuple with (sec, key). Security can be ``None ``, ``WLAN.WEP ``,
362+ ``WLAN.WPA `` or ``WLAN.WPA2 ``. The key is a string with the network password.
363+ If ``sec `` is ``WLAN.WEP `` the key must be a string representing hexadecimal
364+ values (e.g. 'ABC1DE45BF'). Only needed when mode is ``WLAN.AP ``
365+ - ``bssid `` is the MAC address of the AP to connect to. Useful when there are several
366+ APs with the same ssid.
360367 - ``timeout `` is the maximum time in milliseconds to wait for the connection to succeed.
361368
362369 .. method :: wlan.scan()
@@ -373,16 +380,36 @@ For example::
373380 In case of STA mode, returns ``True `` if connected to a wifi access point and has a valid IP address.
374381 In AP mode returns ``True `` when a station is connected. Returns ``False `` otherwise.
375382
376- .. method :: wlan.ifconfig(if_id, config=['dhcp' or configtuple])
383+ .. method :: wlan.ifconfig(if_id=0 , config=['dhcp' or configtuple])
377384
378- With no parameters given eturns a 4-tuple of ``(ip, subnet mask , gateway, DNS server ) ``.
385+ With no parameters given eturns a 4-tuple of ``(ip, subnet_mask , gateway, DNS_server ) ``.
379386
380387 if ``'dhcp' `` is passed as a parameter then the DHCP client is enabled and the IP params
381388 are negotiated with the AP.
382389
383390 if the 4-tuple config is given then a static IP is configured. For example::
384391
385- nic.ifconfig(config=('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
392+ wlan.ifconfig(config=('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
393+
394+ .. method :: wlan.mode([mode])
395+
396+ Get or set the WLAN mode.
397+
398+ .. method :: wlan.ssid([ssid])
399+
400+ Get or set the SSID when in AP mode.
401+
402+ .. method :: wlan.auth([auth])
403+
404+ Get or set the authentication type when in AP mode.
405+
406+ .. method :: wlan.channel([channel])
407+
408+ Get or set the channel (only applicable in AP mode).
409+
410+ .. method :: wlan.antenna([antenna])
411+
412+ Get or set the antenna type (external or internal).
386413
387414 .. method :: wlan.mac([mac_addr])
388415
@@ -396,18 +423,15 @@ For example::
396423 - ``handler `` is the function that gets called when the irq is triggered.
397424 - ``wake `` must be ``machine.SLEEP ``.
398425
399- Returns a callback object.
426+ Returns a irq object.
400427
401428 Constants
402429 ---------
403-
404- .. data :: WLAN.STA
405-
406- WiFi station mode
407430
431+ .. data :: WLAN.STA
408432 .. data :: WLAN.AP
409433
410- WiFi access point mode
434+ selects the WLAN mode
411435
412436 .. data :: WLAN.WEP
413437 .. data :: WLAN.WPA
0 commit comments