Compare commits

..

No commits in common. "147c2b9cdd57c4b7f97c0f3d58e94261e93d1a44" and "7058e865386961a1da7a1049810e584680d39033" have entirely different histories.

10 changed files with 20 additions and 157 deletions

14
Kconfig
View File

@ -916,6 +916,8 @@ menu "WebGUIApp"
endif
endmenu
menu "MQTT settings"
config WEBGUIAPP_MQTT_ENABLE
bool "Enabled MQTT transport"
@ -979,18 +981,6 @@ menu "WebGUIApp"
endif
endmenu
menu "System log"
config WEBGUIAPP_SYSLOG_MAX_CHUNKS
int "Number of syslog parts"
range 1 10
default 4
config WEBGUIAPP_SYSLOG_CHUNK_SIZE
int "Size of one part in kilobytes"
range 1 256
default 50
endmenu
if WEBGUIAPP_WIFI_ENABLE || WEBGUIAPP_ETHERNET_ENABLE || WEBGUIAPP_GPRS_ENABLE
menu "DNS settings"

View File

@ -84,11 +84,9 @@ typedef struct
void (*HandlerRoutine)(char *VarData, void *arg);
} dyn_var_handler_t;
#define BLOCK_OPERATION_TIMEOUT 30
#define MEM_OBLECT_MAX_LENGTH 32
typedef struct
{
int transid;
int opertype;
int operphase;
int part;
@ -99,7 +97,7 @@ typedef struct
struct stat file_stat;
FILE *f;
int open_file_timeout;
} cb_blockdata_transfer_t;
} blockdata_transaction_t;
esp_err_t start_file_server(void);
HTTP_IO_RESULT HTTPPostApp(httpd_req_t *req, const char *filename, char *PostData);
@ -110,9 +108,8 @@ esp_err_t download_get_handler(httpd_req_t *req);
esp_err_t upload_post_handler(httpd_req_t *req);
esp_err_t delete_post_handler(httpd_req_t *req);
esp_err_t ParseBlockDataObject(char *argres, cb_blockdata_transfer_t *ft);
esp_err_t ParseBlockDataObject(char *argres, blockdata_transaction_t *ft);
void FileBlockHandler(char *argres, int rw, const char* path);
void FileListHandler(char *argres, int rw, const char* path);
void FileBlockTimeoutCounter();
#endif /* COMPONENTS_WEB_GUI_APPLICATION_INCLUDE_HTTPSERVER_H_ */

View File

@ -121,9 +121,8 @@ esp_err_t ServiceDataHandler(data_message_t *MSG);
sys_error_code SysVarsPayloadHandler(data_message_t *MSG);
void GetSysErrorDetales(sys_error_code err, const char **br, const char **ds);
#ifdef CONFIG_WEBGUIAPP_I2C_ENABLE
esp_err_t eepr_i2c_read(uint16_t addr, uint8_t *data, int length);
esp_err_t eepr_i2c_write(uint16_t addr, uint8_t *data, int length);
#endif
#endif /* COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_ */

View File

@ -42,6 +42,5 @@ void SetAppVars( rest_var_t* appvars, int size);
bool GetUserAppNeedReset(void);
void SetUserAppNeedReset(bool res);
void LogFile(char *fname, char *format, ...);
void SysLog(char *format, ...);
#endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */

View File

@ -24,8 +24,6 @@
#include "esp_log.h"
#include "esp_err.h"
#ifdef CONFIG_WEBGUIAPP_I2C_ENABLE
#define TAG "EEPROMDriver"
#define I2C_MASTER_TIMEOUT_MS 1000
@ -151,5 +149,3 @@ esp_err_t eepr_i2c_write(uint16_t addr, uint8_t *data, int length)
return ESP_OK;
}
#endif

View File

