mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-14 11:06:32 +02:00
websocket: make esp_websocket_client_send_with_opcode
a public API
This commit is contained in:
@ -10,7 +10,6 @@
|
|||||||
#include "esp_transport.h"
|
#include "esp_transport.h"
|
||||||
#include "esp_transport_tcp.h"
|
#include "esp_transport_tcp.h"
|
||||||
#include "esp_transport_ssl.h"
|
#include "esp_transport_ssl.h"
|
||||||
#include "esp_transport_ws.h"
|
|
||||||
/* using uri parser */
|
/* using uri parser */
|
||||||
#include "http_parser.h"
|
#include "http_parser.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
@ -693,8 +692,6 @@ static esp_err_t esp_websocket_client_recv(esp_websocket_client_handle_t client)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static 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);
|
|
||||||
|
|
||||||
static int esp_websocket_client_send_close(esp_websocket_client_handle_t client, int code, const char *additional_data, int total_len, TickType_t timeout);
|
static int esp_websocket_client_send_close(esp_websocket_client_handle_t client, int code, const char *additional_data, int total_len, TickType_t timeout);
|
||||||
|
|
||||||
static void esp_websocket_client_task(void *pv)
|
static void esp_websocket_client_task(void *pv)
|
||||||
@ -960,7 +957,7 @@ int esp_websocket_client_send_bin(esp_websocket_client_handle_t client, const ch
|
|||||||
return esp_websocket_client_send_with_opcode(client, WS_TRANSPORT_OPCODES_BINARY, (const uint8_t *)data, len, timeout);
|
return esp_websocket_client_send_with_opcode(client, WS_TRANSPORT_OPCODES_BINARY, (const uint8_t *)data, len, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static 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 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 need_write = len;
|
int need_write = len;
|
||||||
int wlen = 0, widx = 0;
|
int wlen = 0, widx = 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: "0.0.3"
|
version: "0.0.4"
|
||||||
description: esp websocket client
|
description: esp websocket client
|
||||||
dependencies:
|
dependencies:
|
||||||
idf:
|
idf:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_event.h"
|
#include "esp_event.h"
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include "esp_transport_ws.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -193,6 +194,21 @@ int esp_websocket_client_send_bin(esp_websocket_client_handle_t client, const ch
|
|||||||
*/
|
*/
|
||||||
int esp_websocket_client_send_text(esp_websocket_client_handle_t client, const char *data, int len, TickType_t timeout);
|
int esp_websocket_client_send_text(esp_websocket_client_handle_t client, const char *data, int len, TickType_t timeout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write opcode data to the WebSocket connection
|
||||||
|
*
|
||||||
|
* @param[in] client The client
|
||||||
|
* @param[in] opcode The opcode
|
||||||
|
* @param[in] data The data
|
||||||
|
* @param[in] len The length
|
||||||
|
* @param[in] timeout Write data timeout in RTOS ticks
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - Number of data was sent
|
||||||
|
* - (-1) if any errors
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Close the WebSocket connection in a clean way
|
* @brief Close the WebSocket connection in a clean way
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user