First commit

This commit is contained in:
Blue Fox 2022-12-29 09:43:33 +01:00
commit c0c663bd07
9 changed files with 992 additions and 0 deletions

103
ESafeP/ESafeP.ino Normal file
View File

@ -0,0 +1,103 @@
#include <EEPROM.h>
#include <WiFi.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <ESP32Servo.h>
// define variables and structs
String version = "ESafeP 1.3"; // 1.0: Web Interface finished; 1.1: Servo motor works now; 1.2: The 3x4 Keyboard functions; 1.3: Added Keyboard functionality: Change the Code
int currentWiFiAP = 1; // 1: normal WiFi; 2: alternative WiFi; 3: softAP (ESP opens an access point)
char apSSID[10] = "ESafeP-AP";
char apPSK[14] = "aA161616161Aa";
bool apON = false;
struct WiFiConfig {
char ssid[33];
char pwd[64];
char alternative_ssid[33];
char alternative_pwd[64];
};
struct Config {
char code[9];
char friendly_name[21];
};
int wiFiConfigAddress = 4; // this is a pointer where objects are stored on EEPROM (points to the end; points to free space); at 0 the state of establishment is stored (0 = not established or 1 established)
int configAddress = wiFiConfigAddress + sizeof(WiFiConfig);
int doorServoPin = 12; // pin number where the control line of the servo motor is connected to
Servo doorServo; // servo object for the door
bool safeOpened = false; // value if the safe is opened or closed
int servo_open_angle = 90;
int servo_closed_angle = 135;
// All pins for I/O (Keyboard, LEDs, etc.)
int keyboard3x4_column1 = 25;
int keyboard3x4_column2 = 26;
int keyboard3x4_column3 = 27;
int keyboard3x4_row1 = 33;
int keyboard3x4_row2 = 32;
int keyboard3x4_row3 = 35;
int keyboard3x4_row4 = 34;
int readyForInputLED = 2;
int wrongCodeLED = 4;
int codeChangeLED = 5;
int newCodeLED = 18;
int newCodeRepeatLED = 19;
int invalidCodeLED = 21;
int typeOldCodeLED = 22;
int webport = 80; // the port for the web interface
WebServer server(webport); // the webserver (port "webport")
void setup() {
pinSetup(); // set up all needed pins
doorServo.attach(doorServoPin);
Serial.begin(115200);
EEPROM.begin(4 + sizeof(WiFiConfig) + sizeof(Config)); // load the data on EEPROM into the RAM
connectWiFi(); // connect to wifi on startup
webSetup(); // register the web paths and start the web server
if (MDNS.begin("esp32")) {
Serial.println("MDNS responder started"); // start the mDNS responder and print a message on success
}
}
void loop() {
// reconnect to WiFi if connection was lost
connectWiFi();
// the keyboard functions...
if(check_3x4keyboard_clicked()) {
// show that now the code can be submitted
digitalWrite(readyForInputLED, HIGH);
// read the code and make checks, to open or close the safe
String output = readCodeFrom3x4keyboard(true);
if (output == getCode() && safeOpened == false && output != "newCodeFinished") {
// open the safe
Serial.println("Opening the safe...");
open();
Serial.println("Opened the safe.");
} else if (safeOpened == true && output != "newCodeFinished") {
// close the safe
Serial.println("Closing the safe...");
close();
Serial.println("Closed the safe.");
} else if(output != "newCodeFinished") { // if the ouput was not the real code AND no new code was set, THEN show that the code was wrong
blinkLED(wrongCodeLED, 700);
// debug message
Serial.printf("Wrong code submitted: %s\n", output);
}
// now show that everything is done and no code will be read now
digitalWrite(readyForInputLED, LOW);
}
// response a client if it's requesting something
server.handleClient();
}

135
ESafeP/keyboard.ino Normal file
View File

