mirror of
https://github.com/s00500/ESPUI.git
synced 2024-12-22 19:30:50 +00:00
ESP8266 Compatibility, finally
This commit is contained in:
parent
489ba045fb
commit
479792e335
@ -1,7 +1,12 @@
|
||||
#include <ESPUI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
const char *ssid = "ESP32";
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
|
||||
const char *ssid = "ESPUI";
|
||||
const char *password = "";
|
||||
|
||||
long oldTime = 0;
|
||||
@ -10,7 +15,13 @@ bool switchi = false;
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.setHostname(ssid);
|
||||
|
||||
#if defined(ESP32)
|
||||
WiFi.setHostname(ssid);
|
||||
#else
|
||||
WiFi.hostname(ssid);
|
||||
#endif
|
||||
|
||||
WiFi.softAP(ssid);
|
||||
// WiFi.softAP(ssid, password);
|
||||
Serial.println("");
|
||||
|
@ -29,7 +29,7 @@ void deleteFile(fs::FS &fs, const char * path){
|
||||
}
|
||||
}
|
||||
|
||||
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||
void writeFile(fs::FS &fs, const char * path, const char * data){
|
||||
Serial.printf("Writing file: %s\n", path);
|
||||
|
||||
File file = fs.open(path, FILE_WRITE);
|
||||
@ -37,7 +37,7 @@ void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||
Serial.println("Failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)){
|
||||
if(file.print(FPSTR(data))){
|
||||
Serial.println("File written");
|
||||
} else {
|
||||
Serial.println("Write failed");
|
||||
@ -67,14 +67,13 @@ deleteFile(SPIFFS, "/js/slider.js");
|
||||
Serial.println('Cleanup done');
|
||||
|
||||
// Now write
|
||||
|
||||
writeFile(SPIFFS, "/index.htm", HTML_INDEX);
|
||||
|
||||
writeFile(SPIFFS, "/css/style.css", CSS_STYLE);
|
||||
writeFile(SPIFFS, "/css/normalize.css", CSS_NORMALIZE);
|
||||
|
||||
writeFile(SPIFFS, "/js/controls.js", JS_CONTROLS);
|
||||
writeFile(SPIFFS, "/js/zepto.js", JS_ZEPTO);
|
||||
writeFile(SPIFFS, "/js/controls.js", JS_CONTROLS);
|
||||
writeFile(SPIFFS, "/js/slider.js", JS_SLIDER);
|
||||
|
||||
Serial.println("Done Initializing filesystem :-)");
|
||||
|
26
src/ESPUI.h
26
src/ESPUI.h
@ -1,23 +1,35 @@
|
||||
#ifndef ESPUI_h
|
||||
#define ESPUI_h
|
||||
|
||||
#define HARDWARE "esp32"
|
||||
|
||||
#define debug true
|
||||
|
||||
// ifdef 8266
|
||||
//#include "Hash.h"
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
#include "WiFi.h"
|
||||
#include "stdlib_noniso.h"
|
||||
|
||||
#if defined(ESP32)
|
||||
|
||||
#include "SPIFFS.h"
|
||||
#include "WiFi.h"
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <FS.h>
|
||||
#include <Hash.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <SPIFFSEditor.h>
|
||||
|
||||
#define FILE_WRITE "w"
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct Control {
|
||||
unsigned int type;
|
||||
unsigned int id; // just mirroring the id here for practical reasons
|
||||
|
Loading…
Reference in New Issue
Block a user