fix website
This commit is contained in:
@@ -191,21 +191,6 @@ export class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadNewFirmware(file: File) {
|
uploadNewFirmware(file: File) {
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = () => {
|
|
||||||
const arrayBuffer = reader.result as ArrayBuffer;
|
|
||||||
const data = new Uint8Array(arrayBuffer);
|
|
||||||
const crc = this.crc32(data);
|
|
||||||
const size = data.length;
|
|
||||||
|
|
||||||
console.log("Uploading new firmware with size " + size + " and crc " + crc + "")
|
|
||||||
|
|
||||||
const payload = new Uint8Array(size + 8);
|
|
||||||
const view = new DataView(payload.buffer);
|
|
||||||
view.setUint32(0, size, true);
|
|
||||||
view.setUint32(4, crc, true);
|
|
||||||
payload.set(data, 8);
|
|
||||||
|
|
||||||
let current = 0;
|
let current = 0;
|
||||||
let max = 100;
|
let max = 100;
|
||||||
controller.progressview.addProgress("ota_upload", (current / max) * 100, "Uploading firmeware (" + current + "/" + max + ")")
|
controller.progressview.addProgress("ota_upload", (current / max) * 100, "Uploading firmeware (" + current + "/" + max + ")")
|
||||||
@@ -235,28 +220,7 @@ export class Controller {
|
|||||||
toast.error("OTA upload was aborted.");
|
toast.error("OTA upload was aborted.");
|
||||||
}, false);
|
}, false);
|
||||||
ajax.open("POST", PUBLIC_URL + "/ota");
|
ajax.open("POST", PUBLIC_URL + "/ota");
|
||||||
ajax.send(payload);
|
ajax.send(file);
|
||||||
};
|
|
||||||
reader.onerror = () => {
|
|
||||||
toast.error("Error reading firmware file.");
|
|
||||||
};
|
|
||||||
reader.readAsArrayBuffer(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
private crc32(data: Uint8Array): number {
|
|
||||||
let crc = 0xFFFFFFFF;
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
let byte = data[i];
|
|
||||||
crc ^= byte;
|
|
||||||
for (let j = 0; j < 8; j++) {
|
|
||||||
if (crc & 1) {
|
|
||||||
crc = (crc >>> 1) ^ 0xEDB88320;
|
|
||||||
} else {
|
|
||||||
crc = crc >>> 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (crc ^ 0xFFFFFFFF) >>> 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async version(): Promise<void> {
|
async version(): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user