Skip to content

Commit a05b262

Browse files
committed
Runtime: Integration
1 parent 5e66c1d commit a05b262

File tree

8 files changed

+16
-0
lines changed

8 files changed

+16
-0
lines changed

src/WebApi_firmware.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <AsyncJson.h>
1111
#include <Update.h>
1212
#include "esp_partition.h"
13+
#include "RuntimeData.h"
1314

1415
void WebApiFirmwareClass::init(AsyncWebServer& server, Scheduler& scheduler)
1516
{
@@ -84,6 +85,7 @@ void WebApiFirmwareClass::onFirmwareUpdateUpload(AsyncWebServerRequest* request,
8485
}
8586

8687
if (final) { // if the final flag is set then this is the last frame of data
88+
RuntimeData.write(); // write the runtime data to LittleFS
8789
if (!Update.end(true)) { // true to set the size to the current progress
8890
Update.printError(Serial);
8991
return request->send(400, asyncsrv::T_text_plain, "Could not end OTA");

src/WebApi_maintenance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "WebApi.h"
99
#include "WebApi_errors.h"
1010
#include <AsyncJson.h>
11+
#include "RuntimeData.h"
1112

1213
void WebApiMaintenanceClass::init(AsyncWebServer& server, Scheduler& scheduler)
1314
{
@@ -43,6 +44,7 @@ void WebApiMaintenanceClass::onRebootPost(AsyncWebServerRequest* request)
4344
retMsg["code"] = WebApiError::MaintenanceRebootTriggered;
4445

4546
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
47+
RuntimeData.write(); // write the runtime data to LittleFS
4648
RestartHelper.triggerRestart();
4749
} else {
4850
retMsg["message"] = "Reboot cancled!";

src/WebApi_sysstatus.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <Hoymiles.h>
1515
#include <LittleFS.h>
1616
#include <ResetReason.h>
17+
#include "RuntimeData.h"
1718

1819
void WebApiSysstatusClass::init(AsyncWebServer& server, Scheduler& scheduler)
1920
{
@@ -77,6 +78,7 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
7778
root["resetreason_1"] = reason;
7879

7980
root["cfgsavecount"] = Configuration.get().Cfg.SaveCount;
81+
root["runtime_savecount"] = RuntimeData.getWriteCountAndTimeString();
8082

8183
char version[16];
8284
snprintf(version, sizeof(version), "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);

src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <LittleFS.h>
3737
#include <TaskScheduler.h>
3838
#include <esp_heap_caps.h>
39+
#include "RuntimeData.h"
3940

4041
#undef TAG
4142
static const char* TAG = "main";
@@ -146,6 +147,8 @@ void setup()
146147
RestartHelper.init(scheduler);
147148

148149
// OpenDTU-OnBattery-specific initializations go below
150+
RuntimeData.init(scheduler);
151+
RuntimeData.read(); // make runtime data available as early as possible
149152
SolarCharger.init(scheduler);
150153
PowerMeter.init(scheduler);
151154
PowerLimiter.init(scheduler);

webapp/src/components/FirmwareInfo.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
<th>{{ $t('firmwareinfo.ConfigSaveCount') }}</th>
8484
<td>{{ $n(systemStatus.cfgsavecount, 'decimal') }}</td>
8585
</tr>
86+
<tr>
87+
<th>{{ $t('firmwareinfo.RuntimeSaveCount') }}</th>
88+
<td>{{ systemStatus.runtime_savecount }}</td>
89+
</tr>
8690
<tr>
8791
<th>{{ $t('firmwareinfo.Uptime') }}</th>
8892
<td>

webapp/src/locales/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"ResetReason0": "Reset Grund CPU 0",
283283
"ResetReason1": "Reset Grund CPU 1",
284284
"ConfigSaveCount": "Anzahl der Konfigurationsspeicherungen",
285+
"RuntimeSaveCount": "Laufzeitdatenspeicherungen Anzahl / Zeit",
285286
"Uptime": "Betriebszeit",
286287
"UptimeValue": "0 Tage {time} | 1 Tag {time} | {count} Tage {time}"
287288
},

webapp/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"ResetReason0": "Reset Reason CPU 0",
283283
"ResetReason1": "Reset Reason CPU 1",
284284
"ConfigSaveCount": "Config save count",
285+
"RuntimeSaveCount": "Runtime data save count / time",
285286
"Uptime": "Uptime",
286287
"UptimeValue": "0 days {time} | 1 day {time} | {count} days {time}"
287288
},

webapp/src/types/SystemStatus.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface SystemStatus {
3131
resetreason_0: string;
3232
resetreason_1: string;
3333
cfgsavecount: number;
34+
runtime_savecount: string;
3435
uptime: number;
3536
update_text: string;
3637
update_url: string;

0 commit comments

Comments
 (0)