mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-10 05:15:46 +00:00
convert to new flash_config functions. add webapp config.
This commit is contained in:
@ -611,6 +611,35 @@ int HTTP_ProcessPacket(http_request_t *request) {
|
||||
|
||||
poststr(request,"<br>");
|
||||
poststr(request,"<a href=\"cfg_mqtt\">Return to MQTT settings</a>");
|
||||
poststr(request,"<br>");
|
||||
poststr(request,htmlReturnToCfg);
|
||||
HTTP_AddBuildFooter(request);
|
||||
poststr(request,htmlEnd);
|
||||
} else if(http_checkUrlBase(urlStr,"cfg_webapp")) {
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
poststr(request,htmlHeader);
|
||||
poststr(request,g_header);
|
||||
poststr(request,"<h2> Use this to set the URL of the Webapp</h2>");
|
||||
poststr(request,"<form action=\"/cfg_webapp_set\">\
|
||||
<label for=\"url\">Url:</label><br>\
|
||||
<input type=\"text\" id=\"url\" name=\"url\" value=\"");
|
||||
poststr(request,CFG_GetWebappRoot());
|
||||
poststr(request,"\"><br>\
|
||||
<input type=\"submit\" value=\"Submit\">\
|
||||
</form> ");
|
||||
poststr(request,htmlReturnToCfg);
|
||||
HTTP_AddBuildFooter(request);
|
||||
poststr(request,htmlEnd);
|
||||
} else if(http_checkUrlBase(urlStr,"cfg_webapp_set")) {
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
poststr(request,htmlHeader);
|
||||
poststr(request,g_header);
|
||||
|
||||
if(http_getArg(urlStr,"url",tmpA,sizeof(tmpA))) {
|
||||
CFG_SetWebappRoot(tmpA);
|
||||
}
|
||||
poststr(request,"Webapp url set!");
|
||||
|
||||
poststr(request,"<br>");
|
||||
poststr(request,htmlReturnToCfg);
|
||||
HTTP_AddBuildFooter(request);
|
||||
@ -903,6 +932,7 @@ int HTTP_ProcessPacket(http_request_t *request) {
|
||||
poststr(request,"<form action=\"cfg_quick\"><input type=\"submit\" value=\"Quick Config\"/></form>");
|
||||
poststr(request,"<form action=\"cfg_wifi\"><input type=\"submit\" value=\"Configure WiFi\"/></form>");
|
||||
poststr(request,"<form action=\"cfg_mqtt\"><input type=\"submit\" value=\"Configure MQTT\"/></form>");
|
||||
poststr(request,"<form action=\"cfg_webapp\"><input type=\"submit\" value=\"Configure Webapp\"/></form>");
|
||||
poststr(request,"<form action=\"cfg_ha\"><input type=\"submit\" value=\"Generate Home Assistant cfg\"/></form>");
|
||||
poststr(request,"<form action=\"ota\"><input type=\"submit\" value=\"OTA (update software by WiFi)\"/></form>");
|
||||
poststr(request,"<form action=\"cmd_single\"><input type=\"submit\" value=\"Execute custom command\"/></form>");
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#endif
|
||||
#include "lwip/sockets.h"
|
||||
#include "../flash_config/flash_config.h"
|
||||
#include "../new_cfg.h"
|
||||
|
||||
|
||||
extern int g_reset;
|
||||
@ -73,9 +74,8 @@ const char * apppage4 = "startup.js\"></script>"
|
||||
|
||||
|
||||
static int http_rest_app(http_request_t *request){
|
||||
//char *webhost = "http://raspberrypi:1880";//CFG_GetWebRoot();
|
||||
char *webhost = CFG_GetWebappRoot();
|
||||
char *ourip = getMyIp(); //CFG_GetOurIP();
|
||||
const char *webhost = CFG_GetWebappRoot();
|
||||
const char *ourip = getMyIp(); //CFG_GetOurIP();
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
if (webhost && ourip){
|
||||
poststr(request, apppage1);
|
||||
@ -94,7 +94,6 @@ static int http_rest_app(http_request_t *request){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BK_LITTLEFS
|
||||
|
||||
int EndsWith(const char *str, const char *suffix)
|
||||
@ -709,7 +708,7 @@ static int http_rest_get_flash(http_request_t *request, int startaddr, int len){
|
||||
|
||||
static int http_rest_get_dumpconfig(http_request_t *request){
|
||||
|
||||
dump_table();
|
||||
config_dump_table();
|
||||
|
||||
http_setup(request, httpMimeTypeText);
|
||||
poststr(request, NULL);
|
||||
@ -736,29 +735,28 @@ static int http_rest_get_testconfig(http_request_t *request){
|
||||
testconfig.head.len = sizeof(testconfig) - sizeof(testconfig.head);
|
||||
strcpy(testconfig.somename, "test it here");
|
||||
|
||||
dump_table();
|
||||
config_dump_table();
|
||||
|
||||
ret = search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ret = config_search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "search found %x", ret);
|
||||
|
||||
dump_table();
|
||||
config_dump_table();
|
||||
|
||||
intres = delete_item(testconfig.head.type);
|
||||
intres = config_delete_item(testconfig.head.type);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "delete_item returned %d", intres);
|
||||
|
||||
intres = save_item((INFO_ITEM_ST *)&testconfig);
|
||||
intres = config_save_item((INFO_ITEM_ST *)&testconfig);
|
||||
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "save_item returned %d", intres);
|
||||
|
||||
ret = search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ret = config_search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "search2 found %x len %d", ret, (ret?ret->len:0));
|
||||
|
||||
intres = save_item((INFO_ITEM_ST *)&testconfig);
|
||||
intres = config_save_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "save_item returned %d", intres);
|
||||
|
||||
ret = search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ret = config_search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "search3 found %x len %d", ret, (ret?ret->len:0));
|
||||
rtos_delay_milliseconds(1000);
|
||||
|
||||
|
||||
if (ret){
|
||||
@ -769,28 +767,24 @@ static int http_rest_get_testconfig(http_request_t *request){
|
||||
}
|
||||
}
|
||||
|
||||
rtos_delay_milliseconds(1000);
|
||||
testconfig.head.len = sizeof(testconfig) - sizeof(testconfig.head) - 1;
|
||||
intres = save_item((INFO_ITEM_ST *)&testconfig);
|
||||
intres = config_save_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "save_item returned %d", intres);
|
||||
|
||||
rtos_delay_milliseconds(1000);
|
||||
|
||||
ret = search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ret = config_search_item((INFO_ITEM_ST *)&testconfig);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "search4 found %x len %d", ret, (ret?ret->len:0));
|
||||
|
||||
dump_table();
|
||||
rtos_delay_milliseconds(1000);
|
||||
config_dump_table();
|
||||
|
||||
intres = delete_item(testconfig.head.type);
|
||||
intres = config_delete_item(testconfig.head.type);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "delete_item returned %d", intres);
|
||||
|
||||
dump_table();
|
||||
rtos_delay_milliseconds(1000);
|
||||
config_dump_table();
|
||||
|
||||
release_tbl();
|
||||
config_release_tbl();
|
||||
|
||||
dump_table();
|
||||
config_dump_table();
|
||||
|
||||
http_setup(request, httpMimeTypeText);
|
||||
poststr(request, NULL);
|
||||
|
||||
Reference in New Issue
Block a user