From 1501c74c461aa44ecd6d93dbcd3f679a539defdd Mon Sep 17 00:00:00 2001 From: richonguzman Date: Fri, 15 Sep 2023 18:23:49 -0300 Subject: [PATCH] first try --- data/igate_conf.json | 2 +- src/LoRa_APRS_iGate.cpp | 2 +- src/utils.cpp | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index 8c4d27f..68f5b45 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,6 +1,6 @@ { "callsign": "CD2RXU-11", - "stationMode": 3, + "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", "wifi": { "AP": [ diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 6b616cb..7bae289 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.09.05"; +String versionDate = "2023.09.15"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; diff --git a/src/utils.cpp b/src/utils.cpp index 8496ef8..e767e9b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -43,10 +43,14 @@ extern String versionDate; extern uint32_t lastWiFiCheck; extern bool WiFiConnect; - +const char* PARAM_MESSAGE = "message"; namespace Utils { +void notFound(AsyncWebServerRequest *request) { + request->send(404, "text/plain", "Not found"); +} + void processStatus() { String status = Config.callsign + ">APLRG1"; if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { @@ -272,12 +276,28 @@ void startServer() { request->send(SPIFFS, "/test_info_1.html", "text/html");//"application/json"); }); + server.on("/test2", HTTP_GET, [](AsyncWebServerRequest *request) { + request->send(SPIFFS, "/test1.html", "text/html"); + }); + if (Config.ota.username != "" && Config.ota.password != "") { AsyncElegantOTA.begin(&server, Config.ota.username.c_str(), Config.ota.password.c_str()); } else { AsyncElegantOTA.begin(&server); } + server.on("/process_form.php", HTTP_POST, [](AsyncWebServerRequest *request){ + String message; + if (request->hasParam(PARAM_MESSAGE, true)) { + message = request->getParam(PARAM_MESSAGE, true)->value(); + } else { + message = "No message sent"; + } + request->send(200, "text/plain", "Hello, POST: " + message); + }); + + server.onNotFound(notFound); + server.serveStatic("/", SPIFFS, "/"); server.begin();