@ -29,7 +29,6 @@
/*
{
"transid": 623787878,
"opertype" : 1, [1-READ, 2-DELETE, 3-WRITE]
"part": 0, []
"parts": 3, []
@ -39,16 +38,16 @@
}
*/
#define READ_ORERATION 1
#define DELETE_ORERATION 2
#define WRITE_ORERATION 3
static cb_blockdata_transfer_t FileTransaction = {
static blockdata_transaction_t FileTransaction = {
.opertype = 0
};
esp_err_t ParseBlockDataObject(char *argres, cb_blockdata_transfer_t *ft)
esp_err_t ParseBlockDataObject(char *argres, blockdata_transaction_t *ft)
{
struct jReadElement result;
jRead(argres, "", &result);
@ -58,33 +57,6 @@ esp_err_t ParseBlockDataObject(char *argres, cb_blockdata_transfer_t *ft)
return ESP_ERR_INVALID_ARG;
}
jRead(argres, "{'transid'", &result);
if (result.elements == 1)
{
int trans = atoi((char*) result.pValue);
if (ft->open_file_timeout != 0)
{
if (trans != ft->transid)
{
ESP_LOGW(TAG, "Attempt second client access while first is not finished");
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"Device is busy, please try later\"");
return ESP_ERR_NOT_FINISHED;
}
}
else
{
ft->transid = trans;
//ESP_LOGI(TAG, "New transaction with id %d", ft->transid);
}
}
else
{
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"ERROR:key 'transid' not found, frontend update needed\"");
return ESP_ERR_INVALID_ARG;
}
jRead(argres, "{'opertype'", &result);
if (result.elements == 1)
{
@ -173,8 +145,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
if (ParseBlockDataObject(argres, &FileTransaction) != ESP_OK)
return;
FileTransaction.open_file_timeout = BLOCK_OPERATION_TIMEOUT; //restart timeout on every block
//Phase of file operation calculate
FileTransaction.operphase = 0; //Simple read or write
if (FileTransaction.parts == 1)
@ -196,7 +166,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
{
ESP_LOGE("FILE_API", "File does not exist : %s", FileTransaction.mem_object);
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"ERROR:DIR_NOT_FOUND\"");
FileTransaction.open_file_timeout = 0;
return;
}
}
@ -216,7 +185,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
if (FileTransaction.opertype == DELETE_ORERATION)
{
unlink(FileTransaction.filepath);
FileTransaction.open_file_timeout = 0;
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"DELETED OK\"");
return;
}
@ -248,8 +216,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
if (FileTransaction.operphase == 2 || FileTransaction.operphase == 3)
{
fclose(FileTransaction.f);
FileTransaction.f = NULL;
FileTransaction.open_file_timeout = 0;
ESP_LOGI("FILE_API", "Close file for read : %s", FileTransaction.mem_object);
}
dlen = 0;
@ -260,7 +226,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
struct jWriteControl jwc;
jwOpen(&jwc, argres, VAR_MAX_VALUE_LENGTH, JW_OBJECT, JW_COMPACT);
jwObj_int(&jwc, "transid", FileTransaction.transid);
jwObj_int(&jwc, "opertype", FileTransaction.opertype);
jwObj_int(&jwc, "parts", FileTransaction.parts);
jwObj_int(&jwc, "part", FileTransaction.part);
@ -271,7 +236,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
jwClose(&jwc);
free(scr);
free(dst);
}
else if (FileTransaction.opertype == WRITE_ORERATION)
{
@ -304,22 +268,18 @@ void FileBlockHandler(char *argres, int rw, const char *path)
if (FileTransaction.operphase == 2 || FileTransaction.operphase == 3)
{
fclose(FileTransaction.f);
FileTransaction.f = NULL;
FileTransaction.open_file_timeout = 0;
ESP_LOGI("FILE_API", "Close file for write : %s", FileTransaction.mem_object);
}
free(dst);
struct jWriteControl jwc;
jwOpen(&jwc, argres, VAR_MAX_VALUE_LENGTH, JW_OBJECT, JW_COMPACT);
jwObj_int(&jwc, "transid", FileTransaction.transid);
jwObj_int(&jwc, "opertype", FileTransaction.opertype);
jwObj_int(&jwc, "parts", FileTransaction.parts);
jwObj_int(&jwc, "part", FileTransaction.part);
jwObj_string(&jwc, "mem_object", FileTransaction.mem_object);
jwObj_int(&jwc, "size", write);
jwClose(&jwc);
}
else
{
@ -337,19 +297,6 @@ void FileBlockHandler(char *argres, int rw, const char *path)
}
void FileBlockTimeoutCounter()
{
if (FileTransaction.open_file_timeout)
{
if (--FileTransaction.open_file_timeout == 0)
{
if (FileTransaction.f != NULL)
fclose(FileTransaction.f);
}
}
//ESP_LOGI(TAG, "Block timeout %d", FileTransaction.open_file_timeout);
}
void FileListHandler(char *argres, int rw, const char* path)
{
char entrypath[FILE_PATH_MAX];

View File

@ -45,7 +45,6 @@ static bool isPPPinitializing = false;
#define MAX_COMMAND_REPEATE_NUMBER 15
#define WATCHDOG_INTERVAL 30
#define WAIT_FOR_GET_IP 30
static bool isPPPConn = false;
static int attimeout = 1000;
@ -266,7 +265,7 @@ static void GSMInitTask(void *pvParameter) {
}
ESP_LOGI(TAG, "PPP data mode OK");
xEventGroupWaitBits(event_group, CONNECT_BIT, pdTRUE, pdTRUE, pdMS_TO_TICKS(WAIT_FOR_GET_IP * 1000));
xEventGroupWaitBits(event_group, CONNECT_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
isPPPinitializing = false;
vTaskDelete(NULL);
@ -280,8 +279,8 @@ modem_init_fail:
void PPPModemColdStart(void) {
ResetType = 0;
xTaskCreatePinnedToCore(GSMInitTask, "GSMInitTask", 1024 * 6, &ResetType, 3,
&initTaskhandle, 1);
xTaskCreate(GSMInitTask, "GSMInitTask", 1024 * 6, &ResetType, 3,
&initTaskhandle);
ESP_LOGI(TAG, "Start GSM cold initialization task");
}
@ -303,7 +302,7 @@ static void GSMRunTask(void *pvParameter) {
}
void PPPModemStart(void) {
xTaskCreatePinnedToCore(GSMRunTask, "GSMRunTask", 1024 * 4, &ResetType, 3, NULL, 1);
xTaskCreate(GSMRunTask, "GSMRunTask", 1024 * 4, &ResetType, 3, NULL);
}
int PPPModemGetRSSI(void) {

View File

@ -154,7 +154,7 @@ void SecondTickSystem(void *param)
{
++UpTime;
MidnightTimer();
FileBlockTimeoutCounter();
}
uint32_t GetUpTime(void)

View File

@ -592,70 +592,6 @@ void SetUserAppNeedReset(bool res)
isUserAppNeedReset = res;
}
#define LOG_MAX_CHUNK_SIZE CONFIG_WEBGUIAPP_SYSLOG_CHUNK_SIZE
#define LOG_MAX_CHUNKS CONFIG_WEBGUIAPP_SYSLOG_MAX_CHUNKS
#define DEFAULT_LOG_FILE_NAME "syslog"
#define LOG_PARTITION "/data/"
static void ComposeLogFilename(int chunk, char *filename)
{
char chunkstr[2];
strcpy(filename, LOG_PARTITION);
strcat(filename, DEFAULT_LOG_FILE_NAME);
itoa(chunk, chunkstr, 10);
strcat(filename, chunkstr);
strcat(filename, ".log");
}
void SysLog(char *format, ...)
{
char tstamp[ISO8601_TIMESTAMP_LENGTH + 2];
static int cur_chunk = 0, isstart = 1;
char filename[32];
struct stat file_stat;
FILE *f;
ComposeLogFilename(cur_chunk, filename);
//If first call after reboot, try to find not full chunk
if (isstart)
{
while (file_stat.st_size > LOG_MAX_CHUNK_SIZE * 1024 && cur_chunk <= LOG_MAX_CHUNKS - 1)
{
cur_chunk++;
ComposeLogFilename(cur_chunk, filename);
}
isstart = 0;
}
stat(filename, &file_stat);
//next if full, else append to current
if (file_stat.st_size > LOG_MAX_CHUNK_SIZE * 1024)
{
if (++cur_chunk > LOG_MAX_CHUNKS - 1)
cur_chunk = 0;
ComposeLogFilename(cur_chunk, filename);
f = fopen(filename, "w");
}
else
f = fopen(filename, "a");
if (f == NULL)
{
ESP_LOGE(TAG, "Failed to open file %s for writing", filename);
return;
}
va_list arg;
va_start(arg, format);
va_end(arg);
strcpy(tstamp, "\r\n");
char ts[ISO8601_TIMESTAMP_LENGTH];
GetISO8601Time(ts);
strcat(tstamp, ts);
strcat(tstamp, " ");
fwrite(tstamp, 1, strlen(tstamp), f);
vfprintf(f, format, arg);
fclose(f);
}
void LogFile(char *fname, char *format, ...)
{
char filename[32];