From 9dde491bcb9aa3451bb09e773bc86990316c2786 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sat, 2 Mar 2024 22:49:10 +0100 Subject: [PATCH] Begin progress on web gui stub. Make AP-only for now and form post. Would bluetooth from a webapp be better? --- ino/contact_printer/WebGUI.cpp | 26 ++++++++++++++++++++++++++ ino/contact_printer/WebGUI.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 ino/contact_printer/WebGUI.cpp create mode 100644 ino/contact_printer/WebGUI.h diff --git a/ino/contact_printer/WebGUI.cpp b/ino/contact_printer/WebGUI.cpp new file mode 100644 index 0000000..ffe70d4 --- /dev/null +++ b/ino/contact_printer/WebGUI.cpp @@ -0,0 +1,26 @@ +#include "WebGUI.h" + +void WebGUI::Setup () { + +} + +void WebGUI::Loop () { + +} + +void WebGUI::HandleNotFound() { + String res = "404 Not Found\n\n"; + res += "URI: "; + res += server.uri(); + res += "\nMethod: "; + res += (server.method() == HTTP_GET) ? "GET" : "POST"; + res += "\nArguments: "; + res += server.args(); + res += "\n"; + + for (uint8_t i = 0; i < server.args(); i++) { + res += " " + server.argName(i) + ": " + server.arg(i) + "\n"; + } + + server.send(404, "text/plain", res); +} \ No newline at end of file diff --git a/ino/contact_printer/WebGUI.h b/ino/contact_printer/WebGUI.h new file mode 100644 index 0000000..4346a79 --- /dev/null +++ b/ino/contact_printer/WebGUI.h @@ -0,0 +1,32 @@ +#ifndef WEBGUI +#define WEBGUI + +#include +#include +#include +#include +#include +#include +#include + +class WebGUI { + private: + const char *AP_SSID = "contact_printer"; + const char *DEFAULT_PASSWORD = "contact_printer"; + const char *MDNS_NAME = "contact_printer"; + //IPAddress wifiIP; + //String IP; + //DynamicJsonDocument postJSON(1024); + WebServer server(80); + + protected: + static void HandleNotFound(); + + public: + WebGUI(); + void Setup(); + void Loop(); + +}; + +#endif \ No newline at end of file