const esp_websocket_client_config_t ws_cfg = {
.uri = "wss://echo.websocket.org",
@@ -278,7 +197,7 @@ In case a host operating system has openssl and sed pa
This command will extract the second certificate in the chain and save it as a pem-file.
-Subprotocol
+Subprotocol
The subprotocol field in the config struct can be used to request a subprotocol
const esp_websocket_client_config_t ws_cfg = {
.uri = "ws://websocket.org",
@@ -294,7 +213,7 @@ In case a host operating system has openssl and sed pa
-Events
+Events
WEBSOCKET_EVENT_CONNECTED: The client has successfully established a connection to the server. The client is now ready to send and receive data. Contains no event data.
WEBSOCKET_EVENT_DISCONNECTED: The client has aborted the connection due to the transport layer failing to read data, e.g. because the server is unavailable. Contains no event data.
@@ -307,16 +226,16 @@ In case a host operating system has openssl and sed pa
-Limitations and Known Issues
+Limitations and Known Issues
-Application Example
-A simple WebSocket example that uses esp_websocket_client to establish a websocket connection and send/receive data with the websocket.org server can be found here: example .
+Application Example
+A simple WebSocket example that uses esp_websocket_client to establish a websocket connection and send/receive data with the websocket.org server can be found here: example .
-Sending Text Data
+Sending Text Data
The WebSocket client supports sending data as a text data frame, which informs the application layer that the payload data is text data encoded as UTF-8. Example:
esp_websocket_client_send_text(client, data, len, portMAX_DELAY);
@@ -324,18 +243,18 @@ In case a host operating system has
openssl and
sed pa
-API Reference
+API Reference
-Functions
+Functions
-
-esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_client_config_t *config)
+esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_client_config_t *config)
Start a Websocket session This function must be the first function to call, and it returns a esp_websocket_client_handle_t that you must use as input to other functions in the interface. This call MUST have a corresponding call to esp_websocket_client_destroy when the operation is complete.
- Parameters:
@@ -353,7 +272,7 @@ In case a host operating system has openssl and sed pa
-
-esp_err_t esp_websocket_client_set_uri(esp_websocket_client_handle_t client, const char *uri)
+esp_err_t esp_websocket_client_set_uri(esp_websocket_client_handle_t client, const char *uri)
Set URL for client, when performing this behavior, the options in the URL will replace the old ones Must stop the WebSocket client before set URI if the client has been connected.
- Parameters:
@@ -370,7 +289,7 @@ In case a host operating system has openssl and sed pa
-
-esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client)
+esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client)
Open the WebSocket connection.
- Parameters:
@@ -384,7 +303,7 @@ In case a host operating system has openssl and sed pa
-
-esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client)
+esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client)
Stops the WebSocket connection without websocket closing handshake.
This API stops ws client and closes TCP connection directly without sending close frames. It is a good practice to close the connection in a clean way using esp_websocket_client_close().
Notes:
@@ -403,7 +322,7 @@ In case a host operating system has openssl and sed pa
-
-esp_err_t esp_websocket_client_destroy(esp_websocket_client_handle_t client)
+esp_err_t esp_websocket_client_destroy(esp_websocket_client_handle_t client)
Destroy the WebSocket connection and free all resources. This function must be the last function to call for an session. It is the opposite of the esp_websocket_client_init function and must be called with the same handle as input that a esp_websocket_client_init call returned. This might close all connections this handle has used.
Notes:
-Structures
+Structures
-
-struct esp_websocket_event_data_t
+struct esp_websocket_event_data_t
Websocket event data.
Public Members
-
-const char *data_ptr
+const char *data_ptr
Data pointer
-
-int data_len
+int data_len
Data length
-
-bool fin
+bool fin
Fin flag
-
-uint8_t op_code
+uint8_t op_code
Received opcode
-
-esp_websocket_client_handle_t client
+esp_websocket_client_handle_t client
esp_websocket_client_handle_t context
-
-void *user_context
+void *user_context
user_data context, from esp_websocket_client_config_t user_data
-
-int payload_len
+int payload_len
Total payload length, payloads exceeding buffer will be posted through multiple events
-
-int payload_offset
+int payload_offset
Actual offset for the data associated with this event
@@ -648,205 +567,205 @@ In case a host operating system has
openssl and
sed pa
-
-struct esp_websocket_client_config_t
+struct esp_websocket_client_config_t
Websocket client setup configuration.
Public Members
-
-const char *uri
+const char *uri
Websocket URI, the information on the URI can be overrides the other fields below, if any
-
-const char *host
+const char *host
Domain or IP as string
-
-int port
+int port
Port to connect, default depend on esp_websocket_transport_t (80 or 443)
-
-const char *username
+const char *username
Using for Http authentication - Not supported for now
-
-const char *password
+const char *password
Using for Http authentication - Not supported for now
-
-const char *path
+const char *path
HTTP Path, if not set, default is /
-
-bool disable_auto_reconnect
+bool disable_auto_reconnect
Disable the automatic reconnect function when disconnected
-
-void *user_context
+void *user_context
HTTP user data context
-
-int task_prio
+int task_prio
Websocket task priority
-
-int task_stack
+int task_stack
Websocket task stack
-
-int buffer_size
+int buffer_size
Websocket buffer size
-
-const char *cert_pem
+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.
-
-size_t cert_len
+size_t cert_len
Length of the buffer pointed to by cert_pem. May be 0 for null-terminated pem
-
-const char *client_cert
+const char *client_cert
Pointer to certificate data in PEM or DER format for SSL mutual authentication, default is NULL, not required if mutual authentication is not needed. If it is not NULL, also client_key
has to be provided. PEM-format must have a terminating NULL-character. DER-format requires the length to be passed in client_cert_len.
-
-size_t client_cert_len
+size_t client_cert_len
Length of the buffer pointed to by client_cert. May be 0 for null-terminated pem
-
-const char *client_key
+const char *client_key
Pointer to private key data in PEM or DER format for SSL mutual authentication, default is NULL, not required if mutual authentication is not needed. If it is not NULL, also client_cert
has to be provided. PEM-format must have a terminating NULL-character. DER-format requires the length to be passed in client_key_len
-
-size_t client_key_len
+size_t client_key_len
Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem
-
-esp_websocket_transport_t transport
+esp_websocket_transport_t transport
Websocket transport type, see `esp_websocket_transport_t
-
-const char *subprotocol
+const char *subprotocol
Websocket subprotocol
-
-const char *user_agent
+const char *user_agent
Websocket user-agent
+const char *headers
Websocket additional headers
-
-int pingpong_timeout_sec
+int pingpong_timeout_sec
Period before connection is aborted due to no PONGs received
-
-bool disable_pingpong_discon
+bool disable_pingpong_discon
Disable auto-disconnect due to no PONG received within pingpong_timeout_sec
-
-bool use_global_ca_store
+bool use_global_ca_store
Use a global ca_store for all the connections in which this bool is set.
-
-bool skip_cert_common_name_check
+bool skip_cert_common_name_check
Skip any validation of server certificate CN field
-
-bool keep_alive_enable
+bool keep_alive_enable
Enable keep-alive timeout
-
-int keep_alive_idle
+int keep_alive_idle
Keep-alive idle time. Default is 5 (second)
-
-int keep_alive_interval
+int keep_alive_interval
Keep-alive interval time. Default is 5 (second)
-
-int keep_alive_count
+int keep_alive_count
Keep-alive packet retry send count. Default is 3 counts
-
-int reconnect_timeout_ms
+int reconnect_timeout_ms
Reconnect after this value in miliseconds if disable_auto_reconnect is not enabled (defaults to 10s)
-
-int network_timeout_ms
+int network_timeout_ms
Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s)
-
-size_t ping_interval_sec
+size_t ping_interval_sec
Websocket ping interval, defaults to 10 seconds if not set
-
-struct ifreq *if_name
+struct ifreq *if_name
The name of interface for data to go through. Use the default interface without setting
@@ -855,82 +774,82 @@ In case a host operating system has
openssl and
sed pa
-Type Definitions
+Type Definitions
-
-typedef struct esp_websocket_client *esp_websocket_client_handle_t
+typedef struct esp_websocket_client *esp_websocket_client_handle_t
-Enumerations
+Enumerations
-
-enum esp_websocket_event_id_t
+enum esp_websocket_event_id_t
Websocket Client events id.
Values:
-
-enumerator WEBSOCKET_EVENT_ANY
+enumerator WEBSOCKET_EVENT_ANY
-
-enumerator WEBSOCKET_EVENT_ERROR
+enumerator WEBSOCKET_EVENT_ERROR
This event occurs when there are any errors during execution
-
-enumerator WEBSOCKET_EVENT_CONNECTED
+enumerator WEBSOCKET_EVENT_CONNECTED
Once the Websocket has been connected to the server, no data exchange has been performed
-
-enumerator WEBSOCKET_EVENT_DISCONNECTED
+enumerator WEBSOCKET_EVENT_DISCONNECTED
The connection has been disconnected
-
-enumerator WEBSOCKET_EVENT_DATA
+enumerator WEBSOCKET_EVENT_DATA
When receiving data from the server, possibly multiple portions of the packet
-
-enumerator WEBSOCKET_EVENT_CLOSED
+enumerator WEBSOCKET_EVENT_CLOSED
The connection has been closed cleanly
-
-enumerator WEBSOCKET_EVENT_MAX
+enumerator WEBSOCKET_EVENT_MAX
-
-enum esp_websocket_transport_t
+enum esp_websocket_transport_t
Websocket Client transport.
Values:
-
-enumerator WEBSOCKET_TRANSPORT_UNKNOWN
+enumerator WEBSOCKET_TRANSPORT_UNKNOWN
Transport unknown
-
-enumerator WEBSOCKET_TRANSPORT_OVER_TCP
+enumerator WEBSOCKET_TRANSPORT_OVER_TCP
Transport over tcp
-
-enumerator WEBSOCKET_TRANSPORT_OVER_SSL
+enumerator WEBSOCKET_TRANSPORT_OVER_SSL
Transport over ssl
@@ -942,27 +861,21 @@ In case a host operating system has openssl and sed pa
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
-
+
@@ -37,45 +27,27 @@
-
-
-
-
-