Skip to content

Commit 76be884

Browse files
committed
fix GetLog retry behavior
1 parent 18e06c4 commit 76be884

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

src/MicroOcpp/Model/Diagnostics/DiagnosticsService.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void DiagnosticsService::loop() {
238238
dtNextTry = -1;
239239
}
240240

241-
if (retries > 0 && dtNextTry >= 0) {
241+
if (retries >= 0 && dtNextTry >= 0) {
242242

243243
if (!uploadIssued) {
244244

@@ -261,7 +261,7 @@ void DiagnosticsService::loop() {
261261
uploadFailure = false;
262262
} else {
263263
MO_DBG_ERR("cannot upload via FTP. Abort");
264-
retries = 0;
264+
retries = -1;
265265
uploadIssued = false;
266266
uploadFailure = true;
267267
cleanUploadData();
@@ -274,7 +274,7 @@ void DiagnosticsService::loop() {
274274
//success!
275275
MO_DBG_DEBUG("end upload routine (by status)");
276276
uploadIssued = false;
277-
retries = 0;
277+
retries = -1;
278278
cleanUploadData();
279279
cleanGetLogData();
280280
}
@@ -303,17 +303,12 @@ void DiagnosticsService::loop() {
303303
//either we have UploadFailed status or (NotUploaded + timeout) here
304304
MO_DBG_WARN("Upload timeout or failed");
305305
cleanUploadData();
306+
uploadIssued = false;
306307

307-
const int TRANSITION_DELAY = 10;
308-
if (retryInterval <= UPLOAD_TIMEOUT + TRANSITION_DELAY) {
309-
nextTry = clock.getUptime();
310-
clock.add(nextTry, TRANSITION_DELAY); //wait for another 10 seconds
311-
} else {
312-
clock.add(nextTry, retryInterval);
313-
}
308+
clock.add(nextTry, retryInterval);
314309
retries--;
315310

316-
if (retries == 0) {
311+
if (retries < 0) {
317312
MO_DBG_DEBUG("end upload routine (no more retry)");
318313
uploadFailure = true;
319314
cleanGetLogData();
@@ -349,7 +344,7 @@ bool DiagnosticsService::requestDiagnosticsUpload(const char *location, unsigned
349344

350345
MO_GetLogStatus DiagnosticsService::getLog(MO_LogType type, int requestId, int retries, unsigned int retryInterval, const char *location, Timestamp oldestTimestamp, Timestamp latestTimestamp, char filenameOut[MO_GETLOG_FNAME_SIZE]) {
351346

352-
if (runCustomUpload || this->retries > 0) {
347+
if (runCustomUpload || this->retries >= 0) {
353348
MO_DBG_INFO("upload still running");
354349
return MO_GetLogStatus_Rejected;
355350
}
@@ -444,8 +439,8 @@ MO_GetLogStatus DiagnosticsService::getLog(MO_LogType type, int requestId, int r
444439
snprintf(this->filename, filenameSize, "%s", filenameOut);
445440

446441
this->logType = type;
447-
this->retries = retries > 0 ? retries : 1;
448-
this->retryInterval = retryInterval > 30 ? retryInterval : 30;
442+
this->retries = retries >= 0 ? retries : 0;
443+
this->retryInterval = retryInterval >= 0 ? retryInterval : 30;
449444
this->oldestTimestamp = oldestTimestamp;
450445
this->latestTimestamp = latestTimestamp;
451446

@@ -475,7 +470,6 @@ MO_GetLogStatus DiagnosticsService::getLog(MO_LogType type, int requestId, int r
475470
#endif
476471

477472
nextTry = clock.now();
478-
clock.add(nextTry, 5); //wait for 5s before upload
479473
uploadIssued = false;
480474
uploadFailure = false;
481475

@@ -496,7 +490,7 @@ MO_GetLogStatus DiagnosticsService::getLog(MO_LogType type, int requestId, int r
496490
}
497491

498492
int DiagnosticsService::getRequestId() {
499-
if (runCustomUpload || this->retries > 0) {
493+
if (runCustomUpload || this->retries >= 0) {
500494
return requestId;
501495
} else {
502496
return -1;
@@ -1000,7 +994,7 @@ void DiagnosticsService::cleanGetLogData() {
1000994
location = nullptr;
1001995
MO_FREE(filename);
1002996
filename = nullptr;
1003-
retries = 0;
997+
retries = -1;
1004998
retryInterval = 0;
1005999
oldestTimestamp = Timestamp();
10061000
latestTimestamp = Timestamp();

src/MicroOcpp/Model/Diagnostics/DiagnosticsService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class DiagnosticsService : public MemoryManaged {
6767
int requestId = -1;
6868
char *location = nullptr;
6969
char *filename = nullptr;
70-
int retries = 0;
70+
int retries = -1;
7171
int retryInterval = 0;
7272
Timestamp oldestTimestamp;
7373
Timestamp latestTimestamp;

src/MicroOcpp/Operations/GetDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void GetDiagnostics::processReq(JsonObject payload) {
2727
return;
2828
}
2929

30-
int retries = payload["retries"] | 1;
30+
int retries = payload["retries"] | 0;
3131
int retryInterval = payload["retryInterval"] | 180;
3232
if (retries < 0 || retryInterval < 0) {
3333
errorCode = "PropertyConstraintViolation";

src/MicroOcpp/Operations/GetLog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void GetLog::processReq(JsonObject payload) {
3030
return;
3131
}
3232

33-
int retries = payload["retries"] | 1;
33+
int retries = payload["retries"] | 0;
3434
int retryInterval = payload["retryInterval"] | 180;
3535
if (retries < 0 || retryInterval < 0) {
3636
errorCode = "PropertyConstraintViolation";

tests/benchmarks/scripts/measure_heap.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
'TC_J_08_CS',
9999
'TC_J_09_CS',
100100
'TC_J_10_CS',
101+
'TC_N_25_CS',
102+
'TC_N_26_CS',
101103
]
102104

103105
# Result data set

0 commit comments

Comments
 (0)