OTA task
This commit is contained in:
@@ -8,13 +8,16 @@ extern "C" {
|
||||
#include <time.h>
|
||||
}
|
||||
|
||||
static const char *TAG = "heartbeat";
|
||||
static const char* TAG = "heartbeat";
|
||||
|
||||
static void heartbeat_task(void *arg)
|
||||
static TaskHandle_t heartbeat_task_handle = nullptr;
|
||||
|
||||
static void heartbeat_task(void* arg)
|
||||
{
|
||||
while (1) {
|
||||
if (protocol_is_connected()) {
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (protocol_is_connected())
|
||||
{
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
||||
@@ -27,5 +30,17 @@ static void heartbeat_task(void *arg)
|
||||
|
||||
void heartbeat_task_start()
|
||||
{
|
||||
xTaskCreate(heartbeat_task, "heartbeat", 4096, NULL, 5, NULL);
|
||||
}
|
||||
if (heartbeat_task_handle == nullptr)
|
||||
{
|
||||
xTaskCreate(heartbeat_task, "heartbeat", 4096, nullptr, 5, &heartbeat_task_handle);
|
||||
}
|
||||
}
|
||||
|
||||
void heartbeat_task_stop()
|
||||
{
|
||||
if (heartbeat_task_handle != nullptr)
|
||||
{
|
||||
vTaskDelete(heartbeat_task_handle);
|
||||
heartbeat_task_handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user