change read sensors, trigger via web possible, modify js to fetch with HTTP_POST
This commit is contained in:
@@ -31,20 +31,33 @@ auto HTTPServer::start() -> bool {
|
||||
// add static root file handler for http
|
||||
this->serveStatic("/", LittleFS, "/");
|
||||
this->begin();
|
||||
Serial.printf("Server active on Port 80 !\n\r");
|
||||
logf("Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTTPServer::start_apps() {
|
||||
this->on("/action=s_oben", [this]() {
|
||||
// treppe->setsensor("oben")
|
||||
this->on("/action", HTTP_POST, [this]() {
|
||||
if (args()) {
|
||||
logf("%s=%s\n", argName(0).c_str(), arg(0).c_str());
|
||||
|
||||
if (argName(0).equals("control")) {
|
||||
if (arg(0).equals("s_oben")) {
|
||||
treppe->overwrite_sensors(true, false);
|
||||
logt("control => s_oben !\n");
|
||||
}
|
||||
else if (arg(0).equals("s_unten")) {
|
||||
treppe->overwrite_sensors(false, true);
|
||||
logt("control => s_unten !\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
send(200, "text/plain", "accepted");
|
||||
});
|
||||
|
||||
this->on("/update", HTTP_POST, [this]() {
|
||||
if (args()) {
|
||||
for (int i = 0; i < args() - 1; i++) {
|
||||
Serial.printf("%s=%s\n", argName(i).c_str(), arg(i).c_str());
|
||||
logf("%s=%s\n", argName(i).c_str(), arg(i).c_str());
|
||||
|
||||
if (argName(i).equals("range_act_pwm")) {
|
||||
treppe->set_active_pwm(arg(i).toInt(), VORGABE_PROZENT);
|
||||
@@ -73,7 +86,7 @@ void HTTPServer::start_apps() {
|
||||
});
|
||||
|
||||
this->on("/terminal", HTTP_POST, [this]() {
|
||||
// Serial.printf("got /terminal\n");
|
||||
// logf("got /terminal\n");
|
||||
if (tbuf_head) {
|
||||
send(200, "text/plain", tbuf);
|
||||
tbuf_head = 0;
|
||||
|
||||
Reference in New Issue
Block a user