multiple changes
This commit is contained in:
parent
ad6332acd4
commit
0b9ef67c39
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
Bestellung.xlsx
|
@ -41,6 +41,7 @@
|
||||
<li><a data-toggle="tab" href="#tab_tank">Öltank</a></li>
|
||||
<li><a data-toggle="tab" href="#tab_maintenance">Wartung</a></li>
|
||||
<li><a data-toggle="tab" href="#tab_sysinfo">Systeminfo</a></li>
|
||||
<li><a data-toggle="tab" href="#tab_fwupdate">Update</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -341,20 +342,6 @@
|
||||
<div id="tab_sysinfo" class="tab-pane fade">
|
||||
<h3>Systeminfo</h3>
|
||||
<hr>
|
||||
<h4>Firmware-Info</h4>
|
||||
<p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-md-8" scope="col">Parameter</td>
|
||||
<th class="col-md-4" scope="col">Value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td>%SW_VERSION%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<h4>Einstellungen</h4>
|
||||
<p>
|
||||
<table class="table">
|
||||
@ -462,6 +449,45 @@
|
||||
</p>
|
||||
</div>
|
||||
<!-- Div Tab SystemInfo -->
|
||||
<!-- Div Tab Firmware Update-->
|
||||
<div id="tab_fwupdate" class="tab-pane fade">
|
||||
<h3>Firmware Update</h3>
|
||||
<hr>
|
||||
<h4>Version-Info</h4>
|
||||
<p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Firmware Version</td>
|
||||
<td>%SW_VERSION%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Flash Version</td>
|
||||
<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>
|
||||
<div class="col-xs-7">
|
||||
<div class="input-group">
|
||||
<input id="fw-update-file" name="fw-update-file" type="file" class="form-control-file"
|
||||
required="required">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-xs-offset-5 col-xs-7">
|
||||
<button name="fw-update" type="submit" class="btn btn-primary">Aktualisieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Div Tab Firmware Update-->
|
||||
</div>
|
||||
<!-- Tabs Content -->
|
||||
</main>
|
||||
|
1
Software/data/version
Normal file
1
Software/data/version
Normal file
@ -0,0 +1 @@
|
||||
1
|
@ -31,10 +31,10 @@ build_flags =
|
||||
-DADMIN_PASSWORD=${wifi_cred.admin_password}
|
||||
-DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
|
||||
-DWIFI_AP_IP_GW=10,0,0,1
|
||||
;-DFEATURE_ENABLE_WIFI_CLIENT
|
||||
-DFEATURE_ENABLE_WIFI_CLIENT
|
||||
-DFEATURE_ENABLE_REMOTE_DEBUG
|
||||
-DFEATURE_ENABLE_CAN
|
||||
-DFEATURE_ENABLE_GPS
|
||||
;-DFEATURE_ENABLE_CAN
|
||||
;-DFEATURE_ENABLE_GPS
|
||||
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#define OTA_DELAY 50 // ticks -> 10ms / tick
|
||||
#endif
|
||||
|
||||
#define ATOMIC_FS_UPDATE
|
||||
|
||||
#ifndef ADMIN_PASSWORD
|
||||
#error "You need to define ADMIN_PASSWORD for OTA-Update"
|
||||
#endif
|
||||
|
@ -12,6 +12,7 @@ typedef enum DTCNums_e
|
||||
DTC_EEPROM_CFG_BAD,
|
||||
DTC_EEPROM_PDS_BAD,
|
||||
DTC_EEPROM_VERSION_BAD,
|
||||
DTC_FLASHFS_ERROR,
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
DTC_NO_GPS_SERIAL,
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@ typedef struct Globals_s
|
||||
char systemStatustxt[16] = "";
|
||||
uint8_t purgePulses = 0;
|
||||
eEERequest requestEEAction = EE_IDLE;
|
||||
char DeviceName[33];
|
||||
} Globals_t;
|
||||
|
||||
extern Globals_t globals;
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <Wire.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
#include <FastLED.h>
|
||||
@ -41,7 +40,6 @@ ESP8266WiFiMulti wifiMulti;
|
||||
#endif
|
||||
|
||||
bool startSetupMode = false;
|
||||
char DeviceName[33];
|
||||
|
||||
Globals_t globals;
|
||||
uint32_t TravelDistance_highRes;
|
||||
@ -84,14 +82,14 @@ Ticker EEPROMCyclicPDSTicker(EEPROMCyclicPDS_callback, 60000, 0, MILLIS);
|
||||
void setup()
|
||||
{
|
||||
system_update_cpu_freq(SYS_CPU_80MHZ);
|
||||
snprintf(DeviceName, 32, HOST_NAME, ESP.getChipId());
|
||||
snprintf(globals.DeviceName, 32, HOST_NAME, ESP.getChipId());
|
||||
WiFi.persistent(false);
|
||||
|
||||
ClearAllDTC(); // Init DTC-Storage
|
||||
|
||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.setHostname(DeviceName);
|
||||
WiFi.setHostname(globals.DeviceName);
|
||||
wifiMulti.addAP(QUOTE(WIFI_SSID), QUOTE(WIFI_PASSWORD));
|
||||
WiFiMaintainConnectionTicker.start();
|
||||
#else
|
||||
@ -102,7 +100,7 @@ void setup()
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
Serial.println("Souko's ChainLube Mk1");
|
||||
Serial.println(DeviceName);
|
||||
Serial.println(globals.DeviceName);
|
||||
|
||||
InitEEPROM();
|
||||
GetConfig_EEPROM();
|
||||
@ -141,10 +139,7 @@ void setup()
|
||||
pinMode(GPIO_PUMP, OUTPUT);
|
||||
|
||||
#ifdef FEATURE_ENABLE_REMOTE_DEBUG
|
||||
if (MDNS.begin(DeviceName))
|
||||
MDNS.addService("telnet", "tcp", 23);
|
||||
|
||||
Debug.begin(DeviceName);
|
||||
Debug.begin(globals.DeviceName);
|
||||
Debug.setResetCmdEnabled(true);
|
||||
Debug.showProfiler(false);
|
||||
Debug.showColors(true);
|
||||
@ -157,7 +152,7 @@ void setup()
|
||||
#endif
|
||||
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname(DeviceName);
|
||||
ArduinoOTA.setHostname(globals.DeviceName);
|
||||
ArduinoOTA.setPassword(QUOTE(ADMIN_PASSWORD));
|
||||
|
||||
ArduinoOTA.onStart([]()
|
||||
@ -302,7 +297,7 @@ void RemoteDebug_formatPersistence()
|
||||
void RemotDebug_printSystemInfo()
|
||||
{
|
||||
debugA("Souko's ChainOiler Mk1");
|
||||
debugA("Hostname: %s", DeviceName);
|
||||
debugA("Hostname: %s", globals.DeviceName);
|
||||
|
||||
FlashMode_t ideMode = ESP.getFlashChipMode();
|
||||
debugA("Sdk version: %s", ESP.getSdkVersion());
|
||||
@ -719,7 +714,7 @@ void toggleWiFiAP(boolean shutdown)
|
||||
{
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAPConfig(IPAddress(WIFI_AP_IP_GW), IPAddress(WIFI_AP_IP_GW), IPAddress(255, 255, 255, 0));
|
||||
WiFi.softAP(DeviceName, QUOTE(WIFI_AP_PASSWORD));
|
||||
WiFi.softAP(globals.DeviceName, QUOTE(WIFI_AP_PASSWORD));
|
||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||
WiFiMaintainConnectionTicker.stop();
|
||||
debugV("WiFi AP started, stopped Maintain-Timer");
|
||||
|
@ -8,21 +8,30 @@ String processor(const String &var);
|
||||
void WebserverPOST_Callback(AsyncWebServerRequest *request);
|
||||
void WebserverNotFound_Callback(AsyncWebServerRequest *request);
|
||||
void Webserver_Callback(AsyncWebServerRequest *request);
|
||||
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final);
|
||||
uint32_t GetFlashVersion();
|
||||
|
||||
void initWebUI()
|
||||
{
|
||||
if (!LittleFS.begin())
|
||||
{
|
||||
Serial.println("An Error has occurred while mounting LittleFS");
|
||||
MaintainDTC(DTC_FLASHFS_ERROR, true);
|
||||
return;
|
||||
}
|
||||
|
||||
MDNS.begin(globals.DeviceName);
|
||||
MDNS.addService("telnet", "tcp", 23);
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
|
||||
webServer.serveStatic("/static/", LittleFS, "/static/").setCacheControl("max-age=360000");
|
||||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{ request->redirect("/index.htm"); });
|
||||
webServer.onNotFound(WebserverNotFound_Callback);
|
||||
webServer.on("/index.htm", HTTP_GET, Webserver_Callback);
|
||||
webServer.on("/post.htm", HTTP_POST, WebserverPOST_Callback);
|
||||
webServer.on(
|
||||
"/doUpdate", HTTP_POST, [](AsyncWebServerRequest *request) {}, WebserverFirmwareUpdate_Callback);
|
||||
|
||||
webServer.begin();
|
||||
}
|
||||
@ -176,6 +185,8 @@ String processor(const String &var)
|
||||
sprintf(buffer, "%d.%02d", SW_VERSION_MAJOR, SW_VERSION_MINOR);
|
||||
return String(buffer);
|
||||
}
|
||||
if (var == "FS_VERSION")
|
||||
return String(GetFlashVersion());
|
||||
|
||||
if (var == "PLACEHOLDER")
|
||||
return "placeholder";
|
||||
@ -276,3 +287,64 @@ void WebserverNotFound_Callback(AsyncWebServerRequest *request)
|
||||
{
|
||||
request->send(404, "text/html", "Not found");
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
this_file.readBytesUntil('\r', buffer, sizeof(buffer));
|
||||
}
|
||||
this_file.close();
|
||||
return atoi(buffer);
|
||||
}
|
||||
|
||||
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)
|
||||
{
|
||||
|
||||
if (!index)
|
||||
{
|
||||
Serial.println("Update");
|
||||
size_t content_len = request->contentLength();
|
||||
// if filename includes spiffs, update the spiffs partition
|
||||
int cmd = (filename.indexOf(".fs") > -1) ? U_FS : U_FLASH;
|
||||
Update.runAsync(true);
|
||||
if (!Update.begin(content_len, cmd))
|
||||
{
|
||||
Update.printError(Serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (Update.write(data, len) != len)
|
||||
{
|
||||
Update.printError(Serial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Progress: %d%%\n", (Update.progress() * 100) / Update.size());
|
||||
}
|
||||
|
||||
if (final)
|
||||
{
|
||||
AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", "Please wait while the device reboots");
|
||||
response->addHeader("Refresh", "20");
|
||||
response->addHeader("Location", "/");
|
||||
request->send(response);
|
||||
if (!Update.end(true))
|
||||
{
|
||||
Update.printError(Serial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Update complete");
|
||||
Serial.flush();
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include <LittleFS.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <Updater.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user