forked from j3d1/fiatlux
Compare commits
1 commit
stable
...
jedi/dev/n
Author | SHA1 | Date | |
---|---|---|---|
e7e7163b81 |
1 changed files with 33 additions and 7 deletions
|
@ -1,18 +1,43 @@
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
|
#include <sntp.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <esp/uart.h>
|
||||||
|
#include <espressif/esp_common.h>
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include "web.h"
|
#include "web.h"
|
||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
#include "lux.h"
|
#include "lux.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#define SNTP_SERVERS "0.pool.ntp.org", "1.pool.ntp.org", \
|
||||||
#include <FreeRTOS.h>
|
"2.pool.ntp.org", "3.pool.ntp.org"
|
||||||
#include <task.h>
|
|
||||||
|
|
||||||
#include <espressif/esp_common.h>
|
#define vTaskDelayMs(ms) vTaskDelay((ms)/portTICK_PERIOD_MS)
|
||||||
#include <esp/uart.h>
|
|
||||||
|
|
||||||
void user_init(void)
|
_Noreturn void sntp_task(void *pvParameters) {
|
||||||
{
|
(void) pvParameters;
|
||||||
|
const char *servers[] = {SNTP_SERVERS};
|
||||||
|
|
||||||
|
while (sdk_wifi_station_get_connect_status() != STATION_GOT_IP) {
|
||||||
|
vTaskDelayMs(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
sntp_set_update_delay(5 * 60000);
|
||||||
|
const struct timezone tz = {1 * 60, 1};
|
||||||
|
sntp_initialize(&tz);
|
||||||
|
sntp_set_servers(servers, sizeof(servers) / sizeof(char *));
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
vTaskDelayMs(5000);
|
||||||
|
time_t ts = time(NULL);
|
||||||
|
long long t = ts;
|
||||||
|
printf("TIME: %lld %s", t, ctime(&ts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_init(void) {
|
||||||
uart_set_baud(0, 115200);
|
uart_set_baud(0, 115200);
|
||||||
printf("SDK version: %s\n", sdk_system_get_sdk_version());
|
printf("SDK version: %s\n", sdk_system_get_sdk_version());
|
||||||
|
|
||||||
|
@ -27,4 +52,5 @@ void user_init(void)
|
||||||
xTaskCreate(&httpd_task, "httpd_task", 1024, NULL, 2, NULL);
|
xTaskCreate(&httpd_task, "httpd_task", 1024, NULL, 2, NULL);
|
||||||
|
|
||||||
xTaskCreate(&lux_task, "lux_task", 512, NULL, 1, NULL);
|
xTaskCreate(&lux_task, "lux_task", 512, NULL, 1, NULL);
|
||||||
|
xTaskCreate(&sntp_task, "SNTP", 512, NULL, 2, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue