Hi, what criteria do you follow to create tasks?, I would not want to create a system too complex, My idea is an application were a microcontroller gets GPS data and tx/rx MQTT messages using a cellular/gnss module.
GPS: data is read every second (task)
cellular module:
MQTT tx: every 10 minutes (task)
MQTT rx: random (task ?)
the MQTT rx is user dependent, when the user wants he sends data from a server, so is not clear for me if I should create a task for this action that is not periodic, used only a few times in the day and could waste system resources and have a task blocked most of the time seems like an useless task, so these are my options:
task_read_gps()
{
//do something
vTaskDelay(pdMS_TO_TICKS(1000));//blocked for 1 sec
}
task_check_rx_mqtt()
{
//do something
vTaskDelay(pdMS_TO_TICKS(1000));//blocked for 1 sec
}
task_tx_mqtt()
{
//do something
vTaskDelay(pdMS_TO_TICKS(600000));//blocked for 10 min
}
or
task_read_gps()
{
//do something
vTaskDelay(pdMS_TO_TICKS(1000));//blocked for 1 sec
}
task_cellular()
{
if(check_rx_mqtt())
{
//do something
}
else if ((HalGetTick() - timestamp) >= 600000)//waits for 10 min
{
timestamp = HalGetTick();
tx_mqtt();
}
vTaskDelay(pdMS_TO_TICKS(1000));//blocked for 1 sec
}
what would be the best choice?