This commit is contained in:
Oliver Marks 2019-09-02 22:20:38 +01:00
commit 2e9d328e73
7 changed files with 132 additions and 0 deletions

101
app/app.ino Normal file
View File

@ -0,0 +1,101 @@
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
//#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <FS.h>
ESP8266WebServer server(80);
//https://steve.fi/Hardware/d1-flash/
void handleNotFound() {
// If we could serve from flash we're good.
Serial.println(server.uri());
return;
//if (loadFromSpiffs(server.uri()))
// return;
// Otherwise a generic 404.
String message = "File Not Detected\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message +=
" NAME:" + server.argName(i) + "\n VALUE:" + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
Serial.println(message);
}
void setup_mode() {
WiFi.softAP("snapwire", "snapwire"); // Start the access point
Serial.print("Access Point \"");
// Serial.print(ssid);
Serial.println("\" started");
Serial.print("IP address:\t");
Serial.println(
WiFi.softAPIP()); // Send the IP address of the ESP8266 to the computer
server.onNotFound(handleNotFound);
server.begin();
}
void connect() {
WiFi.mode(WIFI_STA);
WiFi.hostname("flash-httpd");
WiFi.begin("WEMOS", "SNAPWIRE");
// Wait until we're connected.
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void startup() {
File f = SPIFFS.open("/index.html", "r");
while (f.available()) {
// Lets read line by line from the file
String line = f.readStringUntil('\n');
Serial.println(line);
}
f = SPIFFS.open("/config.txt", "r");
if (!f.available()) {
Serial.println("Launching in access point mode.");
return;
}
Serial.println("Reading existing config.");
while (f.available()) {
// Lets read line by line from the file
String line = f.readStringUntil('\n');
Serial.println(line);
}
}
void setup() {
Serial.begin(115200);
SPIFFS.begin();
startup();
setup_mode();
}
//ESP.restart();
void loop() {
server.handleClient();
//delay(2000);
}

8
app/data/index.html Normal file
View File

@ -0,0 +1,8 @@
<HTML>
<head>
<link rel="stylesheet" href="tachyon.css" type="text/css" media="screen" />
</head>
<body>
Welcome
</body>
</html>

2
app/data/tacyon.css Normal file

File diff suppressed because one or more lines are too long

1
app/state.cpp Normal file
View File

@ -0,0 +1 @@

10
readme.org Normal file
View File

@ -0,0 +1,10 @@
requirements
https://github.com/esp8266/arduino-esp8266fs-plugin
https://github.com/esp8266/arduino-esp8266fs-plugin/files/2936951/ESP8266FS.zip
pip install esptool
esptool -p /dev/ttyUSB0
make sure to set the spiffs size in the arduino before uploading to allocate space for files

8
uploader/data/index.html Normal file
View File

@ -0,0 +1,8 @@
<HTML>
<head>
<link rel="stylesheet" href="tachyon.css" type="text/css" media="screen" />
</head>
<body>
Welcome
</body>
</html>

2
uploader/data/tacyon.css Normal file

File diff suppressed because one or more lines are too long