Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Return correct error code for esp_websocket_client_send_with_opcode (IDFGH-11291) #393

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/esp_websocket_client/esp_websocket_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ int esp_websocket_client_send_fin(esp_websocket_client_handle_t client, TickType

int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client, ws_transport_opcodes_t opcode, const uint8_t *data, int len, TickType_t timeout)
{
int error = ESP_OK;
if (client == NULL || len < 0 || (data == NULL && len > 0)) {
ESP_LOGE(TAG, "Invalid arguments");
return ESP_FAIL;
Expand All @@ -1212,24 +1213,28 @@ int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client,

if (!esp_websocket_client_is_connected(client)) {
ESP_LOGE(TAG, "Websocket client is not connected");
error = ESP_FAIL;
goto unlock_and_return;
}

if (client->transport == NULL) {
ESP_LOGE(TAG, "Invalid transport");
error = ESP_FAIL;
goto unlock_and_return;
}
if (esp_websocket_new_buf(client, true) != ESP_OK) {
ESP_LOGE(TAG, "Failed to setup tx buffer");
error = ESP_FAIL;
goto unlock_and_return;
}
if (esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout) != true) {
ESP_LOGE(TAG, "Failed to send the buffer");
error = ESP_FAIL;
goto unlock_and_return;
}
unlock_and_return:
xSemaphoreGiveRecursive(client->lock);
return ESP_FAIL;
return error;
}

bool esp_websocket_client_is_connected(esp_websocket_client_handle_t client)
Expand Down