Skip to content

Commit dd4f204

Browse files
committed
2rd rewrite of upload error management
Add IPfor websocket setup in [ESP800]per @Nathan-ma suggestion Change `Error 0` by `No connection` message change version to 47
1 parent 1804f02 commit dd4f204

File tree

10 files changed

+56
-23
lines changed

10 files changed

+56
-23
lines changed

index.html.gz

202 Bytes
Binary file not shown.

www/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
var target_firmware = "";
1111
</script>
1212
<script>
13-
var web_ui_version = "2.1b45";
13+
var web_ui_version = "2.1b47";
1414
</script>
1515
<script>
1616
var direct_sd = false;

www/js/SPIFFSdlg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,5 @@ function SPIFFSUploadfailed(errorcode, response) {
257257
document.getElementById('SPIFFS_status').innerHTML = translate_text_item("Upload failed : ") + errorcode;
258258
}
259259
SPIFFS_upload_ongoing = false;
260+
refreshSPIFFS();
260261
}

www/js/app.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var event_source;
66
var log_off = false;
77
var async_webcommunication = false;
88
var websocket_port = 0;
9+
var websocket_ip = "";
910
var esp_hostname = "ESP3D WebUI";
1011
var EP_HOSTNAME;
1112
var EP_STA_SSID;
@@ -120,8 +121,8 @@ function startSocket() {
120121
if (async_webcommunication) {
121122
ws_source = new WebSocket('ws://' + document.location.host + '/ws', ['arduino']);
122123
} else {
123-
console.log("Socket port is :" + websocket_port);
124-
ws_source = new WebSocket('ws://' + document.location.hostname + ':' + websocket_port, ['arduino']);
124+
console.log("Socket is " + websocket_ip + ":" + websocket_port);
125+
ws_source = new WebSocket('ws://' + websocket_ip + ':' + websocket_port, ['arduino']);
125126
}
126127
} catch (exception) {
127128
console.error(exception);
@@ -185,7 +186,13 @@ function startSocket() {
185186
if (tval[0] == 'ERROR') {
186187
esp_error_message = tval[2];
187188
esp_error_code = tval[1];
188-
console.log(tval[2] + " code:" + tval[1]);
189+
console.log("ERROR: " + tval[2] + " code:" + tval[1]);
190+
CancelCurrentUpload();
191+
}
192+
if (tval[0] == 'MSG') {
193+
var error_message = tval[2];
194+
var error_code = tval[1];
195+
console.log("MSG: " + tval[2] + " code:" + tval[1]);
189196
}
190197
}
191198

www/js/commands.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ function SendCustomCommandSuccess(response) {
122122
}
123123

124124
function SendCustomCommandFailed(error_code, response) {
125-
Monitor_output_Update("Error " + error_code + " :" + decode_entitie(response) + "\n");
126-
console.log("Error " + error_code + " :" + decode_entitie(response));
127-
}
125+
if (error_code == 0) {
126+
Monitor_output_Update(translate_text_item("No connection") + "\n");
127+
} else {
128+
Monitor_output_Update(translate_text_item("Error : ") + error_code + " :" + decode_entitie(response) + "\n");
129+
}
130+
console.log("cmd Error " + error_code + " :" + decode_entitie(response));
131+
}

www/js/connectdlg.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ function getFWdata(response) {
7272
else {
7373
async_webcommunication = false;
7474
websocket_port = sublist[2].trim();
75+
if (sublist.length>3) {
76+
websocket_ip = sublist[3].trim();
77+
} else {
78+
console.log("No IP for websocket, use default");
79+
websocket_ip = document.location.hostname;
80+
}
7581
}
7682
}
7783
if (tlist.length > 7) {

www/js/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ function files_serial_M20_list_failed(error_code, response) {
566566
alertdlg (translate_text_item("Error") + " (" + esp_error_code + ")", esp_error_message);
567567
esp_error_code = 0;
568568
} else {
569-
alertdlg (translate_text_item("Error"), "Error " + errorcode + " : " + response);
569+
alertdlg (translate_text_item("Error"), translate_text_item("No connection"));
570570
}
571571
files_build_display_filelist(false);
572572
}

www/js/http.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var http_communication_locked = false;
22
var http_cmd_list = [];
33
var processing_cmd = false;
4+
var xmlhttpupload;
45

