Merge pull request #24 from Qyon/master_sq9mdd

Master sq9mdd
pull/25/head
Rysiek Labus 2 years ago committed by GitHub
commit 924ce92623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      data_embed/index.html
  2. 50
      data_embed/js.js
  3. 18
      data_embed/style.css
  4. 1
      include/taskWebServer.h
  5. 6
      partitions.csv
  6. 2
      platformio.ini
  7. 29
      src/taskWebServer.cpp
  8. 2
      tools/buildscript_versioning.py

File diff suppressed because one or more lines are too long

@ -39,4 +39,52 @@ window.onload = function () {
};
xhttp.open("GET", "/cfg", true);
xhttp.send();
};
};
function onFileChange(obj){
var fileName = obj.value.split('\\');
document.getElementById('file-input').innerHTML = fileName[fileName.length-1];
};
function updateFileUpload(event) {
event.preventDefault();
const file_input = document.getElementById("file-input");
const file_progress = document.getElementById("file-progress");
const data = new FormData(event.target);
const xhr = new XMLHttpRequest();
file_progress.classList.add("show");
file_progress.value = 0;
xhr.upload.onload = () => {
window.location.reload();
};
// listen for `upload.error` event
xhr.upload.onerror = () => {
alert("Error!");
}
// listen for `upload.abort` event
xhr.upload.onabort = () => {
console.error('Upload cancelled.');
}
xhr.upload.onprogress = (event) => {
// event.loaded returns how many bytes are downloaded
// event.total returns the total number of bytes
// event.total is only available if server sends `Content-Length` header
console.log(`Uploaded ${event.loaded} of ${event.total} bytes`);
let progress = 100 * (event.loaded / event.total);
if (progress == 100){
file_input.innerHTML = "Upgrade in progress. Please wait until page reloads!";
file_progress.removeAttribute('value');
} else {
file_input.innerHTML = "Uploaded: " + Math.round(progress) +"%";
file_progress.value = progress;
}
}
xhr.open('POST', '/update');
xhr.send(data);
}

File diff suppressed because one or more lines are too long

@ -4,6 +4,7 @@
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Preferences.h>
#include <Update.h>
#ifndef TASK_WEBSERVER
#define TASK_WEBSERVER

@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1C0000,
app1, app, ota_1, 0x1D0000,0x1C0000,
spiffs, data, spiffs, 0x390000,0x70000,
unable to load file from base commit

@ -13,7 +13,7 @@ platform = espressif32 @ 3.1.1
framework = arduino
monitor_speed = 115200
build_flags = -Wl,--gc-sections,--relax
board_build.partitions = no_ota.csv
board_build.partitions = partitions.csv
board_build.embed_files =
data_embed/index.html.out
data_embed/style.css.out

@ -198,10 +198,34 @@ void handle_saveDeviceCfg(){
server.on("/save_aprs_cfg", handle_SaveAPRSCfg);
server.on("/save_device_cfg", handle_saveDeviceCfg);
server.on("/restore", handle_Restore);
server.on("/update", HTTP_POST, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart();
}, []() {
HTTPUpload& upload = server.upload();
if (upload.status == UPLOAD_FILE_START) {
Serial.printf("Update: %s\n", upload.filename.c_str());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_WRITE) {
/* flashing firmware to ESP*/
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_END) {
if (Update.end(true)) { //true to set the size to the current progress
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
} else {
Update.printError(Serial);
}
}
});
server.onNotFound(handle_NotFound);
String wifi_password = preferences.getString("wifi_password");
String wifi_ssid = preferences.getString("wifi_ssid");
String wifi_password = preferences.getString(PREF_WIFI_PASSWORD);
String wifi_ssid = preferences.getString(PREF_WIFI_SSID);
if (!wifi_ssid.length()){
WiFi.softAP(apSSID.c_str(), apPassword.c_str());
} else {
@ -212,6 +236,7 @@ void handle_saveDeviceCfg(){
Serial.println((int)WiFi.status());
vTaskDelay(500/portTICK_PERIOD_MS);
}
Serial.println("Connected. IP: " + WiFi.localIP().toString());
}
server.begin();

@ -1,6 +1,6 @@
FILENAME_BUILDNO = '.pio/versioning'
FILENAME_VERSION_H = 'include/version.h'
version = 'v0.1.'
version = 'v0.3.'
import datetime

Loading…
Cancel
Save