Skip to content

[FR] Disable WiFi and network services via SSID configuration#669

Open
Copilot wants to merge 6 commits into
developfrom
copilot/fix-613
Open

[FR] Disable WiFi and network services via SSID configuration#669
Copilot wants to merge 6 commits into
developfrom
copilot/fix-613

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 16, 2025

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:

  • Skip WiFi radio startup and power WiFi down with WIFI_MODE_NULL
  • Disable HTTP server startup
  • Skip firmware update checks over WiFi
  • Stop/skip DirCon networking
  • Skip UDP logging and WebSocket logging network services
  • Stop DNS and mDNS services
  • Set internetConnection flag to false
  • Log appropriate messages indicating WiFi/networking is disabled

BLE functionality remains fully operational for device configuration and control when WiFi is disabled.

Usage

Users can disable WiFi through the SmartSpin2K companion app by:

  1. Connecting via Bluetooth
  2. Setting the SSID field to blank or "none"
  3. Saving the configuration

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 values
  • startWifi() - Powers networking down and returns early when WiFi is disabled
  • stopWifi() - Uses shared shutdown logic for WiFi/network services
  • HTTP_Server::start() - Skips server initialization
  • HTTP_Server::FirmwareUpdate() - Skips update checks
  • HTTP_Server::webClientUpdate() - Skips client handling
  • DirConManager::start() - Prevents DirCon startup
  • UDP/WebSocket appenders - Avoid network logging when WiFi is disabled
  • Main startup - Avoids registering network log appenders and starting DirCon when WiFi is disabled

All network-dependent components safely handle the disabled state, and existing functionality remains unchanged when WiFi is enabled.

Validation

  • pio run -e release passes.
  • Native tests are currently blocked by an existing Linux build issue in test/data_helpers.cpp including 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.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 16, 2025

@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 AI changed the title [WIP] [FR] Ability to disable WiFi [FR] Add ability to disable WiFi via SSID configuration Sep 16, 2025
Copilot AI requested a review from doudar September 16, 2025 15:19
@doudar doudar marked this pull request as ready for review May 11, 2026 00:13
Copilot AI review requested due to automatic review settings May 11, 2026 00:13
@doudar
Copy link
Copy Markdown
Owner

doudar commented May 11, 2026

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/HTTP_Server_Basic.cpp
Comment on lines +59 to +64
// 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;
}
Comment thread src/HTTP_Server_Basic.cpp
Comment on lines +59 to +64
// 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;
}
Comment thread src/HTTP_Server_Basic.cpp Outdated
Comment on lines 144 to 150
// 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());
Comment thread src/HTTP_Server_Basic.cpp Outdated
Comment on lines +665 to +670
// 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;
}

Copilot AI and others added 2 commits May 11, 2026 00:29
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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@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,...

Checked against the current firmware paths and updated the PR. Commit 46a5aa0 centralizes WiFi-disabled detection and ensures SSID none/blank powers networking down and skips HTTP startup, firmware update networking, UDP/WebSocket logging appenders, and the newer DirCon startup path in Main.cpp/DirConManager. pio run -e release passes; the native test target is still blocked by the existing Linux build issue in test/data_helpers.cpp including Windows-only <io.h>.

Copilot AI changed the title [FR] Add ability to disable WiFi via SSID configuration [FR] Disable WiFi and network services via SSID configuration May 11, 2026
Copilot finished work on behalf of doudar May 11, 2026 00:38
@doudar doudar requested a review from Copilot May 11, 2026 13:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/HTTP_Server_Basic.cpp Outdated
DirConManager::stop();
dnsServer.stop();
MDNS.end();
WiFi.disconnect(true, true);
@doudar
Copy link
Copy Markdown
Owner

doudar commented May 12, 2026

@copilot I think preferably all the guards would be inside of main for better maintainability.

Copilot AI and others added 2 commits May 12, 2026 14:45
Agent-Logs-Url: https://github.com/doudar/SmartSpin2k/sessions/e759c192-9c60-4e03-be5d-88fac969b873

Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot I think preferably all the guards would be inside of main for better maintainability.

Updated in 745cbfd. The network-feature guards are now centralized in Main.cpp/restartWifi() via a shared startNetworkServices() helper, and I removed the extra lower-level guards from HTTP/DirCon/WebSocket/UDP paths where they were no longer needed. The remaining checks below that level are just the WiFi lifecycle safety in startWifi()/stopWifi().

Copilot finished work on behalf of doudar May 12, 2026 14:53
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.

3 participants