mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 15:38:14 -08:00
Fix update server jquery
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -54,7 +54,7 @@ class Display
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
TFT_eSprite img = TFT_eSprite(&tft);
|
||||
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
|
||||
String version_number = "v0.4.4";
|
||||
String version_number = "v0.4.5";
|
||||
|
||||
bool printing = false;
|
||||
bool loading = false;
|
||||
|
||||
@@ -30,6 +30,14 @@ void Web::main()
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Callback for the embedded jquery.min.js page
|
||||
void Web::onJavaScript(void) {
|
||||
Serial.println("onJavaScript(void)");
|
||||
server.setContentLength(jquery_min_js_v3_2_1_gz_len);
|
||||
server.sendHeader(F("Content-Encoding"), F("gzip"));
|
||||
server.send_P(200, "text/javascript", jquery_min_js_v3_2_1_gz, jquery_min_js_v3_2_1_gz_len);
|
||||
}
|
||||
|
||||
void Web::setupOTAupdate()
|
||||
{
|
||||
display_obj.tft.setTextWrap(false);
|
||||
@@ -65,7 +73,9 @@ void Web::setupOTAupdate()
|
||||
}
|
||||
Serial.println("mDNS responder started");
|
||||
*/
|
||||
|
||||
|
||||
// return javascript jquery
|
||||
server.on("/jquery.min.js", HTTP_GET, onJavaScript);
|
||||
/*return index page which is stored in serverIndex */
|
||||
server.on("/", HTTP_GET, [this]() {
|
||||
server.sendHeader("Connection", "close");
|
||||
|
||||
@@ -11,6 +11,7 @@ Code taken from espressif ESP32 OTA Update example
|
||||
#include <ESPmDNS.h>
|
||||
#include <Update.h>
|
||||
|
||||
#include "Assets.h"
|
||||
#include "Display.h"
|
||||
|
||||
extern Display display_obj;
|
||||
@@ -72,7 +73,14 @@ class Web
|
||||
*/
|
||||
|
||||
const char* serverIndex =
|
||||
"<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>"
|
||||
"<script src='/jquery.min.js'></script>"
|
||||
"Because the lack of an asynchronous webserver in this Arduino sketch like 'ESPAsyncWebServer', <br/>"
|
||||
"both file 'serverIndex' and 'jquery.min.js' can't be read from the webserver at the same time. <br/><br/>"
|
||||
"Your web browser probably requests those two files simultaneously and therefore <br/>"
|
||||
"the javascript file failed to load. By a refresh of this page, the browser cash has already <br/>"
|
||||
"load 'serverIndex' file, the web browser will do a second attempt to only read the javascript file. <br/>"
|
||||
"This second attempt, with an idle webserver, will be processed.<br/><br/>"
|
||||
"Long story short, press F5 (refresh web browser) before uploading your firmware. <br/><br/>"
|
||||
"<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>"
|
||||
"<input type='file' name='update'>"
|
||||
"<input type='submit' value='Update'>"
|
||||
@@ -113,6 +121,7 @@ class Web
|
||||
Web();
|
||||
|
||||
void main();
|
||||
static void onJavaScript();
|
||||
void setupOTAupdate();
|
||||
};
|
||||
|
||||
|
||||
BIN
esp32_marauder/esp32_marauder_v0_4_5_20200222.bin
Normal file
BIN
esp32_marauder/esp32_marauder_v0_4_5_20200222.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user