summaryrefslogtreecommitdiffstatshomepage
path: root/docs/esp32
diff options
context:
space:
mode:
Diffstat (limited to 'docs/esp32')
-rw-r--r--docs/esp32/quickref.rst24
1 files changed, 12 insertions, 12 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst
index d65782e501..ccc01099d1 100644
--- a/docs/esp32/quickref.rst
+++ b/docs/esp32/quickref.rst
@@ -83,30 +83,30 @@ The :class:`network.WLAN` class in the :mod:`network` module::
import network
- wlan = network.WLAN(network.WLAN.IF_STA) # create station interface
- wlan.active(True) # activate the interface
- wlan.scan() # scan for access points
- wlan.isconnected() # check if the station is connected to an AP
+ wlan = network.WLAN() # create station interface (the default, see below for an access point interface)
+ wlan.active(True) # activate the interface
+ wlan.scan() # scan for access points
+ wlan.isconnected() # check if the station is connected to an AP
wlan.connect('ssid', 'key') # connect to an AP
- wlan.config('mac') # get the interface's MAC address
- wlan.ipconfig('addr4') # get the interface's IPv4 addresses
+ wlan.config('mac') # get the interface's MAC address
+ wlan.ipconfig('addr4') # get the interface's IPv4 addresses
ap = network.WLAN(network.WLAN.IF_AP) # create access-point interface
- 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.active(True) # activate the interface
+ 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.active(True) # activate the interface
A useful function for connecting to your local WiFi network is::
def do_connect():
- import network
- wlan = network.WLAN(network.WLAN.IF_STA)
+ import machine, network
+ wlan = network.WLAN()
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('ssid', 'key')
while not wlan.isconnected():
- pass
+ machine.idle()
print('network config:', wlan.ipconfig('addr4'))
Once the network is established the :mod:`socket <socket>` module can be used