added callback for user defined payload handler, some dependencies

cleared
This commit is contained in:
Bogdan Pilyugin 2023-08-18 11:20:08 +02:00
parent 5475f5e165
commit fc2b1879e4
4 changed files with 21 additions and 6 deletions

View File

@ -23,7 +23,7 @@
#ifndef COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_ #ifndef COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_
#define COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_ #define COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_
#include "webguiapp.h" #include "SysConfiguration.h"
#include "esp_err.h" #include "esp_err.h"
#include "jRead.h" #include "jRead.h"
#include "jWrite.h" #include "jWrite.h"

View File

@ -21,7 +21,8 @@
#ifndef COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ #ifndef COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_
#define COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ #define COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_
#include "HTTPServer.h"
#include "webguiapp.h"
//Callback for current time obtain notification //Callback for current time obtain notification
void regTimeSyncCallback(void (*time_sync)(struct timeval *tv)); void regTimeSyncCallback(void (*time_sync)(struct timeval *tv));
@ -38,4 +39,7 @@ void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *
//User handler of variables 'var1=value1&var2=value2' styled in POST requests. //User handler of variables 'var1=value1&var2=value2' styled in POST requests.
void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req, const char *filename, char *PostData)); void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req, const char *filename, char *PostData));
//User handler for various payload types
void regCustomPayloadTypeHandler(sys_error_code (*payload_handler)(data_message_t *MSG));
#endif /* COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ */ #endif /* COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ */

View File

@ -31,12 +31,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "esp_event.h" #include "esp_event.h"
#include "esp_netif.h" #include "esp_netif.h"
#include "esp_system.h"
#include "driver/spi_master.h"
#include "SystemApplication.h" #include "SystemApplication.h"
#include "UserCallbacks.h" #include "UserCallbacks.h"
#include "SysConfiguration.h"
esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc); esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc);
void SetAppVars( rest_var_t* appvars, int size); void SetAppVars( rest_var_t* appvars, int size);

View File

@ -60,6 +60,15 @@
#define MAX_JSON_DATA_SIZE 1024 #define MAX_JSON_DATA_SIZE 1024
//sys_error_code SysPayloadTypeVarsHandler(data_message_t *MSG)
sys_error_code (*CustomPayloadTypeHandler)(data_message_t *MSG);
void regCustomPayloadTypeHandler(sys_error_code (*payload_handler)(data_message_t *MSG))
{
CustomPayloadTypeHandler = payload_handler;
}
static esp_err_t SHA256hmacHash(unsigned char *data, static esp_err_t SHA256hmacHash(unsigned char *data,
int datalen, int datalen,
unsigned char *key, unsigned char *key,
@ -291,7 +300,11 @@ static sys_error_code SysDataParser(data_message_t *MSG)
//MSG->parsedData.payload = malloc(sizeof(payload_type_vars)); Not needed for this case //MSG->parsedData.payload = malloc(sizeof(payload_type_vars)); Not needed for this case
return SysPayloadTypeVarsHandler(MSG); return SysPayloadTypeVarsHandler(MSG);
break; break;
default: default:
if (CustomPayloadTypeHandler)
CustomPayloadTypeHandler(MSG);
else
return SYS_ERROR_PARSE_PAYLOADTYPE; return SYS_ERROR_PARSE_PAYLOADTYPE;
} }