@@ -59,7 +59,7 @@ void DiagnosticsService::loop() {
5959 }
6060
6161 const auto & timestampNow = context.getModel ().getClock ().now ();
62- if (retries > 0 && timestampNow >= nextTry) {
62+ if (retries != - 1 && timestampNow >= nextTry) {
6363
6464 if (!uploadIssued) {
6565 if (onUpload != nullptr ) {
@@ -69,7 +69,7 @@ void DiagnosticsService::loop() {
6969 uploadFailure = false ;
7070 } else {
7171 MO_DBG_ERR (" onUpload must be set! (see setOnUpload). Will abort" );
72- retries = 0 ;
72+ retries = - 1 ;
7373 uploadIssued = false ;
7474 uploadFailure = true ;
7575 }
@@ -80,7 +80,7 @@ void DiagnosticsService::loop() {
8080 // success!
8181 MO_DBG_DEBUG (" end upload routine (by status)" );
8282 uploadIssued = false ;
83- retries = 0 ;
83+ retries = - 1 ;
8484 }
8585
8686 // check if maximum time elapsed or failed
@@ -93,7 +93,7 @@ void DiagnosticsService::loop() {
9393 // No way to find out if failed. But maximum time has elapsed. Assume success
9494 MO_DBG_DEBUG (" end upload routine (by timer)" );
9595 uploadIssued = false ;
96- retries = 0 ;
96+ retries = - 1 ;
9797 } else {
9898 // either we have UploadFailed status or (NotUploaded + timeout) here
9999 MO_DBG_WARN (" Upload timeout or failed" );
@@ -108,7 +108,7 @@ void DiagnosticsService::loop() {
108108 }
109109 retries--;
110110
111- if (retries == 0 ) {
111+ if (retries == - 1 ) {
112112 MO_DBG_DEBUG (" end upload routine (no more retry)" );
113113 uploadFailure = true ;
114114 }
@@ -119,7 +119,7 @@ void DiagnosticsService::loop() {
119119}
120120
121121// timestamps before year 2021 will be treated as "undefined"
122- MicroOcpp::String DiagnosticsService::requestDiagnosticsUpload (const char *location, unsigned int retries, unsigned int retryInterval, Timestamp startTime, Timestamp stopTime) {
122+ MicroOcpp::String DiagnosticsService::requestDiagnosticsUpload (const char *location, int retries, unsigned int retryInterval, Timestamp startTime, Timestamp stopTime) {
123123 if (onUpload == nullptr ) {
124124 return makeString (getMemoryTag ());
125125 }
@@ -177,6 +177,7 @@ MicroOcpp::String DiagnosticsService::requestDiagnosticsUpload(const char *locat
177177 nextTry = context.getModel ().getClock ().now ();
178178 nextTry += 5 ; // wait for 5s before upload
179179 uploadIssued = false ;
180+ uploadFailure = false ;
180181
181182#if MO_DBG_LEVEL >= MO_DL_DEBUG
182183 {
@@ -191,6 +192,11 @@ MicroOcpp::String DiagnosticsService::requestDiagnosticsUpload(const char *locat
191192
192193DiagnosticsStatus DiagnosticsService::getDiagnosticsStatus () {
193194 if (uploadFailure) {
195+ if (lastReportedStatus != DiagnosticsStatus::Uploading &&
196+ lastReportedStatus != DiagnosticsStatus::UploadFailed) {
197+ // TC_045_2_CS Ensure Uploading is reported at least once before UploadFailed
198+ return DiagnosticsStatus::Uploading;
199+ }
194200 return DiagnosticsStatus::UploadFailed;
195201 }
196202
0 commit comments