Browse Source

docs: Update to use new WLAN argument names for ssid/security/key.

Addresses issue #8083.
pull/7868/merge
iabdalkader 2 years ago
committed by Damien George
parent
commit
6e868d47dc
  1. 6
      docs/esp32/quickref.rst
  2. 6
      docs/esp8266/quickref.rst
  3. 4
      docs/esp8266/tutorial/network_basics.rst
  4. 24
      docs/library/network.WLAN.rst
  5. 8
      docs/library/network.rst

6
docs/esp32/quickref.rst

@ -76,12 +76,12 @@ The :mod:`network` module::
wlan.active(True) # activate the interface wlan.active(True) # activate the interface
wlan.scan() # scan for access points wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP wlan.isconnected() # check if the station is connected to an AP
wlan.connect('essid', 'password') # connect to an AP wlan.connect('ssid', 'key') # connect to an AP
wlan.config('mac') # get the interface's MAC address wlan.config('mac') # get the interface's MAC address
wlan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses wlan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses
ap = network.WLAN(network.AP_IF) # create access-point interface ap = network.WLAN(network.AP_IF) # create access-point interface
ap.config(essid='ESP-AP') # set the ESSID of the access point ap.config(ssid='ESP-AP') # set the SSID of the access point
ap.config(max_clients=10) # set how many clients can connect to the network ap.config(max_clients=10) # set how many clients can connect to the network
ap.active(True) # activate the interface ap.active(True) # activate the interface
@ -93,7 +93,7 @@ A useful function for connecting to your local WiFi network is::
wlan.active(True) wlan.active(True)
if not wlan.isconnected(): if not wlan.isconnected():
print('connecting to network...') print('connecting to network...')
wlan.connect('essid', 'password') wlan.connect('ssid', 'key')
while not wlan.isconnected(): while not wlan.isconnected():
pass pass
print('network config:', wlan.ifconfig()) print('network config:', wlan.ifconfig())

6
docs/esp8266/quickref.rst

@ -57,13 +57,13 @@ The :mod:`network` module::
wlan.active(True) # activate the interface wlan.active(True) # activate the interface
wlan.scan() # scan for access points wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP wlan.isconnected() # check if the station is connected to an AP
wlan.connect('essid', 'password') # connect to an AP wlan.connect('ssid', 'key') # connect to an AP
wlan.config('mac') # get the interface's MAC address wlan.config('mac') # get the interface's MAC address
wlan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses wlan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses
ap = network.WLAN(network.AP_IF) # create access-point interface ap = network.WLAN(network.AP_IF) # create access-point interface
ap.active(True) # activate the interface ap.active(True) # activate the interface
ap.config(essid='ESP-AP') # set the ESSID of the access point ap.config(ssid='ESP-AP') # set the SSID of the access point
A useful function for connecting to your local WiFi network is:: A useful function for connecting to your local WiFi network is::
@ -73,7 +73,7 @@ A useful function for connecting to your local WiFi network is::
wlan.active(True) wlan.active(True)
if not wlan.isconnected(): if not wlan.isconnected():
print('connecting to network...') print('connecting to network...')
wlan.connect('essid', 'password') wlan.connect('ssid', 'key')
while not wlan.isconnected(): while not wlan.isconnected():
pass pass
print('network config:', wlan.ifconfig()) print('network config:', wlan.ifconfig())

4
docs/esp8266/tutorial/network_basics.rst

@ -37,7 +37,7 @@ First activate the station interface::
Then connect to your WiFi network:: Then connect to your WiFi network::
>>> sta_if.connect('<your ESSID>', '<your password>') >>> sta_if.connect('<your SSID>', '<your key>')
To check if the connection is established use:: To check if the connection is established use::
@ -61,7 +61,7 @@ connect to your WiFi network::
if not sta_if.isconnected(): if not sta_if.isconnected():
print('connecting to network...') print('connecting to network...')
sta_if.active(True) sta_if.active(True)
sta_if.connect('<essid>', '<password>') sta_if.connect('<ssid>', '<key>')
while not sta_if.isconnected(): while not sta_if.isconnected():
pass pass
print('network config:', sta_if.ifconfig()) print('network config:', sta_if.ifconfig())

24
docs/library/network.WLAN.rst

