Add task_name config option

This commit is contained in:
2023-02-08 15:52:03 +01:00
parent de1480a072
commit 1d6888445d
2 changed files with 6 additions and 1 deletions

View File

@ -63,6 +63,7 @@ const static int CLOSE_FRAME_SENT_BIT = BIT1; // Indicates that a close frame
ESP_EVENT_DEFINE_BASE(WEBSOCKET_EVENTS); ESP_EVENT_DEFINE_BASE(WEBSOCKET_EVENTS);
typedef struct { typedef struct {
const char *task_name;
int task_stack; int task_stack;
int task_prio; int task_prio;
char *uri; char *uri;
@ -236,6 +237,8 @@ static esp_err_t esp_websocket_client_set_config(esp_websocket_client_handle_t c
cfg->task_prio = WEBSOCKET_TASK_PRIORITY; cfg->task_prio = WEBSOCKET_TASK_PRIORITY;
} }
cfg->task_name = config->task_name;
cfg->task_stack = config->task_stack; cfg->task_stack = config->task_stack;
if (cfg->task_stack == 0) { if (cfg->task_stack == 0) {
cfg->task_stack = WEBSOCKET_TASK_STACK; cfg->task_stack = WEBSOCKET_TASK_STACK;
@ -869,7 +872,8 @@ esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client)
return ESP_FAIL; return ESP_FAIL;
} }
if (xTaskCreate(esp_websocket_client_task, "websocket_task", client->config->task_stack, client, client->config->task_prio, &client->task_handle) != pdTRUE) { if (xTaskCreate(esp_websocket_client_task, client->config->task_name ? client->config->task_name : "websocket_task",
client->config->task_stack, client, client->config->task_prio, &client->task_handle) != pdTRUE) {
ESP_LOGE(TAG, "Error create websocket task"); ESP_LOGE(TAG, "Error create websocket task");
return ESP_FAIL; return ESP_FAIL;
} }

View File

@ -74,6 +74,7 @@ typedef struct {
bool disable_auto_reconnect; /*!< Disable the automatic reconnect function when disconnected */ bool disable_auto_reconnect; /*!< Disable the automatic reconnect function when disconnected */
void *user_context; /*!< HTTP user data context */ void *user_context; /*!< HTTP user data context */
int task_prio; /*!< Websocket task priority */ int task_prio; /*!< Websocket task priority */
const char *task_name; /*!< Websocket task name */
int task_stack; /*!< Websocket task stack */ int task_stack; /*!< Websocket task stack */
int buffer_size; /*!< Websocket buffer size */ int buffer_size; /*!< Websocket buffer size */
const char *cert_pem; /*!< Pointer to certificate data in PEM or DER format for server verify (with SSL), default is NULL, not required to verify the server. PEM-format must have a terminating NULL-character. DER-format requires the length to be passed in cert_len. */ const char *cert_pem; /*!< Pointer to certificate data in PEM or DER format for server verify (with SSL), default is NULL, not required to verify the server. PEM-format must have a terminating NULL-character. DER-format requires the length to be passed in cert_len. */