56
var max_cmd = 20;
67

@@ -217,26 +218,32 @@ function SendFileHttp(url, postdata, progress_fn, result_fn, error_fn) {
217218
process_cmd();
218219
}
219220

221+
function CancelCurrentUpload() {
222+
xmlhttpupload.abort();
223+
//http_communication_locked = false;
224+
console.log("Cancel Upload");
225+
}
226+
220227
function ProcessFileHttp(url, postdata, progressfn, resultfn, errorfn) {
221228
if (http_communication_locked) {
222229
errorfn(503, translate_text_item("Communication locked!"));
223230
return;
224231
}
225232
http_communication_locked = true;
226-
var xmlhttp = new XMLHttpRequest();
227-
xmlhttp.onreadystatechange = function() {
228-
if (xmlhttp.readyState == 4) {
233+
xmlhttpupload = new XMLHttpRequest();
234+
xmlhttpupload.onreadystatechange = function() {
235+
if (xmlhttpupload.readyState == 4) {
229236
http_communication_locked = false;
230-
if (xmlhttp.status == 200) {
231-
if (typeof resultfn != 'undefined' && resultfn != null) resultfn(xmlhttp.responseText);
237+
if (xmlhttpupload.status == 200) {
238+
if (typeof resultfn != 'undefined' && resultfn != null) resultfn(xmlhttpupload.responseText);
232239
} else {
233-
if (xmlhttp.status == 401) GetIdentificationStatus();
234-
if (typeof errorfn != 'undefined' && errorfn != null) errorfn(xmlhttp.status, xmlhttp.responseText);
240+
if (xmlhttpupload.status == 401) GetIdentificationStatus();
241+
if (typeof errorfn != 'undefined' && errorfn != null) errorfn(xmlhttpupload.status, xmlhttpupload.responseText);
235242
}
236243
}
237244
}
238245
//console.log(url);
239-
xmlhttp.open("POST", url, true);
240-
if (typeof progressfn != 'undefined' && progressfn != null) xmlhttp.upload.addEventListener("progress", progressfn, false);
241-
xmlhttp.send(postdata);
242-
}
246+
xmlhttpupload.open("POST", url, true);
247+
if (typeof progressfn != 'undefined' && progressfn != null) xmlhttpupload.upload.addEventListener("progress", progressfn, false);
248+
xmlhttpupload.send(postdata);
249+
}

www/js/printercmd.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ function SendPrinterCommandSuccess(response) {
4949
}
5050

5151
function SendPrinterCommandFailed(error_code, response) {
52-
Monitor_output_Update("Error " + error_code + " :" + decode_entitie(response) + "\n");
53-
console.log("Error " + error_code + " :" + decode_entitie(response));
54-
}
52+
if (error_code == 0) {
53+
Monitor_output_Update(translate_text_item("No connection") + "\n");
54+
} else {
55+
Monitor_output_Update(translate_text_item("Error : ") + error_code + " :" + decode_entitie(response) + "\n");
56+
}
57+
console.log("printer cmd Error " + error_code + " :" + decode_entitie(response));
58+
}

www/js/updatedlg.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ function updatesuccess(response) {
107107
function updatefailed(errorcode, response) {
108108
document.getElementById('fw-select_form').style.display = 'block';
109109
document.getElementById('prgfw').style.display = 'none';
110-
document.getElementById('uploadfw-button').style.display = 'block';
110+
document.getElementById("fw_file_name").innerHTML = translate_text_item("No file chosen");
111+
document.getElementById('uploadfw-button').style.display = 'none';
112+
//document.getElementById('updatemsg').innerHTML = "";
113+
document.getElementById('fw-select').value = "";
111114
if (esp_error_code !=0){
112115
alertdlg (translate_text_item("Error") + " (" + esp_error_code + ")", esp_error_message);
113116
document.getElementById('updatemsg').innerHTML = translate_text_item("Upload failed : ") + esp_error_message;
@@ -118,4 +121,5 @@ function updatefailed(errorcode, response) {
118121
}
119122
console.log("Error " + errorcode + " : " + response);
120123
update_ongoing = false;
124+
SendGetHttp("/updatefw");
121125
}

0 commit comments

Comments
 (0)