Skip to content

Commit 503e615

Browse files
authored
Merge pull request #848 from Josverl/copilot/add-powermanagement-constants
Document platform-specific WiFi power management constants for ESP32, ESP8266, and Cyw43
2 parents 1dae9b0 + 6b588ea commit 503e615

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

reference/micropython/network/WLAN.pyi

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@ class WLAN:
1818
# now use sockets as usual
1919
"""
2020

21-
PM_NONE: int
22-
PM_POWERSAVE: int
23-
PM_PERFORMANCE: int
24-
25-
"""\
26-
Allowed values for the ``WLAN.config(pm=...)`` network interface parameter:
27-
28-
* ``PM_PERFORMANCE``: enable WiFi power management to balance power
29-
savings and WiFi performance
30-
* ``PM_POWERSAVE``: enable WiFi power management with additional power
31-
savings and reduced WiFi performance
32-
* ``PM_NONE``: disable wifi power management
33-
"""
21+
PM_NONE: int = ...
22+
"""Disable WiFi power management (always on, highest performance, highest power consumption)"""
23+
PM_PERFORMANCE: int = ...
24+
"""Enable WiFi power management to balance power savings and WiFi performance"""
25+
PM_POWERSAVE: int = ...
26+
"""Enable WiFi power management with additional power savings and reduced WiFi performance""""
27+
28+
// **Note:** The numeric values of these constants are platform-specific:
3429

3530
def __init__(self, interface_id: int = ..., /) -> None:
3631
"""

tests/quality_tests/feat_networking/check_network/check_wlan.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
# ref : https://github.com/Josverl/micropython-stubber/issues/338
55
wlan = network.WLAN(network.STA_IF)
66

7-
wlan.config(pm = 0xa11140) # set power mode to get WiFi power-saving off (if needed)
7+
wlan.config(pm = 0xa11140) # set power mode to get WiFi power-saving off (if needed)
8+
9+
# Better: Use symbolic constants for portability across different MicroPython ports
10+
wlan.config(pm=network.WLAN.PM_NONE) # Disable power management
11+
wlan.config(pm=network.WLAN.PM_PERFORMANCE) # Balanced power/performance
12+
wlan.config(pm=network.WLAN.PM_POWERSAVE) # Maximum power saving

0 commit comments

Comments
 (0)