I would like to know if it is possible to get the TaskHandle_t from the httpd task, if it is only a single task.
I created a centralized task ( "gatekeeper task" ) to access shared data, like (set() and get() functions, all encapsulated functions.
I want to take advantage of this same task to implement some way of notifying/routing information that has changed.
So, i need httpd TaskHandle_t, but I'm open to other suggestions.
I would like to do something like this:
Code: Select all
typedef struct
{
server_state_t data;
my_server_state_command_t cmd_id;
TaskHandle_t task_handle;
}mss_task_dev_t;
static QueueHandle_t mss_data_queue = NULL;
mss_data_queue = xQueueCreate( 4, sizeof(mss_task_dev_t) );
// gatekeeper task call this function.
static void task_send_notification_to_interested_tasks(const mss_task_dev_t* mss_msg)
{
ESP_LOGI(MY_SERVER_STATE_TAG, LOG_USER1("[%s:] Notify Tasks.", __func__));
// Message came from the server ?
if (mss_msg->task_handle == httpd_task)
{
// test if any data has changed, just notify if the data has changed.
// notify hardware task.
// notify ui task.
// notify all client connected to the server, except the one that sent the information (I need to see how to identify this yet).
}
// Message came from the gui ?
if (mss_msg->task_handle == gui_task)
{
// test if any data has changed, just notify if the data has changed.
// notify hardware task.
// update_clients_state(); // notify all clients connected to the server.
}
}
// Lib interface
void set_server_state(server_state_t st)
{
mss_task_dev_t var;
memset(&var, 0, sizeof(mss_task_dev_t));
var.cmd_id = CMD_SET_ALL_STRUCT;
var.data = st;
var.task_handle = xTaskGetCurrentTaskHandle(); // handle of the task that called this function.
BaseType_t ret = xQueueSend(mss_data_queue, (void *)&var, 0);
if (ret == errQUEUE_FULL)
{
ESP_LOGW(MY_SERVER_STATE_TAG, "[%s] Queue [mss_data_queue] full, cannot send command to task [%s], returning without blocking the task.", __func__, pcTaskGetName(my_server_state_task_Handle) );
return;
}
}
Thank's.