@ -0,0 +1,135 @@
bool check_3x4keyboard_clicked() { // just a function that checks if some key on the keyboard was pressed
digitalWrite(keyboard3x4_column1, HIGH);
digitalWrite(keyboard3x4_column2, HIGH);
digitalWrite(keyboard3x4_column3, HIGH);
if (analogRead(keyboard3x4_row1) >= 4000) {
return true;
} else if (analogRead(keyboard3x4_row2) >= 4000) {
return true;
} else if (analogRead(keyboard3x4_row3) >= 4000) {
return true;
} else if (analogRead(keyboard3x4_row4) >= 4000) {
return true;
}
return false;
}
String readCodeFrom3x4keyboard(bool codeChange) { // the parameter "codeChange" is just to prevent a loop, look further down
String input = "";
int currentpower = 1;
while (true) {
switch (currentpower) {
case 1:
digitalWrite(keyboard3x4_column3, LOW);
digitalWrite(keyboard3x4_column1, HIGH);
currentpower = 2;
if (analogRead(keyboard3x4_row1) >= 4000) {
int timeAtClick = millis();
while (analogRead(keyboard3x4_row1) >= 4000) {}
if(millis() - timeAtClick >= 2000 && codeChange) { // if the button was pressed longer than 2 seconds then... (here's the loop-preventing codeChange parameter)
Serial.println("Changing code...");
digitalWrite(codeChangeLED, HIGH); // turn on the led that indicates code change
digitalWrite(typeOldCodeLED, HIGH); // turn on the led that prompts to type in the old code
// read the old code and check if it's correct
String currentCode = readCodeFrom3x4keyboard(false);
while(currentCode != getCode()) { blinkLED(wrongCodeLED, 700); currentCode = readCodeFrom3x4keyboard(false); }
// show that now the new code has to be submitted (only if the old code was right)
digitalWrite(typeOldCodeLED, LOW);
digitalWrite(newCodeLED, HIGH);
// read the new code
String newCode = readCodeFrom3x4keyboard(false);
while(newCode.length() != 8) { blinkLED(invalidCodeLED, 700); newCode = readCodeFrom3x4keyboard(false); } // make sure the code is 8 numbers long
// prompt the user to repeat the code
digitalWrite(newCodeLED, LOW);
digitalWrite(newCodeRepeatLED, HIGH);
// read repeated new code
String newCodeRepeat = readCodeFrom3x4keyboard(false);
while(newCode != newCodeRepeat) { blinkLED(wrongCodeLED, 700); newCodeRepeat = readCodeFrom3x4keyboard(false); }
// ...and finally set the code
setCode(newCode);
// turn off the used leds
digitalWrite(newCodeRepeatLED, LOW);
digitalWrite(codeChangeLED, LOW);
// debug message
Serial.println("Changed code.");
return "newCodeFinished"; // statuscode "newCodeFinished" (just shows that a new code was set)
} else { // if pressed short, just remove one number from the read code
input = input.substring(0, input.length() - 1);
}
delay(10);
} else if (analogRead(keyboard3x4_row2) >= 4000) {
while (analogRead(keyboard3x4_row2) >= 4000) {}
delay(10);
input += "7";
} else if (analogRead(keyboard3x4_row3) >= 4000) {
while (analogRead(keyboard3x4_row3) >= 4000) {}
delay(10);
input += "4";
} else if (analogRead(keyboard3x4_row4) >= 4000) {
while (analogRead(keyboard3x4_row4) >= 4000) {}
delay(10);
input += "1";
}
break;
case 2:
digitalWrite(keyboard3x4_column1, LOW);
digitalWrite(keyboard3x4_column2, HIGH);
currentpower = 3;
if (analogRead(keyboard3x4_row1) >= 4000) {
while (analogRead(keyboard3x4_row1) >= 4000) {}
delay(10);
input += "0";
} else if (analogRead(keyboard3x4_row2) >= 4000) {
while (analogRead(keyboard3x4_row2) >= 4000) {}
delay(10);
input += "8";
} else if (analogRead(keyboard3x4_row3) >= 4000) {
while (analogRead(keyboard3x4_row3) >= 4000) {}
delay(10);
input += "5";
} else if (analogRead(keyboard3x4_row4) >= 4000) {
while (analogRead(keyboard3x4_row4) >= 4000) {}
delay(10);
input += "2";
}
break;
case 3:
digitalWrite(keyboard3x4_column2, LOW);
digitalWrite(keyboard3x4_column3, HIGH);
currentpower = 1;
if (analogRead(keyboard3x4_row1) >= 4000) {
while (analogRead(keyboard3x4_row1) >= 4000) {}
delay(10);
return input;
} else if (analogRead(keyboard3x4_row2) >= 4000) {
while (analogRead(keyboard3x4_row2) >= 4000) {}
delay(10);
input += "9";
} else if (analogRead(keyboard3x4_row3) >= 4000) {
while (analogRead(keyboard3x4_row3) >= 4000) {}
delay(10);
input += "6";
} else if (analogRead(keyboard3x4_row4) >= 4000) {
while (analogRead(keyboard3x4_row4) >= 4000) {}
delay(10);
input += "3";
}
break;
}
}
}

308
ESafeP/utils.ino Normal file
View File

