first try

This commit is contained in:
richonguzman 2023-09-15 18:23:49 -03:00
parent 0d99af0c57
commit 1501c74c46
3 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"callsign": "CD2RXU-11",
"stationMode": 3,
"stationMode": 2,
"iGateComment": "LoRa_APRS_iGate",
"wifi": {
"AP": [

View file

@ -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];

View file

@ -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();