3
3
* AutoConnectUpdate class.
4
4
* @file AutoConnectUpdatePage.h
5
5
6
- * @version 1.3.5
7
- * @date 2022-04-22
6
+ * @version 1.3.6
7
+ * @date 2022-07-25
8
8
* @copyright MIT license.
9
9
*/
10
10
11
11
#ifndef _AUTOCONNECTUPDATEPAGE_H_
12
12
#define _AUTOCONNECTUPDATEPAGE_H_
13
13
14
+ /**
15
+ * Definitions of notification commands to synchronize update processing
16
+ * with the Web client.
17
+ */
18
+ #define AUTOCONNECT_UPDATE_NOTIFY_START "#s"
19
+ #define AUTOCONNECT_UPDATE_NOTIFY_PROGRESS "#p"
20
+ #define AUTOCONNECT_UPDATE_NOTIFY_END "#e"
21
+ #define AUTOCONNECT_UPDATE_NOTIFY_REBOOT "#r"
22
+
14
23
// Define the AUTOCONNECT_URI_UPDATE page to select the sketch binary
15
24
// for update and order update execution.
16
25
const AutoConnectAux ::ACElementProp_t AutoConnectUpdateAct ::_elmCatalog [] PROGMEM = {
@@ -38,9 +47,9 @@ const AutoConnectAux::ACElementProp_t AutoConnectUpdateAct::_elmProgress[] PROGM
38
47
{ AC_Element , "progress_loader" , "<div id=\"ld\" />" , nullptr },
39
48
{ AC_Element , "c4" , "</span></div>" , nullptr },
40
49
{ AC_Text , "status" , nullptr , nullptr },
41
- { AC_Element , "c5" , "<script type=\"text/javascript\">var lap,cls;function rd(){clearInterval(lap),location.href=\"" AUTOCONNECT_URI_UPDATE_RESULT "\"}function bar(){var t=new FormData;t.append(\"op\",\"#s \");var e=new XMLHttpRequest;e.timeout=" AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_TIMEOUT ) ",e .open (\"POST\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),e.onreadystatechange=function(){4==e.readyState&&(200==e.status?(cls=!1,lap=setInterval(upd," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_INTERVAL ) ")):document.getElementById(\"status\").textContent=\"Could not start (\"+e.status+\"): \"+e.responseText)},e.send(t)}function upd(){if(!cls){var t=new XMLHttpRequest;t.onload=function(){var t=this.responseText.split(\",\");\"#s \"==t[0]?(window.setTimeout(rd()," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_DURATION ) ")" , nullptr },
50
+ { AC_Element , "c5" , "<script type=\"text/javascript\">var lap,cls;function rd(){clearInterval(lap),location.href=\"" AUTOCONNECT_URI_UPDATE_RESULT "\"}function bar(){var t=new FormData;t.append(\"op\",\"" AUTOCONNECT_UPDATE_NOTIFY_START " \");var e=new XMLHttpRequest;e.timeout=" AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_TIMEOUT ) ",e .open (\"POST\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),e.onreadystatechange=function(){4==e.readyState&&(200==e.status?(cls=!1,lap=setInterval(upd," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_INTERVAL ) ")):document.getElementById(\"status\").textContent=\"Could not start (\"+e.status+\"): \"+e.responseText)},e.send(t)}function upd(){if(!cls){var t=new XMLHttpRequest;t.onload=function(){var t=this.responseText.split(\",\");\"" AUTOCONNECT_UPDATE_NOTIFY_START " \"==t[0]?(window.setTimeout(rd()," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_DURATION ) ")" , nullptr },
42
51
{ AC_Element , "enable_loader" , ",document.getElementById(\"ld\").className=\"loader\"" , nullptr },
43
- { AC_Element , "c6" , "):\"#e \"==t[0]?(cls=!0,rd()):\"#p \"==t[0]&&incr(t[1])},t.onerror=function(){document.getElementById(\"status\").textContent=\"Failed to update: \"+t.status,console.log(\"http err:%d %s\",t.status,t.responseText),clearInterval(lap)},t.open(\"GET\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),t.send()}}function incr(t){" , nullptr },
52
+ { AC_Element , "c6" , "):\"" AUTOCONNECT_UPDATE_NOTIFY_END " \"==t[0]?(cls=!0,rd()):\"" AUTOCONNECT_UPDATE_NOTIFY_PROGRESS " \"==t[0]&&incr(t[1])},t.onerror=function(){\"0\"!=t.status&&( document.getElementById(\"status\").textContent=\"" AUTOCONNECT_TEXT_OTAFAILURE " \"+t.status,console.log(\"http err:%d %s\",t.status,t.responseText),clearInterval(lap) )},t.open(\"GET\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),t.send()}}function incr(t){" , nullptr },
44
53
{ AC_Element , "inprogress_meter" , "var e=t.split(\":\"),n=document.getElementById(\"progress\").getElementsByTagName(\"meter\");n[0].setAttribute(\"value\",e[0]),n[0].setAttribute(\"max\",e[1])" , nullptr },
45
54
{ AC_Element , "c7" , "}window.onload=bar;</script>" , nullptr }
46
55
};
@@ -51,7 +60,7 @@ const AutoConnectAux::ACPage_t AutoConnectUpdateAct::_pageProgress PROGMEM = {
51
60
// Definition of the AUTOCONNECT_URI_UPDATE_RESULT page to notify update results
52
61
const AutoConnectAux ::ACElementProp_t AutoConnectUpdateAct ::_elmResult [] PROGMEM = {
53
62
{ AC_Text , "status" , nullptr , nullptr },
54
- { AC_Element , "restart" , "<script type=\"text/javascript\">window.onload=function(){var e=new FormData;e.append(\"op\",\"#r \");var o=new XMLHttpRequest;o.timeout=" AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_TIMEOUT ) ",o.onloadend=function(){setTimeout(\"location.href='" AUTOCONNECT_HOMEURI "'\"," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_WAITFORREBOOT ) ")},o.open(\"POST\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),o.send(e)};</script>" , nullptr }
63
+ { AC_Element , "restart" , "<script type=\"text/javascript\">window.onload=function(){var e=new FormData;e.append(\"op\",\"" AUTOCONNECT_UPDATE_NOTIFY_REBOOT " \");var o=new XMLHttpRequest;o.timeout=" AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_TIMEOUT ) ",o.onloadend=function(){setTimeout(\"location.href='" AUTOCONNECT_HOMEURI "'\"," AUTOCONNECT_STRING_DEPLOY (AUTOCONNECT_UPDATE_WAITFORREBOOT ) ")},o.open(\"POST\",\"" AUTOCONNECT_URI_UPDATE_PROGRESS "\",!0),o.send(e)};</script>" , nullptr }
55
64
};
56
65
const AutoConnectAux ::ACPage_t AutoConnectUpdateAct ::_pageResult PROGMEM = {
57
66
AUTOCONNECT_URI_UPDATE_RESULT , AUTOCONNECT_MENULABEL_UPDATE , false, AutoConnectUpdateAct ::_elmResult
0 commit comments