cron global switch added

This commit is contained in:
Bogdan Pilyugin 2024-12-12 17:29:49 +02:00
parent 56d568954c
commit ca082595d9
5 changed files with 19 additions and 4 deletions

View File

@ -238,8 +238,9 @@ typedef struct
} modbusSettings;
cron_timer_t Timers[CONFIG_WEBGUIAPP_CRON_NUMBER];
bool bIsCRONEnabled;
} SYS_CONFIG;

View File

@ -20,6 +20,7 @@
*/
#include <CronTimers.h>
#include "SysConfiguration.h"
#include "esp_log.h"
#include "webguiapp.h"
#include "string.h"
@ -42,7 +43,8 @@ char* GetCronError()
void custom_cron_job_callback(cron_job *job)
{
ExecCommand(((cron_timer_t*) job->data)->exec);
if (GetSysConf()->bIsCRONEnabled)
ExecCommand(((cron_timer_t*) job->data)->exec);
}
const char* check_expr(const char *expr)
@ -96,7 +98,8 @@ static void ExecuteLastAction(obj_struct_t *objarr)
if (minimal != -1)
{
ESP_LOGI(TAG, "Run previous CRON \"%s\" with delta %d", GetSysConf()->Timers[minimal].exec, (int )delta);
ExecCommand(GetSysConf()->Timers[minimal].exec);
if (GetSysConf()->bIsCRONEnabled)
ExecCommand(GetSysConf()->Timers[minimal].exec);
}
}

View File

@ -449,7 +449,9 @@ const rest_var_t SystemVariables[] =
{ 0, "lat", &funct_lat, VAR_FUNCT, RW, 0, 0 },
{ 0, "lon", &funct_lon, VAR_FUNCT, RW, 0, 0 },
{ 0, "cronrecs_enab", &SysConfig.bIsCRONEnabled, VAR_BOOL, RW, 0, 1 },
#if CONFIG_WEBGUIAPP_MQTT_ENABLE
{ 0, "mqtt_1_enab", &SysConfig.mqttStation[0].Flags1.bIsGlobalEnabled, VAR_BOOL, RW, 0, 1 },
{ 0, "mqtt_1_serv", &SysConfig.mqttStation[0].ServerAddr, VAR_STRING, RW, 3, 63 },

View File

@ -452,6 +452,7 @@ esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &C
strcpy(Conf->Timers[i].exec, "OBJECT,ACTION,ARGUMENTS");
}
Conf->bIsCRONEnabled = true;
#ifdef CONFIG_WEBGUIAPP_ASTRO_ENABLE

View File

@ -307,6 +307,8 @@ static void wifi_init_sta(void *pvParameter)
memcpy(wifi_config.sta.password, GetSysConf()->wifiSettings.InfSecurityKey,
strlen(GetSysConf()->wifiSettings.InfSecurityKey));
esp_netif_set_hostname(sta_netif, GetSysConf()->NetBIOSName);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
@ -458,6 +460,12 @@ static void wifi_init_apsta(void *pvParameter)
strlen(GetSysConf()->wifiSettings.InfSecurityKey));
//END STA MODE CONFIGURATION
ESP_ERROR_CHECK(esp_netif_set_hostname(sta_netif, "test_TEST"));
ESP_ERROR_CHECK(esp_netif_set_hostname(ap_netif, GetSysConf()->NetBIOSName));
char name[32];
esp_netif_get_hostname(sta_netif, &name);
ESP_LOGW(TAG, "Net bios name set to %s", name);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_wifi_config));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &sta_wifi_config));