Compare commits
	
		
			1 commit
		
	
	
		
			stable
			...
			jedi/dev/n
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 82146efb03 | 
					 4 changed files with 29 additions and 8 deletions
				
			
		|  | @ -1,18 +1,17 @@ | |||
| #include <FreeRTOS.h> | ||||
| #include <task.h> | ||||
| #include <esp/uart.h> | ||||
| #include <espressif/esp_common.h> | ||||
| 
 | ||||
| #include "system.h" | ||||
| #include "wifi.h" | ||||
| #include "web.h" | ||||
| #include "mqtt.h" | ||||
| #include "lux.h" | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <FreeRTOS.h> | ||||
| #include <task.h> | ||||
| 
 | ||||
| #include <espressif/esp_common.h> | ||||
| #include <esp/uart.h> | ||||
| 
 | ||||
| void user_init(void) | ||||
| { | ||||
| void user_init(void) { | ||||
|     uart_set_baud(0, 115200); | ||||
|     printf("SDK version: %s\n", sdk_system_get_sdk_version()); | ||||
| 
 | ||||
|  | @ -27,4 +26,6 @@ void user_init(void) | |||
|     xTaskCreate(&httpd_task, "httpd_task", 1024, NULL, 2, NULL); | ||||
| 
 | ||||
|     xTaskCreate(&lux_task, "lux_task", 512, NULL, 1, NULL); | ||||
| 
 | ||||
|     xTaskCreate(&sntp_task, "sntp_task", 512, NULL, 2, NULL); | ||||
| } | ||||
|  |  | |||
|  | @ -10,7 +10,6 @@ | |||
| #include <sysparam.h> | ||||
| #include <spiflash.h> | ||||
| 
 | ||||
| #include <espressif/user_interface.h> | ||||
| #include <espressif/esp_system.h> | ||||
| #include <rboot/rboot.h> | ||||
| #include <rboot-ota/rboot-api.h> | ||||
|  |  | |||
|  | @ -10,11 +10,13 @@ | |||
| #include <FreeRTOS.h> | ||||
| #include <task.h> | ||||
| #include <sockets.h> | ||||
| #include <time.h> | ||||
| 
 | ||||
| extern "C" { | ||||
| #include <sysparam.h> | ||||
| #include <lwipopts.h> | ||||
| #include <espressif/user_interface.h> | ||||
| #include <sntp.h> | ||||
| } | ||||
| 
 | ||||
| #include <espressif/esp_wifi.h> | ||||
|  | @ -357,5 +359,22 @@ extern "C" void wifi_task(void *pvParameters) { | |||
|     xSemaphoreGive(wifi_available_semaphore); | ||||
| 
 | ||||
|     //monitor loop connection here
 | ||||
|     vTaskDelete(nullptr); | ||||
| } | ||||
| 
 | ||||
| const char *servers[] = {"0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org", "3.pool.ntp.org"}; | ||||
| const struct timezone tz = {1 * 60, DST_NONE}; // DST_MET would actually be correct, but the SDK has a bug and doesn't handle it correctly
 | ||||
| 
 | ||||
| extern "C" void sntp_task(void *pvParameters) { | ||||
|     (void) pvParameters; | ||||
| 
 | ||||
|     while (sdk_wifi_station_get_connect_status() != STATION_GOT_IP) { | ||||
|         vTaskDelay(1000 / portTICK_PERIOD_MS); | ||||
|     } | ||||
| 
 | ||||
|     sntp_set_update_delay(5 * 60000); | ||||
|     sntp_initialize(&tz); | ||||
|     sntp_set_servers(servers, sizeof(servers) / sizeof(char *)); | ||||
| 
 | ||||
|     vTaskDelete(nullptr); | ||||
| } | ||||
|  | @ -16,6 +16,8 @@ extern SemaphoreHandle_t wifi_available_semaphore; | |||
| 
 | ||||
| void wifi_task(void *pvParameters); | ||||
| 
 | ||||
| void sntp_task(void *pvParameters); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue