-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
An example showing the ESP32 as a | ||
WebSocket server. | ||
Demonstrates: | ||
the ESP32 as a WiFi Access Point, | ||
embedding files (html, js, etc.) for a server, | ||
WebSockets, | ||
LED control. | ||
All example options are in "Example Options" | ||
All WebSocket Server options are in: | ||
Component config ---> WebSocket Server | ||
Connect an LED to pin 2 (default) | ||
Connect to the Access Point, | ||
default name: "ESP32 Test" | ||
password: "hello world" | ||
go to 192.168.4.1 in a browser | ||
Note that there are two regular server tasks. | ||
The first gets incoming clients, then passes them | ||
to a queue for the second task to actually handle. | ||
I found that connections were dropped much less frequently | ||
this way, especially when handling large requests. It | ||
does use more RAM though. | ||
*/ | ||
|
||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "freertos/queue.h" | ||
|
||
#include "lwip/api.h" | ||
|
||
#include "esp_wifi.h" | ||
#include "esp_log.h" | ||
#include "esp_event.h" | ||
#include "nvs_flash.h" | ||
#include "driver/ledc.h" | ||
|
||
#include "string.h" | ||
|
||
#include "websocket_server.h" | ||
|
||
#include "server.h" | ||
|
||
|
||
|
||
|
||
|
||
|
||
void app_main() { | ||
|
||
|
||
tcpip_adapter_init(); | ||
nvs_flash_init(); | ||
wifi_setup(); | ||
|
||
ws_server_start(); | ||
xTaskCreate(&server_task,"server_task",3000,NULL,9,NULL); | ||
xTaskCreate(&server_handle_task,"server_handle_task",4000,NULL,6,NULL); | ||
|
||
} |