mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Adding feature to log to SD Card (#708)
* Adding feature to log to SD Card Co-authored-by: mvgalen <marijnvangalen@gmail.com>
This commit is contained in:
parent
3d1f535b09
commit
f138f97905
10 changed files with 234 additions and 68 deletions
|
@ -65,7 +65,7 @@ void init_webserver() {
|
|||
request->send(response);
|
||||
});
|
||||
|
||||
#ifdef DEBUG_VIA_WEB
|
||||
#if defined(DEBUG_VIA_WEB) || defined(LOG_TO_SD)
|
||||
// Route for going to debug logging web page
|
||||
server.on("/log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
AsyncWebServerResponse* response = request->beginResponse(200, "text/html", debug_logger_processor());
|
||||
|
@ -123,6 +123,22 @@ void init_webserver() {
|
|||
});
|
||||
#endif
|
||||
|
||||
#ifdef LOG_TO_SD
|
||||
// Define the handler to delete log file
|
||||
server.on("/delete_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
delete_log();
|
||||
request->send_P(200, "text/plain", "Log file deleted");
|
||||
});
|
||||
|
||||
// Define the handler to export debug log
|
||||
server.on("/export_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
pause_log_writing();
|
||||
request->send(SD, LOG_FILE, String(), true);
|
||||
resume_log_writing();
|
||||
});
|
||||
#endif
|
||||
|
||||
#ifndef LOG_TO_SD
|
||||
// Define the handler to export debug log
|
||||
server.on("/export_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
String logs = String(datalayer.system.info.logged_can_messages);
|
||||
|
@ -149,6 +165,7 @@ void init_webserver() {
|
|||
response->addHeader("Content-Disposition", String("attachment; filename=\"") + String(filename) + "\"");
|
||||
request->send(response);
|
||||
});
|
||||
#endif
|
||||
|
||||
// Route for going to cellmonitor web page
|
||||
server.on("/cellmonitor", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
|
@ -1061,7 +1078,7 @@ String processor(const String& var) {
|
|||
content += "<button onclick='Settings()'>Change Settings</button> ";
|
||||
content += "<button onclick='Advanced()'>More Battery Info</button> ";
|
||||
content += "<button onclick='CANlog()'>CAN logger</button> ";
|
||||
#ifdef DEBUG_VIA_WEB
|
||||
#if defined(DEBUG_VIA_WEB) || defined(LOG_TO_SD)
|
||||
content += "<button onclick='Log()'>Log</button> ";
|
||||
#endif // DEBUG_VIA_WEB
|
||||
content += "<button onclick='Cellmon()'>Cellmonitor</button> ";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue