got most of the WebUI updated and working
This commit is contained in:
8
Software/src/common.cpp
Normal file
8
Software/src/common.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "common.h"
|
||||
|
||||
const char *BatteryString[] = {
|
||||
"Undefined",
|
||||
"LiPo 2S",
|
||||
"LiPo 3S"};
|
||||
|
||||
const size_t BatteryString_Elements = sizeof(BatteryString) / sizeof(BatteryString[0]);
|
@@ -288,6 +288,18 @@ void Debug_printSystemInfo()
|
||||
Debug_pushMessage("OTA-Pass: %s\n", QUOTE(ADMIN_PASSWORD));
|
||||
Debug_pushMessage("Git-Revision: %s\n", constants.GitHash);
|
||||
Debug_pushMessage("Sw-Version: %d.%02d\n", constants.FW_Version_major, constants.FW_Version_minor);
|
||||
|
||||
Debug_pushMessage("globals.systemStatus: %d\n", globals.systemStatus);
|
||||
Debug_pushMessage("globals.resumeStatus: %d\n", globals.resumeStatus);
|
||||
Debug_pushMessage("globals.systemStatustxt: %s\n", globals.systemStatustxt);
|
||||
Debug_pushMessage("globals.requestEEAction: %d\n", globals.requestEEAction);
|
||||
Debug_pushMessage("globals.DeviceName: %s\n", globals.DeviceName);
|
||||
Debug_pushMessage("globals.FlashVersion: %s\n", globals.FlashVersion);
|
||||
Debug_pushMessage("globals.eePersistanceAdress: %u\n", globals.eePersistanceAdress);
|
||||
Debug_pushMessage("globals.hasDTC: %d\n", globals.hasDTC);
|
||||
Debug_pushMessage("globals.loadvoltage_mV: %d\n", globals.loadvoltage_mV);
|
||||
Debug_pushMessage("globals.battery_level: %d\n", globals.battery_level);
|
||||
Debug_pushMessage("globals.timer_disabled: %d\n", globals.timer_disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,4 +6,5 @@ void initGlobals()
|
||||
{
|
||||
globals.systemStatus = sysStat_Startup;
|
||||
globals.requestEEAction = EE_IDLE;
|
||||
globals.systemStatustxt[0] = 0;
|
||||
}
|
||||
|
@@ -251,7 +251,7 @@ void loop()
|
||||
tmrWiFiMaintainConnection.update();
|
||||
#endif
|
||||
|
||||
static tSystem_Status lastStatus = sysStat_Error;
|
||||
static tSystem_Status lastStatus = sysStat_Init;
|
||||
|
||||
// Handle different system statuses
|
||||
switch (globals.systemStatus)
|
||||
@@ -293,7 +293,12 @@ void loop()
|
||||
}
|
||||
SystemShutdown(false);
|
||||
break;
|
||||
|
||||
case sysStat_Error:
|
||||
if (lastStatus != globals.systemStatus)
|
||||
{
|
||||
strcpy_P(globals.systemStatustxt, PSTR("Error"));
|
||||
lastStatus = globals.systemStatus;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ AsyncWebServer webServer(80);
|
||||
|
||||
const char *PARAM_MESSAGE = "message";
|
||||
|
||||
batteryType_t batterytypePreselect; /**< Preselect Memory for change Batterytype */
|
||||
|
||||
String processor(const String &var);
|
||||
void WebserverNotFound_Callback(AsyncWebServerRequest *request);
|
||||
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final);
|
||||
@@ -446,8 +448,14 @@ void Websocket_HandleButtons(uint8_t *data)
|
||||
char value[32];
|
||||
|
||||
parseWebsocketString((char *)data, identifier, sizeof(identifier), value, sizeof(value));
|
||||
|
||||
if (strcmp(identifier, "debugstart") == 0)
|
||||
if (strcmp(identifier, "reset-timer") == 0)
|
||||
{
|
||||
PersistenceData.activeFaction = NONE;
|
||||
PersistenceData.faction_1_timer = 0;
|
||||
PersistenceData.faction_2_timer = 0;
|
||||
PersistenceData.faction_3_timer = 0;
|
||||
}
|
||||
else if (strcmp(identifier, "debugstart") == 0)
|
||||
{
|
||||
SetDebugportStatus(dbg_Webui, enabled);
|
||||
}
|
||||
@@ -457,6 +465,7 @@ void Websocket_HandleButtons(uint8_t *data)
|
||||
}
|
||||
else if (strcmp(identifier, "settingssave") == 0)
|
||||
{
|
||||
ConfigData.batteryType = batterytypePreselect;
|
||||
globals.requestEEAction = EE_CFG_SAVE;
|
||||
}
|
||||
else if (strcmp(identifier, "reboot") == 0)
|
||||
@@ -484,7 +493,33 @@ void Websocket_HandleSettings(uint8_t *data)
|
||||
|
||||
parseWebsocketString((char *)data, identifier, sizeof(identifier), value, sizeof(value));
|
||||
|
||||
if (strcmp(identifier, "wifi-ssid") == 0)
|
||||
if (strcmp(identifier, "active_faction_on_reboot") == 0)
|
||||
{
|
||||
ConfigData.active_faction_on_reboot = value[0] == '1' ? true : false;
|
||||
}
|
||||
|
||||
else if (strcmp(identifier, "name_faction1") == 0)
|
||||
{
|
||||
strncpy(ConfigData.Faction_1_Name, value, sizeof(ConfigData.Faction_1_Name));
|
||||
}
|
||||
else if (strcmp(identifier, "name_faction2") == 0)
|
||||
{
|
||||
strncpy(ConfigData.Faction_2_Name, value, sizeof(ConfigData.Faction_2_Name));
|
||||
}
|
||||
else if (strcmp(identifier, "name_faction3") == 0)
|
||||
{
|
||||
strncpy(ConfigData.Faction_3_Name, value, sizeof(ConfigData.Faction_3_Name));
|
||||
}
|
||||
else if (strcmp(identifier, "batterytype") == 0)
|
||||
{
|
||||
strncpy(ConfigData.wifi_client_ssid, value, sizeof(ConfigData.wifi_client_ssid));
|
||||
}
|
||||
else if (strcmp(identifier, "batterytype") == 0)
|
||||
{
|
||||
int index = findIndexByString(value, BatteryString, BatteryString_Elements);
|
||||
batterytypePreselect = (batteryType_t)index;
|
||||
}
|
||||
else if (strcmp(identifier, "wifi-ssid") == 0)
|
||||
{
|
||||
strncpy(ConfigData.wifi_client_ssid, value, sizeof(ConfigData.wifi_client_ssid));
|
||||
}
|
||||
@@ -579,6 +614,8 @@ void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
|
||||
webSocket.text(client_id, mapping);
|
||||
else
|
||||
webSocket.textAll(mapping);
|
||||
|
||||
Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n");
|
||||
}
|
||||
|
||||
String temp = "STATUS:";
|
||||
|
Reference in New Issue
Block a user