Add error handling to OTA process
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8f052ecb37
commit
24f5e4398d
6 changed files with 119 additions and 51 deletions
|
@ -189,6 +189,10 @@
|
|||
return pos;
|
||||
};
|
||||
|
||||
DataView.prototype.getChar = function (pos) {
|
||||
return String.fromCharCode(this.getInt8(pos));
|
||||
};
|
||||
|
||||
DataView.prototype.setString = function (pos, str) {
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
this.setInt8(pos++, str.charCodeAt(i));
|
||||
|
@ -366,11 +370,11 @@
|
|||
frame.set(new Uint8Array(slice), 12);
|
||||
receive_chunk_confirmation = (dv) => {
|
||||
setTimeout(() => {
|
||||
resolve(i);
|
||||
resolve({cmd: dv.getChar(0), ret: dv.getUint8(1), val: dv.getUint16(2)});
|
||||
}, 50);
|
||||
}
|
||||
setTimeout(() => {
|
||||
reject(i);
|
||||
reject({frame_error: i});
|
||||
}, 2000);
|
||||
wsWrite(frame.buffer);
|
||||
});
|
||||
|
@ -384,10 +388,10 @@
|
|||
headerview.setInt32(4, buf.byteLength);
|
||||
headerview.setInt32(8, hash);
|
||||
receive_chunk_confirmation = (dv) => {
|
||||
resolve(true);
|
||||
resolve({cmd: dv.getChar(0), ret: dv.getUint8(1), val: dv.getUint16(2)});
|
||||
}
|
||||
setTimeout(() => {
|
||||
reject(false);
|
||||
reject({final_error: 0});
|
||||
}, 500);
|
||||
wsWrite(frame);
|
||||
});
|
||||
|
@ -400,7 +404,8 @@
|
|||
const ash = crc32(firmware_file);
|
||||
for (var i = 0; i * chunk_size < firmware_file.byteLength; i++) {
|
||||
update_progress("ota", i * chunk_size / firmware_file.byteLength * 100);
|
||||
await transmit_firmware_chunk(firmware_file, i);
|
||||
const reply = await transmit_firmware_chunk(firmware_file, i);
|
||||
console.log("reply", reply)
|
||||
}
|
||||
await transmit_firmware_final(firmware_file, crc32(firmware_file));
|
||||
update_progress("ota", 100);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue