2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @file webui.cpp
|
|
|
|
*
|
|
|
|
* @brief Implementation file for web-based user interface (WebUI) functions in the ChainLube application.
|
|
|
|
*
|
|
|
|
* This file contains the implementation of functions related to the initialization and processing of the
|
|
|
|
* web-based user interface (WebUI). It includes the setup of LittleFS, handling of firmware version checks,
|
|
|
|
* initialization of mDNS, setup of web server routes, and handling of various HTTP events.
|
|
|
|
*
|
|
|
|
* @author Marcel Peterkau
|
|
|
|
* @date 09.01.2024
|
|
|
|
*/
|
|
|
|
|
2022-01-10 00:55:04 +01:00
|
|
|
#include "webui.h"
|
2022-01-07 21:02:27 +01:00
|
|
|
|
2022-02-10 22:33:52 +01:00
|
|
|
AsyncWebServer webServer(80);
|
2022-01-09 20:51:16 +01:00
|
|
|
|
2022-02-10 22:33:52 +01:00
|
|
|
const char *PARAM_MESSAGE = "message";
|
2022-01-07 21:02:27 +01:00
|
|
|
|
2022-02-10 22:33:52 +01:00
|
|
|
String processor(const String &var);
|
2022-02-15 20:58:32 +01:00
|
|
|
void WebserverPOST_Callback(AsyncWebServerRequest *request);
|
2022-02-10 22:33:52 +01:00
|
|
|
void WebserverNotFound_Callback(AsyncWebServerRequest *request);
|
2022-08-14 17:38:45 +02:00
|
|
|
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final);
|
2022-09-01 23:46:20 +02:00
|
|
|
void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final);
|
|
|
|
void WebServerEEJSON_Callback(AsyncWebServerRequest *request);
|
2022-08-22 14:45:44 +02:00
|
|
|
void GetFlashVersion(char *buff, size_t buff_size);
|
2022-01-19 22:23:36 +01:00
|
|
|
|
2023-02-23 23:14:58 +01:00
|
|
|
AsyncWebSocket webSocket("/ws");
|
|
|
|
|
|
|
|
void WebsocketEvent_Callback(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
|
|
|
void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len);
|
2023-12-25 02:05:22 +01:00
|
|
|
void Websocket_RefreshClientData_DTCs(uint32_t client_id);
|
|
|
|
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping = false);
|
|
|
|
void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping = false);
|
2023-02-23 23:14:58 +01:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Initializes the web-based user interface (WebUI) for the ChainLube application.
|
|
|
|
*
|
|
|
|
* This function sets up the necessary components for the WebUI, including mounting LittleFS,
|
|
|
|
* performing flash version checks, initializing mDNS, and configuring the web server with
|
|
|
|
* routes and event handlers. If any errors occur during setup, appropriate diagnostic messages
|
|
|
|
* are pushed to the debugging system, and potential error conditions are recorded as Diagnostic
|
|
|
|
* Trouble Codes (DTCs).
|
|
|
|
*
|
|
|
|
* @note This function should be called during the initialization phase of the application.
|
|
|
|
*/
|
2022-02-10 22:33:52 +01:00
|
|
|
void initWebUI()
|
2022-01-08 03:14:26 +01:00
|
|
|
{
|
2024-01-09 12:56:41 +01:00
|
|
|
// Attempt to mount LittleFS
|
2022-02-10 22:33:52 +01:00
|
|
|
if (!LittleFS.begin())
|
2022-01-08 03:14:26 +01:00
|
|
|
{
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("An Error has occurred while mounting LittleFS\n");
|
2023-09-27 19:13:54 +02:00
|
|
|
MaintainDTC(DTC_FLASHFS_ERROR, true);
|
2022-02-10 22:33:52 +01:00
|
|
|
return;
|
2022-01-09 20:51:16 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Retrieve the flash version
|
2022-08-22 14:26:37 +02:00
|
|
|
GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion));
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Compare the flash version with the required version
|
2023-03-02 23:35:41 +01:00
|
|
|
char buffer[6];
|
2023-03-03 10:48:19 +01:00
|
|
|
snprintf(buffer, sizeof(buffer), "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor);
|
2023-03-02 23:35:41 +01:00
|
|
|
if (strcmp(globals.FlashVersion, buffer))
|
2022-08-22 14:26:37 +02:00
|
|
|
{
|
2023-09-27 19:13:54 +02:00
|
|
|
MaintainDTC(DTC_FLASHFS_VERSION_ERROR, true);
|
2022-08-22 14:26:37 +02:00
|
|
|
}
|
2022-08-19 11:25:26 +02:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Initialize mDNS and add service
|
2022-08-14 17:38:45 +02:00
|
|
|
MDNS.begin(globals.DeviceName);
|
|
|
|
MDNS.addService("http", "tcp", 80);
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Set up WebSocket event handler and attach to web server
|
2023-02-23 23:14:58 +01:00
|
|
|
webSocket.onEvent(WebsocketEvent_Callback);
|
|
|
|
webServer.addHandler(&webSocket);
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Serve static files and define routes
|
2022-03-09 20:25:02 +01:00
|
|
|
webServer.serveStatic("/static/", LittleFS, "/static/").setCacheControl("max-age=360000");
|
2024-01-09 12:17:13 +01:00
|
|
|
webServer.serveStatic("/index.htm", LittleFS, "/index.htm").setCacheControl("max-age=360000");
|
2022-02-27 22:23:58 +01:00
|
|
|
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
|
|
|
{ request->redirect("/index.htm"); });
|
2022-02-10 22:33:52 +01:00
|
|
|
webServer.onNotFound(WebserverNotFound_Callback);
|
2022-09-01 23:46:20 +02:00
|
|
|
webServer.on("/eejson", HTTP_GET, WebServerEEJSON_Callback);
|
2022-08-14 17:38:45 +02:00
|
|
|
webServer.on(
|
|
|
|
"/doUpdate", HTTP_POST, [](AsyncWebServerRequest *request) {}, WebserverFirmwareUpdate_Callback);
|
2022-09-01 23:46:20 +02:00
|
|
|
webServer.on(
|
|
|
|
"/eeRestore", HTTP_POST, [](AsyncWebServerRequest *request) {}, WebserverEERestore_Callback);
|
2022-01-09 20:51:16 +01:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
// Start the web server
|
2022-02-10 22:33:52 +01:00
|
|
|
webServer.begin();
|
2022-01-07 21:02:27 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Processes the web server functionality for the ChainLube application.
|
|
|
|
*
|
|
|
|
* This function performs periodic processing tasks for the web server, including cleaning up
|
|
|
|
* WebSocket clients and refreshing client data when WebSocket connections are active. It ensures
|
|
|
|
* that WebSocket client data related to Diagnostic Trouble Codes (DTCs) and system status is
|
|
|
|
* updated at regular intervals.
|
|
|
|
*
|
|
|
|
* @note This function should be called in the main loop of the application.
|
|
|
|
*/
|
2023-02-23 23:14:58 +01:00
|
|
|
void Webserver_Process()
|
|
|
|
{
|
2023-12-04 02:18:16 +01:00
|
|
|
static uint32_t previousMillis = 0;
|
|
|
|
|
2023-02-23 23:14:58 +01:00
|
|
|
webSocket.cleanupClients();
|
2023-12-04 02:18:16 +01:00
|
|
|
|
|
|
|
if ((webSocket.count() > 0) && (millis() - previousMillis >= 10000))
|
|
|
|
{
|
2023-12-25 02:05:22 +01:00
|
|
|
Websocket_RefreshClientData_DTCs(0);
|
|
|
|
Websocket_RefreshClientData_Status(0);
|
2023-12-04 02:18:16 +01:00
|
|
|
previousMillis = millis();
|
|
|
|
}
|
2023-02-23 23:14:58 +01:00
|
|
|
}
|
|
|
|
|
2022-02-15 20:58:32 +01:00
|
|
|
void WebserverPOST_Callback(AsyncWebServerRequest *request)
|
2022-02-10 22:33:52 +01:00
|
|
|
{
|
2022-03-08 22:31:37 +01:00
|
|
|
request->send(LittleFS, "/post.htm", "text/html", false, processor);
|
|
|
|
|
2023-02-24 19:25:59 +01:00
|
|
|
Debug_pushMessage("POST:\n");
|
2022-02-27 22:23:58 +01:00
|
|
|
int paramsNr = request->params();
|
|
|
|
for (int i = 0; i < paramsNr; i++)
|
2022-01-19 22:23:36 +01:00
|
|
|
{
|
2022-02-27 22:23:58 +01:00
|
|
|
AsyncWebParameter *p = request->getParam(i);
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("%s : %s\n", p->name().c_str(), p->value().c_str());
|
2022-02-27 22:23:58 +01:00
|
|
|
|
2022-03-08 21:23:52 +01:00
|
|
|
// begin: POST Form Source Changed
|
|
|
|
if (p->name() == "sourceselect")
|
|
|
|
{
|
|
|
|
SpeedSource_t temp = (SpeedSource_t)p->value().toInt();
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("temp: %d", temp);
|
|
|
|
Debug_pushMessage("SpeedSource: %d", LubeConfig.SpeedSource);
|
2022-03-08 21:23:52 +01:00
|
|
|
if (LubeConfig.SpeedSource != temp)
|
|
|
|
{
|
|
|
|
LubeConfig.SpeedSource = temp;
|
|
|
|
globals.systemStatus = sysStat_Shutdown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// end: POST Form Source Changed
|
|
|
|
// begin: POST Form Source Pulse Settings
|
|
|
|
if (p->name() == "tirewidth")
|
|
|
|
LubeConfig.TireWidth_mm = p->value().toInt();
|
|
|
|
if (p->name() == "tireratio")
|
|
|
|
LubeConfig.TireWidthHeight_Ratio = p->value().toInt();
|
|
|
|
if (p->name() == "tiredia")
|
|
|
|
LubeConfig.RimDiameter_Inch = p->value().toInt();
|
|
|
|
if (p->name() == "pulserev")
|
|
|
|
LubeConfig.PulsePerRevolution = p->value().toInt();
|
|
|
|
if (p->name() == "pulsesave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
2023-12-25 02:05:22 +01:00
|
|
|
// end: POST Form Source Pulse Settings
|
2022-03-08 21:23:52 +01:00
|
|
|
// begin: POST Form Source GPS Settings
|
|
|
|
if (p->name() == "gpsbaud")
|
|
|
|
LubeConfig.GPSBaudRate = (GPSBaudRate_t)p->value().toInt();
|
|
|
|
if (p->name() == "gpssave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
2023-12-25 02:05:22 +01:00
|
|
|
// end: POST Form Source GPS Settings
|
2022-03-08 21:23:52 +01:00
|
|
|
// begin: POST Form Source CAN Settings
|
|
|
|
if (p->name() == "cansource")
|
|
|
|
LubeConfig.CANSource = (CANSource_t)p->value().toInt();
|
|
|
|
if (p->name() == "cansave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
2023-12-25 02:05:22 +01:00
|
|
|
// end: POST Form Source CAN Settings
|
2022-03-09 20:25:02 +01:00
|
|
|
// begin: POST Form Lubrication
|
2022-03-08 22:31:37 +01:00
|
|
|
if (p->name() == "lubedistancenormal")
|
|
|
|
LubeConfig.DistancePerLube_Default = p->value().toInt();
|
|
|
|
if (p->name() == "lubedistancerain")
|
|
|
|
LubeConfig.DistancePerLube_Rain = p->value().toInt();
|
|
|
|
if (p->name() == "lubesave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
|
|
|
// end: POST Form Lubrication
|
|
|
|
// begin: POST Form Oiltank
|
|
|
|
if (p->name() == "tankcap")
|
|
|
|
LubeConfig.tankCapacity_ml = p->value().toInt();
|
|
|
|
if (p->name() == "tankwarn")
|
|
|
|
LubeConfig.TankRemindAtPercentage = p->value().toInt();
|
|
|
|
if (p->name() == "pumppulse")
|
2023-02-19 14:29:38 +01:00
|
|
|
LubeConfig.amountPerDose_microL = p->value().toInt();
|
2022-03-08 22:31:37 +01:00
|
|
|
if (p->name() == "oilsave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
|
|
|
// end: POST Form Oiltank
|
|
|
|
// begin: POST Form Maintenance
|
|
|
|
if (p->name() == "purgepulse")
|
|
|
|
LubeConfig.BleedingPulses = p->value().toInt();
|
|
|
|
if (p->name() == "maintsave")
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
|
|
|
if (p->name() == "resettank")
|
|
|
|
{
|
2023-02-19 14:29:38 +01:00
|
|
|
PersistenceData.tankRemain_microL = LubeConfig.tankCapacity_ml * 1000;
|
2022-03-08 22:31:37 +01:00
|
|
|
globals.requestEEAction = EE_PDS_SAVE;
|
|
|
|
}
|
2022-08-22 14:49:14 +02:00
|
|
|
if (p->name() == "reset_ee_btn")
|
2022-08-22 14:28:32 +02:00
|
|
|
{
|
2022-08-24 20:59:00 +02:00
|
|
|
if (request->hasParam("reset_ee_pds", true))
|
2022-08-22 14:49:14 +02:00
|
|
|
{
|
2022-08-24 20:59:00 +02:00
|
|
|
AsyncWebParameter *param = request->getParam("reset_ee_pds", true);
|
2022-08-22 21:25:14 +02:00
|
|
|
if (param->value() == "on")
|
2022-08-22 14:49:14 +02:00
|
|
|
globals.requestEEAction = globals.requestEEAction == EE_CFG_FORMAT ? EE_FORMAT_ALL : EE_PDS_FORMAT;
|
|
|
|
}
|
2022-08-24 20:59:00 +02:00
|
|
|
if (request->hasParam("reset_ee_cfg", true))
|
2022-08-22 14:49:14 +02:00
|
|
|
{
|
2022-08-24 20:59:00 +02:00
|
|
|
AsyncWebParameter *param = request->getParam("reset_ee_cfg", true);
|
2022-08-22 21:25:14 +02:00
|
|
|
if (param->value() == "on")
|
2022-08-22 14:49:14 +02:00
|
|
|
globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT;
|
|
|
|
}
|
2022-08-22 14:28:32 +02:00
|
|
|
}
|
2022-08-24 23:09:26 +02:00
|
|
|
if (p->name() == "purgenow")
|
|
|
|
{
|
|
|
|
globals.systemStatus = sysStat_Purge;
|
|
|
|
globals.purgePulses = LubeConfig.BleedingPulses;
|
|
|
|
}
|
2023-02-23 23:14:58 +01:00
|
|
|
if (p->name() == "reboot")
|
2022-09-01 23:46:20 +02:00
|
|
|
{
|
|
|
|
globals.systemStatus = sysStat_Shutdown;
|
|
|
|
}
|
2022-03-08 22:31:37 +01:00
|
|
|
// end: POST Form Maintenance
|
2023-03-02 22:30:42 +01:00
|
|
|
// begin: POST Form LED Settings
|
|
|
|
if (p->name() == "ledmaxbrightness")
|
|
|
|
LubeConfig.LED_Max_Brightness = p->value().toInt();
|
|
|
|
if (p->name() == "ledminbrightness")
|
|
|
|
LubeConfig.LED_Min_Brightness = p->value().toInt();
|
|
|
|
if (p->name() == "ledsave")
|
|
|
|
{
|
|
|
|
if (request->hasParam("ledmodeflash", true))
|
|
|
|
{
|
|
|
|
AsyncWebParameter *param = request->getParam("ledmodeflash", true);
|
|
|
|
if (param->value() == "on")
|
|
|
|
LubeConfig.LED_Mode_Flash = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LubeConfig.LED_Mode_Flash = false;
|
|
|
|
}
|
|
|
|
globals.requestEEAction = EE_CFG_SAVE;
|
|
|
|
}
|
|
|
|
// end: POST Form LED SEttings
|
2023-03-03 10:51:16 +01:00
|
|
|
// begin: POST Form Measure Pulses
|
|
|
|
if (p->name() == "measurereset")
|
|
|
|
globals.measuredPulses = 0;
|
|
|
|
if (p->name() == "measurestartstop")
|
|
|
|
globals.measurementActive = !globals.measurementActive;
|
|
|
|
// end: POST Form Measure Pulses
|
2022-03-08 21:23:52 +01:00
|
|
|
}
|
2022-01-08 03:14:26 +01:00
|
|
|
}
|
2022-01-12 01:10:21 +01:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Callback function for handling HTTP 404 (Not Found) errors on the web server.
|
|
|
|
*
|
|
|
|
* This function is invoked when an HTTP request results in a 404 error (Not Found). It sends
|
|
|
|
* a simple "Not found" text response with an HTTP status code of 404.
|
|
|
|
*
|
|
|
|
* @param request Pointer to the AsyncWebServerRequest object representing the HTTP request.
|
|
|
|
*/
|
2022-02-10 22:33:52 +01:00
|
|
|
void WebserverNotFound_Callback(AsyncWebServerRequest *request)
|
2022-01-12 01:10:21 +01:00
|
|
|
{
|
2022-03-08 22:31:37 +01:00
|
|
|
request->send(404, "text/html", "Not found");
|
2022-08-14 17:38:45 +02:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Reads the flash version information from a file in LittleFS.
|
|
|
|
*
|
|
|
|
* This function reads the flash version information stored in a file named "version" in the
|
|
|
|
* LittleFS filesystem. It opens the file, reads the content until a carriage return ('\r') is
|
|
|
|
* encountered, and stores the result in the provided buffer. The buffer is null-terminated.
|
|
|
|
*
|
|
|
|
* @param buff Pointer to the buffer where the flash version information will be stored.
|
|
|
|
* @param buff_size Size of the buffer.
|
|
|
|
*/
|
2022-08-22 14:26:37 +02:00
|
|
|
void GetFlashVersion(char *buff, size_t buff_size)
|
2022-08-14 17:38:45 +02:00
|
|
|
{
|
2022-08-22 14:26:37 +02:00
|
|
|
File this_file = LittleFS.open("version", "r");
|
|
|
|
if (!this_file)
|
|
|
|
{ // failed to open the file, retrn empty result
|
|
|
|
buff[0] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this_file.available())
|
|
|
|
{
|
|
|
|
int bytes_read;
|
2022-08-22 14:53:56 +02:00
|
|
|
bytes_read = this_file.readBytesUntil('\r', buff, buff_size - 1);
|
2022-08-22 14:26:37 +02:00
|
|
|
buff[bytes_read] = '\0';
|
|
|
|
}
|
|
|
|
this_file.close();
|
2022-08-14 17:38:45 +02:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Callback function for handling firmware updates via the web server.
|
|
|
|
*
|
|
|
|
* This function is invoked during the firmware update process when a new firmware file
|
|
|
|
* is received. It handles the update process using the ESPAsyncHTTPUpdate library. The update
|
|
|
|
* process involves checking the firmware type, initializing the update, writing data, and finalizing
|
|
|
|
* the update. If the update is successful, it triggers a system shutdown.
|
|
|
|
*
|
|
|
|
* @param request Pointer to the AsyncWebServerRequest object.
|
|
|
|
* @param filename The name of the file being updated.
|
|
|
|
* @param index The index of the file being updated.
|
|
|
|
* @param data Pointer to the data buffer.
|
|
|
|
* @param len The length of the data buffer.
|
|
|
|
* @param final Boolean indicating if this is the final chunk of data.
|
|
|
|
*/
|
2022-08-14 17:38:45 +02:00
|
|
|
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!index)
|
|
|
|
{
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("Update");
|
2022-08-14 17:38:45 +02:00
|
|
|
size_t content_len = request->contentLength();
|
|
|
|
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
|
|
|
|
{
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("Progress: %d%%\n", (Update.progress() * 100) / Update.size());
|
2022-08-14 17:38:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("Update complete\n");
|
2022-08-19 08:16:33 +02:00
|
|
|
globals.systemStatus = sysStat_Shutdown;
|
2022-08-14 17:38:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-01 23:46:20 +02:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Callback function for handling EEPROM restore via the web server.
|
|
|
|
*
|
|
|
|
* This function is invoked during the EEPROM restore process when a new EEPROM file
|
|
|
|
* is received. It handles the restore process by reading the data from the received file,
|
|
|
|
* deserializing the JSON data, and updating the configuration and persistence data accordingly.
|
|
|
|
* If the restore is successful, it triggers a system shutdown.
|
|
|
|
*
|
|
|
|
* @param request Pointer to the AsyncWebServerRequest object.
|
|
|
|
* @param filename The name of the file being restored.
|
|
|
|
* @param index The index of the file being restored.
|
|
|
|
* @param data Pointer to the data buffer.
|
|
|
|
* @param len The length of the data buffer.
|
|
|
|
* @param final Boolean indicating if this is the final chunk of data.
|
|
|
|
*/
|
2022-09-01 23:46:20 +02:00
|
|
|
void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)
|
|
|
|
{
|
|
|
|
bool ee_done = false;
|
2023-03-03 22:01:32 +01:00
|
|
|
static bool validext = false;
|
|
|
|
static char *buffer = NULL;
|
|
|
|
static uint32_t read_ptr = 0;
|
|
|
|
DeserializationError error;
|
2022-09-01 23:46:20 +02:00
|
|
|
|
|
|
|
if (!index)
|
|
|
|
{
|
|
|
|
validext = (filename.indexOf(".ee.json") > -1);
|
2023-03-03 22:01:32 +01:00
|
|
|
if (validext)
|
|
|
|
{
|
|
|
|
buffer = (char *)malloc(1536);
|
|
|
|
read_ptr = 0;
|
|
|
|
if (buffer == NULL)
|
|
|
|
Debug_pushMessage("malloc() failed for EEPROM-Restore");
|
|
|
|
}
|
2022-09-01 23:46:20 +02:00
|
|
|
}
|
|
|
|
|
2023-03-03 22:01:32 +01:00
|
|
|
if (buffer != NULL)
|
2022-09-01 23:46:20 +02:00
|
|
|
{
|
2023-03-03 22:01:32 +01:00
|
|
|
memcpy(buffer + read_ptr, data, len);
|
|
|
|
read_ptr = read_ptr + len;
|
2022-09-01 23:46:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (final)
|
|
|
|
{
|
2023-03-03 22:01:32 +01:00
|
|
|
if (buffer != NULL)
|
|
|
|
{
|
|
|
|
Serial.print(buffer);
|
|
|
|
StaticJsonDocument<1536> doc;
|
|
|
|
error = deserializeJson(doc, buffer);
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
Debug_pushMessage("deserializeJson() failed: %s\n", error.f_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
LubeConfig.DistancePerLube_Default = doc["config"]["DistancePerLube_Default"].as<uint32_t>();
|
|
|
|
LubeConfig.DistancePerLube_Rain = doc["config"]["DistancePerLube_Rain"].as<uint32_t>();
|
|
|
|
LubeConfig.tankCapacity_ml = doc["config"]["tankCapacity_ml"].as<uint32_t>();
|
|
|
|
LubeConfig.amountPerDose_microL = doc["config"]["amountPerDose_microL"].as<uint32_t>();
|
|
|
|
LubeConfig.TankRemindAtPercentage = doc["config"]["TankRemindAtPercentage"].as<uint8_t>();
|
|
|
|
LubeConfig.PulsePerRevolution = doc["config"]["PulsePerRevolution"].as<uint8_t>();
|
|
|
|
LubeConfig.TireWidth_mm = doc["config"]["TireWidth_mm"].as<uint32_t>();
|
|
|
|
LubeConfig.TireWidthHeight_Ratio = doc["config"]["TireWidthHeight_Ratio"].as<uint32_t>();
|
|
|
|
LubeConfig.RimDiameter_Inch = doc["config"]["RimDiameter_Inch"].as<uint32_t>();
|
|
|
|
LubeConfig.DistancePerRevolution_mm = doc["config"]["DistancePerRevolution_mm"].as<uint32_t>();
|
|
|
|
LubeConfig.BleedingPulses = doc["config"]["BleedingPulses"].as<uint16_t>();
|
|
|
|
LubeConfig.SpeedSource = (SpeedSource_t)doc["config"]["SpeedSource"].as<int>();
|
|
|
|
LubeConfig.GPSBaudRate = (GPSBaudRate_t)doc["config"]["GPSBaudRate"].as<int>();
|
|
|
|
LubeConfig.CANSource = (CANSource_t)doc["config"]["CANSource"].as<int>();
|
|
|
|
LubeConfig.LED_Mode_Flash = doc["config"]["LED_Mode_Flash"].as<bool>();
|
|
|
|
LubeConfig.LED_Max_Brightness = doc["config"]["LED_Max_Brightness"].as<uint8_t>();
|
|
|
|
LubeConfig.LED_Min_Brightness = doc["config"]["LED_Min_Brightness"].as<uint8_t>();
|
|
|
|
|
|
|
|
PersistenceData.writeCycleCounter = doc["persis"]["writeCycleCounter"].as<uint16_t>();
|
|
|
|
PersistenceData.tankRemain_microL = doc["persis"]["tankRemain_microL"].as<uint32_t>();
|
|
|
|
PersistenceData.TravelDistance_highRes_mm = doc["persis"]["TravelDistance_highRes_mm"].as<uint32_t>();
|
|
|
|
PersistenceData.odometer_mm = doc["persis"]["odometer_mm"].as<uint32_t>();
|
|
|
|
PersistenceData.odometer = doc["persis"]["odometer"].as<uint32_t>();
|
|
|
|
PersistenceData.checksum = doc["persis"]["checksum"].as<uint32_t>();
|
|
|
|
|
|
|
|
ee_done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(buffer);
|
|
|
|
|
2022-09-01 23:46:20 +02:00
|
|
|
AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", "Please wait while the device reboots");
|
|
|
|
response->addHeader("Refresh", "20");
|
|
|
|
response->addHeader("Location", "/");
|
|
|
|
request->send(response);
|
2023-03-03 22:01:32 +01:00
|
|
|
|
2022-09-01 23:46:20 +02:00
|
|
|
if (ee_done)
|
|
|
|
{
|
2023-02-23 23:14:58 +01:00
|
|
|
Debug_pushMessage("Update complete");
|
2022-09-01 23:46:20 +02:00
|
|
|
globals.systemStatus = sysStat_Shutdown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Callback function for handling EEPROM JSON request via the web server.
|
|
|
|
*
|
|
|
|
* This function is invoked when a request for EEPROM JSON data is received. It constructs a JSON
|
|
|
|
* response containing information about the firmware, configuration, and persistence data.
|
|
|
|
*
|
|
|
|
* @param request Pointer to the AsyncWebServerRequest object.
|
|
|
|
*/
|
2022-09-01 23:46:20 +02:00
|
|
|
void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
|
|
|
|
{
|
|
|
|
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
|
|
|
DynamicJsonDocument json(1024);
|
|
|
|
JsonObject fwinfo = json.createNestedObject("info");
|
|
|
|
|
|
|
|
char buffer[16];
|
|
|
|
|
|
|
|
fwinfo["DeviceName"] = globals.DeviceName;
|
2023-03-03 22:01:32 +01:00
|
|
|
sprintf(buffer, "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor);
|
2023-03-02 23:35:41 +01:00
|
|
|
fwinfo["FW-Version"] = buffer;
|
2022-09-01 23:46:20 +02:00
|
|
|
fwinfo["FS-Version"] = globals.FlashVersion;
|
2023-03-03 22:01:32 +01:00
|
|
|
snprintf_P(buffer, sizeof(buffer), "%s", constants.GitHash);
|
|
|
|
fwinfo["Git-Hash"] = buffer;
|
2022-09-01 23:46:20 +02:00
|
|
|
|
|
|
|
JsonObject config = json.createNestedObject("config");
|
|
|
|
|
|
|
|
config["EEPROM_Version"] = LubeConfig.EEPROM_Version;
|
|
|
|
config["DistancePerLube_Default"] = LubeConfig.DistancePerLube_Default;
|
|
|
|
config["DistancePerLube_Rain"] = LubeConfig.DistancePerLube_Rain;
|
|
|
|
config["tankCapacity_ml"] = LubeConfig.tankCapacity_ml;
|
2023-02-19 14:29:38 +01:00
|
|
|
config["amountPerDose_microL"] = LubeConfig.amountPerDose_microL;
|
2022-09-01 23:46:20 +02:00
|
|
|
config["TankRemindAtPercentage"] = LubeConfig.TankRemindAtPercentage;
|
|
|
|
config["PulsePerRevolution"] = LubeConfig.PulsePerRevolution;
|
|
|
|
config["TireWidth_mm"] = LubeConfig.TireWidth_mm;
|
|
|
|
config["TireWidthHeight_Ratio"] = LubeConfig.TireWidthHeight_Ratio;
|
|
|
|
config["RimDiameter_Inch"] = LubeConfig.RimDiameter_Inch;
|
|
|
|
config["DistancePerRevolution_mm"] = LubeConfig.DistancePerRevolution_mm;
|
|
|
|
config["BleedingPulses"] = LubeConfig.BleedingPulses;
|
|
|
|
config["SpeedSource"] = LubeConfig.SpeedSource;
|
|
|
|
config["SpeedSource_Str"] = SpeedSourceString[LubeConfig.SpeedSource];
|
|
|
|
config["GPSBaudRate"] = LubeConfig.GPSBaudRate;
|
|
|
|
config["GPSBaudRate_Str"] = GPSBaudRateString[LubeConfig.GPSBaudRate];
|
|
|
|
config["CANSource"] = LubeConfig.CANSource;
|
|
|
|
config["CANSource_Str"] = CANSourceString[LubeConfig.CANSource];
|
2023-03-02 22:30:42 +01:00
|
|
|
config["LED_Mode_Flash"] = LubeConfig.LED_Mode_Flash;
|
|
|
|
config["LED_Max_Brightness"] = LubeConfig.LED_Max_Brightness;
|
|
|
|
config["LED_Min_Brightness"] = LubeConfig.LED_Min_Brightness;
|
2022-09-01 23:46:20 +02:00
|
|
|
sprintf(buffer, "0x%08X", LubeConfig.checksum);
|
|
|
|
config["checksum"] = buffer;
|
|
|
|
|
|
|
|
JsonObject eepart = json.createNestedObject("eepart");
|
|
|
|
|
|
|
|
sprintf(buffer, "0x%04X", globals.eePersistanceAdress);
|
|
|
|
eepart["PersistanceAddress"] = buffer;
|
|
|
|
|
|
|
|
JsonObject persis = json.createNestedObject("persis");
|
|
|
|
|
|
|
|
persis["writeCycleCounter"] = PersistenceData.writeCycleCounter;
|
2023-02-19 14:29:38 +01:00
|
|
|
persis["tankRemain_microL"] = PersistenceData.tankRemain_microL;
|
2022-09-01 23:46:20 +02:00
|
|
|
persis["TravelDistance_highRes_mm"] = PersistenceData.TravelDistance_highRes_mm;
|
|
|
|
persis["odometer_mm"] = PersistenceData.odometer_mm;
|
|
|
|
persis["odometer"] = PersistenceData.odometer;
|
|
|
|
sprintf(buffer, "0x%08X", PersistenceData.checksum);
|
|
|
|
persis["checksum"] = buffer;
|
|
|
|
|
|
|
|
serializeJsonPretty(json, *response);
|
|
|
|
|
|
|
|
response->addHeader("Content-disposition", "attachment; filename=backup.ee.json");
|
|
|
|
|
|
|
|
request->send(response);
|
2023-02-23 23:14:58 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Callback function for handling WebSocket events.
|
|
|
|
*
|
|
|
|
* This function is invoked when events occur in the WebSocket communication, such as client connection,
|
|
|
|
* disconnection, reception of data, and others. It dispatches the events to the appropriate handlers.
|
|
|
|
*
|
|
|
|
* @param server Pointer to the AsyncWebSocket object.
|
|
|
|
* @param client Pointer to the AsyncWebSocketClient object representing the WebSocket client.
|
|
|
|
* @param type Type of WebSocket event.
|
|
|
|
* @param arg Event-specific argument.
|
|
|
|
* @param data Pointer to the received data (if applicable).
|
|
|
|
* @param len Length of the received data.
|
|
|
|
*/
|
2023-02-23 23:14:58 +01:00
|
|
|
void WebsocketEvent_Callback(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case WS_EVT_CONNECT:
|
|
|
|
Debug_pushMessage("WebSocket client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str());
|
2023-12-25 02:05:22 +01:00
|
|
|
Websocket_RefreshClientData_Status(client->id(), true);
|
|
|
|
Websocket_RefreshClientData_Static(client->id(), true);
|
|
|
|
Websocket_RefreshClientData_DTCs(client->id());
|
2023-02-23 23:14:58 +01:00
|
|
|
break;
|
|
|
|
case WS_EVT_DISCONNECT:
|
|
|
|
Debug_pushMessage("WebSocket client #%u disconnected\n", client->id());
|
|
|
|
break;
|
|
|
|
case WS_EVT_DATA:
|
|
|
|
Websocket_HandleMessage(arg, data, len);
|
|
|
|
break;
|
|
|
|
case WS_EVT_PONG:
|
|
|
|
case WS_EVT_ERROR:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Handles WebSocket messages received from clients.
|
|
|
|
*
|
|
|
|
* This function processes WebSocket messages, such as starting or stopping debugging,
|
|
|
|
* and provides appropriate responses.
|
|
|
|
*
|
|
|
|
* @param arg Pointer to the WebSocket frame information.
|
|
|
|
* @param data Pointer to the received data.
|
|
|
|
* @param len Length of the received data.
|
|
|
|
*/
|
2023-02-23 23:14:58 +01:00
|
|
|
void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len)
|
|
|
|
{
|
|
|
|
AwsFrameInfo *info = (AwsFrameInfo *)arg;
|
|
|
|
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT)
|
|
|
|
{
|
|
|
|
data[len] = 0;
|
|
|
|
|
|
|
|
Debug_pushMessage("Got WebSocket Message: %s \n", (char *)data);
|
|
|
|
|
|
|
|
if (strcmp((char *)data, "start") == 0)
|
|
|
|
{
|
2023-02-24 00:05:51 +01:00
|
|
|
SetDebugportStatus(dbg_Webui, enabled);
|
2023-02-23 23:14:58 +01:00
|
|
|
}
|
|
|
|
else if (strcmp((char *)data, "stop") == 0)
|
|
|
|
{
|
2023-02-24 00:05:51 +01:00
|
|
|
SetDebugportStatus(dbg_Webui, disabled);
|
2023-02-23 23:14:58 +01:00
|
|
|
}
|
|
|
|
else if (strcmp((char *)data, "foo") == 0)
|
|
|
|
{
|
|
|
|
Debug_pushMessage("Got WebSocket Message 'foo' from client\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Pushes live debug messages to all WebSocket clients.
|
|
|
|
*
|
|
|
|
* This function sends a live debug message to all connected WebSocket clients.
|
|
|
|
*
|
|
|
|
* @param Message The debug message to be sent.
|
|
|
|
*/
|
2023-02-23 23:14:58 +01:00
|
|
|
void Websocket_PushLiveDebug(String Message)
|
|
|
|
{
|
2023-12-04 02:18:16 +01:00
|
|
|
webSocket.textAll("DEBUG:" + Message);
|
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Refreshes client data related to Diagnostic Trouble Codes (DTCs) on WebSocket clients.
|
|
|
|
*
|
|
|
|
* This function constructs a DTC-related string and sends it to a specific WebSocket client or
|
|
|
|
* broadcasts it to all connected WebSocket clients.
|
|
|
|
*
|
|
|
|
* @param client_id The ID of the WebSocket client to which the data should be sent. If 0, the data
|
|
|
|
* will be broadcasted to all connected clients.
|
|
|
|
*/
|
2023-12-25 02:05:22 +01:00
|
|
|
void Websocket_RefreshClientData_DTCs(uint32_t client_id)
|
2023-12-04 02:18:16 +01:00
|
|
|
{
|
2023-12-25 02:05:22 +01:00
|
|
|
String temp = "DTC:";
|
2023-12-04 02:18:16 +01:00
|
|
|
|
|
|
|
// Build DTC-String
|
|
|
|
if (globals.hasDTC != true)
|
|
|
|
{
|
2023-12-25 02:05:22 +01:00
|
|
|
temp.concat(String(DTC_NO_DTC) + ";");
|
2023-12-04 02:18:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
|
|
|
{
|
|
|
|
if (DTCStorage[i].Number < DTC_LAST_DTC)
|
|
|
|
{
|
2023-12-25 02:05:22 +01:00
|
|
|
temp.concat(String(DTCStorage[i].timestamp) + ",");
|
|
|
|
temp.concat(String(DTCStorage[i].Number) + ",");
|
|
|
|
temp.concat(String(getSeverityForDTC(DTCStorage[i].Number)) + ",");
|
|
|
|
temp.concat(String(DTCStorage[i].active) + ",");
|
|
|
|
temp.concat(String(DTCStorage[i].debugVal) + ";");
|
2023-12-04 02:18:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-25 02:05:22 +01:00
|
|
|
if (client_id > 0)
|
|
|
|
{
|
|
|
|
webSocket.text(client_id, temp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
webSocket.textAll(temp);
|
|
|
|
}
|
2023-02-23 23:14:58 +01:00
|
|
|
}
|
2023-12-25 02:05:22 +01:00
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Refreshes client data related to system status and relevant parameters on WebSocket clients.
|
|
|
|
*
|
|
|
|
* This function constructs a status-related string and sends it to a specific WebSocket client or
|
|
|
|
* broadcasts it to all connected WebSocket clients. It also sends a mapping of the status parameters.
|
|
|
|
*
|
|
|
|
* @param client_id The ID of the WebSocket client to which the data should be sent. If 0, the data
|
|
|
|
* will be broadcasted to all connected clients.
|
|
|
|
* @param send_mapping Flag indicating whether to send the parameter mapping to the client(s).
|
|
|
|
*/
|
2023-12-25 02:05:22 +01:00
|
|
|
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (send_mapping)
|
|
|
|
{
|
|
|
|
const char mapping[] = "MAPPING_STATUS:"
|
|
|
|
"SystemStatus;"
|
2024-01-09 12:17:13 +01:00
|
|
|
"tankremain;"
|
|
|
|
"Odometer;";
|
2023-12-25 02:05:22 +01:00
|
|
|
|
|
|
|
if (client_id > 0)
|
|
|
|
webSocket.text(client_id, mapping);
|
|
|
|
else
|
|
|
|
webSocket.textAll(mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
String temp = "STATUS:";
|
|
|
|
|
|
|
|
temp.concat(String(globals.systemStatustxt) + ";");
|
|
|
|
temp.concat(String((PersistenceData.tankRemain_microL / 10) / LubeConfig.tankCapacity_ml) + ";");
|
2024-01-09 12:17:13 +01:00
|
|
|
temp.concat(String(PersistenceData.odometer + (PersistenceData.odometer_mm / 1000)) + ";");
|
2023-12-25 02:05:22 +01:00
|
|
|
|
|
|
|
if (client_id > 0)
|
|
|
|
{
|
|
|
|
webSocket.text(client_id, temp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
webSocket.textAll(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 12:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Refreshes client data related to static configuration parameters on WebSocket clients.
|
|
|
|
*
|
|
|
|
* This function constructs a static configuration-related string and sends it to a specific WebSocket client or
|
|
|
|
* broadcasts it to all connected WebSocket clients. It also sends a mapping of the static configuration parameters.
|
|
|
|
*
|
|
|
|
* @param client_id The ID of the WebSocket client to which the data should be sent. If 0, the data
|
|
|
|
* will be broadcasted to all connected clients.
|
|
|
|
* @param send_mapping Flag indicating whether to send the parameter mapping to the client(s).
|
|
|
|
*/
|
2023-12-25 02:05:22 +01:00
|
|
|
void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (send_mapping)
|
|
|
|
{
|
|
|
|
const char mapping[] = "MAPPING_STATIC:"
|
2024-01-09 12:17:13 +01:00
|
|
|
"lubedistancenormal;"
|
|
|
|
"lubedistancerain;"
|
|
|
|
"tankcap;"
|
|
|
|
"pumppulse;"
|
|
|
|
"tankwarn;"
|
|
|
|
"pulserev;"
|
|
|
|
"tirewidth;"
|
|
|
|
"tireratio;"
|
|
|
|
"tiredia;"
|
2023-12-25 02:05:22 +01:00
|
|
|
"DistancePerRevolution_mm;"
|
2024-01-09 12:17:13 +01:00
|
|
|
"sourceselect;"
|
|
|
|
"gpsbaud;"
|
|
|
|
"cansource;"
|
|
|
|
"ledmodeflash;"
|
|
|
|
"ledmaxbrightness;"
|
|
|
|
"ledminbrightness;"
|
|
|
|
"showimpulse;"
|
|
|
|
"showgps;"
|
|
|
|
"showcan;"
|
|
|
|
"BleedingPulses;";
|
2023-12-25 02:05:22 +01:00
|
|
|
|
|
|
|
if (client_id > 0)
|
|
|
|
webSocket.text(client_id, mapping);
|
|
|
|
else
|
|
|
|
webSocket.textAll(mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
String temp = "STATIC:";
|
|
|
|
|
|
|
|
temp.concat(String(LubeConfig.DistancePerLube_Default) + ";");
|
|
|
|
temp.concat(String(LubeConfig.DistancePerLube_Rain) + ";");
|
|
|
|
temp.concat(String(LubeConfig.tankCapacity_ml) + ";");
|
|
|
|
temp.concat(String(LubeConfig.amountPerDose_microL) + ";");
|
|
|
|
temp.concat(String(LubeConfig.TankRemindAtPercentage) + ";");
|
|
|
|
temp.concat(String(LubeConfig.PulsePerRevolution) + ";");
|
|
|
|
temp.concat(String(LubeConfig.TireWidth_mm) + ";");
|
|
|
|
temp.concat(String(LubeConfig.TireWidthHeight_Ratio) + ";");
|
|
|
|
temp.concat(String(LubeConfig.RimDiameter_Inch) + ";");
|
|
|
|
temp.concat(String(LubeConfig.DistancePerRevolution_mm) + ";");
|
|
|
|
temp.concat(String(SpeedSourceString[LubeConfig.SpeedSource]) + ";");
|
|
|
|
temp.concat(String(GPSBaudRateString[LubeConfig.GPSBaudRate]) + ";");
|
|
|
|
temp.concat(String(CANSourceString[LubeConfig.CANSource]) + ";");
|
2024-01-09 12:17:13 +01:00
|
|
|
temp.concat(String(LubeConfig.LED_Mode_Flash == true ? "1" : "0") + ";");
|
2023-12-25 02:05:22 +01:00
|
|
|
temp.concat(String(LubeConfig.LED_Max_Brightness) + ";");
|
|
|
|
temp.concat(String(LubeConfig.LED_Min_Brightness) + ";");
|
2024-01-09 12:17:13 +01:00
|
|
|
temp.concat(String(LubeConfig.SpeedSource == SOURCE_IMPULSE ? "1" : "0") + ";");
|
|
|
|
temp.concat(String(LubeConfig.SpeedSource == SOURCE_GPS ? "1" : "0") + ";");
|
|
|
|
temp.concat(String(LubeConfig.SpeedSource == SOURCE_CAN ? "1" : "0") + ";");
|
|
|
|
temp.concat(String(LubeConfig.BleedingPulses) + ";");
|
2023-12-25 02:05:22 +01:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < SpeedSourceString_Elements; i++)
|
|
|
|
{
|
|
|
|
temp.concat(String(SpeedSourceString[i]) + ",");
|
|
|
|
}
|
|
|
|
temp.concat(";");
|
|
|
|
|
|
|
|
if (client_id > 0)
|
|
|
|
{
|
|
|
|
webSocket.text(client_id, temp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
webSocket.textAll(temp);
|
|
|
|
}
|
|
|
|
}
|