diff --git a/include/webguiapp.h b/include/webguiapp.h index 05f2715..5a0cf57 100644 --- a/include/webguiapp.h +++ b/include/webguiapp.h @@ -40,5 +40,6 @@ esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, s bool GetUserAppNeedReset(void); void SetUserAppNeedReset(bool res); +void LogFile(char *fname, char *mess); #endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */ diff --git a/src/WebGUIAppMain.c b/src/WebGUIAppMain.c index c874fe5..d84864c 100644 --- a/src/WebGUIAppMain.c +++ b/src/WebGUIAppMain.c @@ -65,7 +65,6 @@ StaticSemaphore_t xSemaphoreSPIBuf; #define NETWORK_START_TIMEOUT (5) -static int NetworkStartTimeout = 0; static bool isUserAppNeedReset = false; static void InitSysIO(void); @@ -511,3 +510,22 @@ void SetUserAppNeedReset(bool res) isUserAppNeedReset = res; } +void LogFile(char *fname, char *mess) +{ + char filename[32]; + strcpy(filename, "/data/"); + strcat(filename, fname); + FILE *f = fopen(filename, "a"); + if (f == NULL) + { + ESP_LOGE(TAG, "Failed to open file %s for writing", filename); + return; + } + fwrite(esp_log_system_timestamp(), 1, 12, f); + fwrite(" ", 1, 1, f); + fwrite(mess, 1, strlen(mess), f); + fwrite("\r\n", 1, 2, f); + fclose(f); + ESP_LOGI(TAG, "File written to %s", filename); +} +