Print dyn vars user handler added
This commit is contained in:
parent
540da33248
commit
7038b80d4f
|
|
@ -43,6 +43,9 @@
|
|||
#include "esp_eth.h"
|
||||
#include "mbedtls/base64.h"
|
||||
|
||||
#define MAX_DYNVAR_LENGTH 64
|
||||
#define MAX_INCFILE_LENGTH 1024
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HTTP_IO_DONE = 0u, // Finished with procedure
|
||||
|
|
@ -51,6 +54,15 @@ typedef enum
|
|||
HTTP_IO_REDIRECT
|
||||
} HTTP_IO_RESULT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char tag[16];
|
||||
const int taglen;
|
||||
void (*HandlerRoutine)(char *VarData, void *arg);
|
||||
} dyn_var_handler_t;
|
||||
|
||||
void regHTTPPrintCustom(int (*print_handler));
|
||||
|
||||
esp_err_t start_file_server(void);
|
||||
HTTP_IO_RESULT HTTPPostApp(httpd_req_t *req, const char *filename, char *PostData);
|
||||
int HTTPPrint(httpd_req_t *req, char* buf, char* var);
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ static HTTP_IO_RESULT AfterPostHandler(httpd_req_t *req, const char *filename, c
|
|||
if (!memcmp(filename, pg_mm, sizeof(pg_mm)))
|
||||
return HTTPPostMemJson(req, PostData);
|
||||
|
||||
|
||||
|
||||
return HTTP_IO_DONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,18 +23,12 @@
|
|||
|
||||
#include "HTTPServer.h"
|
||||
|
||||
#define MAX_DYNVAR_LENGTH 64
|
||||
#define MAX_INCFILE_LENGTH 1024
|
||||
// uint32_t UpTime;
|
||||
|
||||
|
||||
|
||||
static const char *TAG = "HTTPServerPrint";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char tag[16];
|
||||
const int taglen;
|
||||
void (*HandlerRoutine)(char *VarData, void *arg);
|
||||
} dyn_var_handler_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
@ -43,6 +37,14 @@ typedef enum
|
|||
GW
|
||||
} IP_PRINT_TYPE;
|
||||
|
||||
//Pointer to extend user implemented print handler
|
||||
static int (*HTTPPrintCust)(httpd_req_t *req, char *buf, char *var);
|
||||
|
||||
void regHTTPPrintCustom(int (*print_handler))
|
||||
{
|
||||
HTTPPrintCust = print_handler;
|
||||
}
|
||||
|
||||
static void PrintInterfaceState(char *VarData, void *arg, esp_netif_t *netif)
|
||||
{
|
||||
if (netif != NULL && esp_netif_is_netif_up(netif))
|
||||
|
|
@ -574,7 +576,12 @@ int HTTPPrint(httpd_req_t *req, char *buf, char *var)
|
|||
}
|
||||
}
|
||||
if (!fnd)
|
||||
{
|
||||
if (HTTPPrintCust != NULL)
|
||||
HTTPPrintCust(req, buf, var);
|
||||
else
|
||||
HTTPPrint_DEF(VarData, NULL);
|
||||
}
|
||||
int dLen = strlen(VarData);
|
||||
memcpy(buf, VarData, dLen);
|
||||
return dLen;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user