From b997490431be3991697e757ac25fe61a87f81660 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Thu, 13 Oct 2022 10:58:36 -0500 Subject: [PATCH] Use remote requests for controlling, rather than refreshing the page --- src/main.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1910f5b..e739065 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ const char* loginIndex = "" "" "" "
" @@ -134,6 +134,7 @@ const char* serverIndex = const char* movePage = "" "" + "Blind-POC" "" + "" "" "" - "" - "" - "" - "" + "" + "" + "" + "" "" ""; @@ -216,7 +224,7 @@ void setup(void) { server.send(200, "text/html", movePage); }); - server.on("/open", HTTP_GET, []() { + server.on("/open", HTTP_PUT, []() { server.sendHeader("Connection", "close"); Serial.println("Opening"); digitalWrite(motor1Pin1, LOW); @@ -227,7 +235,7 @@ void setup(void) { server.send(200, "text/html", movePage); }); - server.on("/close", HTTP_GET, []() { + server.on("/close", HTTP_PUT, []() { server.sendHeader("Connection", "close"); Serial.println("Closing"); digitalWrite(motor1Pin1, HIGH); @@ -239,7 +247,7 @@ void setup(void) { server.send(200, "text/html", movePage); }); - server.on("/fwd", HTTP_GET, []() { + server.on("/fwd", HTTP_PUT, []() { server.sendHeader("Connection", "close"); // Move the DC motor forward at maximum speed Serial.println("Moving Forward"); @@ -251,7 +259,7 @@ void setup(void) { server.send(200, "text/html", movePage); }); - server.on("/rev", HTTP_GET, []() { + server.on("/rev", HTTP_PUT, []() { server.sendHeader("Connection", "close"); Serial.println("Moving Backward"); digitalWrite(motor1Pin1, HIGH);
" - "
ESP32 Login Page
" + "
BLIND-Controller Login Page
" "
" "