cleanup_task.c 657 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Helmut Pozimski <helmut@pozimski.eu>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0-only
  5. */
  6. #include <esp_log.h>
  7. #include <freertos/FreeRTOS.h>
  8. #include <freertos/event_groups.h>
  9. #include "storage.h"
  10. #include "ds3231.h"
  11. #define SECONDS_PER_DAY 86400
  12. #define TAG "cleanup-task"
  13. void cleanup_task(void *pvParameters) {
  14. char* namespace = (char*) pvParameters;
  15. struct tm current_time;
  16. while (1) {
  17. ESP_LOGI(TAG, "Executing database cleanup");
  18. ds3231_read_date_time(&current_time);
  19. delete_outdated_entries(&current_time, namespace);
  20. vTaskDelay(SECONDS_PER_DAY * 1000 / portTICK_PERIOD_MS);
  21. }
  22. vTaskDelete( NULL );
  23. }