When the network module was first introduced in the esp8266 port in
ee3fec3167 there was only one interface (STA)
and, to save flash, the WLAN object was aliased to the network module,
which had just static methods for WLAN operations. This was subsequently
changed in 9e8396accb when the AP interface
was introduced, and the WLAN object became a true class.
But, network.WLAN remained a function that returned either the STA or AP
object and was never upgraded to the type itself. This scheme was then
copied over to the esp32 port when it was first introduced.
This commit changes network.WLAN from a function to a reference to the WLAN
type. This makes it consistent with other ports and network objects, and
allows accessing constants of network.WLAN without creating an instance.
Signed-off-by: Damien George <damien@micropython.org>
For esp32 and esp8266 this commit adds:
- a 'pm' option to WLAN.config() to set/get the wifi power saving mode; and
- PM_NONE, PM_PERFORMANCE and PM_POWERSAVE constants to the WLAN class.
This API should be general enough to use with all WLAN drivers.
Documentation is also added.
Rather than duplicating the implementation of `network`, this allows
ESP8266 to use the shared one in extmod. In particular this gains access
to network.hostname and network.country.
Other than adding these two methods, there is no other user-visible change.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>