Skip to content

Commit 8e011f1

Browse files
committed
feat: espidf demo
1 parent 2955cb7 commit 8e011f1

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed

demo/esp32idf/.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch
6+
7+
src/credentials.h
8+
include/**/*.h
9+
CMakeLists.txt
10+
sdkconfig.idf*

demo/esp32idf/.vscode/extensions.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

demo/esp32idf/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Example platformio project
2+
3+
This folder contains a buildable minimalistic project. An example shows how to use the header file in a platformio project. It also works as a native ESP-IDF project.
4+
5+
It can be built on both web servers with the following command (if platformio is installed).
6+
7+
```bash
8+
~/.platformio/penv/bin/pio run -d ./demo/esp32idf
9+
```

demo/esp32idf/include/placeholder.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generated header files

demo/esp32idf/platformio.ini

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[env]
2+
platform = espressif32
3+
board = lolin_s3_mini
4+
framework = espidf
5+
6+
7+
8+
[env:idf]
9+
build_flags =
10+
-I include/_
11+
12+
[env:idf_E]
13+
build_flags =
14+
-I include/e
15+
16+
[env:idf_EC]
17+
build_flags =
18+
-I include/ec
19+
-D SVELTEESP32_ENABLE_ETAG
20+
21+
[env:idf_ECG]
22+
build_flags =
23+
-I include/ecg
24+
-D SVELTEESP32_ENABLE_ETAG
25+
26+
[env:idf_ECGC]
27+
build_flags =
28+
-I include/ecgc
29+
-D SVELTEESP32_ENABLE_ETAG
30+
-D SVELTEESP32_ENABLE_GZIP
31+
32+
[env:idf_EG]
33+
build_flags =
34+
-I include/eg
35+
36+
[env:idf_EGC]
37+
build_flags =
38+
-I include/egc
39+
-D SVELTEESP32_ENABLE_GZIP
40+
41+
[env:idf_G]
42+
build_flags =
43+
-I include/g
44+
45+
[env:idf_GC]
46+
build_flags =
47+
-I include/gc
48+
-D SVELTEESP32_ENABLE_GZIP

demo/esp32idf/src/main.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <esp_http_server.h>
2+
#include "svelteesp32espidf.h"
3+
4+
void start_http_server(void)
5+
{
6+
httpd_handle_t httpd;
7+
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
8+
config.max_uri_handlers = SVELTEESP32_COUNT + 99;
9+
10+
printf("Starting server on port: '%d'\n", config.server_port);
11+
12+
ESP_ERROR_CHECK(httpd_start(&httpd, &config));
13+
initSvelteStaticFiles(httpd);
14+
}
15+
16+
void app_main(void)
17+
{
18+
printf("Hello from ESP-IDF!\n");
19+
start_http_server();
20+
while (1)
21+
{
22+
vTaskDelay(1000 / portTICK_PERIOD_MS);
23+
}
24+
}

0 commit comments

Comments
 (0)