Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/HTTP_Server_Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ void _APSetup() {
void startWifi() {
int i = 0;

// 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;
}

// Trying Station mode first:
if (strcmp(userConfig->getSsid(), DEVICE_NAME) != 0) {
SS2K_LOG(HTTP_SERVER_LOG_TAG, "Connecting to: %s", userConfig->getSsid());
Expand Down Expand Up @@ -134,13 +141,25 @@ void startWifi() {
}

void stopWifi() {
// 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());
// Stop DirCon service before disconnecting WiFi
DirConManager::stop();
WiFi.disconnect();
}

void HTTP_Server::start() {
// Don't start HTTP server if WiFi is disabled
if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) {
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP server not started - WiFi disabled");
return;
}

server.enableCORS(true);
server.onNotFound(handleIndexFile);

Expand Down Expand Up @@ -413,6 +432,11 @@ void HTTP_Server::start() {
}

void HTTP_Server::webClientUpdate() {
// Don't handle web clients if WiFi is disabled
if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) {
return;
}

static unsigned long int _webClientTimer = millis();
if (millis() - _webClientTimer > WEBSERVER_DELAY) {
_webClientTimer = millis();
Expand Down Expand Up @@ -638,6 +662,12 @@ void HTTP_Server::settingsProcessor() {
}

void HTTP_Server::stop() {
// 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;
}

SS2K_LOG(HTTP_SERVER_LOG_TAG, "Stopping Http Server");
server.stop();
server.close();
Expand All @@ -647,6 +677,13 @@ void HTTP_Server::stop() {
// 70:94:DE:DD:E6:C4:69:48:3A:92:70:A1:48:56:78:2D:18:64:E0:B7

void HTTP_Server::FirmwareUpdate() {
// Skip firmware update if WiFi is disabled
if (strcmp(userConfig->getSsid(), "") == 0 || strcmp(userConfig->getSsid(), "none") == 0) {
SS2K_LOG(HTTP_SERVER_LOG_TAG, "Firmware update skipped - WiFi disabled");
httpServer.internetConnection = false;
return;
}

HTTPClient http;
WiFiClientSecure localClient;
localClient.setCACert(rootCACertificate);
Expand Down