Compare commits

...

2 Commits

9 changed files with 33 additions and 23 deletions

@ -48,5 +48,6 @@
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
},
"python.pythonPath": "C:\\Users\\simon\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
}

BIN
data/compress.html.gz Normal file

Binary file not shown.

@ -1,5 +1,4 @@
#ifndef __OTA_H
#define __OTA_H
#pragma once
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
@ -46,7 +45,4 @@ void ota_setup() {
});
ArduinoOTA.begin();
}
#endif // __OTA_H
}

@ -4,7 +4,7 @@
// deleteFile("/hello.txt");
// writeFile("/hello.txt", "Hello ");
// appendFile("/hello.txt", "World!\n\r");
// readFile("/hello.txt");
// printFile("/hello.txt");
// listDir("/");
FSInfo fsinfo;
@ -58,7 +58,12 @@ void ls(const char * dirname) {
Serial.println();
}
void readFile(const char * path) {
File open(const char * path) {
return LittleFS.open(path, "r");
}
void printFile(const char * path) {
Serial.printf("Reading file: %s\n\r", path);
File file = LittleFS.open(path, "r");

@ -1,16 +1,15 @@
#ifndef __FILESYS_H
#define __FILESYS_H
#pragma once
#include <LittleFS.h>
bool mount_fs();
bool format_fs();
File open(const char * path);
void ls(const char * dirname);
void readFile(const char * path);
void printFile(const char * path);
void writeFile(const char * path, const char * message);
void appendFile(const char * path, const char * message);
void renameFile(const char * path1, const char * path2);
void deleteFile(const char * path);
#endif // __FILESYS_H

@ -14,4 +14,4 @@ bool HTTPServer::addRootFileHandler() {
this->serveStatic("/favicon.png", LittleFS, "/favicon.png");
return true;
}
}

@ -1,10 +1,8 @@
#ifndef __HTTPSERVER_H
#define __HTTPSERVER_H
#pragma once
#include "filesys.h"
#include <ESP8266WebServer.h>
class HTTPServer : public ESP8266WebServer {
private:
const char* rootDir;
@ -35,6 +33,20 @@ public:
this->listRoot();
Serial.printf("\n\r");
// https://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11
on("/compress.html", [this]() {
File f = open("/compress.html.gz");
if (!f) {
Serial.println("Failed to open file for reading");
}
else
{
Serial.println("Streaming /compress.html.gz to client");
const String cont = "text/html";
streamFile(f, cont);
}
});
if( this->addRootFileHandler() ){
this->begin();
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");
@ -44,5 +56,3 @@ public:
return false;
}
};
#endif // __HTTPSERVER_H

@ -9,8 +9,8 @@ extern "C" {
#include "user_interface.h"
}
// OTA & WEB
#include "ota.h"
#include "wifi_credentials.h"
#include "ota.h"
#include "httpserver.h"
// BOARD

@ -1,6 +1,5 @@
#include <Arduino.h>
// #include <Arduino.h>
#include "treppe.h"
#include <unity.h>
Treppe stairs(10);