mirror of
https://github.com/RonMeier/LoRa-Monitor.git
synced 2026-03-28 17:43:01 +01:00
Update OTAWebUpdater.ino
This commit is contained in:
@@ -8,42 +8,14 @@ const char* password = "pwd";
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
const char* serverIndex =
|
||||
"<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>"
|
||||
"<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>"
|
||||
"<input type='file' name='update'>"
|
||||
"<input type='submit' value='Update'>"
|
||||
"</form>"
|
||||
"<div id='prg'>progress: 0%</div>"
|
||||
"<script>"
|
||||
"$('form').submit(function(e){"
|
||||
"e.preventDefault();"
|
||||
"var form = $('#upload_form')[0];"
|
||||
"var data = new FormData(form);"
|
||||
" $.ajax({"
|
||||
"url: '/update',"
|
||||
"type: 'POST',"
|
||||
"data: data,"
|
||||
"contentType: false,"
|
||||
"processData:false,"
|
||||
"xhr: function() {"
|
||||
"var xhr = new window.XMLHttpRequest();"
|
||||
"xhr.upload.addEventListener('progress', function(evt) {"
|
||||
"if (evt.lengthComputable) {"
|
||||
"var per = evt.loaded / evt.total;"
|
||||
"$('#prg').html('progress: ' + Math.round(per*100) + '%');"
|
||||
"}"
|
||||
"}, false);"
|
||||
"return xhr;"
|
||||
"},"
|
||||
"success:function(d, s) {"
|
||||
"console.log('success!')"
|
||||
"},"
|
||||
"error: function (a, b, c) {"
|
||||
"}"
|
||||
"});"
|
||||
"});"
|
||||
"</script>";
|
||||
const char* serverIndex = "<!DOCTYPE HTML><html><head>"
|
||||
"<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
|
||||
"<meta name='viewport' content='width=device-width, initial-scale=1.1'>"
|
||||
"<h2>FW update</h2><hr>"
|
||||
"<form method='POST' action='/update' enctype='multipart/form-data'>"
|
||||
"<input type='file' name='update'><br><br>"
|
||||
"<input type='submit' value='Update'>"
|
||||
"</head></html>";
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
|
||||
Reference in New Issue
Block a user