-
-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(power): automatic WiFi disable when running on battery #9428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lexfrei
wants to merge
8
commits into
meshtastic:develop
Choose a base branch
from
lexfrei:feat/wifi-power-management
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add wifi_on_external_power_only and wifi_power_loss_timeout_secs fields to NetworkConfig structure. Updated init macros, field tags, and size. Note: Full regeneration with nanopb required before merge. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Add deinitWebServer() to properly stop and clean up web servers (HTTPS and HTTP) when WiFi is disabled at runtime. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Add stop() method to properly close UDP multicast listener when WiFi is disabled at runtime. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Add deinitWifiServices() to properly stop all WiFi-dependent services before disabling WiFi: - Syslog client - API server - Web server - mDNS - NTP client Reset APStartupComplete flag to allow services to reinitialize on reconnect. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Add handleWifiPowerManagement() to automatically manage WiFi based on external power state: - When external power is lost: start timer, disable WiFi after timeout - When external power is restored: cancel timer, re-enable WiFi - Timeout prevents accidental WiFi toggle on brief power interruptions Configuration: - wifi_on_external_power_only: enable feature (default: false) - wifi_power_loss_timeout_secs: delay before WiFi disable (default: 30s) Closes: meshtastic#9427 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Points to feat/wifi-power-management branch with new NetworkConfig fields. Will be updated to upstream master after protobufs PR is merged. See: meshtastic/protobufs#851 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Contributor
@lexfrei, Welcome to Meshtastic!Thanks for opening your first pull request. We really appreciate it. We discuss work as a team in discord, please join us in the #firmware channel. Welcome to the team 😄 |
The close() method is only available in ESP32's AsyncUDP implementation. Other platforms (nrf52, portduino/native) don't have this method, causing build failures in native simulator tests. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Portduino has HAS_WIFI=1 but excludes mesh/wifi/ from build, causing undefined reference errors for isWifiAvailable(), initWifi(), deinitWifi(). Added !defined(ARCH_PORTDUINO) guard to all WiFi power management code. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implement automatic WiFi management based on power source. When enabled, WiFi is automatically disabled when running on battery and re-enabled when external power is connected.
wifi_on_external_power_onlyconfig option to enable featurewifi_power_loss_timeout_secsconfig option for delay before disabling WiFi (default: 30s)Use Case
Docked mode (at home, charging):
Portable mode (on the go):
Implementation
WiFi Service Cleanup (hot toggle support)
deinitWebServer()to stop HTTPS/HTTP serversstop()method toUdpMulticastHandlerdeinitWifiServices()to properly shutdown all WiFi-dependent services (mDNS, NTP, Syslog, WebServer, API Server)APStartupCompleteflag to allow service reinitialization on reconnectPower-Based WiFi Control
handleWifiPowerManagement()inPower.cppmonitors USB power stateDependencies
Test Plan
Platforms
Closes: #9427