File tree Expand file tree Collapse file tree 5 files changed +63
-3
lines changed Expand file tree Collapse file tree 5 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ <h2 id="large-modal-header"></h2>
58
58
</ div >
59
59
</ div >
60
60
61
+ < div id ="communication-error-bar " class ="communication-error-bar ">
62
+ < p > Communication problem between ESP and STM</ p >
63
+ </ div >
64
+
61
65
<!-- 'Add CAN Mapping' modal -->
62
66
< div id ="can-mapping-modal-overlay " class ="modal-overlay ">
63
67
< div id ="can-mapping-modal-container " class ="can-mapping-modal-container ">
Original file line number Diff line number Diff line change 26
26
var paramsCache = {
27
27
data : undefined ,
28
28
dataById : { } ,
29
+ failedFetchCount : 0 ,
29
30
30
31
get : function ( name ) {
31
32
if ( paramsCache . data !== undefined )
@@ -77,6 +78,25 @@ var inverter = {
77
78
{
78
79
if ( replyFunc ) replyFunc ( this . responseText ) ;
79
80
}
81
+ xmlhttp . onreadystatechange = function ( )
82
+ {
83
+ if ( xmlhttp . readyState === XMLHttpRequest . DONE ) {
84
+ console . log ( req + ": " + xmlhttp . status ) ;
85
+ if ( xmlhttp . status != 200 ) {
86
+ paramsCache . failedFetchCount += 1 ;
87
+ if ( paramsCache . failedFetchCount >= 2 ) {
88
+ ui . showCommunicationErrorBar ( ) ;
89
+ }
90
+ }
91
+ else {
92
+ paramsCache . failedFetchCount = 0 ;
93
+ }
94
+ if ( paramsCache . failedFetchCount < 2 )
95
+ {
96
+ ui . hideCommunicationErrorBar ( ) ;
97
+ }
98
+ }
99
+ }
80
100
81
101
if ( repeat )
82
102
req += "&repeat=" + repeat ;
@@ -104,6 +124,7 @@ var inverter = {
104
124
inverter . firmwareVersion = parseFloat ( param . value ) ;
105
125
}
106
126
} catch ( ex ) { }
127
+
107
128
paramsCache . setData ( params ) ;
108
129
if ( replyFunc ) replyFunc ( params ) ;
109
130
} ) ;
Original file line number Diff line number Diff line change @@ -635,3 +635,24 @@ input:checked + .slider:before {
635
635
width : 60px ;
636
636
}
637
637
}
638
+
639
+ /* notification bar */
640
+
641
+ .communication-error-bar {
642
+ display : none;
643
+ padding : 15px ;
644
+ background-color : # f44336 ;
645
+ color : white;
646
+ z-index : 100 ;
647
+ margin : 0 auto;
648
+ position : relative;
649
+ width : 30% ;
650
+ top : 0px ;
651
+ clear : left;
652
+ height : 20px ;
653
+ border-radius : 0px 0px 20px 20px ;
654
+ }
655
+
656
+ .communication-error-bar p {
657
+ text-align : center;
658
+ }
Original file line number Diff line number Diff line change @@ -141,7 +141,6 @@ var ui = {
141
141
wifi . populateWiFiTab ( ) ;
142
142
ui . populateFileList ( ) ;
143
143
ui . refreshStatusBox ( ) ;
144
- ui . refreshMessagesBox ( ) ;
145
144
ui . getNodeId ( ) ;
146
145
} ,
147
146
@@ -150,7 +149,6 @@ var ui = {
150
149
{
151
150
ui . updateTables ( ) ;
152
151
ui . refreshStatusBox ( ) ;
153
- ui . refreshMessagesBox ( ) ;
154
152
} ,
155
153
156
154
getNodeId : function ( ) {
@@ -391,6 +389,16 @@ var ui = {
391
389
clearInterval ( ui . autoRefreshHandle ) ;
392
390
}
393
391
} ,
392
+
393
+ /** @brief Show notification bar */
394
+ showCommunicationErrorBar : function ( ) {
395
+ document . getElementById ( 'communication-error-bar' ) . style . display = 'block' ;
396
+ } ,
397
+
398
+ /** @brief Hide notification bar */
399
+ hideCommunicationErrorBar : function ( ) {
400
+ document . getElementById ( 'communication-error-bar' ) . style . display = 'none' ;
401
+ } ,
394
402
/**
395
403
* ~~~ DASHBOARD ~~~
396
404
*/
Original file line number Diff line number Diff line change @@ -332,9 +332,15 @@ void SendJson(WiFiClient client) {
332
332
twai_message_t rxframe;
333
333
334
334
File file = SPIFFS.open (jsonFileName, " r" );
335
- deserializeJson (doc, file);
335
+ auto result = deserializeJson (doc, file);
336
336
file.close ();
337
337
338
+ if (result != DeserializationError::Ok) {
339
+ SPIFFS.remove (jsonFileName); // if json file is invalid, remove it and trigger re-download
340
+ updstate == REQUEST_JSON;
341
+ return ;
342
+ }
343
+
338
344
JsonObject root = doc.as <JsonObject>();
339
345
340
346
for (JsonPair kv : root) {
You can’t perform that action at this time.
0 commit comments