|
@ -162,18 +162,14 @@ class Web { |
|
|
mUploadFp.write(data, len); |
|
|
mUploadFp.write(data, len); |
|
|
if (final) { |
|
|
if (final) { |
|
|
mUploadFp.close(); |
|
|
mUploadFp.close(); |
|
|
#if !defined(ETHERNET) |
|
|
|
|
|
char pwd[PWD_LEN]; |
|
|
char pwd[PWD_LEN]; |
|
|
strncpy(pwd, mConfig->sys.stationPwd, PWD_LEN); // backup WiFi PWD
|
|
|
strncpy(pwd, mConfig->sys.stationPwd, PWD_LEN); // backup WiFi PWD
|
|
|
#endif |
|
|
|
|
|
if (!mApp->readSettings("/tmp.json")) { |
|
|
if (!mApp->readSettings("/tmp.json")) { |
|
|
mUploadFail = true; |
|
|
mUploadFail = true; |
|
|
DPRINTLN(DBG_ERROR, F("upload JSON error!")); |
|
|
DPRINTLN(DBG_ERROR, F("upload JSON error!")); |
|
|
} else { |
|
|
} else { |
|
|
LittleFS.remove("/tmp.json"); |
|
|
LittleFS.remove("/tmp.json"); |
|
|
#if !defined(ETHERNET) |
|
|
|
|
|
strncpy(mConfig->sys.stationPwd, pwd, PWD_LEN); // restore WiFi PWD
|
|
|
strncpy(mConfig->sys.stationPwd, pwd, PWD_LEN); // restore WiFi PWD
|
|
|
#endif |
|
|
|
|
|
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { |
|
|
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { |
|
|
if((mConfig->inst.iv[i].serial.u64 != 0) && (mConfig->inst.iv[i].serial.u64 < 138999999999)) { // hexadecimal
|
|
|
if((mConfig->inst.iv[i].serial.u64 != 0) && (mConfig->inst.iv[i].serial.u64 < 138999999999)) { // hexadecimal
|
|
|
mConfig->inst.iv[i].serial.u64 = ah::Serial2u64(String(mConfig->inst.iv[i].serial.u64).c_str()); |
|
|
mConfig->inst.iv[i].serial.u64 = ah::Serial2u64(String(mConfig->inst.iv[i].serial.u64).c_str()); |
|
@ -322,10 +318,18 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onIndex(AsyncWebServerRequest *request, bool checkAp = true) { |
|
|
void onIndex(AsyncWebServerRequest *request, bool checkAp = true) { |
|
|
|
|
|
#if !defined(ETHERNET) |
|
|
if(mApp->isApActive() && checkAp) { |
|
|
if(mApp->isApActive() && checkAp) { |
|
|
onWizard(request); |
|
|
onWizard(request); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
|
// show wizard only if ethernet is not configured
|
|
|
|
|
|
if(mApp->isApActive() && checkAp && !mConfig->sys.eth.enabled) { |
|
|
|
|
|
onWizard(request); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
getPage(request, PROT_MASK_INDEX, index_html, index_html_len); |
|
|
getPage(request, PROT_MASK_INDEX, index_html, index_html_len); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -432,6 +436,13 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onWizard(AsyncWebServerRequest *request) { |
|
|
void onWizard(AsyncWebServerRequest *request) { |
|
|
|
|
|
#if defined(ETHERNET) |
|
|
|
|
|
if(mConfig->sys.eth.enabled) { |
|
|
|
|
|
getPage(request, PROT_MASK_INDEX, index_html, index_html_len); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len); |
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
response->addHeader(F("content-type"), "text/html; charset=UTF-8"); |
|
|
response->addHeader(F("content-type"), "text/html; charset=UTF-8"); |
|
@ -449,13 +460,12 @@ class Web { |
|
|
char buf[20] = {0}; |
|
|
char buf[20] = {0}; |
|
|
|
|
|
|
|
|
// general
|
|
|
// general
|
|
|
#if !defined(ETHERNET) |
|
|
|
|
|
if (request->arg("ssid") != "") |
|
|
if (request->arg("ssid") != "") |
|
|
request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); |
|
|
request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); |
|
|
if (request->arg("pwd") != "{PWD}") |
|
|
if (request->arg("pwd") != "{PWD}") |
|
|
request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); |
|
|
request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); |
|
|
mConfig->sys.isHidden = (request->arg("hidd") == "on"); |
|
|
mConfig->sys.isHidden = (request->arg("hidd") == "on"); |
|
|
#endif /* !defined(ETHERNET) */ |
|
|
|
|
|
if (request->arg("ap_pwd") != "") |
|
|
if (request->arg("ap_pwd") != "") |
|
|
request->arg("ap_pwd").toCharArray(mConfig->sys.apPwd, PWD_LEN); |
|
|
request->arg("ap_pwd").toCharArray(mConfig->sys.apPwd, PWD_LEN); |
|
|
if (request->arg("device") != "") |
|
|
if (request->arg("device") != "") |
|
|