clean from old http handlers

This commit is contained in:
Bogdan Pilyugin 2023-10-22 10:28:32 +02:00
parent 51e909d863
commit 70fab5f04b
5 changed files with 1 additions and 1784 deletions

1515
.project

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 8dd3f1bdac8e1945239037b4cf9f284b17c41867
Subproject commit b4cb524ea18dc882bd727c12197f2b702878ef3b

View File

@ -7,8 +7,6 @@
#include "jobs.h"
#include "AppConfiguration.h"
int HTTPPrintCustom(httpd_req_t *req, char *buf, char *var, int arg);
HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, char *PostData);
void UserMQTTEventHndlr(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
void SaveUserConf();
@ -21,8 +19,6 @@ const char my_context_data[] = "MyContextDataPassedIntoMQTTHandler";
void app_main(void)
{
regHTTPPrintCustom(&HTTPPrintCustom);
regAfterPostHandlerCustom(&AfterPostHandlerCustom);
regUserEventHandler(&UserMQTTEventHndlr, (void*) my_context_data);
regCustomSaveConf(&SaveUserConf);
regCustomPayloadTypeHandler(&CustomPayloadHandler);

View File

@ -1,137 +0,0 @@
/*! Copyright 2022 Bogdan Pilyugin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* \file HTTPPostCustom.c
* \version 1.0
* \date 2022-08-18
* \author Bogdan Pilyugin
* \brief
* \details
* \copyright Apache License, Version 2.0
*/
#include <CronTimers.h>
#include "webguiapp.h"
#include "AppConfiguration.h"
const char pg_40[] = "index40.html";
const char pg_42[] = "index42.html";
const char pg_43[] = "index43.html";
const char pg_44[] = "index44.html";
const char url_application[] = "application.html";
static HTTP_IO_RESULT HTTPPostIndex40(httpd_req_t *req, char *PostData);
static HTTP_IO_RESULT HTTPPostIndex42(httpd_req_t *req, char *PostData);
static HTTP_IO_RESULT HTTPPostIndex43(httpd_req_t *req, char *PostData);
static HTTP_IO_RESULT HTTPPostIndex44(httpd_req_t *req, char *PostData);
static HTTP_IO_RESULT HTTPPostApplication(httpd_req_t *req, char *PostData);
HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, char *PostData)
{
if (!memcmp(filename, pg_40, sizeof(pg_40)))
return HTTPPostIndex40(req, PostData);
if (!memcmp(filename, pg_42, sizeof(pg_42)))
return HTTPPostIndex42(req, PostData);
if (!memcmp(filename, pg_43, sizeof(pg_43)))
return HTTPPostIndex43(req, PostData);
if (!memcmp(filename, pg_44, sizeof(pg_44)))
return HTTPPostIndex44(req, PostData);
if (!memcmp(filename, url_application, sizeof(url_application)))
return HTTPPostApplication(req, PostData);
return HTTP_IO_DONE;
}
static HTTP_IO_RESULT HTTPPostApplication(httpd_req_t *req, char *PostData)
{
return HTTP_IO_DONE;
}
static HTTP_IO_RESULT HTTPPostIndex40(httpd_req_t *req, char *PostData)
{
char tmp[8];
if (httpd_query_key_value(PostData, "cmd", tmp, 4) == ESP_OK)
{
if (!strcmp(tmp, (const char*) "1"))
{
// SetCTRL_BAT(ON);
}
else if (!strcmp(tmp, (const char*) "2"))
{
// SetCTRL_BAT(OFF);
}
else if (!strcmp(tmp, (const char*) "3"))
{
//MQTTStart();
}
else if (!strcmp(tmp, (const char*) "4"))
{
// MQTTStop();
}
else if (!strcmp(tmp, (const char*) "5"))
{
}
else if (!strcmp(tmp, (const char*) "6"))
{
}
else if (!strcmp(tmp, (const char*) "7"))
{
//SetDefaultNetIF(GetETHNetifAdapter());
}
else if (!strcmp(tmp, (const char*) "8"))
{
//SetDefaultNetIF(GetSTANetifAdapter());
}
else if (!strcmp(tmp, (const char*) "9"))
{
//SetDefaultNetIF(GetPPPNetifAdapter());
}
else if (!strcmp(tmp, (const char*) "10"))
{
//NextDefaultNetIF();
}
else if (!strcmp(tmp, (const char*) "11"))
{
//PrintNetifs();
}
else if (!strcmp(tmp, (const char*) "12"))
{
// SendTestEvent();
}
}
return HTTP_IO_DONE;
}
static HTTP_IO_RESULT HTTPPostIndex42(httpd_req_t *req, char *PostData)
{
return HTTP_IO_DONE;
}
static HTTP_IO_RESULT HTTPPostIndex43(httpd_req_t *req, char *PostData)
{
return HTTP_IO_DONE;
}
static HTTP_IO_RESULT HTTPPostIndex44(httpd_req_t *req, char *PostData)
{
return HTTP_IO_DONE;
}

View File

@ -1,127 +0,0 @@
/*! Copyright 2022 Bogdan Pilyugin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* \file HTTPPrintCustom.c
* \version 1.0
* \date 2022-08-18
* \author Bogdan Pilyugin
* \brief
* \details
* \copyright Apache License, Version 2.0
*/
#include <CronTimers.h>
#include "webguiapp.h"
#include "AppConfiguration.h"
static void HTTPPrint_crontmr(char *VarData, void *arg)
{
/*
int idx = *((int*)(arg));
if(idx < CRON_TIMERS_NUMBER)
{
char data[MAX_DYNVAR_LENGTH];
cron_timer_t T;
memcpy(&T, &GetAppConf()->Timers[idx], sizeof(cron_timer_t));
struct jWriteControl jwc;
jwOpen(&jwc, data, sizeof(data), JW_OBJECT, JW_COMPACT);
jwObj_int(&jwc, "num", (unsigned int) T.num);
jwObj_int(&jwc, "del", (T.del)?1:0);
jwObj_int(&jwc, "enab", (T.enab)?1:0);
jwObj_int(&jwc, "prev", (T.prev)?1:0);
jwObj_string(&jwc, "name", T.name);
jwObj_int(&jwc, "obj", (unsigned int) T.obj);
jwObj_int(&jwc, "act", (unsigned int) T.act);
jwObj_string(&jwc, "cron", T.cron);
jwEnd(&jwc);
jwClose(&jwc);
snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", data);
}
*/
}
static void HTTPPrint_cronerr(char *VarData, void *arg)
{
//snprintf(VarData, MAX_DYNVAR_LENGTH, GetCronError());
}
static void HTTPPrint_cronobjs(char *VarData, void *arg)
{
/*
char data[MAX_DYNVAR_LENGTH];
int idx = *((int*)(arg));
if(idx < CRON_OBJECTS_NUMBER)
{
struct jWriteControl jwc;
jwOpen(&jwc, data, sizeof(data), JW_OBJECT, JW_COMPACT);
jwObj_string(&jwc, "name", GetAppConf()->CronObjects[idx].objname);
jwObj_raw(&jwc, "acts", GetCronActAvail(idx));
jwEnd(&jwc);
jwClose(&jwc);
snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", data);
}
*/
}
static void HTTPPrint_cronacts(char *VarData, void *arg)
{
//int idx = *((int*) (arg));
//snprintf(VarData, MAX_DYNVAR_LENGTH, "\"%s\"", GetCronActionName(idx));
}
//Default string if not found handler
static void HTTPPrint_DEF(char *VarData, void *arg)
{
snprintf(VarData, MAX_DYNVAR_LENGTH, "#DEF");
}
static void HTTPPrint_status_fail(char *VarData, void *arg)
{
snprintf(VarData, MAX_DYNVAR_LENGTH, "none");
}
dyn_var_handler_t HANDLERS_ARRAY_CUST[] = {
{ "crontmr", sizeof("crontmr") - 1, &HTTPPrint_crontmr },
{ "cronerr", sizeof("cronerr") - 1, &HTTPPrint_cronerr },
{ "cronobjs", sizeof("cronobjs") - 1, &HTTPPrint_cronobjs },
{ "cronacts", sizeof("cronacts") - 1, &HTTPPrint_cronacts },
/*ERROR report*/
{ "status_fail", sizeof("status_fail") - 1, &HTTPPrint_status_fail },
};
int HTTPPrintCustom(httpd_req_t *req, char *buf, char *var, int arg)
{
char VarData[MAX_DYNVAR_LENGTH];
bool fnd = false;
//searching for tag in handles array
for (int i = 0; i < (sizeof(HANDLERS_ARRAY_CUST) / sizeof(HANDLERS_ARRAY_CUST[0])); ++i)
{
if (strcmp(var, HANDLERS_ARRAY_CUST[i].tag) == 0
&& HANDLERS_ARRAY_CUST[i].HandlerRoutine != NULL)
{
HANDLERS_ARRAY_CUST[i].HandlerRoutine(VarData, (void*) &arg);
fnd = true;
break;
}
}
if (!fnd)
{
HTTPPrint_DEF(VarData, NULL);
}
int dLen = strlen(VarData);
memcpy(buf, VarData, dLen);
return dLen;
}