move http and ota to lib/ for testing, add #pragma once include guards
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
#ifndef __FILESYS_H
|
||||
#define __FILESYS_H
|
||||
|
||||
#include <LittleFS.h>
|
||||
|
||||
bool mount_fs();
|
||||
bool format_fs();
|
||||
|
||||
void ls(const char * dirname);
|
||||
void readFile(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
|
||||
@@ -1,48 +0,0 @@
|
||||
#ifndef __HTTPSERVER_H
|
||||
#define __HTTPSERVER_H
|
||||
|
||||
#include "filesys.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
|
||||
class HTTPServer : public ESP8266WebServer {
|
||||
private:
|
||||
const char* rootDir;
|
||||
|
||||
bool addRootFileHandler();
|
||||
bool formatFS() {
|
||||
return format_fs();
|
||||
}
|
||||
void listRoot() {
|
||||
ls(rootDir);
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPServer(const int _port, const char* _rootDir) :
|
||||
ESP8266WebServer(_port), rootDir(_rootDir)
|
||||
{ }
|
||||
~HTTPServer()
|
||||
{
|
||||
Serial.printf("[HTTPServer] shut down ...\n\r");
|
||||
}
|
||||
|
||||
bool start() {
|
||||
if(!mount_fs())
|
||||
return false;
|
||||
Serial.printf("[HTTPServer] LittleFS mounted !\n\r");
|
||||
|
||||
Serial.printf("[HTTPServer] root:\n\r");
|
||||
this->listRoot();
|
||||
Serial.printf("\n\r");
|
||||
|
||||
if( this->addRootFileHandler() ){
|
||||
this->begin();
|
||||
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
Serial.printf("[HTTPServer] Not starting Server, something went wrong !\n\r");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __HTTPSERVER_H
|
||||
+2
-6
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user