From 106dbaf9750cc457cb3f602667a18c7b1c588c25 Mon Sep 17 00:00:00 2001 From: RaffaelW Date: Thu, 31 Oct 2024 23:27:07 +0100 Subject: [PATCH 1/9] added callback for request body --- src/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 39c9646..97e4dcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,6 +87,17 @@ void setup() serializeJson(doc, jsonString); request->send(200, "application/json", jsonString); }); + + server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) + { + if (request->url() == "/config" && request->method() == HTTP_PUT) { + Serial.printf("[REQUEST]\t%s\r\n", (const char *)data); + + StaticJsonDocument<256> doc; + deserializeJson(doc, data); + request->send(200); + } }); + delay(1000); server.begin(); Serial.println("Server started!"); @@ -95,4 +106,4 @@ void setup() void loop() { artnet.parse(); // check if artnet packet has come and execute callback -} \ No newline at end of file +} From 13055b4b320c1b09a42ab347967aceb1e4d6aff4 Mon Sep 17 00:00:00 2001 From: RaffaelW Date: Sat, 2 Nov 2024 00:07:33 +0100 Subject: [PATCH 2/9] added settings.json to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 691739c..6e29f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +.vscode/settings.json \ No newline at end of file From 8fed61f78c77550fe7774b89c4bfdbd355db1087 Mon Sep 17 00:00:00 2001 From: RaffaelW Date: Sat, 2 Nov 2024 19:28:14 +0100 Subject: [PATCH 3/9] added handler for PUT /config --- data/index.html | 16 ++--- src/main.cpp | 27 +++----- src/routes/config.cpp | 147 ++++++++++++++++++++++++++++++++++++++++++ src/routes/config.h | 35 ++++++++++ 4 files changed, 198 insertions(+), 27 deletions(-) create mode 100644 src/routes/config.cpp create mode 100644 src/routes/config.h diff --git a/data/index.html b/data/index.html index 8011dbf..02c61e3 100644 --- a/data/index.html +++ b/data/index.html @@ -3,11 +3,7 @@ - Konfiguration - - - - + Test
@@ -64,7 +60,7 @@