fix pass dynamic variable with parameter to the custom handler

This commit is contained in:
Bogdan Pilyugin 2022-10-11 14:48:14 +02:00
parent 88ac20f673
commit 29b49efdab
4 changed files with 1303 additions and 1306 deletions

View File

@ -64,7 +64,7 @@ typedef struct
void (*HandlerRoutine)(char *VarData, void *arg);
} dyn_var_handler_t;
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var));
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var, int arg));
void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req, const char *filename, char *PostData));
esp_err_t start_file_server(void);

View File

@ -358,12 +358,12 @@ static HTTP_IO_RESULT HTTPPostServicesSettings(httpd_req_t *req, char *PostData)
GetSysConf()->sntpClient.Flags1.bIsGlobalEnabled = TempIsSNTPEnabled;
}
if (httpd_query_key_value(PostData, "apply", tmp, 5) == ESP_OK)
if (httpd_query_key_value(PostData, "apply", tmp, 6) == ESP_OK)
{
WriteNVSSysConfig(GetSysConf());
return HTTP_IO_DONE;
}
else if (httpd_query_key_value(PostData, "save", tmp, 5) == ESP_OK)
else if (httpd_query_key_value(PostData, "save", tmp, 6) == ESP_OK)
{
WriteNVSSysConfig(GetSysConf());
memcpy(PostData, "/reboot.html", sizeof "/reboot.html");

View File

@ -40,9 +40,9 @@ typedef enum
} IP_PRINT_TYPE;
//Pointer to extend user implemented print handler
static int (*HTTPPrintCust)(httpd_req_t *req, char *buf, char *var);
static int (*HTTPPrintCust)(httpd_req_t *req, char *buf, char *var, int arg);
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var))
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var, int arg))
{
HTTPPrintCust = print_handler;
}
@ -754,7 +754,7 @@ for (int i = 0; i < (sizeof(HANDLERS_ARRAY) / sizeof(HANDLERS_ARRAY[0])); ++i)
if (!fnd)
{
if (HTTPPrintCust != NULL)
return HTTPPrintCust(req, buf, var);
return HTTPPrintCust(req, buf, var, arg);
else
HTTPPrint_DEF(VarData, NULL);

View File

@ -183,9 +183,6 @@ static void InitSysIO(void)
static void InitSysSPI(void)
{
#ifdef CONFIG_WEBGUIAPP_SPI_ENABLE
//spi_device_init_custom();
spi_bus_config_t buscfg = {
.miso_io_num = CONFIG_SPI_MISO_GPIO,
.mosi_io_num = CONFIG_SPI_MOSI_GPIO,