diff --git a/index.html b/index.html
index 0698a1c..0289be1 100644
--- a/index.html
+++ b/index.html
@@ -41,10 +41,10 @@
-
Flashing: {{progress}}%
+
Flashing: {{flashingProgress}}%
Flashing: please wait...
@@ -64,7 +64,7 @@
data() {
return {
isFlashing: false,
- progress: 0,
+ flashingProgress: 0,
};
},
mounted() {
@@ -114,22 +114,24 @@
// update progress
this.isFlashing = true;
- this.progress = 0;
+ this.flashingProgress = 0;
- // flash file
try {
+
+ // flash file
const flasher = new Nrf52DfuFlasher(serialPort);
- await flasher.flash(file, (percentage) => {
- this.progress = percentage;
- if(this.progress === 100){
- this.isFlashing = false;
- alert("Firmware has been flashed!");
- }
+ await flasher.flash(file, (percentage, message) => {
+ this.flashingProgress = percentage;
});
+
+ // flashing successful
+ alert("Firmware has been flashed!");
+
} catch(e) {
- this.isFlashing = false;
alert("Firmware flashing failed: " + e);
console.log(e);
+ } finally {
+ this.isFlashing = false;
}
},
diff --git a/nrf52_dfu_flasher.js b/nrf52_dfu_flasher.js
index 6db69dc..0bcf54b 100644
--- a/nrf52_dfu_flasher.js
+++ b/nrf52_dfu_flasher.js
@@ -175,18 +175,16 @@ class Nrf52DfuFlasher {
console.log("Sending DFU init packet");
await this.sendInitPacket(init_packet);
- console.log("Sending firmware file")
+ console.log("Sending firmware");
await this.sendFirmware(firmware, progressCallback);
// close port
- console.log("Closing Port");
+ console.log("Closing serial port");
await this.serialPort.close();
// todo
// sleep(self.dfu_transport.get_activate_wait_time())
- console.log("Done");
-
}
/**
@@ -399,11 +397,6 @@ class Nrf52DfuFlasher {
...this.int32ToBytes(this.DFU_STOP_DATA_PACKET),
]));
- // send final progress
- if(progressCallback){
- progressCallback(100);
- }
-
}
/**