@ -0,0 +1,308 @@
int biggest2thPotency(int number) {
int res = 1;
while (res <= number) {
res <<= 1; // multiply res with 2 (res << 1) as long as res isn't bigger than the number,
}
// so that we have the nearest (bigger) 2th potency.
res >>= 1; // now divide the result once so that we have the nearest (but smaller or equal) 2th potency
return res;
}
bool checkCommitID(int commit_id, int searched_bit) {
// a function that checks if the searched_bit was ever set
// Technically: the commit_id is an Integer which is the sum of other numbers (related to the ext4 permissions). List of those numbers:
// *** 1: WiFi ***
// *** 2: Alternative WiFi ***
// *** 4: Code ***
// *** 8: Friendly name ***
int b2thP;
while (commit_id > 0) {
b2thP = biggest2thPotency(commit_id);
if (b2thP == searched_bit) {
return true;
}
commit_id -= b2thP;
}
return false;
}
bool hasWiFi(int commit_id) {
return checkCommitID(commit_id, 1);
}
bool hasAlternativeWiFi(int commit_id) {
return checkCommitID(commit_id, 2);
}
bool hasCode(int commit_id) {
return checkCommitID(commit_id, 4);
}
bool hasFriendlyName(int commit_id) {
return checkCommitID(commit_id, 8);
}
void setFriendlyName(String name) {
// get the configuration
Config config; EEPROM.get(configAddress, config);
// convert the String to a char array
int nameLength = name.length();
char nameArray[21];
for (int i = 0; i <= 20; i++) {
if (nameLength >= i) {
nameArray[i] = name[i];
} else {
nameArray[i] = (char) 0;
}
}
// get the commit id
int commit_id; EEPROM.get(0, commit_id);
if (hasFriendlyName(commit_id)) {
strncpy(config.friendly_name, nameArray, 21);
}
else {
strncpy(config.friendly_name, nameArray, 21);
EEPROM.put(0, commit_id + 8);
}
// save the config
EEPROM.put(configAddress, config);
EEPROM.commit();
}
void setCode(String code) {
// get the configuration
Config config; EEPROM.get(configAddress, config);
// convert the String to a char array
int codeLength = code.length();
char codeArray[9];
for (int i = 0; i <= 8; i++) {
if (codeLength >= i) {
codeArray[i] = code[i];
} else {
codeArray[i] = (char) 0;
}
}
// get the commit id
int commit_id; EEPROM.get(0, commit_id);
if (hasCode(commit_id)) {
strncpy(config.code, codeArray, 9);
}
else {
strncpy(config.code, codeArray, 9);
EEPROM.put(0, commit_id + 4);
}
// save the config
EEPROM.put(configAddress, config);
EEPROM.commit();
}
void setWiFi(String ssid, String password) {
// get the configuration
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
// convert the Strings to char arrays
int ssidLength = ssid.length(); int pwdLength = password.length();
char ssidArray[33];
char pwdArray[64];
for (int i = 0; i <= 31; i++) {
if (ssidLength >= i) {
ssidArray[i] = ssid[i];
} else {
ssidArray[i] = (char) 0;
}
}
for (int i = 0; i <= 62; i++) {
if (pwdLength >= i) {
pwdArray[i] = password[i];
} else {
pwdArray[i] = (char) 0;
}
}
// get the commit id
int commit_id; EEPROM.get(0, commit_id);
if (hasWiFi(commit_id)) {
strncpy(config.ssid, ssidArray, 33);
strncpy(config.pwd, pwdArray, 64);
}
else {
strncpy(config.ssid, ssidArray, 33);
strncpy(config.pwd, pwdArray, 64);
EEPROM.put(0, commit_id + 1);
}
// save the config
EEPROM.put(wiFiConfigAddress, config);
EEPROM.commit();
// reboot to go into the wifi
ESP.restart();
}
void setAlternativeWiFi(String ssid, String password) {
// get the configuration
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
// convert the Strings to char arrays
int ssidLength = ssid.length(); int pwdLength = password.length();
char ssidArray[33];
char pwdArray[64];
for (int i = 0; i <= 31; i++) {
if (ssidLength >= i) {
ssidArray[i] = ssid[i];
} else {
ssidArray[i] = (char) 0;
}
}
for (int i = 0; i <= 62; i++) {
if (pwdLength >= i) {
pwdArray[i] = password[i];
} else {
pwdArray[i] = (char) 0;
}
}
// get the commit id
int commit_id; EEPROM.get(0, commit_id);
if (hasAlternativeWiFi(commit_id)) {
strncpy(config.alternative_ssid, ssidArray, 33);
strncpy(config.alternative_pwd, pwdArray, 64);
}
else {
strncpy(config.alternative_ssid, ssidArray, 33);
strncpy(config.alternative_pwd, pwdArray, 64);
EEPROM.put(0, commit_id + 2);
}
// save the config
EEPROM.put(wiFiConfigAddress, config);
EEPROM.commit();
// reboot to go into the wifi
ESP.restart();
}
String getFriendlyName() {
Config config; EEPROM.get(configAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasFriendlyName(commitID)) {
return (String) config.friendly_name;
}
else {
setFriendlyName("ESafeP #1"); // set a default
return getFriendlyName();
}
}
String getCode() {
Config config; EEPROM.get(configAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasCode(commitID)) {
return (String) config.code;
}
else {
setCode("12345678"); // set a default
return getCode();
}
}
String getWiFiSSID() {
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasWiFi(commitID)) {
return (String) config.ssid;
}
else {
return "";
}
}
String getWiFiPassword() {
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasWiFi(commitID)) {
return (String) config.pwd;
}
else {
return "";
}
}
String getAlternativeWiFiSSID() {
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasAlternativeWiFi(commitID)) {
return (String) config.alternative_ssid;
}
else {
return "";
}
}
String getAlternativeWiFiPassword() {
WiFiConfig config; EEPROM.get(wiFiConfigAddress, config);
int commitID; EEPROM.get(0, commitID);
if (hasAlternativeWiFi(commitID)) {
return (String) config.alternative_pwd;
}
else {
return "";
}
}
void reset() {
EEPROM.begin(4096);
for (int i = 0 ; i <= 4096 ; i++) {
EEPROM.write(i, 0);
}
EEPROM.commit();
}
void open() {
doorServo.write(servo_open_angle);
safeOpened = true;
// if this is not done, the ESP32Servo library would try to set the servo angle to 1 degree all the time. So this resets the connection to the servo motor
delay(400);
doorServo.detach();
doorServo.attach(doorServoPin);
}
void close() {
doorServo.write(servo_closed_angle);
safeOpened = false;
// if this is not done, the ESP32Servo library would try to set the servo angle to 1 degree all the time. So this resets the connection to the servo motor
delay(400);
doorServo.detach();
doorServo.attach(doorServoPin);
}
bool isIn(String target, String list[], int listlength) {
for (int i = 0; i < listlength; i++) {
//list[i].toCharArray(listElmnt, list[i].length());
if (list[i] == target) {
return true;
}
}
return false;
}
void blinkLED(int pin, int length) {
digitalWrite(pin, HIGH);
delay(length);
digitalWrite(pin, LOW);
}
void pinSetup() {
pinMode(keyboard3x4_column1, OUTPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_column2, OUTPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_column3, OUTPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_row1, INPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_row2, INPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_row3, INPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(keyboard3x4_row4, INPUT); // The I/O Pins of the 3x4 Keyboard
pinMode(readyForInputLED, OUTPUT);
pinMode(wrongCodeLED, OUTPUT);
pinMode(codeChangeLED, OUTPUT);
pinMode(newCodeLED, OUTPUT);
pinMode(newCodeRepeatLED, OUTPUT);
pinMode(invalidCodeLED, OUTPUT);
pinMode(typeOldCodeLED, OUTPUT);
}

329
ESafeP/web.ino Normal file
View File

@ -0,0 +1,329 @@
void root() {
Serial.println("WEB: 200 - GET '/'");
String html = "<html><head><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'><link rel='icon' href='/favicon.svg'><link rel='stylesheet' href='/all.css'><title>Your safe!</title></head><body><div style='text-align:center;display:inline-block;color:#ffffff;min-width:340px;'><h3>ESafeP</h3><h2>";
html += getFriendlyName();
html += "</h2><p style='font-size: 62px;'>";
html += safeOpened ? "Offen" : "Zu";
html += "</p><br>";
html += safeOpened ?
"<form action='/close' method='get'><button>Schlie&szlig;en</button></form>"
: "<form style='display: block;' action='/check' method='get'><input type='hidden' name='opensafe' value='1'><button>&Ouml;ffnen</button></form>";
html += "<p></p><form id='but4' style='display: block;' action='/settings' method='GET'><button>Einstellungen</button></form><p></p><form id='but4' style='display: block;' action='/info' method='GET'><button>Informationen</button></form><p></p><div id='but3d' style='display: block;'></div><form id='but0' style='display: block;' action='/reboot' method='get' onsubmit='return confirm(&quot;Wirklich neustarten?&quot;);'><button class='button bred'>Neustart</button></form><p></p><hr><a style='text-align:right;font-size:11px;color:#aaa;' href='http://10.0.30.20' target='_blank'>" + version + "</a></div></body></html>";
server.send(200, "text/html", html);
}
void all_css(){
Serial.println("WEB: 200 - GET '/all.css'");
String css = "td{text-align:center;padding:3pt;}div,fieldset,input,select{padding:5px;font-size:1em}p{margin:.5em 0}input{width:100%;background:#fff;color:#2a2a2e;border-radius:20pt;text-align:center;border:0;line-height:2rem;font-size:15.5pt;}input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px}input[type=range]{width:99%}select{width:100%;background:#fff;color:#000}textarea{resize:vertical;width:98%;height:318px;padding:5px;overflow:auto;background:#fff;color:#000}body{text-align:center;font-family:verdana,sans-serif;background:#2a2a2e;color:#ffffff;}button{border:0;border-radius:20pt;background:#0dcaf0;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:.2s;transition-duration:.2s;cursor:pointer}button:hover{background:#0d6efd}.bred{background:#fd7e14}.bred:hover{background:#dc3545}.bgrn{background:#47c266}.bgrn:hover{background:#5aaf6f}a{color:#1fa3ec;text-decoration:none}.p{float:left;text-align:left}.q{float:right;text-align:right}.r{border-radius:.3em;padding:2px;margin:6px 2px}";
server.send(200, "text/css", css);
}
void favicon_svg() {
Serial.println("WEB: 200 - GET '/favicon.svg'");
String svg = "<svg width='16' height='16' xmlns='http://www.w3.org/2000/svg'><style>path { fill: #000000; }@media (prefers-color-scheme: dark) {path { fill: #ffffff; }}</style><path d='M1 1.5A1.5 1.5 0 0 1 2.5 0h12A1.5 1.5 0 0 1 16 1.5v13a1.5 1.5 0 0 1-1.5 1.5h-12A1.5 1.5 0 0 1 1 14.5V13H.5a.5.5 0 0 1 0-1H1V8.5H.5a.5.5 0 0 1 0-1H1V4H.5a.5.5 0 0 1 0-1H1V1.5zM2.5 1a.5.5 0 0 0-.5.5v13a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5v-13a.5.5 0 0 0-.5-.5h-12z' fill-rule='nonzero'/><path d='M13.5 6a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3a.5.5 0 0 1 .5-.5zM4.828 4.464a.5.5 0 0 1 .708 0l1.09 1.09a3.003 3.003 0 0 1 3.476 0l1.09-1.09a.5.5 0 1 1 .707.708l-1.09 1.09c.74 1.037.74 2.44 0 3.476l1.09 1.09a.5.5 0 1 1-.707.708l-1.09-1.09a3.002 3.002 0 0 1-3.476 0l-1.09 1.09a.5.5 0 1 1-.708-.708l1.09-1.09a3.003 3.003 0 0 1 0-3.476l-1.09-1.09a.5.5 0 0 1 0-.708zM6.95 6.586a2 2 0 1 0 2.828 2.828A2 2 0 0 0 6.95 6.586z' fill-rule='nonzero'/></svg>";
server.send(200, "image/svg+xml", svg);
}
void settings() {
Serial.println("WEB: 200 - GET '/settings'");
String html = "<meta charset=utf-8><meta content='width=device-width,initial-scale=1,user-scalable=no' name='viewport'><link href=/favicon.svg rel=icon><link href=/all.css rel=stylesheet><title>Einstellungen</title><div style=text-align:center;display:inline-block;color:#fff;min-width:340px><p style=font-size:40px><svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='currentColor' class='bi bi-gear' viewBox='0 0 16 16'><path d='M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492zM5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0z'></path><path d='M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52l-.094-.319zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115l.094-.319z'></path></svg><br><br>Einstellungen<br><hr><br><form action=/settings/chpwdform><button>Code ändern</button></form><p><form action=/settings/chfriendlynameform><button>Namen ändern</button></form><p><form action=/settings/chwificonfigform><button>WLAN-Konfiguration</button></form><form id='but0' style='display: block;' action='/reset' method='get' onsubmit='return confirm(&quot;Wirklich zur&uuml;cksetzen? Dies wird alle gespeicherten Daten, inklusive Zugangscode, l&ouml;schen.&quot;);'><button class='button bred'>Zur&uuml;cksetzen</button></form><br><hr><a href=http://10.0.30.20 style=text-align:right;font-size:11px;color:#aaa target=_blank>" + version + "</a></div>";
server.send(200, "text/html", html);
}
void settings_chpwdform() {
Serial.println("WEB: 200 - GET '/settings/chpwdform'");
String html = "";
if(server.hasArg("codes-not-equal")) { html += "<script>alert('Der eingegebene (alte) Code ist falsch!')</script>"; }
html += "<meta charset=utf-8><meta content='width=device-width,initial-scale=1,user-scalable=no'name=viewport><link href=/favicon.svg rel=icon><link href=/all.css rel=stylesheet><title>Einstellungen</title><div class=text-center style=display:inline-block;color:#fff;min-width:340px><p style=font-size:40><svg class='bi bi-key'fill=currentColor height=100 viewBox='0 0 16 16'width=100 xmlns=http://www.w3.org/2000/svg><path d='M0 8a4 4 0 0 1 7.465-2H14a.5.5 0 0 1 .354.146l1.5 1.5a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0L13 9.207l-.646.647a.5.5 0 0 1-.708 0L11 9.207l-.646.647a.5.5 0 0 1-.708 0L9 9.207l-.646.647A.5.5 0 0 1 8 10h-.535A4 4 0 0 1 0 8zm4-3a3 3 0 1 0 2.712 4.285A.5.5 0 0 1 7.163 9h.63l.853-.854a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.793-.793-1-1h-6.63a.5.5 0 0 1-.451-.285A3 3 0 0 0 4 5z'></path><path d='M4 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'></path></svg><br><br>Code ändern<br><hr><br><div><form action=/settings/chpwd><input maxlength=8 minlength=8 name=code_old pattern=[0-9]{8} title='Der Code besteht aus exakt 8 Ziffern' placeholder='Aktueller Code'required><br><p></p><input maxlength=8 minlength=8 name=code_new pattern=[0-9]{8} title='Der Code muss aus exakt 8 Ziffern bestehen' placeholder='Neuer Code'required><br><br><button>Speichern</button></form></div><hr><a href=http://10.0.30.20 style=color:#aaa;text-align:right;font-size:11px target=_blank>" + version + "</a></div>";
server.send(200, "text/html", html);
}
void settings_chpwd() {
Serial.println("WEB: 200 - GET '/settings/chpwd'");
if(server.hasArg("code_old") && server.hasArg("code_new")) {
String code_old = server.arg("code_old");
String code_new = server.arg("code_new");
if(code_old.length() != 8 || code_new.length() != 8) {
server.sendHeader("Location", "/settings/chpwdform?", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings/chpwdform?'</p></body></html>");
}
if(code_old == getCode()) {
setCode(code_new);
} else {
server.sendHeader("Location", "/settings/chpwdform?codes-not-equal=1", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings/chpwdform?codes-not-equal=1'</p></body></html>");
}
server.sendHeader("Location", "/", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
} else {
server.sendHeader("Location", "/settings/chpwdform", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings/chpwdform'</p></body></html>");
}
}
void settings_chfriendlynameform() {
Serial.println("WEB: 200 - GET '/settings/chfriendlynameform'");
String html = "<meta charset=utf-8><meta content='width=device-width,initial-scale=1,user-scalable=no'name=viewport><link href=/favicon.svg rel=icon><link href=/all.css rel=stylesheet><title>Einstellungen</title><div class=text-center style=display:inline-block;color:#fff;min-width:340px><p style=font-size:40><svg class='bi bi-tag'fill=currentColor height=100 viewBox='0 0 16 16'width=100 xmlns=http://www.w3.org/2000/svg><path d='M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0z'/><path d='M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1zm0 5.586 7 7L13.586 9l-7-7H2v4.586z'/></svg><br><br>Namen &auml;ndern<br><hr><br><div><form action=/settings/change_frdlyname><input maxlength=20 name=name max=20 placeholder='Neuer Name (leer zum löschen)'><br><br><button>Speichern</button></form></div><hr><a href=http://10.0.30.20 style=color:#aaa;text-align:right;font-size:11px target=_blank>" + version + "</a></div>";
server.send(200, "text/html", html);
}
void settings_chfrdyname() {
Serial.println("WEB: 200 - GET '/settings/change_frdlyname'");
if(server.hasArg("name")) {
String name = server.arg("name");
if(name.length() <= 20) {
setFriendlyName(name);
}
}
server.sendHeader("Location", "/", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
}
void settings_chwificonfigform() {
Serial.println("WEB: 200 - GET '/settings/chwificonfigform'");
// get commit id (for wifi password)
int commit_id; EEPROM.get(0, commit_id);
// do the wifi scan
int total_network_count = WiFi.scanNetworks();
String unique[total_network_count]; int unique_counter = 0;
String html = "";
if(server.hasArg("ssidandpwdneeded")) { html += "<script>alert('Gib bitte sowohl SSID und Passwort an!');</script>"; }
html = "<meta charset=utf-8><meta content='width=device-width,initial-scale=1,user-scalable=no'name=viewport><link href=/favicon.svg rel=icon><link href=/all.css rel=stylesheet><title>WLAN-Konfiguration</title><div class=text-center style=display:inline-block;color:#fff;min-width:340px><p style=font-size:40><svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='currentColor' class='bi bi-wifi' viewBox='0 0 16 16'><path d='M15.384 6.115a.485.485 0 0 0-.047-.736A12.444 12.444 0 0 0 8 3C5.259 3 2.723 3.882.663 5.379a.485.485 0 0 0-.048.736.518.518 0 0 0 .668.05A11.448 11.448 0 0 1 8 4c2.507 0 4.827.802 6.716 2.164.205.148.49.13.668-.049z'/><path d='M13.229 8.271a.482.482 0 0 0-.063-.745A9.455 9.455 0 0 0 8 6c-1.905 0-3.68.56-5.166 1.526a.48.48 0 0 0-.063.745.525.525 0 0 0 .652.065A8.46 8.46 0 0 1 8 7a8.46 8.46 0 0 1 4.576 1.336c.206.132.48.108.653-.065zm-2.183 2.183c.226-.226.185-.605-.1-.75A6.473 6.473 0 0 0 8 9c-1.06 0-2.062.254-2.946.704-.285.145-.326.524-.1.75l.015.015c.16.16.407.19.611.09A5.478 5.478 0 0 1 8 10c.868 0 1.69.201 2.42.56.203.1.45.07.61-.091l.016-.015zM9.06 12.44c.196-.196.198-.52-.04-.66A1.99 1.99 0 0 0 8 11.5a1.99 1.99 0 0 0-1.02.28c-.238.14-.236.464-.04.66l.706.706a.5.5 0 0 0 .707 0l.707-.707z'/></svg><br><br>";
html += "WLAN-Konfiguration";
html += "<br><hr><div><h4>MAC-Addresse des Tresors </h4><i><p style='font-size: 20pt;'>";
html += WiFi.macAddress();
html += "</p></i><hr style=width:40%><h4>Verf&uuml;gbare WLAN-Netzwerke</h4><table style='margin-left: auto;margin-right: auto;'><tbody><tr><th width=55%>SSID</th><th></th><th>RSSI</th></tr>";
for(int i = 0; i < total_network_count; i++) {
if(!isIn(WiFi.SSID(i), unique, unique_counter)) { // duplications are not displayed
html += "<tr><td>";
html += WiFi.SSID(i);
html += "</td><td>";
html += WiFi.encryptionType(i) == WIFI_AUTH_OPEN ? "Offen" : "";
html += "</td><td>";
html += WiFi.RSSI(i);
html += "</td></tr>";
unique[unique_counter] = WiFi.SSID(i);
unique_counter++;
}
}
html += "</tbody></table><br><hr style='width:40%;'><br><form action=/settings/chwifi method='GET'><input required maxlength=32 name=wifissid placeholder='";
html += getWiFiSSID() == "" ? "WiFi-SSID eingeben" : getWiFiSSID();
html += "'><br><p></p><input required maxlength=63 name=wifipwd placeholder='";
html += hasWiFi(commit_id) ? "******" : "WiFi-Passwort eingeben";
html += "'><br><br><input name=alternativewifissid placeholder='";
html += getAlternativeWiFiSSID() == "" ? "Alternative WiFi-SSID eingeben" : getAlternativeWiFiSSID();
html += "'><br><p></p><input name=alternativewifipwd placeholder='";
html += hasAlternativeWiFi(commit_id) ? "******" : "Alternatives WiFi-Passwort eingeben";
html += "'><br><br><p></p><button>Speichern</button></form></div><hr><a href=http://10.0.30.20 style=color:#aaa;text-align:right;font-size:11px target=_blank>" + version + "</a></div>";
server.send(302, "text/html", html);
}
void settings_chwifi() {
Serial.println("WEB: 200 - GET '/settings/chwifi'");
if(!server.hasArg("wifissid") && !server.hasArg("wifipwd") && !server.hasArg("alternativewifissid") && !server.hasArg("alternativewifipwd")) { // no data to use
server.sendHeader("Location", "/settings/chwificonfigform", true); // Redirect to our html web page
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings/chwificonfigform'</p></body></html>");
}
if((server.hasArg("wifissid") && !server.hasArg("wifipwd") || (!server.hasArg("wifissid") && server.hasArg("wifipwd"))) || ((server.hasArg("alternativewifissid") && !server.hasArg("alternativewifipwd")) || (!server.hasArg("alternativewifissid") && server.hasArg("alternativewifipwd")))) { // only if ssid OR pwd were typed in
server.sendHeader("Location", "/settings/chwificonfigform?ssidandpwdneeded=1", true); // Redirect to our html web page
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings/chwificonfigform&ssidandpwdneeded=1'</p></body></html>");
}
if(server.hasArg("wifissid") && server.hasArg("wifipwd")) {
if(server.arg("wifissid") != "" && server.arg("wifipwd") != "") {
String ssid = server.arg("wifissid");
String pwd = server.arg("wifipwd");
setWiFi(ssid, pwd);
}
}
if(server.hasArg("alternativewifissid") && server.hasArg("alternativewifipwd")) {
if(server.arg("alternativewifissid") != "" && server.arg("alternativewifipwd") != "") {
String alternative_ssid = server.arg("alternativewifissid");
String alternative_pwd = server.arg("alternativewifipwd");
setAlternativeWiFi(alternative_ssid, alternative_pwd);
}
}
server.sendHeader("Location", "/", true); // Redirect to our html web page
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
}
void info() {
Serial.println("WEB: 200 - GET '/info'");
String html = "";
server.send(200, "text/html", html);
}
void reboot() { // restart the ESP8266 when this is requested
Serial.println("WEB: 200 - GET '/reboot'");
String html = "<html><head><meta http-equiv='refresh' content='5 url=";
html += WiFi.localIP().toString();
html += "'><link rel='stylesheet' href='/all.css'><link rel='icon' href='/favicon.svg'><title>Please wait</title></head><body><div class='text-center'><br><br><br><br><h2>Neustart</h2><br><svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='currentColor' class='bi bi-arrow-repeat' viewBox='0 0 16 16'><path d='M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41zm-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9z'/><path fill-rule='evenodd' d='M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5.002 5.002 0 0 0 8 3zM3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9H3.1z'/><br><h4>Bitte warten.</h4><br><br><h3 id='counter'></h3></div></body></html>";
server.send(200, "text/html", html);
Serial.println("----- REBOOTING -----");
delay(2000);
ESP.restart();
}
void settings_reset() {
Serial.println("WEB: 200 - GET '/reset'");
if(server.hasArg("code")) {
if(server.arg("code") == getCode()) {
Serial.println("----- RESETTING -----");
reset();
Serial.println("... RESET!");
server.sendHeader("Location", "/settings", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/settings'</p></body></html>");
} else {
server.sendHeader("Location", "/check?false=1&reset=1", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/check?false=1&reset=1'</p></body></html>");
}
} else {
server.sendHeader("Location", "/check?reset=1", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/check?reset=1'</p></body></html>");
}
}
void open_web() {
Serial.println("WEB: 200 - GET '/open'");
if(server.hasArg("code")) {
if(server.arg("code") == getCode()) {
Serial.println("----- OPENING -----");
open();
Serial.println("... OPENED");
server.sendHeader("Location", "/", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
} else {
server.sendHeader("Location", "/check?false=1&opensafe=1", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/check?false=1&opensafe=1'</p></body></html>");
}
} else {
server.sendHeader("Location", "/check?opensafe=1", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/check?opensafe=1'</p></body></html>");
}
}
void close_web() {
Serial.println("----- CLOSING -----");
close();
Serial.println("... CLOSED");
server.sendHeader("Location", "/", true);
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
}
void check() {
Serial.println("WEB: GET - 200 '/check'");
String html = "<html><head>";
html += server.hasArg("false") ? "<script>alert('Der eingegebene Code ist falsch!')</script>" : "";
html += "<meta charset='utf-8'><meta content='width=device-width,initial-scale=1,user-scalable=no' name='viewport'><link href='/favicon.svg' rel='icon'><link href='/all.css' rel='stylesheet'><title>Einstellungen</title></head><body><div class='text-center' style='display:inline-block;color:#fff;min-width:340px'><p style='font-size:40'><svg xmlns='http://www.w3.org/2000/svg' fill='currentColor' class='bi bi-shield-lock-fill' viewBox='0 0 16 16' width='100' height='100'><path fill-rule='evenodd' d='M8 0c-.69 0-1.843.265-2.928.56-1.11.3-2.229.655-2.887.87a1.54 1.54 0 0 0-1.044 1.262c-.596 4.477.787 7.795 2.465 9.99a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.775 11.775 0 0 0 2.517-2.453c1.678-2.195 3.061-5.513 2.465-9.99a1.541 1.541 0 0 0-1.044-1.263 62.467 62.467 0 0 0-2.887-.87C9.843.266 8.69 0 8 0zm0 5a1.5 1.5 0 0 1 .5 2.915l.385 1.99a.5.5 0 0 1-.491.595h-.788a.5.5 0 0 1-.49-.595l.384-1.99A1.5 1.5 0 0 1 8 5z'></path></svg><br><br>Bist du das?<br></p><hr><br><div><form action='";
if(server.hasArg("reset")) {
html += "/reset";
} else if(server.hasArg("opensafe")) {
html += "/open";
}
html += "'><input maxlength='8' minlength='8' name='code' pattern='[0-9]{8}' title='Der Code besteht aus exakt 8 Ziffern' required='' placeholder='Code eingeben'><br><br><button>Prüfen</button></form></div><hr><a href='http://10.0.30.20' style='color:#aaa;text-align:right;font-size:11px' target='_blank'>" + version + "</a></div></body></html>";
server.send(200, "text/html", html);
}
void webSetup() {
server.on("/", root);
server.on("/all.css", all_css);
server.on("/favicon.svg", favicon_svg);
server.on("/check", check);
server.on("/open", open_web);
server.on("/close", close_web);
server.on("/settings", settings);
server.on("/settings/chpwdform", settings_chpwdform);
server.on("/settings/chpwd", settings_chpwd);
server.on("/settings/chfriendlynameform", settings_chfriendlynameform);
server.on("/settings/change_frdlyname", settings_chfrdyname);
server.on("/settings/chwificonfigform", settings_chwificonfigform);
server.on("/settings/chwifi", settings_chwifi);
server.on("/info", info);
server.on("/reboot", reboot);
server.on("/reset", settings_reset);
server.onNotFound([]() {
Serial.println("WEB: 404: Redirecting to '/'.");
server.sendHeader("Location", "/", true); // Redirect to our html web page
server.send(302, "text/html", "<html><head><title>Code 302</title></head><body><h1>302 Redirect</h1><p>Redirect to '/'</p></body></html>");
});
Serial.println("Starting web server on port " + String(webport));
server.begin();
Serial.println("Started web server");
}
void connectWiFi() { // connect to the wifi with the above defined credentials
if(WiFi.status() == WL_CONNECTED) { return; } // return if not connected
switch(currentWiFiAP) {
case 1: {
Serial.println("Connecting to WiFi...");
String WiFiSSIDstr = getWiFiSSID();
String WiFiPSKstr = getWiFiPassword();
char WiFiSSID[33];
char WiFiPSK[64];
for(int i = 0; i<33; i++) { if(WiFiSSIDstr.length() >= i) {WiFiSSID[i] = WiFiSSIDstr[i];} else {WiFiSSID[i] = (char) 0;} }
for(int i = 0; i<64; i++) { if(WiFiPSKstr.length() >= i) {WiFiPSK[i] = WiFiPSKstr[i];} else {WiFiPSK[i] = (char) 0;} }
WiFi.begin(WiFiSSID, WiFiPSK);
delay(5000); // pause the program 5 secs
if(WiFi.status() != WL_CONNECTED) {
currentWiFiAP = 2;
break;
}
Serial.printf("Connected to wifi %s, got IP-Adress ", WiFiSSID);
Serial.println(WiFi.localIP());
}
break;
case 2: {
Serial.println("Connecting to alternative WiFi");
String alternativeWiFiSSIDstr = getAlternativeWiFiSSID();
String alternativeWiFiPSKstr = getAlternativeWiFiPassword();
char alternativeWiFiSSID[33];
char alternativeWiFiPSK[64];
for(int i = 0; i<33; i++) { if(alternativeWiFiSSIDstr.length() >= i) {alternativeWiFiSSID[i] = alternativeWiFiSSIDstr[i];} else {alternativeWiFiSSID[i] = (char) 0;} }
for(int i = 0; i<64; i++) { if(alternativeWiFiPSKstr.length() >= i) {alternativeWiFiPSK[i] = alternativeWiFiPSKstr[i];} else {alternativeWiFiPSK[i] = (char) 0;} }
WiFi.begin(alternativeWiFiSSID, alternativeWiFiPSK);
delay(5000); // pause the program 5 secs
if(WiFi.status() != WL_CONNECTED) {
currentWiFiAP = 3;
}
}
break;
case 3: {
if(!apON) {
Serial.println("Opening AP");
WiFi.softAP(apSSID, apPSK);
apON = true;
Serial.println("Opened AP");
}
}
break;
}
}

1
HTML/all.css Normal file
View File

@ -0,0 +1 @@
div,fieldset,input,select{padding:5px;font-size:1em}p{margin:.5em 0}input{width:100%;background:#fff;color:#2a2a2e;border-radius:20pt;text-align:center;border:0;line-height:2rem;font-size:15.5pt;}input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px}input[type=range]{width:99%}select{width:100%;background:#fff;color:#000}textarea{resize:vertical;width:98%;height:318px;padding:5px;overflow:auto;background:#fff;color:#000}body{text-align:center;font-family:verdana,sans-serif;background:#2a2a2e;color:#ffffff;}td{padding:0}button{border:0;border-radius:20pt;background:#0dcaf0;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:.2s;transition-duration:.2s;cursor:pointer}button:hover{background:#0d6efd}.bred{background:#fd7e14}.bred:hover{background:#dc3545}.bgrn{background:#47c266}.bgrn:hover{background:#5aaf6f}a{color:#1fa3ec;text-decoration:none}.p{float:left;text-align:left}.q{float:right;text-align:right}.r{border-radius:.3em;padding:2px;margin:6px 2px}

26
HTML/chfriendlynameform Normal file
View File

@ -0,0 +1,26 @@
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
<link href="/favicon.svg" rel="icon">
<link href="/all.css" rel="stylesheet">
<title>Einstellungen</title>
</head>
<body>
<div class='text-center' style='display:inline-block;color:#ffffff;min-width:340px'>
<p style='font-size:40;'>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-tag" viewBox="0 0 16 16">
<path d="M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0z"/>
<path d="M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1zm0 5.586 7 7L13.586 9l-7-7H2v4.586z"/>
</svg>
<br>
<br>
Namen &auml;ndern
<br>
</p>
<div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,34 @@
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
<link href="/favicon.svg" rel="icon">
<link href="/all.css" rel="stylesheet">
<title>Einstellungen</title>
</head>
<body>
<div class='text-center' style='display:inline-block;color:#ffffff;min-width:340px'>
<p style='font-size:40;'>
<svg xmlns="http://www.w3.org/2000/svg" width='100' height='100' fill='currentColor' class="bi bi-tag" viewBox="0 0 16 16">
<path d="M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0z"/>
<path d="M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1zm0 5.586 7 7L13.586 9l-7-7H2v4.586z"/>
</svg>
<br>
<br>
Namen &auml;ndern
<br>
</p>
<hr>
<br>
<div>
<form action="chfriendlynameform/change" method="GET">
<input type='text' name='name' placeholder="Neuer Name">
<br><br>
<button>Senden</button>
</form>
</div>
<hr>
<a href="http://10.0.30.20" target="_blank" style="color:#aaa;text-align:right;font-size:11px;">ESafeP 1.0 (ESP 8266)</a>
</div>
</body>
</html>

10
HTML/favicon.svg Normal file
View File

@ -0,0 +1,10 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
<style>
path { fill: #000000; }
@media (prefers-color-scheme: dark) {
path { fill: #ffffff; }
}
</style>
<path d="M1 1.5A1.5 1.5 0 0 1 2.5 0h12A1.5 1.5 0 0 1 16 1.5v13a1.5 1.5 0 0 1-1.5 1.5h-12A1.5 1.5 0 0 1 1 14.5V13H.5a.5.5 0 0 1 0-1H1V8.5H.5a.5.5 0 0 1 0-1H1V4H.5a.5.5 0 0 1 0-1H1V1.5zM2.5 1a.5.5 0 0 0-.5.5v13a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5v-13a.5.5 0 0 0-.5-.5h-12z" fill-rule="nonzero"/>
<path d="M13.5 6a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3a.5.5 0 0 1 .5-.5zM4.828 4.464a.5.5 0 0 1 .708 0l1.09 1.09a3.003 3.003 0 0 1 3.476 0l1.09-1.09a.5.5 0 1 1 .707.708l-1.09 1.09c.74 1.037.74 2.44 0 3.476l1.09 1.09a.5.5 0 1 1-.707.708l-1.09-1.09a3.002 3.002 0 0 1-3.476 0l-1.09 1.09a.5.5 0 1 1-.708-.708l1.09-1.09a3.003 3.003 0 0 1 0-3.476l-1.09-1.09a.5.5 0 0 1 0-.708zM6.95 6.586a2 2 0 1 0 2.828 2.828A2 2 0 0 0 6.95 6.586z" fill-rule="nonzero"/>
</svg>

After

Width:  |  Height:  |  Size: 943 B

46
HTML/index.html Normal file
View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<link rel="icon" href="favicon.svg">
<link rel="stylesheet" href="all.css">
<title>Your safe!</title>
</head>
<body>
<div style="text-align:left;display:inline-block;color:#ffffff;min-width:340px;">
<div style="text-align:center;color:#ffffff;">
<h3>ESafeP</h3>
<h2>%s</h2>
</div>
<div style="padding:0;" id="l1" name="l1">
<table style="width:100%"></table>
<table style="width:100%">
<tbody>
<tr>
<td style="width:100%;text-align:center;font-weight:normal;font-size:62px">%s</td>
</tr>
<tr></tr>
</tbody>
</table>
</div>
<form id="but3" style="display: block;" action="/chpwd" method="get"><button onclick="la(&quot;&amp;o=1&quot;);" name="">&Ouml;ffnen</button></form>
<div id="but3d" style="display: block;"></div>
<br>
<form id="but3" style="display: block;" action="/chpwd" method="get"><button>Code &auml;ndern</button></form>
<p></p>
<form id="but4" style="display: block;" action="/info" method="get"><button>Informationen</button></form>
<p></p>
<form id="but14" style="display: block;" action="/console" method="get"><button>Konsole</button></form>
<p>
<div id="but3d" style="display: block;"></div>
<form id="but0" style="display: block;" action="/reboot" method="get" onsubmit="return confirm(&quot;Wirklich neustarten?&quot;);"><button class="button bred">Neustart</button></form>
<p></p>
<div style="text-align:right;font-size:11px;">
<hr>
<a href="http://10.0.30.20" target="_blank" style="color:#aaa;">ESafeP 1.0 (ESP 8266)</a>
</div>
</div>
</body>
</html>