From 28d21b8a1364088821b6b7b1edef7ca3ebd360b1 Mon Sep 17 00:00:00 2001 From: bogdan Date: Wed, 11 Oct 2023 07:45:33 +0200 Subject: [PATCH] clean cron configuration structure --- include/SysConfiguration.h | 4 +-- src/CronTimers.c | 64 +------------------------------------- src/SysConfiguration.c | 8 ----- 3 files changed, 2 insertions(+), 74 deletions(-) diff --git a/include/SysConfiguration.h b/include/SysConfiguration.h index 0343d91..3ce8b2a 100644 --- a/include/SysConfiguration.h +++ b/include/SysConfiguration.h @@ -210,9 +210,7 @@ typedef struct } modbusSettings; - cron_timer_t Timers[16]; - cron_obj_t CronObjects[16]; - + cron_timer_t Timers[CONFIG_WEBGUIAPP_CRON_NUMBER]; } SYS_CONFIG; diff --git a/src/CronTimers.c b/src/CronTimers.c index a9b81fa..fbfd398 100644 --- a/src/CronTimers.c +++ b/src/CronTimers.c @@ -36,60 +36,8 @@ #define TAG "CRON_TIMER" -extern obj_struct_t app_com_obj_arr[]; -extern obj_struct_t com_obj_arr[]; -const char *cron_actions[] = { "ON", "REBOOT", "TOGGLE", "OFF", "VERYLONG_OPERATION" }; -const char *cron_objects[] = { - "RELAY1", - "RELAY2", - "RELAY3", - "RELAY4", - "RELAY5", - "RELAY6", - "RELAY7", - "RELAY8", - "SYSTEM" }; -const char *cron_act_avail[] = { - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[0,2,3]", - "[1,4]" }; - -char* GetCronObjectNameDef(int idx) -{ - if (idx < 0 || idx >= sizeof(cron_objects) / sizeof(char*)) - return ""; - return (char*) cron_objects[idx]; -} - -char* GetCronObjectName(int idx) -{ - if (idx < 0 || idx >= sizeof(cron_objects) / sizeof(char*)) - return ""; - return GetSysConf()->CronObjects[idx].objname; -} - -char* GetCronActionName(int idx) -{ - if (idx < 0 || idx >= sizeof(cron_actions) / sizeof(char*)) - return ""; - return (char*) cron_actions[idx]; -} - -char* GetCronActAvail(int idx) -{ - if (idx < 0 || idx >= sizeof(cron_act_avail) / sizeof(char*)) - return "[]"; - return (char*) cron_act_avail[idx]; -} - -static cron_job *JobsList[CRON_TIMERS_NUMBER]; +static cron_job *JobsList[CONFIG_WEBGUIAPP_CRON_NUMBER]; static char cron_express_error[CRON_EXPRESS_MAX_LENGTH]; char* GetCronError() @@ -97,16 +45,6 @@ char* GetCronError() return cron_express_error; } -/** - * \brief Handle all actions under all objects - * \param obj Index of the object - * \param act Index of the action - */ -void custom_cron_execute(int obj, int act) -{ - -} - void custom_cron_job_callback(cron_job *job) { ExecCommand(((cron_timer_t*) job->data)->exec); diff --git a/src/SysConfiguration.c b/src/SysConfiguration.c index 7853f81..9f7bbcf 100644 --- a/src/SysConfiguration.c +++ b/src/SysConfiguration.c @@ -402,19 +402,11 @@ esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &C Conf->Timers[i].del = true; Conf->Timers[i].enab = false; Conf->Timers[i].prev = false; - Conf->Timers[i].obj = 0; - Conf->Timers[i].act = 0; strcpy(Conf->Timers[i].name, "Timer Name"); strcpy(Conf->Timers[i].cron, "* * * * * *"); strcpy(Conf->Timers[i].exec, "OBJECT,ACTION,ARGUMENTS"); } - for (int i = 0; i < 16; i++ ) - { - strcpy(Conf->CronObjects[i].objname, GetCronObjectNameDef(i)); - Conf->CronObjects[i].idx = i; - } - } esp_err_t ReadNVSSysConfig(SYS_CONFIG *SysConf)