Files
iot_skeleton/esp32/main/heartbeat_task.cpp
2026-04-22 20:11:55 +03:00

31 lines
572 B
C++

#include "heartbeat_task.h"
extern "C" {
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "protocol.h"
#include <time.h>
}
static const char *TAG = "heartbeat";
static void heartbeat_task(void *arg)
{
while (1) {
if (protocol_is_connected()) {
time_t now;
time(&now);
protocol_send_event_hb((uint32_t)now);
}
vTaskDelay(pdMS_TO_TICKS(10000)); // 10 сек
}
}
void heartbeat_task_start()
{
xTaskCreate(heartbeat_task, "heartbeat", 4096, NULL, 5, NULL);
}