[FR] Disable WiFi and network services via SSID configuration#669
[FR] Disable WiFi and network services via SSID configuration#669Copilot wants to merge 6 commits into
Conversation
|
@doudar 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
|
@copilot There have been several firmware updates since this was first drafted. Please check to see if it's still viable. If the SSID is "none" there should be no WiFi startup, no UDP logging, No Dircon, or anything else that requires networking. |
There was a problem hiding this comment.
Pull request overview
Adds a configuration-driven way to disable WiFi (and associated HTTP/update behaviors) by treating SSID values "" or "none" as a sentinel “WiFi disabled” setting, keeping BLE-based configuration/control available.
Changes:
- Add early-exit checks in
startWifi()to skip WiFi radio initialization when SSID is""or"none". - Skip HTTP server startup/client handling and firmware update checks when WiFi is disabled.
- Add guard logic to
stopWifi()/HTTP_Server::stop()for the disabled-SSID case.
| // Check if WiFi is disabled via special SSID values | ||
| if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) { | ||
| SS2K_LOG(HTTP_SERVER_LOG_TAG, "WiFi disabled via SSID configuration: '%s'", userConfig->getSsid()); | ||
| httpServer.internetConnection = false; | ||
| return; | ||
| } |
| // Check if WiFi is disabled via special SSID values | ||
| if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) { | ||
| SS2K_LOG(HTTP_SERVER_LOG_TAG, "WiFi disabled via SSID configuration: '%s'", userConfig->getSsid()); | ||
| httpServer.internetConnection = false; | ||
| return; | ||
| } |
| // Check if WiFi was disabled via special SSID values | ||
| if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) { | ||
| SS2K_LOG(HTTP_SERVER_LOG_TAG, "WiFi was disabled, nothing to stop"); | ||
| return; | ||
| } | ||
|
|
||
| SS2K_LOG(HTTP_SERVER_LOG_TAG, "Closing connection to: %s", userConfig->getSsid()); |
| // Don't try to stop HTTP server if WiFi is disabled | ||
| if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) { | ||
| SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP server was not started - WiFi disabled"); | ||
| return; | ||
| } | ||
|
|
Agent-Logs-Url: https://github.com/doudar/SmartSpin2k/sessions/931c8bb8-5824-4b5e-b080-084036fdcd3d Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/doudar/SmartSpin2k/sessions/931c8bb8-5824-4b5e-b080-084036fdcd3d Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Checked against the current firmware paths and updated the PR. Commit 46a5aa0 centralizes WiFi-disabled detection and ensures SSID |
| DirConManager::stop(); | ||
| dnsServer.stop(); | ||
| MDNS.end(); | ||
| WiFi.disconnect(true, true); |
|
@copilot I think preferably all the guards would be inside of main for better maintainability. |
Agent-Logs-Url: https://github.com/doudar/SmartSpin2k/sessions/e759c192-9c60-4e03-be5d-88fac969b873 Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/doudar/SmartSpin2k/sessions/e759c192-9c60-4e03-be5d-88fac969b873 Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Updated in 745cbfd. The network-feature guards are now centralized in |
This PR implements the ability to completely disable WiFi and network-dependent services by setting the SSID to special values, addressing the need to eliminate unnecessary WiFi signals and networking activity that could interfere with other devices.
Implementation
When the SSID is set to either an empty string
""or"none", the SmartSpin2k will:WIFI_MODE_NULLinternetConnectionflag to falseBLE functionality remains fully operational for device configuration and control when WiFi is disabled.
Usage
Users can disable WiFi through the SmartSpin2K companion app by:
The setting persists across device reboots and can be re-enabled by setting a valid SSID.
Technical Details
The implementation adds a shared WiFi-disabled check and guards key network paths:
isWifiDisabled()- Centralized check for disabled SSID valuesstartWifi()- Powers networking down and returns early when WiFi is disabledstopWifi()- Uses shared shutdown logic for WiFi/network servicesHTTP_Server::start()- Skips server initializationHTTP_Server::FirmwareUpdate()- Skips update checksHTTP_Server::webClientUpdate()- Skips client handlingDirConManager::start()- Prevents DirCon startupAll network-dependent components safely handle the disabled state, and existing functionality remains unchanged when WiFi is enabled.
Validation
pio run -e releasepasses.test/data_helpers.cppincluding Windows-only<io.h>.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.