ugly hack
This commit is contained in:
1 parent
d17091651f
commit
006404fccf
6 files changed
+135
-89
No files matched your search
+14
-32
@@ -19,9 +19,7 @@ extern "C" {
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
#include "filesys.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiClient.h>
|
||||
#include "httpserver.h"
|
||||
|
||||
#include "index.html.gz.h"
|
||||
#include "style.css.gz.h"
|
||||
@@ -40,40 +38,29 @@ void setup_pwm_pca9685();
|
||||
void handleNotFound();
|
||||
|
||||
const int led = 13;
|
||||
ESP8266WebServer server(80);
|
||||
PCA9685 pwmController;
|
||||
|
||||
HTTPServer httpServer(80, "/", handleNotFound);
|
||||
void handleNotFound() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += server.uri();
|
||||
message += httpServer.server.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += (httpServer.server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += server.args();
|
||||
message += httpServer.server.args();
|
||||
message += "\n";
|
||||
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||
for (uint8_t i = 0; i < httpServer.server.args(); i++) {
|
||||
message += " " + httpServer.server.argName(i) + ": " + httpServer.server.arg(i) + "\n";
|
||||
}
|
||||
server.send(404, "text/plain", message);
|
||||
|
||||
httpServer.server.send(404, "text/plain", message);
|
||||
}
|
||||
|
||||
PCA9685 pwmController;
|
||||
|
||||
void setup_webserver() {
|
||||
// //experimental, see doku.md
|
||||
// server.serveStatic("/compressed", LittleFS, "/compressed.html.gzip");
|
||||
|
||||
server.serveStatic("", LittleFS, "/index.html");
|
||||
server.serveStatic("/", LittleFS, "/index.html");
|
||||
server.serveStatic("/#", LittleFS, "/index.html");
|
||||
server.serveStatic("/style.css", LittleFS, "/style.css");
|
||||
server.serveStatic("/index.js", LittleFS, "/index.js");
|
||||
server.serveStatic("/favicon.png", LittleFS, "/favicon.png");
|
||||
server.onNotFound(handleNotFound);
|
||||
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void setup_ota() {
|
||||
ArduinoOTA.setPort(8266);
|
||||
@@ -153,11 +140,6 @@ void setup() {
|
||||
|
||||
Serial.println(F("Booting ...."));
|
||||
|
||||
mount_fs();
|
||||
//format_fs();
|
||||
ls("/");
|
||||
ls("http/");
|
||||
// readFile("/test.txt");
|
||||
|
||||
pinMode(NODEMCU_LED, OUTPUT);
|
||||
pinMode(ESP12_LED, OUTPUT);
|
||||
@@ -183,7 +165,7 @@ void setup() {
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
os_timer_setfn(&timer1, timer_callback, &timer_arg);
|
||||
os_timer_arm(&timer1, 1000, true);
|
||||
os_timer_arm(&timer1, 1, true);
|
||||
|
||||
Serial.println("Ready");
|
||||
Serial.print("IP address: ");
|
||||
@@ -191,7 +173,7 @@ void setup() {
|
||||
|
||||
setup_ota();
|
||||
|
||||
setup_webserver();
|
||||
httpServer.start();
|
||||
Serial.println("HTTP server started !");
|
||||
|
||||
setup_pwm_pca9685();
|
||||
@@ -295,11 +277,11 @@ void loop() {
|
||||
direction = 0;
|
||||
}
|
||||
TIMEIF_US(ArduinoOTA.handle(), 1000, "OTA");
|
||||
TIMEIF_US(server.handleClient(), 1000, "HTTP");
|
||||
TIMEIF_US(httpServer.handleClient(), 1000, "HTTP");
|
||||
|
||||
if(flag) {
|
||||
flag = 0;
|
||||
ledsequence(direction, onoff, 4);
|
||||
Serial.printf("[%lu] interrupt\n\r", millis());
|
||||
//Serial.printf("[%lu] interrupt\n\r", millis());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user