refactoring

This commit is contained in:
Proddy
2024-02-12 14:21:30 +01:00
parent ed5f0bc6d5
commit 80a3007f8b
56 changed files with 555 additions and 516 deletions

View File

@@ -1,15 +1,13 @@
#include <OTASettingsService.h>
#include "OTASettingsService.h"
#include "../../src/emsesp_stub.hpp"
using namespace std::placeholders; // for `_1` etc
OTASettingsService::OTASettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
: _httpEndpoint(OTASettings::read, OTASettings::update, this, server, OTA_SETTINGS_SERVICE_PATH, securityManager)
, _fsPersistence(OTASettings::read, OTASettings::update, this, fs, OTA_SETTINGS_FILE)
, _arduinoOTA(nullptr) {
WiFi.onEvent(std::bind(&OTASettingsService::WiFiEvent, this, _1, _2));
addUpdateHandler([&] { configureArduinoOTA(); }, false);
WiFi.onEvent([this](WiFiEvent_t event, WiFiEventInfo_t info) { WiFiEvent(event); });
addUpdateHandler([this] { configureArduinoOTA(); }, false);
}
void OTASettingsService::begin() {
@@ -32,7 +30,7 @@ void OTASettingsService::configureArduinoOTA() {
if (_state.enabled) {
_arduinoOTA = new ArduinoOTAClass;
_arduinoOTA->setPort(_state.port);
_arduinoOTA->setPort(static_cast<uint16_t>(_state.port));
_arduinoOTA->setPassword(_state.password.c_str());
_arduinoOTA->onStart([] { emsesp::EMSESP::system_.upload_status(true); });
@@ -64,7 +62,7 @@ void OTASettingsService::configureArduinoOTA() {
}
}
void OTASettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
void OTASettingsService::WiFiEvent(WiFiEvent_t event) {
switch (event) {
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case ARDUINO_EVENT_ETH_GOT_IP: