mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
refactoring
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user