Add configurable WiFi power save mode via NVS key "wifi_ps"#552
Add configurable WiFi power save mode via NVS key "wifi_ps"#552gnoe-gnoe wants to merge 1 commit intosle118:master-v4.3from
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the WiFi management system by introducing a user-configurable power save mode. Previously, the power save setting was fixed, which could lead to connectivity and stability problems in certain scenarios. The update allows the system to dynamically adjust its power consumption behavior based on a setting stored in Non-Volatile Storage (NVS), providing greater control and improving overall reliability for connected devices. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WiFi power save was hardcoded to WIFI_PS_MIN_MODEM, which can cause watchdog timeouts and CCMP replay errors when routers reset overnight. The power save mode is now configurable via the NVS key "wifi_ps": 0 = WIFI_PS_NONE (no power management) 1 = WIFI_PS_MIN_MODEM (default, minimum power save) 2 = WIFI_PS_MAX_MODEM (maximum power save) Also explicitly calls esp_wifi_set_ps() in STA mode (previously only called in AP mode).
a09510e to
d384f38
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable WiFi power save mode via an NVS key, which is a valuable enhancement for flexibility. The implementation is sound, creating a new function to retrieve the setting and applying it during WiFi setup. I have provided a couple of minor suggestions to streamline the code and reduce log redundancy.
| uint16_t ps_mode = DEFAULT_STA_POWER_SAVE; | ||
| config_get_uint16t_from_str("wifi_ps", &ps_mode, DEFAULT_STA_POWER_SAVE); |
There was a problem hiding this comment.
The ps_mode variable is initialized, but its value is immediately overwritten by config_get_uint16t_from_str in the next line, as this function handles setting a default value if the NVS key is not found. The initial assignment is redundant and can be removed to make the code slightly cleaner.
uint16_t ps_mode;
config_get_uint16t_from_str("wifi_ps", &ps_mode, DEFAULT_STA_POWER_SAVE);| msg = "Setting wifi power save"; | ||
| ESP_LOGD(TAG, "%s (%d)", msg, DEFAULT_STA_POWER_SAVE); | ||
| wifi_ps_type_t ps_mode = network_wifi_get_ps_mode(); | ||
| ESP_LOGD(TAG, "%s (%d)", msg, ps_mode); |
WiFi power save was hardcoded to WIFI_PS_MIN_MODEM, which can cause watchdog timeouts and CCMP replay errors when routers reset overnight.
The power save mode is now configurable via the NVS key "wifi_ps":
0 = WIFI_PS_NONE (no power management)
1 = WIFI_PS_MIN_MODEM (default, minimum power save)
2 = WIFI_PS_MAX_MODEM (maximum power save)
Also explicitly calls esp_wifi_set_ps() in STA mode (previously only called in AP mode).