mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
Merge branch 'feature/ws_client_support_cont_frames' into 'master'
transport_ws: Parse and expose frame fin flag Closes IDFGH-6767 and IDFGH-6737 See merge request espressif/esp-idf!17748
This commit is contained in:
@@ -126,6 +126,16 @@ esp_err_t esp_transport_ws_set_config(esp_transport_handle_t t, const esp_transp
|
|||||||
*/
|
*/
|
||||||
int esp_transport_ws_send_raw(esp_transport_handle_t t, ws_transport_opcodes_t opcode, const char *b, int len, int timeout_ms);
|
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 fin flag for last received data
|
||||||
|
*
|
||||||
|
* @param t websocket transport handle
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - Fin flag as a boolean
|
||||||
|
*/
|
||||||
|
bool esp_transport_ws_get_fin_flag(esp_transport_handle_t t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns websocket op-code for last received data
|
* @brief Returns websocket op-code for last received data
|
||||||
*
|
*
|
||||||
|
@@ -41,6 +41,7 @@ static const char *TAG = "TRANSPORT_WS";
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t opcode;
|
uint8_t opcode;
|
||||||
|
bool fin; /*!< Frame fin flag, for continuations */
|
||||||
char mask_key[4]; /*!< Mask key for this payload */
|
char mask_key[4]; /*!< Mask key for this payload */
|
||||||
int payload_len; /*!< Total length of the payload */
|
int payload_len; /*!< Total length of the payload */
|
||||||
int bytes_remaining; /*!< Bytes left to read of the payload */
|
int bytes_remaining; /*!< Bytes left to read of the payload */
|
||||||
@@ -382,6 +383,7 @@ static int ws_read_header(esp_transport_handle_t t, char *buffer, int len, int t
|
|||||||
return rlen;
|
return rlen;
|
||||||
}
|
}
|
||||||
ws->frame_state.header_received = true;
|
ws->frame_state.header_received = true;
|
||||||
|
ws->frame_state.fin = (*data_ptr & 0x80) != 0;
|
||||||
ws->frame_state.opcode = (*data_ptr & 0x0F);
|
ws->frame_state.opcode = (*data_ptr & 0x0F);
|
||||||
data_ptr ++;
|
data_ptr ++;
|
||||||
mask = ((*data_ptr >> 7) & 0x01);
|
mask = ((*data_ptr >> 7) & 0x01);
|
||||||
@@ -711,6 +713,12 @@ esp_err_t esp_transport_ws_set_config(esp_transport_handle_t t, const esp_transp
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool esp_transport_ws_get_fin_flag(esp_transport_handle_t t)
|
||||||
|
{
|
||||||
|
transport_ws_t *ws = esp_transport_get_context_data(t);
|
||||||
|
return ws->frame_state.fin;
|
||||||
|
}
|
||||||
|
|
||||||
ws_transport_opcodes_t esp_transport_ws_get_read_opcode(esp_transport_handle_t t)
|
ws_transport_opcodes_t esp_transport_ws_get_read_opcode(esp_transport_handle_t t)
|
||||||
{
|
{
|
||||||
transport_ws_t *ws = esp_transport_get_context_data(t);
|
transport_ws_t *ws = esp_transport_get_context_data(t);
|
||||||
|
Reference in New Issue
Block a user