diff --git a/Software/USER_SETTINGS.h b/Software/USER_SETTINGS.h index 6b189660..ab97689d 100644 --- a/Software/USER_SETTINGS.h +++ b/Software/USER_SETTINGS.h @@ -41,7 +41,7 @@ //#define TESLA_MODEL_SX_BATTERY //#define VOLVO_SPA_BATTERY //#define VOLVO_SPA_HYBRID_BATTERY -#define TEST_FAKE_BATTERY +//#define TEST_FAKE_BATTERY //#define DOUBLE_BATTERY //Enable this line if you use two identical batteries at the same time (requires CAN_ADDON setup) //#define SERIAL_LINK_TRANSMITTER //Enable this line to send battery data over RS485 pins to another Lilygo (This LilyGo interfaces with battery) @@ -67,7 +67,7 @@ //#define SERIAL_LINK_RECEIVER //Enable this line to receive battery data over RS485 pins from another Lilygo (This LilyGo interfaces with inverter) /* Select hardware used for Battery-Emulator */ -#define HW_LILYGO +//#define HW_LILYGO //#define HW_STARK //#define HW_3LB //#define HW_DEVKIT @@ -81,7 +81,7 @@ //#define PERIODIC_BMS_RESET //Enable to have the emulator powercycle the connected battery every 24hours via GPIO. Useful for some batteries like Nissan LEAF //#define REMOTE_BMS_RESET //Enable to allow the emulator to remotely trigger a powercycle of the battery via MQTT. Useful for some batteries like Nissan LEAF // PERIODIC_BMS_RESET_AT Uses NTP server, internet required. In 24 Hour format WITHOUT leading 0. e.g 0230 should be 230. Time Zone is set in USER_SETTINGS.cpp -#define PERIODIC_BMS_RESET_AT 525 +//#define PERIODIC_BMS_RESET_AT 525 /* Shunt/Contactor settings (Optional) */ //#define BMW_SBOX // SBOX relay control & battery current/voltage measurement @@ -101,7 +101,7 @@ //#define LOG_CAN_TO_SD //Enable this line to log incoming/outgoing CAN & CAN-FD messages to SD card (WARNING, raises CPU load, do not use for production) //#define DEBUG_VIA_USB //Enable this line to have the USB port output serial diagnostic data while program runs (WARNING, raises CPU load, do not use for production) //#define DEBUG_VIA_WEB //Enable this line to log diagnostic data while program runs, which can be viewed via webpage (WARNING, slightly raises CPU load, do not use for production) -#define DEBUG_CAN_DATA //Enable this line to print incoming/outgoing CAN & CAN-FD messages to USB serial (WARNING, raises CPU load, do not use for production) +#define DEBUG_CAN_DATA //Enable this line to print incoming/outgoing CAN & CAN-FD messages to USB serial (WARNING, raises CPU load, do not use for production) /* CAN options */ //#define CAN_ADDON //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 chip (Needed for some inverters / double battery) diff --git a/Software/src/devboard/webserver/can_replay_html.cpp b/Software/src/devboard/webserver/can_replay_html.cpp index 7607ad4e..ac4cc9e4 100644 --- a/Software/src/devboard/webserver/can_replay_html.cpp +++ b/Software/src/devboard/webserver/can_replay_html.cpp @@ -33,18 +33,16 @@ String can_replay_processor(void) { // Dropdown with choices content += ""; content += ""; @@ -54,14 +52,14 @@ String can_replay_processor(void) { content += "

Step 2: Upload CAN Log File

"; -content += "
"; -content += "

Drag & drop a .txt file here, or click Browse to select one.

"; -content += ""; -content += "
"; + content += "
"; + content += "

Drag & drop a .txt file here, or click Browse to select one.

"; + content += ""; + content += "
"; -content += "
"; + content += "
"; -content += ""; + content += ""; content += "

Step 3: Playback control

"; @@ -71,41 +69,50 @@ content += ""; // Add a button to stop playing the log content += " "; -content += "

Uploaded Log Preview:

"; -content += "
";
+  content += "

Uploaded Log Preview:

"; + content += "
";
 
-content += "";
+  content += "uploadBtn.addEventListener('click', () => {";
+  content += "if (!selectedFile) { alert('Please select a file first!'); return; }";
+  content += "const formData = new FormData();";
+  content += "formData.append('file', selectedFile);";
+  content += "const xhr = new XMLHttpRequest();";
+  content += "xhr.open('POST', '/import_can_log', true);";
+  content +=
+      "xhr.upload.onprogress = (event) => { if (event.lengthComputable) { const percent = (event.loaded / event.total) "
+      "* 100; progressContainer.style.display = 'block'; progressBar.style.width = percent + '%'; }};";
+  content +=
+      "xhr.onload = () => { if (xhr.status === 200) { alert('File uploaded successfully!'); progressBar.style.width = "
+      "'100%'; const reader = new FileReader(); reader.onload = function (e) { fileContent.textContent = "
+      "e.target.result; }; reader.readAsText(selectedFile); } else { alert('Upload failed! Server error.'); }};";
+  content += "xhr.send(formData);";
+  content += "});";
+  content += "";
 
   content += "";
 
   // Add JavaScript for navigation
   content += "