|
@@ -23,6 +23,7 @@
|
|
|
#include "api.h"
|
|
|
#include "storage.h"
|
|
|
#include "cleanup_task.h"
|
|
|
+#include "wifi_management_task.h"
|
|
|
|
|
|
|
|
|
static const char* STORAGE_NAMESPACE = "a1";
|
|
@@ -33,13 +34,14 @@ static void IRAM_ATTR gpio_interrupt_handler(void *args)
|
|
|
*button_pressed_flag = 1;
|
|
|
}
|
|
|
|
|
|
-static void init_peripherals(uint8_t* button_pressed_flag) {
|
|
|
+static void init_peripherals(uint8_t* button_pressed_flag, uint8_t* wifi_enabled_flag) {
|
|
|
ESP_ERROR_CHECK(nvs_flash_init());
|
|
|
ESP_ERROR_CHECK(esp_netif_init());
|
|
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
|
|
|
|
wifi_init();
|
|
|
wifi_start();
|
|
|
+ *wifi_enabled_flag = 1;
|
|
|
|
|
|
ESP_ERROR_CHECK(storage_init(STORAGE_NAMESPACE));
|
|
|
ds3231_init(DS3231_SDA_PIN, DS3231_SCL_PIN);
|
|
@@ -57,6 +59,7 @@ static void init_peripherals(uint8_t* button_pressed_flag) {
|
|
|
void app_main(void) {
|
|
|
static httpd_handle_t server;
|
|
|
static uint8_t button_pressed_flag = 0;
|
|
|
+ static uint8_t wifi_enabled_flag = 0;
|
|
|
static TaskHandle_t alarm_task_handle;
|
|
|
static alarm_parameters alarm_task_parameters = {
|
|
|
.button_pressed_flag = &button_pressed_flag,
|
|
@@ -64,7 +67,7 @@ void app_main(void) {
|
|
|
};
|
|
|
struct tm current_time;
|
|
|
|
|
|
- init_peripherals(&button_pressed_flag);
|
|
|
+ init_peripherals(&button_pressed_flag, &wifi_enabled_flag);
|
|
|
|
|
|
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, &server));
|
|
|
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, &server));
|
|
@@ -78,5 +81,6 @@ void app_main(void) {
|
|
|
|
|
|
xTaskCreate(display_update_task, "display_update_task", 2048, NULL, 8, NULL);
|
|
|
xTaskCreate(alarm_task, "alarm_task", 2048, (void*) &alarm_task_parameters, 7, NULL);
|
|
|
- xTaskCreate(cleanup_task, "cleanup_task", 2048, STORAGE_NAMESPACE, 8, NULL);
|
|
|
+ xTaskCreate(cleanup_task, "cleanup_task", 2048, (void*) STORAGE_NAMESPACE, 1, NULL);
|
|
|
+ xTaskCreate(wifi_management_task, "wifi_management_task", 2048, (void*) &wifi_enabled_flag, 1, NULL);
|
|
|
}
|