Revert "Dodanie REST API w tle (endpoint /api/wifi) sluzacego do zdalnego dopisywania nowej sieci WiFi do pliku konfiguracyjnego w czasie normalnej pracy"

This reverts commit 37b9c8160f.
This commit is contained in:
Victus
2026-05-11 01:21:38 +02:00
parent 7699c48fcb
commit 1e2dc7a3aa
2 changed files with 0 additions and 31 deletions

View File

@@ -46,7 +46,6 @@ class WiFiManager {
void handleClient();
void startCaptivePortal();
void handleApiWifi();
void handleRoot();
void handleSave();
void handleNotFound();
@@ -71,7 +70,6 @@ class WiFiManager {
private:
bool isAccessPoint = false;
bool captivePortalActive = false;
bool serverActive = false;
WebServer server{80};
DNSServer dnsServer;
int expectedCaptchaAnswer = 0;

View File

@@ -107,12 +107,6 @@ void WiFiManager::connectToWiFi() {
ESP_LOGI(WIFI, "%s", gatewayInfo.c_str());
String dnsInfo = "DNS: " + WiFi.dnsIP().toString();
ESP_LOGI(WIFI, "%s", dnsInfo.c_str());
// Start background API server
server.on("/api/wifi", HTTP_POST, std::bind(&WiFiManager::handleApiWifi, this));
server.begin();
serverActive = true;
ESP_LOGI(WIFI, "REST API Server started on port 80");
} else {
String infoWiFi = "WIFI CONNECTION ERROR: ALL FAILED";
ESP_LOGI(WIFI, "%s", infoWiFi.c_str());
@@ -306,33 +300,10 @@ void WiFiManager::startCaptivePortal() {
void WiFiManager::handleClient() {
if (captivePortalActive) {
dnsServer.processNextRequest();
}
if (captivePortalActive || serverActive) {
server.handleClient();
}
}
void WiFiManager::handleApiWifi() {
if (!server.hasArg("ssid") || !server.hasArg("password")) {
server.send(400, "text/plain", "Error: Missing 'ssid' or 'password' parameter.");
return;
}
String newSSID = server.arg("ssid");
String newPass = server.arg("password");
File f = SD.open("/wifi.txt", FILE_APPEND);
if (f) {
f.println(newSSID + ";" + newPass);
f.close();
server.send(200, "text/plain", "Success: WiFi credentials saved to SD card.");
ESP_LOGI(WIFI, "API received new WiFi config: %s", newSSID.c_str());
} else {
server.send(500, "text/plain", "Error: Cannot open wifi.txt on SD card.");
ESP_LOGE(WIFI, "API Error: Cannot open wifi.txt");
}
}
void WiFiManager::handleRoot() {
int bases[] = {2, 2, 2, 2, 3, 3, 10, 10};
int vals[] = {4, 8, 16, 32, 9, 27, 100, 1000};