From 6534ff1d27d99325c55fa740f605ff9baf7e311d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:18:39 +0000 Subject: [PATCH 1/4] Initial plan From d076a22f509efa904752797dbf7c72b7d8397c6e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:28:36 +0000 Subject: [PATCH 2/4] Document power management constants for ESP32/ESP8266 and Cyw43 Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com> --- reference/micropython/network/WLAN.pyi | 29 +++++++++++++++---- .../check_network/check_wlan.py | 7 ++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/reference/micropython/network/WLAN.pyi b/reference/micropython/network/WLAN.pyi index 9820180cb..6794ea0bb 100644 --- a/reference/micropython/network/WLAN.pyi +++ b/reference/micropython/network/WLAN.pyi @@ -19,17 +19,34 @@ class WLAN: """ PM_NONE: int - PM_POWERSAVE: int PM_PERFORMANCE: int + PM_POWERSAVE: int """\ Allowed values for the ``WLAN.config(pm=...)`` network interface parameter: - * ``PM_PERFORMANCE``: enable WiFi power management to balance power - savings and WiFi performance - * ``PM_POWERSAVE``: enable WiFi power management with additional power - savings and reduced WiFi performance - * ``PM_NONE``: disable wifi power management + * ``PM_NONE``: disable WiFi power management (always on, highest performance, highest power consumption) + * ``PM_PERFORMANCE``: enable WiFi power management to balance power savings and WiFi performance + * ``PM_POWERSAVE``: enable WiFi power management with additional power savings and reduced WiFi performance + + **Note:** The numeric values of these constants are platform-specific: + + * **ESP32/ESP8266** (using Espressif WiFi driver): + + - ``PM_NONE = 0`` (maps to WIFI_PS_NONE) + - ``PM_PERFORMANCE = 1`` (maps to WIFI_PS_MIN_MODEM) + - ``PM_POWERSAVE = 2`` (maps to WIFI_PS_MAX_MODEM) + + * **RP2 Pico W** (using Cyw43 driver): + + - ``PM_NONE = 16`` (0x10) + - ``PM_PERFORMANCE = 10555714`` (0xa11142, aggressive power saving disabled) + - ``PM_POWERSAVE = 17`` (0x11, aggressive power saving enabled) + + Always use the symbolic constants (``PM_NONE``, ``PM_PERFORMANCE``, ``PM_POWERSAVE``) rather than + numeric values for portability across different MicroPython ports and boards. + + See: https://github.com/micropython/micropython/blob/master/ports/esp32/network_wlan.c """ def __init__(self, interface_id: int = ..., /) -> None: diff --git a/tests/quality_tests/feat_networking/check_network/check_wlan.py b/tests/quality_tests/feat_networking/check_network/check_wlan.py index 09d62ad63..647677db6 100644 --- a/tests/quality_tests/feat_networking/check_network/check_wlan.py +++ b/tests/quality_tests/feat_networking/check_network/check_wlan.py @@ -4,4 +4,9 @@ # ref : https://github.com/Josverl/micropython-stubber/issues/338 wlan = network.WLAN(network.STA_IF) -wlan.config(pm = 0xa11140) # set power mode to get WiFi power-saving off (if needed) \ No newline at end of file +wlan.config(pm = 0xa11140) # set power mode to get WiFi power-saving off (if needed) + +# Better: Use symbolic constants for portability across different MicroPython ports +wlan.config(pm=network.WLAN.PM_NONE) # Disable power management +wlan.config(pm=network.WLAN.PM_PERFORMANCE) # Balanced power/performance +wlan.config(pm=network.WLAN.PM_POWERSAVE) # Maximum power saving \ No newline at end of file From 8953700974897009a3adb99cadd20966ff1b41d5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:31:34 +0000 Subject: [PATCH 3/4] Fix ESP8266 PM constant values in documentation Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com> --- reference/micropython/network/WLAN.pyi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reference/micropython/network/WLAN.pyi b/reference/micropython/network/WLAN.pyi index 6794ea0bb..934dc1792 100644 --- a/reference/micropython/network/WLAN.pyi +++ b/reference/micropython/network/WLAN.pyi @@ -31,12 +31,18 @@ class WLAN: **Note:** The numeric values of these constants are platform-specific: - * **ESP32/ESP8266** (using Espressif WiFi driver): + * **ESP32** (using Espressif WiFi driver): - ``PM_NONE = 0`` (maps to WIFI_PS_NONE) - ``PM_PERFORMANCE = 1`` (maps to WIFI_PS_MIN_MODEM) - ``PM_POWERSAVE = 2`` (maps to WIFI_PS_MAX_MODEM) + * **ESP8266** (using Espressif WiFi driver): + + - ``PM_NONE = 0`` + - ``PM_PERFORMANCE = 2`` + - ``PM_POWERSAVE = 1`` + * **RP2 Pico W** (using Cyw43 driver): - ``PM_NONE = 16`` (0x10) From 6b588ea15a6858fd042490fbfa87a6df23b092d0 Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Mon, 10 Nov 2025 10:58:05 +0100 Subject: [PATCH 4/4] Refactor WLAN power management constants Updated WLAN power management constants to include default values and improved documentation. --- reference/micropython/network/WLAN.pyi | 44 +++++--------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/reference/micropython/network/WLAN.pyi b/reference/micropython/network/WLAN.pyi index 934dc1792..c0552a45c 100644 --- a/reference/micropython/network/WLAN.pyi +++ b/reference/micropython/network/WLAN.pyi @@ -18,42 +18,14 @@ class WLAN: # now use sockets as usual """ - PM_NONE: int - PM_PERFORMANCE: int - PM_POWERSAVE: int - - """\ - Allowed values for the ``WLAN.config(pm=...)`` network interface parameter: - - * ``PM_NONE``: disable WiFi power management (always on, highest performance, highest power consumption) - * ``PM_PERFORMANCE``: enable WiFi power management to balance power savings and WiFi performance - * ``PM_POWERSAVE``: enable WiFi power management with additional power savings and reduced WiFi performance - - **Note:** The numeric values of these constants are platform-specific: - - * **ESP32** (using Espressif WiFi driver): - - - ``PM_NONE = 0`` (maps to WIFI_PS_NONE) - - ``PM_PERFORMANCE = 1`` (maps to WIFI_PS_MIN_MODEM) - - ``PM_POWERSAVE = 2`` (maps to WIFI_PS_MAX_MODEM) - - * **ESP8266** (using Espressif WiFi driver): - - - ``PM_NONE = 0`` - - ``PM_PERFORMANCE = 2`` - - ``PM_POWERSAVE = 1`` - - * **RP2 Pico W** (using Cyw43 driver): - - - ``PM_NONE = 16`` (0x10) - - ``PM_PERFORMANCE = 10555714`` (0xa11142, aggressive power saving disabled) - - ``PM_POWERSAVE = 17`` (0x11, aggressive power saving enabled) - - Always use the symbolic constants (``PM_NONE``, ``PM_PERFORMANCE``, ``PM_POWERSAVE``) rather than - numeric values for portability across different MicroPython ports and boards. - - See: https://github.com/micropython/micropython/blob/master/ports/esp32/network_wlan.c - """ + PM_NONE: int = ... + """Disable WiFi power management (always on, highest performance, highest power consumption)""" + PM_PERFORMANCE: int = ... + """Enable WiFi power management to balance power savings and WiFi performance""" + PM_POWERSAVE: int = ... + """Enable WiFi power management with additional power savings and reduced WiFi performance"""" + + // **Note:** The numeric values of these constants are platform-specific: def __init__(self, interface_id: int = ..., /) -> None: """