Skip to content

Commit

Permalink
- Fixed Async logic
Browse files Browse the repository at this point in the history
- Improved definition scheme
  • Loading branch information
ayushsharma82 committed Aug 30, 2023
1 parent 3eb8730 commit f1ce3f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/ElegantOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void ElegantOTAClass::begin(AsyncWebServer *server, const char * username, const
if(_authenticate && !request->authenticate(_username, _password)){
return request->requestAuthentication();
}
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ELEGANT_HTML, sizeof(ELEGANT_HTML)));
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ELEGANT_HTML, sizeof(ELEGANT_HTML));
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});
Expand All @@ -40,8 +40,8 @@ void ElegantOTAClass::begin(AsyncWebServer *server, const char * username, const

#if ELEGANTOTA_USE_ASYNC_WEBSERVER == 1
_server->on("/ota/start", HTTP_GET, [&](AsyncWebServerRequest *request) {
if (_authenticate && !_server->authenticate(_username, _password)) {
return _server->requestAuthentication();
if (_authenticate && !request->authenticate(_username, _password)) {
return request->requestAuthentication();
}

// Get header x-ota-mode value, if present
Expand Down
21 changes: 5 additions & 16 deletions src/ElegantOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@ _____ _ _ ___ _____ _
#include "stdlib_noniso.h"
#include "elop.h"

#ifndef ELEGANTOTA_USE_SPIFFS
#define ELEGANTOTA_USE_SPIFFS 0
#endif

#ifndef ELEGANTOTA_USE_ASYNC_WEBSERVER
#define ELEGANTOTA_USE_ASYNC_WEBSERVER 0
#endif

#ifndef ELEGANTOTA_DEBUG
#define ELEGANTOTA_DEBUG 1
#endif

#ifndef UPDATE_DEBUG
#define UPDATE_DEBUG 1
#endif
#define ELEGANTOTA_USE_SPIFFS 0
#define ELEGANTOTA_USE_ASYNC_WEBSERVER 0
#define ELEGANTOTA_DEBUG 1
#define UPDATE_DEBUG 1

#if ELEGANTOTA_DEBUG
#define ELEGANTOTA_DEBUG_MSG(x) Serial.printf("%s %s", "[ElegantOTA] ", x)
Expand Down Expand Up @@ -100,7 +89,7 @@ class ElegantOTAClass{
void begin(WebServer *server, const char * username = "", const char * password = "");
#endif
#endif

void setAuth(const char * username, const char * password);
void clearAuth();
void loop();
Expand Down

0 comments on commit f1ce3f1

Please sign in to comment.