fixed return type of user save config callbak
This commit is contained in:
parent
35b69b526b
commit
d90588ed4b
|
|
@ -42,6 +42,6 @@ void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req,
|
||||||
//User handler for various payload types
|
//User handler for various payload types
|
||||||
void regCustomPayloadTypeHandler(sys_error_code (*payload_handler)(data_message_t *MSG));
|
void regCustomPayloadTypeHandler(sys_error_code (*payload_handler)(data_message_t *MSG));
|
||||||
//User handler for save App configuration
|
//User handler for save App configuration
|
||||||
void regCustomSaveConf(esp_err_t (custom_saveconf)(void));
|
void regCustomSaveConf(void (*custom_saveconf)(void));
|
||||||
|
|
||||||
#endif /* COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ */
|
#endif /* COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ */
|
||||||
|
|
|
||||||
55
src/SNTP.c
55
src/SNTP.c
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2022 Bogdan Pilyugin
|
/* Copyright 2022 Bogdan Pilyugin
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -37,9 +37,8 @@ void regTimeSyncCallback(void (*time_sync)(struct timeval *tv))
|
||||||
|
|
||||||
static void initialize_sntp(void);
|
static void initialize_sntp(void);
|
||||||
|
|
||||||
|
|
||||||
void SecondTickSystem(void *arg);
|
void SecondTickSystem(void *arg);
|
||||||
esp_timer_handle_t system_seconds_timer;
|
esp_timer_handle_t system_seconds_timer;
|
||||||
const esp_timer_create_args_t system_seconds_timer_args = {
|
const esp_timer_create_args_t system_seconds_timer_args = {
|
||||||
.callback = &SecondTickSystem,
|
.callback = &SecondTickSystem,
|
||||||
.name = "secondsTimer"
|
.name = "secondsTimer"
|
||||||
|
|
@ -47,33 +46,47 @@ const esp_timer_create_args_t system_seconds_timer_args = {
|
||||||
|
|
||||||
static void obtain_time(void *pvParameter)
|
static void obtain_time(void *pvParameter)
|
||||||
{
|
{
|
||||||
initialize_sntp();
|
initialize_sntp();
|
||||||
|
|
||||||
// wait for time to be set
|
// wait for time to be set
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
const int retry_count = 10;
|
const int retry_count = 10;
|
||||||
while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET && ++retry < retry_count)
|
while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET && ++retry < retry_count)
|
||||||
{
|
{
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void time_sync_notification_cb(struct timeval *tv)
|
static void time_sync_notification_cb(struct timeval *tv)
|
||||||
{
|
{
|
||||||
if(time_sync_notif)
|
if (time_sync_notif)
|
||||||
time_sync_notif(tv);
|
time_sync_notif(tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_sntp(void)
|
static void initialize_sntp(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||||
|
esp_sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||||
|
esp_sntp_setservername(0, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
|
esp_sntp_setservername(1, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
|
esp_sntp_setservername(2, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
|
#else
|
||||||
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||||
sntp_setservername(0, GetSysConf()->sntpClient.SntpServerAdr);
|
sntp_setservername(0, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
sntp_setservername(1, GetSysConf()->sntpClient.SntpServerAdr);
|
sntp_setservername(1, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
sntp_setservername(2, GetSysConf()->sntpClient.SntpServerAdr);
|
sntp_setservername(2, GetSysConf()->sntpClient.SntpServerAdr);
|
||||||
sntp_set_sync_interval(6*3600*1000);
|
#endif
|
||||||
sntp_set_time_sync_notification_cb(time_sync_notification_cb);
|
|
||||||
|
sntp_set_sync_interval(6 * 3600 * 1000);
|
||||||
|
sntp_set_time_sync_notification_cb(time_sync_notification_cb);
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||||
|
esp_sntp_init();
|
||||||
|
#else
|
||||||
sntp_init();
|
sntp_init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartTimeGet(void)
|
void StartTimeGet(void)
|
||||||
|
|
@ -88,12 +101,12 @@ void GetRFC3339Time(char *t)
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
sprintf(t, "%04d-%02d-%02dT%02d:%02d:%02d+00:00",
|
sprintf(t, "%04d-%02d-%02dT%02d:%02d:%02d+00:00",
|
||||||
(timeinfo.tm_year) + YEAR_BASE,
|
(timeinfo.tm_year) + YEAR_BASE,
|
||||||
(timeinfo.tm_mon) + 1,
|
(timeinfo.tm_mon) + 1,
|
||||||
timeinfo.tm_mday,
|
timeinfo.tm_mday,
|
||||||
timeinfo.tm_hour,
|
timeinfo.tm_hour,
|
||||||
timeinfo.tm_min,
|
timeinfo.tm_min,
|
||||||
timeinfo.tm_sec);
|
timeinfo.tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartSystemTimer(void)
|
void StartSystemTimer(void)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ void regCustomPayloadTypeHandler(sys_error_code (*payload_handler)(data_message_
|
||||||
{
|
{
|
||||||
CustomPayloadTypeHandler = payload_handler;
|
CustomPayloadTypeHandler = payload_handler;
|
||||||
}
|
}
|
||||||
void regCustomSaveConf(esp_err_t (custom_saveconf)(void))
|
void regCustomSaveConf(void (*custom_saveconf)(void))
|
||||||
{
|
{
|
||||||
CustomSaveConf = custom_saveconf;
|
CustomSaveConf = custom_saveconf;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user