Skip to content

Commit 37ab061

Browse files
deshipudpgeorge
authored andcommitted
docs: Update esp8266 documentation to match the code.
* Move the esp.status() to network module. * Describe the wifi.isconnected() method. * Describe esp.mac(), esp.wifi_mode(), esp.phy_mode(), esp.sleep_type(), esp.deepsleep(), and esp.flash_id() functions.
1 parent aaa8867 commit 37ab061

2 files changed

Lines changed: 79 additions & 10 deletions

File tree

docs/library/esp.rst

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ The ``esp`` module contains specific functions related to the ESP8266 module.
1010
Functions
1111
---------
1212

13-
.. function:: status()
13+
.. function:: mac([address])
1414

15-
Return the current status of the wireless connection.
15+
Get or set the network interface's MAC address.
1616

17-
The possible statuses are defined as constants:
18-
19-
* ``STAT_IDLE`` -- no connection and no activity,
20-
* ``STAT_CONNECTING`` -- connecting in progress,
21-
* ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password,
22-
* ``STAT_NO_AP_FOUND`` -- failed because no access point replied,
23-
* ``STAT_CONNECT_FAIL`` -- failed due to other problems,
24-
* ``STAT_GOT_IP`` -- connection susccessful.
17+
If the ``address`` parameter is provided, sets the address to its value. If
18+
the function is called wihout parameters, returns the current address.
2519

2620
.. function:: getaddrinfo((hostname, port, lambda))
2721

@@ -31,6 +25,61 @@ Functions
3125
called with two arguments, first being the hostname being resolved,
3226
second a tuple with information about that hostname.
3327

28+
.. function:: wifi_mode([mode])
29+
30+
Get or set the wireless network operating mode.
31+
32+
If the ``mode`` parameter is provided, sets the mode to its value. If
33+
the function is called wihout parameters, returns the current mode.
34+
35+
The possible modes are defined as constants:
36+
37+
* ``STA_MODE`` -- station mode,
38+
* ``AP_MODE`` -- software access point mode,
39+
* ``STA_AP_MODE`` -- mixed station and software access point mode.
40+
41+
.. function:: phy_mode([mode])
42+
43+
Get or set the network interface mode.
44+
45+
If the ``mode`` parameter is provided, sets the mode to its value. If
46+
the function is called wihout parameters, returns the current mode.
47+
48+
The possible modes are defined as constants:
49+
* ``MODE_11B`` -- IEEE 802.11b,
50+
* ``MODE_11G`` -- IEEE 802.11g,
51+
* ``MODE_11N`` -- IEEE 802.11n.
52+
53+
.. function:: sleep_type([sleep_type])
54+
55+
Get or set the sleep type.
56+
57+
If the ``sleep_type`` parameter is provided, sets the sleep type to its
58+
value. If the function is called wihout parameters, returns the current
59+
sleep type.
60+
61+
The possible sleep types are defined as constants:
62+
63+
* ``SLEEP_NONE`` -- all functions enabled,
64+
* ``SLEEP_MODEM`` -- modem sleep, shuts down the WiFi Modem circuit.
65+
* ``SLEEP_LIGHT`` -- light sleep, shuts down the WiFi Modem circuit
66+
and suspends the processor periodically.
67+
68+
The system enters the set sleep mode automatically when possible.
69+
70+
.. function:: deepsleep(time=0)
71+
72+
Enter deep sleep.
73+
74+
The whole module powers down, except for the RTC clock circuit, which can
75+
be used to restart the module after the specified time if the pin 16 is
76+
connected to the reset pin. Otherwise the module will sleep until manually
77+
reset.
78+
79+
.. function:: flash_id()
80+
81+
Read the device ID of the flash memory.
82+
3483
Classes
3584
-------
3685

docs/library/network.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,26 @@ class WLAN
236236
* 0 -- visible
237237
* 1 -- hidden
238238

239+
.. method:: status()
240+
241+
Return the current status of the wireless connection.
242+
243+
The possible statuses are defined as constants:
244+
245+
* ``STAT_IDLE`` -- no connection and no activity,
246+
* ``STAT_CONNECTING`` -- connecting in progress,
247+
* ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password,
248+
* ``STAT_NO_AP_FOUND`` -- failed because no access point replied,
249+
* ``STAT_CONNECT_FAIL`` -- failed due to other problems,
250+
* ``STAT_GOT_IP`` -- connection susccessful.
251+
252+
.. method:: wlan.isconnected()
253+
254+
In case of STA mode, returns ``True`` if connected to a wifi access
255+
point and has a valid IP address. In AP mode returns ``True`` when a
256+
station is connected. Returns ``False`` otherwise.
257+
258+
239259
.. only:: port_wipy
240260

241261
This class provides a driver for WiFi network processor in the WiPy. Example usage::

0 commit comments

Comments
 (0)