working begin routine

This commit is contained in:
Siwat Sirichai 2024-01-15 15:19:49 +07:00
parent 05236797c2
commit fdf32d8503
8 changed files with 510 additions and 415 deletions

View file

@ -12,16 +12,18 @@ void ESPMegaDisplayOTA::begin(const char* base_path, ESPMegaDisplay *display, ES
char ota_begin_path[100];
char ota_write_path[100];
char ota_end_path[100];
char ota_page_path[100];
sprintf(ota_begin_path, "%s/ota/begin", base_path);
sprintf(ota_write_path, "%s/ota/write", base_path);
sprintf(ota_end_path, "%s/ota/end", base_path);
sprintf(ota_page_path, "%s/index.html", base_path);
this->otaUpdateBeginWebHandler = new AsyncCallbackJsonWebHandler(ota_begin_path, std::bind(&ESPMegaDisplayOTA::otaUpdateBeginHandler, this, std::placeholders::_1, std::placeholders::_2));
this->otaUpdateWriteWebHandler = new AsyncCallbackJsonWebHandler(ota_write_path, std::bind(&ESPMegaDisplayOTA::otaUpdateWriteHandler, this, std::placeholders::_1, std::placeholders::_2));
this->otaUpdateEndWebHandler = new AsyncCallbackJsonWebHandler(ota_end_path, std::bind(&ESPMegaDisplayOTA::otaUpdateEndHandler, this, std::placeholders::_1, std::placeholders::_2));
this->server->addHandler(this->otaUpdateBeginWebHandler);
this->server->addHandler(this->otaUpdateWriteWebHandler);
this->server->addHandler(this->otaUpdateEndWebHandler);
this->server->on(this->base_path, HTTP_GET, std::bind(&ESPMegaDisplayOTA::displayWebPageHandler, this, std::placeholders::_1));
this->server->on(ota_page_path, HTTP_GET, std::bind(&ESPMegaDisplayOTA::displayWebPageHandler, this, std::placeholders::_1));
}
void ESPMegaDisplayOTA::otaUpdateBeginHandler(AsyncWebServerRequest *request, JsonVariant &json) {