@ -10,7 +10,7 @@ This class provides a driver for WiFi network processors. Example usage::
# enable station interface and connect to WiFi access point # enable station interface and connect to WiFi access point
nic = network.WLAN(network.STA_IF) nic = network.WLAN(network.STA_IF)
nic.active(True) nic.active(True)
nic.connect('your-ssid', 'your-password') nic.connect('your-ssid', 'your-key')
# now use sockets as usual # now use sockets as usual
Constructors Constructors
@ -32,9 +32,9 @@ Methods
argument is passed. Otherwise, query current state if no argument is argument is passed. Otherwise, query current state if no argument is
provided. Most other methods require active interface. provided. Most other methods require active interface.
.. method:: WLAN.connect(ssid=None, password=None, *, bssid=None) .. method:: WLAN.connect(ssid=None, key=None, *, bssid=None)
Connect to the specified wireless network, using the specified password. Connect to the specified wireless network, using the specified key.
If *bssid* is given then the connection will be restricted to the If *bssid* is given then the connection will be restricted to the
access-point with that MAC address (the *ssid* must also be specified access-point with that MAC address (the *ssid* must also be specified
in this case). in this case).
@ -52,12 +52,12 @@ Methods
Scanning is only possible on STA interface. Returns list of tuples with Scanning is only possible on STA interface. Returns list of tuples with
the information about WiFi access points: the information about WiFi access points:
(ssid, bssid, channel, RSSI, authmode, hidden) (ssid, bssid, channel, RSSI, security, hidden)
*bssid* is hardware address of an access point, in binary form, returned as *bssid* is hardware address of an access point, in binary form, returned as
bytes object. You can use `binascii.hexlify()` to convert it to ASCII form. bytes object. You can use `binascii.hexlify()` to convert it to ASCII form.
There are five values for authmode: There are five values for security:
* 0 -- open * 0 -- open
* 1 -- WEP * 1 -- WEP
@ -112,10 +112,10 @@ Methods
multiple parameters can be set at once. For querying, parameters name should multiple parameters can be set at once. For querying, parameters name should
be quoted as a string, and only one parameter can be queries at time:: be quoted as a string, and only one parameter can be queries at time::
# Set WiFi access point name (formally known as ESSID) and WiFi channel # Set WiFi access point name (formally known as SSID) and WiFi channel
ap.config(essid='My AP', channel=11) ap.config(ssid='My AP', channel=11)
# Query params one by one # Query params one by one
print(ap.config('essid')) print(ap.config('ssid'))
print(ap.config('channel')) print(ap.config('channel'))
Following are commonly supported parameters (availability of a specific parameter Following are commonly supported parameters (availability of a specific parameter
@ -125,11 +125,11 @@ Methods
Parameter Description Parameter Description
============= =========== ============= ===========
mac MAC address (bytes) mac MAC address (bytes)
essid WiFi access point name (string) ssid WiFi access point name (string)
channel WiFi channel (integer) channel WiFi channel (integer)
hidden Whether ESSID is hidden (boolean) hidden Whether SSID is hidden (boolean)
authmode Authentication mode supported (enumeration, see module constants) security Security protocol supported (enumeration, see module constants)
password Access password (string) key Access key (string)
dhcp_hostname The DHCP hostname to use dhcp_hostname The DHCP hostname to use
reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited) reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited)
txpower Maximum transmit power in dBm (integer or float) txpower Maximum transmit power in dBm (integer or float)

8
docs/library/network.rst

@ -89,7 +89,7 @@ parameter should be `id`.
network media, there are different variants of predefined/ network media, there are different variants of predefined/
recommended tuple formats, among them: recommended tuple formats, among them:
* WiFi: (ssid, bssid, channel, RSSI, authmode, hidden). There * WiFi: (ssid, bssid, channel, RSSI, security, hidden). There
may be further fields, specific to a particular device. may be further fields, specific to a particular device.
The function may accept additional keyword arguments to filter scan The function may accept additional keyword arguments to filter scan
@ -133,10 +133,10 @@ parameter should be `id`.
querying, a parameter name should be quoted as a string, and only one querying, a parameter name should be quoted as a string, and only one
parameter can be queried at a time:: parameter can be queried at a time::
# Set WiFi access point name (formally known as ESSID) and WiFi channel # Set WiFi access point name (formally known as SSID) and WiFi channel
ap.config(essid='My AP', channel=11) ap.config(ssid='My AP', channel=11)
# Query params one by one # Query params one by one
print(ap.config('essid')) print(ap.config('ssid'))
print(ap.config('channel')) print(ap.config('channel'))
Specific network class implementations Specific network class implementations

Loading…
Cancel
Save