Parameters saved");
+ page.replace(F("{v}"), S_SAVE_CONFIGURATION);
+ page += F("
" D_CONFIGURATION_SAVED "
");
page += result;
page += F("
");
page += FPSTR(HTTP_MSG_RSTRT);
@@ -1084,16 +1090,16 @@ void handleReset()
char svalue[16]; // was MESSZ
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Reset parameters"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESET_CONFIGURATION);
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Default parameters"));
- page += F("
Parameters reset to default
");
+ page.replace(F("{v}"), S_RESET_CONFIGURATION);
+ page += F("
" D_CONFIGURATION_RESET "
");
page += FPSTR(HTTP_MSG_RSTRT);
page += FPSTR(HTTP_BTN_MAIN);
showPage(page);
- snprintf_P(svalue, sizeof(svalue), PSTR("reset 1"));
+ snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_RESET " 1"));
do_cmnd(svalue);
}
@@ -1102,13 +1108,13 @@ void handleRestore()
if (httpUser()) {
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Restore"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTORE_CONFIGURATION);
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Restore Configuration"));
+ page.replace(F("{v}"), S_RESTORE_CONFIGURATION);
page += FPSTR(HTTP_FORM_RST);
page += FPSTR(HTTP_FORM_RST_UPG);
- page.replace(F("{r1}"), F("restore"));
+ page.replace(F("{r1}"), F(D_RESTORE));
page += FPSTR(HTTP_BTN_CONF);
showPage(page);
@@ -1121,14 +1127,14 @@ void handleUpgrade()
if (httpUser()) {
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Upgrade"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_FIRMWARE_UPGRADE);
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Firmware upgrade"));
+ page.replace(F("{v}"), S_FIRMWARE_UPGRADE);
page += FPSTR(HTTP_FORM_UPG);
page.replace(F("{o1}"), sysCfg.otaUrl);
page += FPSTR(HTTP_FORM_RST_UPG);
- page.replace(F("{r1}"), F("upgrade"));
+ page.replace(F("{r1}"), F(D_UPGRADE));
page += FPSTR(HTTP_BTN_MAIN);
showPage(page);
@@ -1143,22 +1149,22 @@ void handleUpgradeStart()
}
char svalue[100]; // was MESSZ
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Firmware upgrade start"));
+ addLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED));
WIFI_configCounter();
if (strlen(webServer->arg("o").c_str())) {
- snprintf_P(svalue, sizeof(svalue), PSTR("otaurl %s"), webServer->arg("o").c_str());
+ snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_OTAURL " %s"), webServer->arg("o").c_str());
do_cmnd(svalue);
}
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Info"));
- page += F("
Upgrade started ...
");
+ page.replace(F("{v}"), S_INFORMATION);
+ page += F("
" D_UPGRADE_STARTED " ...
");
page += FPSTR(HTTP_MSG_RSTRT);
page += FPSTR(HTTP_BTN_MAIN);
showPage(page);
- snprintf_P(svalue, sizeof(svalue), PSTR("upgrade 1"));
+ snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_UPGRADE " 1"));
do_cmnd(svalue);
}
@@ -1167,39 +1173,40 @@ void handleUploadDone()
if (httpUser()) {
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: File upload done"));
+ addLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE));
- char error[80];
+ char error[100];
char log[LOGSZ];
-
+
WIFI_configCounter();
restartflag = 0;
mqttcounter = 0;
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Info"));
- page += F("
Upload ");
+ page.replace(F("{v}"), S_INFORMATION);
+ page += F("" D_UPLOAD " failed
");
+ page += F("red'>" D_FAILED "
");
switch (_uploaderror) {
- case 1: strcpy_P(error, PSTR("No file selected")); break;
- case 2: strcpy_P(error, PSTR("Not enough space")); break;
- case 3: strcpy_P(error, PSTR("Magic byte is not 0xE9")); break;
- case 4: strcpy_P(error, PSTR("IDE flash size larger than device flash size")); break;
- case 5: strcpy_P(error, PSTR("Upload buffer miscompare")); break;
- case 6: strcpy_P(error, PSTR("Upload failed. Enable logging 3")); break;
- case 7: strcpy_P(error, PSTR("Upload aborted")); break;
- case 8: strcpy_P(error, PSTR("File invalid")); break;
- case 9: strcpy_P(error, PSTR("File too large")); break;
+ case 1: strcpy_P(error, PSTR(D_UPLOAD_ERR_1)); break;
+ case 2: strcpy_P(error, PSTR(D_UPLOAD_ERR_2)); break;
+ case 3: strcpy_P(error, PSTR(D_UPLOAD_ERR_3)); break;
+ case 4: strcpy_P(error, PSTR(D_UPLOAD_ERR_4)); break;
+ case 5: strcpy_P(error, PSTR(D_UPLOAD_ERR_5)); break;
+ case 6: strcpy_P(error, PSTR(D_UPLOAD_ERR_6)); break;
+ case 7: strcpy_P(error, PSTR(D_UPLOAD_ERR_7)); break;
+ case 8: strcpy_P(error, PSTR(D_UPLOAD_ERR_8)); break;
+ case 9: strcpy_P(error, PSTR(D_UPLOAD_ERR_9)); break;
default:
- snprintf_P(error, sizeof(error), PSTR("Upload error code %d"), _uploaderror);
+ snprintf_P(error, sizeof(error), PSTR(D_UPLOAD_ERROR_CODE " %d"), _uploaderror);
}
page += error;
- snprintf_P(log, sizeof(log), PSTR("Upload: %s"), error);
+ snprintf_P(log, sizeof(log), PSTR(D_UPLOAD ": %s"), error);
addLog(LOG_LEVEL_DEBUG, log);
stop_flash_rotate = sysCfg.flag.stop_flash_rotate;
} else {
- page += F("successful
Device will restart in a few seconds");
+ page += F("green'>" D_SUCCESSFUL "
");
+ page += FPSTR(HTTP_MSG_RSTRT);
restartflag = 2;
}
page += F("
");
@@ -1232,7 +1239,7 @@ void handleUploadLoop()
return;
}
CFG_Save(1); // Free flash for upload
- snprintf_P(log, sizeof(log), PSTR("Upload: File %s ..."), upload.filename.c_str());
+ snprintf_P(log, sizeof(log), PSTR(D_LOG_UPLOAD D_FILE " %s ..."), upload.filename.c_str());
addLog(LOG_LEVEL_INFO, log);
if (!_uploadfiletype) {
mqttcounter = 60;
@@ -1312,7 +1319,7 @@ void handleUploadLoop()
}
}
if (!_uploaderror) {
- snprintf_P(log, sizeof(log), PSTR("Upload: Successful %u bytes. Restarting"), upload.totalSize);
+ snprintf_P(log, sizeof(log), PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes. " D_RESTARTING), upload.totalSize);
addLog(LOG_LEVEL_INFO, log);
}
} else if (UPLOAD_FILE_ABORTED == upload.status) {
@@ -1333,7 +1340,7 @@ void handleCmnd()
}
char svalue[INPUT_BUFFER_SIZE]; // big to serve Backlog
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Command"));
+ addLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND));
uint8_t valid = 1;
if (sysCfg.web_password[0] != 0) {
@@ -1376,10 +1383,10 @@ void handleCmnd()
}
} while (counter != logidx);
} else {
- message = F("Enable weblog 2 if response expected\n");
+ message = F(D_ENABLE_WEBLOG_FOR_RESPONSE "\n");
}
} else {
- message = F("Need user=&password=\n");
+ message = F(D_NEED_USER_AND_PASSWORD "\n");
}
webServer->send(200, FPSTR(HDR_CTYPE_PLAIN), message);
}
@@ -1390,10 +1397,10 @@ void handleConsole()
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Console"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONSOLE);
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Console"));
+ page.replace(F("{v}"), S_CONSOLE);
page.replace(F(""), FPSTR(HTTP_SCRIPT_CONSOL));
page.replace(F(""), F(""));
page += FPSTR(HTTP_FORM_CMND);
@@ -1413,14 +1420,14 @@ void handleAjax()
if (strlen(webServer->arg("c1").c_str())) {
snprintf_P(svalue, sizeof(svalue), PSTR("%s"), webServer->arg("c1").c_str());
- snprintf_P(log, sizeof(log), PSTR("CMND: %s"), svalue);
+ snprintf_P(log, sizeof(log), PSTR(D_LOG_COMMAND "%s"), svalue);
addLog(LOG_LEVEL_INFO, log);
byte syslog_now = syslog_level;
syslog_level = 0; // Disable UDP syslog to not trigger hardware WDT
do_cmnd(svalue);
syslog_level = syslog_now;
}
-
+
if (strlen(webServer->arg("c2").c_str())) {
counter = atoi(webServer->arg("c2").c_str());
}
@@ -1463,103 +1470,100 @@ void handleInfo()
if (httpUser()) {
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Info"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_INFORMATION);
char stopic[TOPSZ];
int freeMem = ESP.getFreeHeap();
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Information"));
+ page.replace(F("{v}"), S_INFORMATION);
// page += F("");
page += FPSTR(HTTP_BTN_MAIN);
@@ -1571,10 +1575,10 @@ void handleRestart()
if (httpUser()) {
return;
}
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Restarting"));
+ addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART);
String page = FPSTR(HTTP_HEAD);
- page.replace(F("{v}"), F("Info"));
+ page.replace(F("{v}"), S_RESTART);
page += FPSTR(HTTP_MSG_RSTRT);
if (HTTP_MANAGER == _httpflag) {
_httpflag = HTTP_ADMIN;
@@ -1594,14 +1598,14 @@ void handleNotFound()
return;
}
-#ifdef USE_EMULATION
+#ifdef USE_EMULATION
String path = webServer->uri();
if ((EMUL_HUE == sysCfg.flag.emulation) && (path.startsWith("/api"))) {
handle_hue_api(&path);
} else
#endif // USE_EMULATION
{
- String message = F("File Not Found\n\nURI: ");
+ String message = F(D_FILE_NOT_FOUND "\n\nURI: ");
message += webServer->uri();
message += F("\nMethod: ");
message += (webServer->method() == HTTP_GET) ? F("GET") : F("POST");
@@ -1620,7 +1624,7 @@ void handleNotFound()
boolean captivePortal()
{
if ((HTTP_MANAGER == _httpflag) && !isIp(webServer->hostHeader())) {
- addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Request redirected to captive portal"));
+ addLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED));
webServer->sendHeader(F("Location"), String("http://") + webServer->client().localIP().toString(), true);
webServer->send(302, FPSTR(HDR_CTYPE_PLAIN), ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
diff --git a/sonoff/xdrv_domoticz.ino b/sonoff/xdrv_domoticz.ino
index d496b2f92..6ea9e6a46 100644
--- a/sonoff/xdrv_domoticz.ino
+++ b/sonoff/xdrv_domoticz.ino
@@ -23,22 +23,22 @@
#ifdef USE_WEBSERVER
const char HTTP_FORM_DOMOTICZ[] PROGMEM =
- "