HB, OTA etc
This commit is contained in:
31
esp32/main/heartbeat_task.cpp
Normal file
31
esp32/main/heartbeat_task.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user