mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-07 01:13:28 +02:00
feat: send beacon and reboot buttons
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "web_utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
extern uint32_t lastBeaconTx;
|
||||
|
||||
extern const char web_index_html[] asm("_binary_data_embed_index_html_gz_start");
|
||||
extern const char web_index_html_end[] asm("_binary_data_embed_index_html_gz_end");
|
||||
@@ -163,6 +164,21 @@ namespace WEB_Utils {
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
void handleAction(AsyncWebServerRequest *request) {
|
||||
String type = request->getParam("type", false)->value();
|
||||
|
||||
if (type == "send-beacon") {
|
||||
Serial.println(lastBeaconTx);
|
||||
lastBeaconTx = 0;
|
||||
|
||||
request->send(200, "text/plain", "Beacon will be sent in a while");
|
||||
} else if (type == "reboot") {
|
||||
ESP.restart();
|
||||
} else {
|
||||
request->send(404, "text/plain", "Not Found");
|
||||
}
|
||||
}
|
||||
|
||||
void handleStyle(AsyncWebServerRequest *request) {
|
||||
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", (const uint8_t*)web_style_css, web_style_css_len);
|
||||
response->addHeader("Content-Encoding", "gzip");
|
||||
@@ -194,6 +210,7 @@ namespace WEB_Utils {
|
||||
server.on("/status", HTTP_GET, handleStatus);
|
||||
server.on("/configuration.json", HTTP_GET, handleReadConfiguration);
|
||||
server.on("/configuration.json", HTTP_POST, handleWriteConfiguration);
|
||||
server.on("/action", HTTP_POST, handleAction);
|
||||
server.on("/style.css", HTTP_GET, handleStyle);
|
||||
server.on("/script.js", HTTP_GET, handleScript);
|
||||
server.on("/bootstrap.css", HTTP_GET, handleBootstrapStyle);
|
||||
|
||||
Reference in New Issue
Block a user