mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-25 16:27:15 +02:00
IDF release/v4.0 08219f3cf
This commit is contained in:
@ -22,7 +22,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct esp_transport_list_t* esp_transport_list_handle_t;
|
||||
typedef struct esp_transport_internal* esp_transport_list_handle_t;
|
||||
typedef struct esp_transport_item_t* esp_transport_handle_t;
|
||||
|
||||
typedef int (*connect_func)(esp_transport_handle_t t, const char *host, int port, int timeout_ms);
|
||||
@ -33,6 +33,8 @@ typedef int (*poll_func)(esp_transport_handle_t t, int timeout_ms);
|
||||
typedef int (*connect_async_func)(esp_transport_handle_t t, const char *host, int port, int timeout_ms);
|
||||
typedef esp_transport_handle_t (*payload_transfer_func)(esp_transport_handle_t);
|
||||
|
||||
typedef struct esp_tls_last_error* esp_tls_error_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Create transport list
|
||||
*
|
||||
@ -298,6 +300,21 @@ esp_err_t esp_transport_set_async_connect_func(esp_transport_handle_t t, connect
|
||||
*/
|
||||
esp_err_t esp_transport_set_parent_transport_func(esp_transport_handle_t t, payload_transfer_func _parent_transport);
|
||||
|
||||
/**
|
||||
* @brief Returns esp_tls error handle.
|
||||
* Warning: The returned pointer is valid only as long as esp_transport_handle_t exists. Once transport
|
||||
* handle gets destroyed, this value (esp_tls_error_handle_t) is freed automatically.
|
||||
*
|
||||
* @param[in] A transport handle
|
||||
*
|
||||
* @return
|
||||
* - valid pointer of esp_error_handle_t
|
||||
* - NULL if invalid transport handle
|
||||
*/
|
||||
esp_tls_error_handle_t esp_transport_get_error_handle(esp_transport_handle_t t);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define _ESP_TRANSPORT_SSL_H_
|
||||
|
||||
#include "esp_transport.h"
|
||||
#include "esp_tls.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -1,40 +0,0 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _ESP_TRANSPORT_UTILS_H_
|
||||
#define _ESP_TRANSPORT_UTILS_H_
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Convert milliseconds to timeval struct
|
||||
*
|
||||
* @param[in] timeout_ms The timeout milliseconds
|
||||
* @param[out] tv Timeval struct
|
||||
*/
|
||||
void esp_transport_utils_ms_to_timeval(int timeout_ms, struct timeval *tv);
|
||||
|
||||
|
||||
#define ESP_TRANSPORT_MEM_CHECK(TAG, a, action) if (!(a)) { \
|
||||
ESP_LOGE(TAG,"%s:%d (%s): %s", __FILE__, __LINE__, __FUNCTION__, "Memory exhausted"); \
|
||||
action; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _ESP_TRANSPORT_UTILS_H_ */
|
@ -13,6 +13,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum ws_transport_opcodes {
|
||||
WS_TRANSPORT_OPCODES_TEXT = 0x01,
|
||||
WS_TRANSPORT_OPCODES_BINARY = 0x02,
|
||||
WS_TRANSPORT_OPCODES_CLOSE = 0x08,
|
||||
WS_TRANSPORT_OPCODES_PING = 0x09,
|
||||
WS_TRANSPORT_OPCODES_PONG = 0x0a,
|
||||
} ws_transport_opcodes_t;
|
||||
|
||||
/**
|
||||
* @brief Create web socket transport
|
||||
@ -23,8 +30,56 @@ extern "C" {
|
||||
*/
|
||||
esp_transport_handle_t esp_transport_ws_init(esp_transport_handle_t parent_handle);
|
||||
|
||||
/**
|
||||
* @brief Set HTTP path to update protocol to websocket
|
||||
*
|
||||
* @param t websocket transport handle
|
||||
* @param path The HTTP Path
|
||||
*/
|
||||
void esp_transport_ws_set_path(esp_transport_handle_t t, const char *path);
|
||||
|
||||
/**
|
||||
* @brief Set websocket sub protocol header
|
||||
*
|
||||
* @param t websocket transport handle
|
||||
* @param sub_protocol Sub protocol string
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes
|
||||
*/
|
||||
esp_err_t esp_transport_ws_set_subprotocol(esp_transport_handle_t t, const char *sub_protocol);
|
||||
|
||||
/**
|
||||
* @brief Sends websocket raw message with custom opcode and payload
|
||||
*
|
||||
* Note that generic esp_transport_write for ws handle sends
|
||||
* binary massages by default if size is > 0 and
|
||||
* ping message if message size is set to 0.
|
||||
* This API is provided to support explicit messages with arbitrary opcode,
|
||||
* should it be PING, PONG or TEXT message with arbitrary data.
|
||||
*
|
||||
* @param[in] t Websocket transport handle
|
||||
* @param[in] opcode ws operation code
|
||||
* @param[in] buffer The buffer
|
||||
* @param[in] len The length
|
||||
* @param[in] timeout_ms The timeout milliseconds
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes was written
|
||||
* - (-1) if there are any errors, should check errno
|
||||
*/
|
||||
int esp_transport_ws_send_raw(esp_transport_handle_t t, ws_transport_opcodes_t opcode, const char *b, int len, int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Returns websocket op-code for last received data
|
||||
*
|
||||
* @param t websocket transport handle
|
||||
*
|
||||
* @return
|
||||
* - Received op-code as enum
|
||||
*/
|
||||
ws_transport_opcodes_t esp_transport_ws_get_read_opcode(esp_transport_handle_t t);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Reference in New Issue
Block a user