#include "system.h"

#include "esp_log.h"
#include "esp_system.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

static const char *TAG = "system";

void system_sleep(size_t secs)
{
    vTaskDelay((1000 * secs) / portTICK_PERIOD_MS);
}

size_t system_show_free_memory()
{
    size_t v = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
    ESP_LOGI(TAG, "heap_caps_free_size(MALLOC_CAP_DEFAULT) = %d", v);
    return v;
}

void reboot()
{
    fflush(stdout);
    esp_restart();
}