diff --git a/cmd/cmd.h b/cmd/cmd.h index 769326e..a73119a 100644 --- a/cmd/cmd.h +++ b/cmd/cmd.h @@ -49,7 +49,7 @@ typedef enum { CMD_REST_REQUEST, CMD_REST_SETHEADER, - CMD_WEB_DATA = 30, + CMD_WEB_JSON_DATA = 30, CMD_WEB_REQ_CB, } CmdName; diff --git a/cmd/handlers.c b/cmd/handlers.c index 9e719a7..834b757 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -12,6 +12,7 @@ #ifdef REST #include #endif +#include #ifdef CMD_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) @@ -47,6 +48,7 @@ const CmdList commands[] = { {CMD_REST_REQUEST, "REST_REQ", REST_Request}, {CMD_REST_SETHEADER, "REST_SETHDR", REST_SetHeader}, #endif + {CMD_WEB_JSON_DATA, "WEB_JSON_DATA", WEB_JsonData}, }; //===== List of registered callbacks (to uC) diff --git a/esp-link/cgi.c b/esp-link/cgi.c index 891b688..e829594 100644 --- a/esp-link/cgi.c +++ b/esp-link/cgi.c @@ -222,7 +222,7 @@ int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { "\"version\": \"%s\", " "\"name\": \"%s\"" " }", - webServerUserPages(), esp_link_version, name); + WEB_UserPages(), esp_link_version, name); httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; diff --git a/esp-link/cgiwebserver.c b/esp-link/cgiwebserver.c index a34737f..58dc544 100644 --- a/esp-link/cgiwebserver.c +++ b/esp-link/cgiwebserver.c @@ -60,7 +60,7 @@ int ICACHE_FLASH_ATTR webServerMultipartCallback(MultipartCmd cmd, char *data, i { uint32_t magic = ESPFS_MAGIC; spi_flash_write( (int)getUserPageSectionStart(), (uint32_t *)&magic, sizeof(uint32_t) ); - webServerInit(); + WEB_Init(); } break; } diff --git a/esp-link/main.c b/esp-link/main.c index 4eeac66..fd3f624 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -100,7 +100,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/mqtt", cgiMqtt, NULL }, #endif { "/web-server/upload", cgiWebServerUpload, NULL }, - { "*.json", cgiJsonHook, NULL }, //Catch-all cgi JSON queries + { "*.json", WEB_CgiJsonHook, NULL }, //Catch-all cgi JSON queries { "*", cgiEspFsHook, NULL }, //Catch-all cgi function for the filesystem { NULL, NULL, NULL } }; @@ -159,7 +159,7 @@ void user_init(void) { //os_printf("espFsInit %s\n", res?"ERR":"ok"); // mount the http handlers httpdInit(builtInUrls, 80); - webServerInit(); + WEB_Init(); // init the wifi-serial transparent bridge (port 23) serbridgeInit(23, 2323); diff --git a/examples/arduino/EspLinkSample/EspLink.h b/examples/arduino/EspLinkSample/EspLink.h index aff43f9..c13a390 100644 --- a/examples/arduino/EspLinkSample/EspLink.h +++ b/examples/arduino/EspLinkSample/EspLink.h @@ -43,7 +43,7 @@ typedef enum { CMD_REST_REQUEST, CMD_REST_SETHEADER, - CMD_WEB_DATA = 30, + CMD_WEB_JSON_DATA = 30, CMD_WEB_REQ_CB, } CmdName; diff --git a/web-server/web-server.c b/web-server/web-server.c index 654937f..67b1fd8 100644 --- a/web-server/web-server.c +++ b/web-server/web-server.c @@ -16,12 +16,12 @@ static char* web_server_reasons[] = { char * webServerPages = NULL; -char * ICACHE_FLASH_ATTR webServerUserPages() +char * ICACHE_FLASH_ATTR WEB_UserPages() { return webServerPages; } -void ICACHE_FLASH_ATTR webServerBrowseFiles() +void ICACHE_FLASH_ATTR WEB_BrowseFiles() { char buffer[1024]; buffer[0] = 0; @@ -74,17 +74,17 @@ void ICACHE_FLASH_ATTR webServerBrowseFiles() os_memcpy( webServerPages, buffer, len ); } -void ICACHE_FLASH_ATTR webServerInit() +void ICACHE_FLASH_ATTR WEB_Init() { espFsInit(userPageCtx, (void *)getUserPageSectionStart(), ESPFS_FLASH); if( espFsIsValid( userPageCtx ) ) os_printf("Valid user file system found!\n"); else os_printf("No user file system found!\n"); - webServerBrowseFiles(); + WEB_BrowseFiles(); } -int ICACHE_FLASH_ATTR cgiJsonHook(HttpdConnData *connData) +int ICACHE_FLASH_ATTR WEB_CgiJsonHook(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. @@ -180,3 +180,7 @@ int ICACHE_FLASH_ATTR cgiJsonHook(HttpdConnData *connData) // TODO return HTTPD_CGI_MORE; } + +void ICACHE_FLASH_ATTR WEB_JsonData(CmdPacket *cmd) +{ +} \ No newline at end of file diff --git a/web-server/web-server.h b/web-server/web-server.h index b17373f..34be3db 100644 --- a/web-server/web-server.h +++ b/web-server/web-server.h @@ -4,6 +4,7 @@ #include #include "httpd.h" +#include "cmd.h" typedef enum { @@ -15,11 +16,12 @@ typedef enum INVALID=-1, } RequestReason; -void webServerInit(); +void WEB_Init(); -char * webServerUserPages(); +char * WEB_UserPages(); -int ICACHE_FLASH_ATTR cgiJsonHook(HttpdConnData *connData); +int WEB_CgiJsonHook(HttpdConnData *connData); +void WEB_JsonData(CmdPacket *cmd); #endif /* WEB_SERVER_H */