⛱️ Updates logging to use ESP_LOG in favor Serial

This commit is contained in:
Rune Harlyk
2024-06-08 20:59:41 +02:00
committed by Rune Harlyk
parent 2e370ea217
commit 81792f3dd5
@@ -14,6 +14,8 @@
#include <APSettingsService.h> #include <APSettingsService.h>
static const char* TAG = "APSettingsService";
APSettingsService::APSettingsService(PsychicHttpServer *server, APSettingsService::APSettingsService(PsychicHttpServer *server,
FS *fs, FS *fs,
SecurityManager *securityManager) : _server(server), SecurityManager *securityManager) : _server(server),
@@ -45,9 +47,7 @@ void APSettingsService::reconfigureAP()
void APSettingsService::recoveryMode() void APSettingsService::recoveryMode()
{ {
#ifdef SERIAL_INFO ESP_LOGI(TAG, "Recovery Mode needed");
Serial.println("Recovery Mode needed");
#endif
_lastManaged = millis() - MANAGE_NETWORK_DELAY; _lastManaged = millis() - MANAGE_NETWORK_DELAY;
_recoveryMode = true; _recoveryMode = true;
_reconfigureAp = true; _reconfigureAp = true;
@@ -56,7 +56,7 @@ void APSettingsService::recoveryMode()
void APSettingsService::loop() void APSettingsService::loop()
{ {
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
unsigned long manageElapsed = (unsigned long)(currentMillis - _lastManaged); unsigned long manageElapsed = (currentMillis - _lastManaged);
if (manageElapsed >= MANAGE_NETWORK_DELAY) if (manageElapsed >= MANAGE_NETWORK_DELAY)
{ {
_lastManaged = currentMillis; _lastManaged = currentMillis;
@@ -86,9 +86,7 @@ void APSettingsService::manageAP()
void APSettingsService::startAP() void APSettingsService::startAP()
{ {
#ifdef SERIAL_INFO ESP_LOGI(TAG, "Starting software access point");
Serial.println("Starting software access point");
#endif
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask); WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients); WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients);
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3
@@ -97,10 +95,7 @@ void APSettingsService::startAP()
if (!_dnsServer) if (!_dnsServer)
{ {
IPAddress apIp = WiFi.softAPIP(); IPAddress apIp = WiFi.softAPIP();
#ifdef SERIAL_INFO ESP_LOGI(TAG, "Starting captive portal on %s", apIp.toString().c_str());
Serial.print("Starting captive portal on ");
Serial.println(apIp);
#endif
_dnsServer = new DNSServer; _dnsServer = new DNSServer;
_dnsServer->start(DNS_PORT, "*", apIp); _dnsServer->start(DNS_PORT, "*", apIp);
} }
@@ -110,16 +105,12 @@ void APSettingsService::stopAP()
{ {
if (_dnsServer) if (_dnsServer)
{ {
#ifdef SERIAL_INFO ESP_LOGI(TAG, "Stopping captive portal");
Serial.println("Stopping captive portal");
#endif
_dnsServer->stop(); _dnsServer->stop();
delete _dnsServer; delete _dnsServer;
_dnsServer = nullptr; _dnsServer = nullptr;
} }
#ifdef SERIAL_INFO ESP_LOGI(TAG, "Stopping AP");
Serial.println("Stopping software access point");
#endif
WiFi.softAPdisconnect(true); WiFi.softAPdisconnect(true);
} }