Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Revision 158:80441390de93, committed 2021-02-01
- Comitter:
- andrewboyson
- Date:
- Mon Feb 01 19:33:21 2021 +0000
- Parent:
- 157:57bd76aa5e97
- Child:
- 159:bda5b89e8c19
- Commit message:
- Modified firmware module to disable the restart button until the file upload had completed successfully.
Changed in this revision
--- a/base/firmware/web-firmware-ajax.c Mon Feb 01 13:24:09 2021 +0000
+++ b/base/firmware/web-firmware-ajax.c Mon Feb 01 19:33:21 2021 +0000
@@ -10,11 +10,7 @@
HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
//Upload status
- if (FirmwareSentLength == FirmwareFileLength)
- {
- HttpAddText("Length ok\r\n");
- }
- else
+ if (FirmwareSentLength != FirmwareFileLength)
{
HttpAddText("Length error\r\n");
HttpAddF (" sent %6d\r\n", FirmwareSentLength);
@@ -29,7 +25,7 @@
}
else
{
- HttpAddText("Saved ok");
+ HttpAddF("Saved %d bytes", FirmwareFileLength);
}
//Delimiter
--- a/base/firmware/web-firmware-html.c Mon Feb 01 13:24:09 2021 +0000
+++ b/base/firmware/web-firmware-html.c Mon Feb 01 19:33:21 2021 +0000
@@ -26,7 +26,7 @@
HttpAddText("<code id='uploadresult'></code>\r\n");
WebAddH2("Restart the device");
- HttpAddText("<div><button onclick='restart();'>Restart</button></div>\r\n");
+ HttpAddText("<div><button id='restartbutton' onclick='restart();'>Restart</button></div>\r\n");
HttpAddText("<code id='restartresult'></code>\r\n");
WebAddEnd();
--- a/base/firmware/web-firmware-script.inc Mon Feb 01 13:24:09 2021 +0000
+++ b/base/firmware/web-firmware-script.inc Mon Feb 01 19:33:21 2021 +0000
@@ -9,6 +9,7 @@
"}\n"
"function xhrUploadResponse()\n"
"{\n"
+" document.getElementById('restartbutton').disabled = false;\n"
" var topics = xhr.responseText.split('\\f');\n"
" logUpload(topics[0]);\n"
" if (topics.length > 1) document.getElementById('list').textContent = topics[1];\n"
@@ -24,9 +25,7 @@
"}\n"
"function xhrUploadProgress(e)\n"
"{\n"
-" logUpload('Uploading...\\r\\n' +\n"
-" 'Total ' + e.total + ' bytes\\r\\n' +\n"
-" 'Sent ' + e.loaded.toString().padStart(e.total.toString().length, ' ') + ' bytes');\n"
+" logUpload('Uploading ' + e.total + ' bytes ' + '(' + Math.round(e.loaded/e.total * 100) + '%)...\\r\\n');\n"
"}\n"
"function xhrUploadComplete(e)\n"
"{\n"
@@ -34,6 +33,7 @@
"}\n"
"function xhrUploadStart()\n"
"{\n"
+" document.getElementById('restartbutton').disabled = true;\n"
" logUpload('Upload starting...');\n"
" \n"
" xhr = new XMLHttpRequest();\n"
--- a/base/firmware/web-firmware-script.js Mon Feb 01 13:24:09 2021 +0000
+++ b/base/firmware/web-firmware-script.js Mon Feb 01 19:33:21 2021 +0000
@@ -9,6 +9,7 @@
}
function xhrUploadResponse()
{
+ document.getElementById('restartbutton').disabled = false;
var topics = xhr.responseText.split('\f');
logUpload(topics[0]);
if (topics.length > 1) document.getElementById('list').textContent = topics[1];
@@ -24,9 +25,7 @@
}
function xhrUploadProgress(e)
{
- logUpload('Uploading...\r\n' +
- 'Total ' + e.total + ' bytes\r\n' +
- 'Sent ' + e.loaded.toString().padStart(e.total.toString().length, ' ') + ' bytes');
+ logUpload('Uploading ' + e.total + ' bytes ' + '(' + Math.round(e.loaded/e.total * 100) + '%)...\r\n');
}
function xhrUploadComplete(e)
{
@@ -34,6 +33,7 @@
}
function xhrUploadStart()
{
+ document.getElementById('restartbutton').disabled = true;
logUpload('Upload starting...');
xhr = new XMLHttpRequest();