Compare commits
4 Commits
a6ae30d655
...
a6f5b4ef65
Author | SHA1 | Date | |
---|---|---|---|
a6f5b4ef65 | |||
7c38d02bf8 | |||
01ba4b7333 | |||
3048c6c2a1 |
@ -4,7 +4,6 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>KTM CAN Chain Oiler</title>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="static/css/custom.css">
|
||||
@ -47,7 +46,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main role="main" class="container">
|
||||
<main class="container">
|
||||
|
||||
<!-- Tabs Content -->
|
||||
<div class="tab-content">
|
||||
@ -76,9 +75,9 @@
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-md-4" scope="col">Timestamp</td>
|
||||
<th class="col-md-4" scope="col">DTC</td>
|
||||
<th class="col-md-4" scope="col">active</td>
|
||||
<th class="col-md-4" scope="col">Timestamp</th>
|
||||
<th class="col-md-4" scope="col">DTC</th>
|
||||
<th class="col-md-4" scope="col">active</th>
|
||||
</tr>
|
||||
%DTC_TABLE%
|
||||
</tbody>
|
||||
@ -454,7 +453,6 @@
|
||||
<h3>Firmware Update</h3>
|
||||
<hr>
|
||||
<h4>Version-Info</h4>
|
||||
<p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -466,10 +464,9 @@
|
||||
<td>%FS_VERSION%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<hr>
|
||||
<h4>Firmware-Update</h4>
|
||||
<p>
|
||||
|
||||
<form method='POST' action='/doUpdate' enctype='multipart/form-data'>
|
||||
<div class="form-group">
|
||||
<label for="fw-update-file" class="col-sm-2 col-form-label">Firmware-File</label>
|
||||
@ -485,7 +482,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Div Tab Firmware Update-->
|
||||
</div>
|
||||
|
@ -35,6 +35,8 @@
|
||||
#define OTA_DELAY 50 // ticks -> 10ms / tick
|
||||
#endif
|
||||
|
||||
#define SHUTDOWN_DELAY_MS 5000
|
||||
|
||||
#define ATOMIC_FS_UPDATE
|
||||
|
||||
#ifndef ADMIN_PASSWORD
|
||||
|
@ -4,7 +4,6 @@ I2C_eeprom ee(0x50, EEPROM_SIZE_BYTES);
|
||||
|
||||
LubeConfig_t LubeConfig;
|
||||
persistenceData_t PersistenceData;
|
||||
uint16_t eePersistenceMarker = 0;
|
||||
const uint16_t eeVersion = 1; // inc
|
||||
boolean eeAvailable = false;
|
||||
|
||||
@ -93,11 +92,6 @@ void GetConfig_EEPROM()
|
||||
LubeConfig.checksum = checksum;
|
||||
}
|
||||
|
||||
uint16_t getPersistanceAddress()
|
||||
{
|
||||
return startofPersistence + eePersistenceMarker;
|
||||
}
|
||||
|
||||
void StorePersistence_EEPROM()
|
||||
{
|
||||
if (PersistenceData.writeCycleCounter >= 0xFFF0)
|
||||
@ -111,7 +105,7 @@ void StorePersistence_EEPROM()
|
||||
if (!checkEEPROMavailable())
|
||||
return;
|
||||
|
||||
ee.updateBlock(getPersistanceAddress(), (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||
ee.updateBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||
}
|
||||
|
||||
void GetPersistence_EEPROM()
|
||||
@ -119,8 +113,18 @@ void GetPersistence_EEPROM()
|
||||
if (!checkEEPROMavailable())
|
||||
return;
|
||||
|
||||
eePersistenceMarker = (ee.readByte(0) << 8) | ee.readByte(1);
|
||||
ee.readBlock(getPersistanceAddress(), (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||
ee.readBlock(0, (uint8_t *)&globals.eePersistanceAdress, sizeof(globals.eePersistanceAdress));
|
||||
// if we got the StartAdress of Persistance and it's out of Range - we Reset it and store defaults
|
||||
// otherwise we Read from eeprom and check if everything is correct
|
||||
if (globals.eePersistanceAdress < startofPersistence || globals.eePersistanceAdress > ee.getDeviceSize())
|
||||
{
|
||||
MovePersistencePage_EEPROM(true);
|
||||
FormatPersistence_EEPROM();
|
||||
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ee.readBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||
|
||||
uint32_t checksum = PersistenceData.checksum;
|
||||
PersistenceData.checksum = 0;
|
||||
@ -128,9 +132,9 @@ void GetPersistence_EEPROM()
|
||||
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
|
||||
{
|
||||
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
|
||||
FormatPersistence_EEPROM();
|
||||
}
|
||||
PersistenceData.checksum = checksum;
|
||||
}
|
||||
}
|
||||
|
||||
void FormatConfig_EEPROM()
|
||||
@ -145,7 +149,6 @@ void FormatPersistence_EEPROM()
|
||||
{
|
||||
persistenceData_t defaults;
|
||||
PersistenceData = defaults;
|
||||
eePersistenceMarker = 0;
|
||||
StorePersistence_EEPROM();
|
||||
}
|
||||
|
||||
@ -154,17 +157,16 @@ void MovePersistencePage_EEPROM(boolean reset)
|
||||
if (!checkEEPROMavailable())
|
||||
return;
|
||||
|
||||
eePersistenceMarker = eePersistenceMarker + sizeof(PersistenceData);
|
||||
globals.eePersistanceAdress = +sizeof(PersistenceData);
|
||||
PersistenceData.writeCycleCounter = 0;
|
||||
|
||||
// check if we reached the End of the EEPROM and Startover at the beginning
|
||||
// if ((startofPersistence + eePersistenceMarker + sizeof(PersistenceData)) > ee.getDeviceSize() || reset)
|
||||
// {
|
||||
// eePersistenceMarker = 0;
|
||||
// }
|
||||
if ((globals.eePersistanceAdress + sizeof(PersistenceData)) > ee.getDeviceSize() || reset)
|
||||
{
|
||||
globals.eePersistanceAdress = startofPersistence;
|
||||
}
|
||||
|
||||
ee.updateByte(0, (uint8_t)(eePersistenceMarker >> 8));
|
||||
ee.updateByte(1, (uint8_t)(eePersistenceMarker & 0xFF));
|
||||
ee.updateBlock(0, (uint8_t *)&globals.eePersistanceAdress, sizeof(globals.eePersistanceAdress));
|
||||
}
|
||||
|
||||
uint32_t Checksum_EEPROM(uint8_t const *data, size_t len)
|
||||
|
@ -105,7 +105,6 @@ void FormatPersistence_EEPROM();
|
||||
uint32_t Checksum_EEPROM(uint8_t const *data, size_t len);
|
||||
void dumpEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
void MovePersistencePage_EEPROM(boolean reset);
|
||||
uint16_t getPersistanceAddress();
|
||||
|
||||
extern LubeConfig_t LubeConfig;
|
||||
extern persistenceData_t PersistenceData;
|
||||
|
@ -11,6 +11,7 @@ typedef enum DTCNums_e
|
||||
DTC_NO_EEPROM_FOUND,
|
||||
DTC_EEPROM_CFG_BAD,
|
||||
DTC_EEPROM_PDS_BAD,
|
||||
DTC_EEPROM_PDSADRESS_BAD,
|
||||
DTC_EEPROM_VERSION_BAD,
|
||||
DTC_FLASHFS_ERROR,
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
|
@ -31,6 +31,8 @@ typedef struct Globals_s
|
||||
uint8_t purgePulses = 0;
|
||||
eEERequest requestEEAction = EE_IDLE;
|
||||
char DeviceName[33];
|
||||
uint32_t FlashVersion;
|
||||
uint16_t eePersistanceAdress;
|
||||
} Globals_t;
|
||||
|
||||
extern Globals_t globals;
|
||||
|
@ -354,7 +354,7 @@ void RemoteDebug_dumpPersistance()
|
||||
debugA("tankRemain_µl: %d", PersistenceData.tankRemain_µl);
|
||||
debugA("TravelDistance_highRes_mm: %d", PersistenceData.TravelDistance_highRes_mm);
|
||||
debugA("checksum: %d", PersistenceData.checksum);
|
||||
debugA("PSD Adress: 0x%04X", getPersistanceAddress());
|
||||
debugA("PSD Adress: 0x%04X", globals.eePersistanceAdress);
|
||||
}
|
||||
|
||||
void RemoteDebug_printWifiInfo()
|
||||
@ -735,8 +735,19 @@ void toggleWiFiAP(boolean shutdown)
|
||||
|
||||
void SystemShutdown()
|
||||
{
|
||||
static uint32_t shutdown_delay = 0;
|
||||
|
||||
if (shutdown_delay == 0)
|
||||
{
|
||||
shutdown_delay = millis() + SHUTDOWN_DELAY_MS;
|
||||
Serial.printf("Shutdown requested - Restarting in %d seconds\n", SHUTDOWN_DELAY_MS);
|
||||
}
|
||||
if (shutdown_delay < millis())
|
||||
{
|
||||
StoreConfig_EEPROM();
|
||||
StorePersistence_EEPROM();
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Process_Impulse_WheelSpeed()
|
||||
|
@ -20,6 +20,8 @@ void initWebUI()
|
||||
return;
|
||||
}
|
||||
|
||||
globals.FlashVersion = GetFlashVersion();
|
||||
|
||||
MDNS.begin(globals.DeviceName);
|
||||
MDNS.addService("telnet", "tcp", 23);
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
@ -64,13 +66,17 @@ String processor(const String &var)
|
||||
return String(LubeConfig.BleedingPulses);
|
||||
if (var == "SPEED_SOURCE")
|
||||
return String(SpeedSourceString[LubeConfig.SpeedSource]);
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
if (var == "GPS_BAUD")
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
return String(GPSBaudRateString[LubeConfig.GPSBaudRate]);
|
||||
#else
|
||||
return "Feature N/A";
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
if (var == "CAN_SOURCE")
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
return String(CANSourceString[LubeConfig.CANSource]);
|
||||
#else
|
||||
return "Feature N/A";
|
||||
#endif
|
||||
if (var == "CONFIG_CHECKSUM")
|
||||
{
|
||||
@ -81,7 +87,7 @@ String processor(const String &var)
|
||||
if (var == "WRITE_CYCLE_COUNT")
|
||||
return String(PersistenceData.writeCycleCounter);
|
||||
if (var == "PERSISTENCE_MARKER")
|
||||
return String(getPersistanceAddress());
|
||||
return String(globals.eePersistanceAdress);
|
||||
if (var == "TANK_REMAIN_UL")
|
||||
return String(PersistenceData.tankRemain_µl);
|
||||
if (var == "TRAVEL_DISTANCE_HIGHRES")
|
||||
@ -190,7 +196,7 @@ String processor(const String &var)
|
||||
return String(buffer);
|
||||
}
|
||||
if (var == "FS_VERSION")
|
||||
return String(GetFlashVersion());
|
||||
return String(globals.FlashVersion);
|
||||
|
||||
if (var == "PLACEHOLDER")
|
||||
return "placeholder";
|
||||
@ -294,14 +300,13 @@ void WebserverNotFound_Callback(AsyncWebServerRequest *request)
|
||||
|
||||
uint32_t GetFlashVersion()
|
||||
{
|
||||
|
||||
char buffer[20];
|
||||
File this_file = LittleFS.open("version", "r");
|
||||
if (!this_file)
|
||||
{ // failed to open the file, retrn empty result
|
||||
return 0;
|
||||
}
|
||||
while (this_file.available())
|
||||
if (this_file.available())
|
||||
{
|
||||
this_file.readBytesUntil('\r', buffer, sizeof(buffer));
|
||||
}
|
||||
@ -348,7 +353,7 @@ void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const Stri
|
||||
{
|
||||
Serial.println("Update complete");
|
||||
Serial.flush();
|
||||
ESP.restart();
|
||||
globals.systemStatus = sysStat_Shutdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user