Skip to content

Commit 1e73806

Browse files
fix(websocket): fix of return value for esp_websocket_client_send_with_opcode API
1 parent ccd74c6 commit 1e73806

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/esp_websocket_client/esp_websocket_client.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static esp_err_t esp_websocket_client_create_transport(esp_websocket_client_hand
545545
return ESP_OK;
546546
}
547547

548-
static bool esp_websocket_client_send_with_exact_opcode(esp_websocket_client_handle_t client, ws_transport_opcodes_t opcode, const uint8_t *data, int len, TickType_t timeout)
548+
static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_handle_t client, ws_transport_opcodes_t opcode, const uint8_t *data, int len, TickType_t timeout)
549549
{
550550
int ret = -1;
551551
int need_write = len;
@@ -571,14 +571,14 @@ static bool esp_websocket_client_send_with_exact_opcode(esp_websocket_client_han
571571
esp_websocket_client_error(client, "esp_transport_write() returned %d, errno=%d", ret, errno);
572572
}
573573
esp_websocket_client_abort_connection(client, WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT);
574-
return false;
574+
return ret;
575575
}
576576
opcode = 0;
577577
widx += wlen;
578578
need_write = len - widx;
579579
}
580580
esp_websocket_free_buf(client, true);
581-
return true;
581+
return widx;
582582
}
583583

584584
esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_client_config_t *config)
@@ -1227,9 +1227,9 @@ int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client,
12271227
ret = ESP_FAIL;
12281228
goto unlock_and_return;
12291229
}
1230-
if (esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout) != true) {
1230+
ret = esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout);
1231+
if (ret <= 0) {
12311232
ESP_LOGE(TAG, "Failed to send the buffer");
1232-
ret = ESP_FAIL;
12331233
goto unlock_and_return;
12341234
}
12351235
unlock_and_return:

0 commit comments

Comments
 (0)