OVMS3-idf/examples/protocols/websocket
Marius Vikhammer 15d39eded5 tcp_transport/ws_client: websockets now correctly handle messages longer than buffer
transport_ws can now be read multiple times in a row to read frames larger than the buffer.

Added reporting of total payload length and offset to the user in websocket_client.

Added local example test for long messages.

Closes IDF-1083
2020-02-27 08:56:43 +00:00
..
main tcp_transport/ws_client: websockets now correctly handle messages longer than buffer 2020-02-27 08:56:43 +00:00
CMakeLists.txt websocket: backport of websocket client to v3.2 2020-02-27 08:56:43 +00:00
example_test.py tcp_transport/ws_client: websockets now correctly handle messages longer than buffer 2020-02-27 08:56:43 +00:00
Makefile websocket: backport of websocket client to v3.2 2020-02-27 08:56:43 +00:00
README.md tcp_transport/ws_client: websockets now correctly handle messages longer than buffer 2020-02-27 08:56:43 +00:00
sdkconfig.ci websocket: backport of websocket client to v3.2 2020-02-27 08:56:43 +00:00

Websocket Sample application

(See the README.md file in the upper level 'examples' directory for more information about examples.) This example will shows how to set up and communicate over a websocket.

How to Use Example

Hardware Required

This example can be executed on any ESP32 board, the only required interface is WiFi and connection to internet or a local server.

Configure the project

make menuconfig
  • Set serial port under Serial Flasher Options.

  • Set ssid and password for the board to connect to AP.

Build and Flash

Build the project and flash it to the board, then run monitor tool to view serial output:

make -j4 flash monitor

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

I (4482) WEBSOCKET: Connecting to ws://echo.websocket.org...
I (5012) WEBSOCKET: WEBSOCKET_EVENT_CONNECTED
I (5492) WEBSOCKET: Sending hello 0000
I (6052) WEBSOCKET: WEBSOCKET_EVENT_DATA
W (6052) WEBSOCKET: Received=hello 0000

I (6492) WEBSOCKET: Sending hello 0001
I (7052) WEBSOCKET: WEBSOCKET_EVENT_DATA
W (7052) WEBSOCKET: Received=hello 0001

I (7492) WEBSOCKET: Sending hello 0002
I (8082) WEBSOCKET: WEBSOCKET_EVENT_DATA
W (8082) WEBSOCKET: Received=hello 0002

I (8492) WEBSOCKET: Sending hello 0003
I (9152) WEBSOCKET: WEBSOCKET_EVENT_DATA
W (9162) WEBSOCKET: Received=hello 0003