Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

The WiFi power management constants (PM_NONE, PM_PERFORMANCE, PM_POWERSAVE) in network.WLAN were undocumented in reference stubs, and their platform-specific numeric values were not clarified.

Changes

  • Enhanced reference/micropython/network/WLAN.pyi:

    • Added detailed docstring documenting PM constants with platform-specific values
    • Documented value discrepancy between ESP32 (0,1,2) and ESP8266 (0,2,1)
    • Added RP2 Pico W/Cyw43 values (16, 10555714, 17)
    • Included C constant mappings for ESP32 (WIFI_PS_NONE, WIFI_PS_MIN_MODEM, WIFI_PS_MAX_MODEM)
    • Recommended using symbolic constants for cross-platform portability
  • Updated tests/quality_tests/feat_networking/check_network/check_wlan.py:

    • Added examples demonstrating symbolic constant usage

Example

import network

wlan = network.WLAN(network.STA_IF)

# Platform-portable approach (recommended)
wlan.config(pm=network.WLAN.PM_NONE)        # Disable power management
wlan.config(pm=network.WLAN.PM_PERFORMANCE) # Balanced mode
wlan.config(pm=network.WLAN.PM_POWERSAVE)   # Maximum power saving

# Platform-specific magic numbers (avoid)
wlan.config(pm=0xa11140)  # Only works on RP2 Pico W

Values verified against published stubs for v1.24.1+ across ESP32, ESP8266, and RP2 ports.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add powermanagement constants for ESPxxx and Cyw43</issue_title>
<issue_description>Document constants for ESPxxx and cyw43 in reference stubs

network.wlan

{ MP_ROM_QSTR(MP_QSTR_PM_NONE), MP_ROM_INT(WIFI_PS_NONE) },
{ MP_ROM_QSTR(MP_QSTR_PM_PERFORMANCE), MP_ROM_INT(WIFI_PS_MIN_MODEM) },
{ MP_ROM_QSTR(MP_QSTR_PM_POWERSAVE), MP_ROM_INT(WIFI_PS_MAX_MODEM) },

https://github.com/micropython/micropython/blob/2762fe680a03706d3c21efe51db9b1f8d193d2d0/ports/esp32/network_wlan.c#L774C1-L776C74</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 7, 2025 13:28
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Copilot AI changed the title [WIP] Add powermanagement constants for ESPxxx and Cyw43 Document platform-specific WiFi power management constants for ESP32, ESP8266, and Cyw43 Nov 7, 2025
Copilot AI requested a review from Josverl November 7, 2025 13:35
Copilot finished work on behalf of Josverl November 7, 2025 13:35
@Josverl Josverl marked this pull request as ready for review November 9, 2025 15:04
Updated WLAN power management constants to include default values and improved documentation.
* ``PM_POWERSAVE``: enable WiFi power management with additional power savings and reduced WiFi performance
**Note:** The numeric values of these constants are platform-specific:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please summarize the different platform values in a table rather than extensive text

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot see comment above

Copilot AI requested a review from Josverl November 10, 2025 09:59
@Josverl Josverl merged commit 503e615 into main Nov 10, 2025
1 of 3 checks passed
@Josverl Josverl deleted the copilot/add-powermanagement-constants branch November 10, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add powermanagement constants for ESPxxx and Cyw43

2 participants