Fixed last things for the webSpiffs

This commit is contained in:
Stefan Kremser
2018-04-03 18:03:08 +02:00
parent f70c644a9d
commit aa7c1f211e
4 changed files with 101 additions and 87 deletions

View File

@@ -30,7 +30,7 @@ void Settings::load() {
if(data.containsKey(keyword(S_SERIALINTERFACE))) setSerialInterface(data.get<bool>(keyword(S_SERIALINTERFACE)));
if(data.containsKey(keyword(S_SERIAL_ECHO))) setSerialEcho(data.get<bool>(keyword(S_SERIAL_ECHO)));
if(data.containsKey(keyword(S_WEBINTERFACE))) setWebInterface(data.get<bool>(keyword(S_WEBINTERFACE)));
if(data.containsKey(keyword(S_WEB_SPIFFS))) setWebInterface(data.get<bool>(keyword(S_WEB_SPIFFS)));
if(data.containsKey(keyword(S_WEB_SPIFFS))) setWebSpiffs(data.get<bool>(keyword(S_WEB_SPIFFS)));
if(data.containsKey(keyword(S_LEDENABLED))) setLedEnabled(data.get<bool>(keyword(S_LEDENABLED)));
if(data.containsKey(keyword(S_MAXCH))) setMaxCh(data.get<uint8_t>(keyword(S_MAXCH)));
if(data.containsKey(keyword(S_MACAP))) setMacAP(data.get<String>(keyword(S_MACAP)));

File diff suppressed because one or more lines are too long

View File

@@ -230,8 +230,10 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
// ================================================================
// post here the output of the webConverter.py
if (settings.getWebSpiffs()) {
if(!settings.getWebSpiffs()){
server.on(PSTR("/"), HTTP_GET, [](){
sendProgmem(indexhtml, sizeof(indexhtml), PSTR("text/html"));
});
server.on(PSTR("/attack.html"), HTTP_GET, [](){
sendProgmem(attackhtml, sizeof(attackhtml), PSTR("text/html"));
});
@@ -268,6 +270,9 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
server.on(PSTR("/ssids.js"), HTTP_GET, [](){
sendProgmem(ssidsjs, sizeof(ssidsjs), PSTR("application/javascript"));
});
server.on(PSTR("/cn.lang"), HTTP_GET, [](){
sendProgmem(cnlang, sizeof(cnlang), PSTR("application/json"));
});
server.on(PSTR("/cs.lang"), HTTP_GET, [](){
sendProgmem(cslang, sizeof(cslang), PSTR("application/json"));
});
@@ -286,8 +291,9 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
}
server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [](){
if (settings.getWebSpiffs()) {
if (settings.getLang() == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), PSTR("application/json"));
if(!settings.getWebSpiffs()){
if(settings.getLang() == String(F("cn"))) sendProgmem(cnlang, sizeof(cnlang), PSTR("application/json"));
else if(settings.getLang() == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), PSTR("application/json"));
else if(settings.getLang() == String(F("de"))) sendProgmem(delang, sizeof(delang), PSTR("application/json"));
else if(settings.getLang() == String(F("en"))) sendProgmem(enlang, sizeof(enlang), PSTR("application/json"));
else if(settings.getLang() == String(F("fr"))) sendProgmem(frlang, sizeof(frlang), PSTR("application/json"));
@@ -298,7 +304,6 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
handleFileRead("/web/lang/"+settings.getLang()+".lang");
}
});
// ================================================================
server.on(str(W_RUN).c_str(), HTTP_GET, []() {

View File

@@ -222,7 +222,9 @@ f.write("#endif\n")
f.write("\n")
f.write("void copyWebFiles(bool force){\n")
f.write("#ifdef USE_PROGMEM_WEB_FILES\n")
f.write("if(settings.getWebSpiffs()){\n")
f.write(copy_files_function)
f.write("}\n")
f.write("#endif\n")
f.write("}\n")
f.write("\n")
@@ -232,11 +234,14 @@ f.close()
print("\n[+] Done, happy uploading :)")
print("Here are the updated functions for wifi.h, in case you added or removed files:")
print();
print('if(settings.getWebSpiffs()){')
print('if(!settings.getWebSpiffs()){')
print(' server.on(PSTR("/"), HTTP_GET, [](){')
print(' sendProgmem(indexhtml, sizeof(indexhtml), PSTR("text/html"));')
print('});')
print(webserver_events)
print('}')
print("server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [](){")
print(" if(settings.getWebSpiffs()){")
print(" if(!settings.getWebSpiffs()){")
print(load_lang)
print(' else handleFileRead("/web/lang/"+settings.getLang()+".lang");')
print(' } else {')