diff --git a/include/SystemApplication.h b/include/SystemApplication.h index 8da5c41..a4205da 100644 --- a/include/SystemApplication.h +++ b/include/SystemApplication.h @@ -23,7 +23,7 @@ #ifndef COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_ #define COMPONENTS_WEBGUIAPP_INCLUDE_SYSTEMAPPLICATION_H_ -#include "webguiapp.h" +#include "SysConfiguration.h" #include "esp_err.h" #include "jRead.h" #include "jWrite.h" diff --git a/include/UserCallbacks.h b/include/UserCallbacks.h index d226021..d370233 100644 --- a/include/UserCallbacks.h +++ b/include/UserCallbacks.h @@ -21,7 +21,8 @@ #ifndef COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ #define COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ -#include "HTTPServer.h" + +#include "webguiapp.h" //Callback for current time obtain notification 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. 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_ */ diff --git a/include/webguiapp.h b/include/webguiapp.h index 5808daa..8f0fc55 100644 --- a/include/webguiapp.h +++ b/include/webguiapp.h @@ -31,12 +31,10 @@ #include "esp_log.h" #include "esp_event.h" #include "esp_netif.h" -#include "esp_system.h" -#include "driver/spi_master.h" #include "SystemApplication.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); void SetAppVars( rest_var_t* appvars, int size); diff --git a/src/SysComm.c b/src/SysComm.c index ad3c69d..ff32006 100644 --- a/src/SysComm.c +++ b/src/SysComm.c @@ -60,6 +60,15 @@ #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, int datalen, unsigned char *key, @@ -291,8 +300,12 @@ static sys_error_code SysDataParser(data_message_t *MSG) //MSG->parsedData.payload = malloc(sizeof(payload_type_vars)); Not needed for this case return SysPayloadTypeVarsHandler(MSG); break; + default: - return SYS_ERROR_PARSE_PAYLOADTYPE; + if (CustomPayloadTypeHandler) + CustomPayloadTypeHandler(MSG); + else + return SYS_ERROR_PARSE_PAYLOADTYPE; } return SYS_ERROR_UNKNOWN;