Browse Source

Resource-change

master
Torsten Stauder 5 years ago
parent
commit
64174df932
  1. 8
      html/website.html
  2. 22
      src/main.cpp
  3. 21
      src/websiteMgmt.h

8
html/website.html

@ -4,10 +4,10 @@
<title>ESPuino-Konfiguration</title> <title>ESPuino-Konfiguration</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://raw.githubusercontent.com/biologist79/Tonuino-ESP32-I2S/master/css/bootstrap.min.css">
<script src="https://raw.githubusercontent.com/biologist79/Tonuino-ESP32-I2S/master/js/jquery.min.js"></script>
<script src="https://raw.githubusercontent.com/biologist79/Tonuino-ESP32-I2S/master/js/popper.min.js"></script>
<script src="https://raw.githubusercontent.com/biologist79/Tonuino-ESP32-I2S/master/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://ts-cs.de/tonuino/css/bootstrap.min.css">
<script src="https://ts-cs.de/tonuino/js/jquery.min.js"></script>
<script src="https://ts-cs.de/tonuino/js/popper.min.js"></script>
<script src="https://ts-cs.de/tonuino/js/bootstrap.min.js"></script>
</head> </head>
<body> <body>
<nav class="navbar navbar-expand-sm bg-primary navbar-dark"> <nav class="navbar navbar-expand-sm bg-primary navbar-dark">

22
src/main.cpp

@ -3028,28 +3028,6 @@ void setup() {
request->send_P(200, "text/html", mgtWebsite, templateProcessor); request->send_P(200, "text/html", mgtWebsite, templateProcessor);
}); });
// Send a GET request to <IP>/get?message=<message>
wServer.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
String message;
if (request->hasParam(PARAM_MESSAGE)) {
message = request->getParam(PARAM_MESSAGE)->value();
} else {
message = "No message sent";
}
request->send(200, "text/plain", "Hello, GET: " + String(playProperties.playMode) + String(currentRfidTagId));
});
// Send a POST request to <IP>/post with a form field message set to <message>
wServer.on("/post", 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);
});
wServer.onNotFound(notFound); wServer.onNotFound(notFound);
wServer.begin(); wServer.begin();
} }

21
src/websiteMgmt.h

@ -4,10 +4,10 @@ static const char mgtWebsite[] PROGMEM = "<!DOCTYPE html>\
<title>ESPuino-Konfiguration</title>\ <title>ESPuino-Konfiguration</title>\
<meta charset=\"utf-8\">\ <meta charset=\"utf-8\">\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\
<link rel=\"stylesheet\" href=\"https://ts-cs.de/css/bootstrap.min.css\">\
<script src=\"https://ts-cs.de/js/jquery.min.js\"></script>\
<script src=\"https://ts-cs.de/js/popper.min.js\"></script>\
<script src=\"https://ts-cs.de/js/bootstrap.min.js\"></script>\
<link rel=\"stylesheet\" href=\"https://ts-cs.de/tonuino/css/bootstrap.min.css\">\
<script src=\"https://ts-cs.de/tonuino/js/jquery.min.js\"></script>\
<script src=\"https://ts-cs.de/tonuino/js/popper.min.js\"></script>\
<script src=\"https://ts-cs.de/tonuino/js/bootstrap.min.js\"></script>\
</head>\ </head>\
<body>\ <body>\
<nav class=\"navbar navbar-expand-sm bg-primary navbar-dark\">\ <nav class=\"navbar navbar-expand-sm bg-primary navbar-dark\">\
@ -197,6 +197,19 @@ static const char mgtWebsite[] PROGMEM = "<!DOCTYPE html>\
});\ });\
\ \
let socket = new WebSocket(\"ws://%IPv4%/ws\");\ let socket = new WebSocket(\"ws://%IPv4%/ws\");\
\
socket.onclose = function(e) {\
console.log('Socket is closed. Reconnect will be attempted in 1 second.', e.reason);\
setTimeout(function() {\
connect();\
}, 5000);\
};\
\
socket.onerror = function(err) {\
console.error('Socket encountered error: ', err.message, 'Closing socket');\
ws.close();\
};\
\
socket.onmessage = function(event) {\ socket.onmessage = function(event) {\
console.log(event.data);\ console.log(event.data);\
var socketMsg = JSON.parse(event.data);\ var socketMsg = JSON.parse(event.data);\

Loading…
Cancel
Save