diff --git a/code/html/index.html b/code/html/index.html
index fcb2cfd9..eae1130c 100644
--- a/code/html/index.html
+++ b/code/html/index.html
@@ -168,9 +168,9 @@
-
Web interface password
-
Change the password for the 'admin' user to access this web interface.
-
+
Administrator password
+
The administrator password is used to access this web interface (user 'admin'), but also to connect to the device when in AP mode or to flash a new firmware over-the-air (OTA).
+
diff --git a/code/platformio.ini b/code/platformio.ini
index a9cdcc9c..ca92094a 100644
--- a/code/platformio.ini
+++ b/code/platformio.ini
@@ -1,5 +1,5 @@
[platformio]
-env_default = sonoff-pow-debug
+env_default = node-debug
[common]
lib_install = 19,31,44,64,305,306,346,727
diff --git a/code/src/defaults.h b/code/src/defaults.h
index fd1ede80..60be3d66 100644
--- a/code/src/defaults.h
+++ b/code/src/defaults.h
@@ -74,16 +74,13 @@
#define WIFI_RECONNECT_INTERVAL 300000
#define WIFI_MAX_NETWORKS 3
#define ADMIN_PASS "fibonacci"
-#define AP_PASS ADMIN_PASS
#define HTTP_USERNAME "admin"
-#define HTTP_PASSWORD ADMIN_PASS
#define CSRF_BUFFER_SIZE 5
// -----------------------------------------------------------------------------
// OTA & NOFUSS
// -----------------------------------------------------------------------------
-#define OTA_PASS ADMIN_PASS
#define OTA_PORT 8266
#define NOFUSS_SERVER "http://192.168.1.100"
#define NOFUSS_INTERVAL 3600000
diff --git a/code/src/ota.ino b/code/src/ota.ino
index 5138f295..56048e0c 100644
--- a/code/src/ota.ino
+++ b/code/src/ota.ino
@@ -13,11 +13,15 @@ Copyright (C) 2016 by Xose PĂ©rez
// OTA
// -----------------------------------------------------------------------------
-void otaSetup() {
-
+void otaConfigure() {
ArduinoOTA.setPort(OTA_PORT);
ArduinoOTA.setHostname(getSetting("hostname", HOSTNAME).c_str());
- ArduinoOTA.setPassword((const char *) OTA_PASS);
+ ArduinoOTA.setPassword(getSetting("adminPass", ADMIN_PASS).c_str());
+}
+
+void otaSetup() {
+
+ otaConfigure();
ArduinoOTA.onStart([]() {
DEBUG_MSG("[OTA] Start\n");
diff --git a/code/src/web.ino b/code/src/web.ino
index 958b2afa..165685cb 100644
--- a/code/src/web.ino
+++ b/code/src/web.ino
@@ -93,7 +93,7 @@ void webSocketParse(uint32_t client_id, uint8_t * payload, size_t length) {
#endif
// Do not change the password if empty
- if (key == "httpPassword") {
+ if (key == "adminPass") {
if (value.length() == 0) continue;
}
@@ -118,6 +118,7 @@ void webSocketParse(uint32_t client_id, uint8_t * payload, size_t length) {
saveSettings();
wifiConfigure();
+ otaConfigure();
buildTopics();
#if ENABLE_RF
@@ -240,11 +241,10 @@ void webSocketEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsE
// WEBSERVER
// -----------------------------------------------------------------------------
-void onHome(AsyncWebServerRequest *request){
- String password = getSetting("httpPassword", HTTP_PASSWORD);
+void onHome(AsyncWebServerRequest *request) {
+ String password = getSetting("adminPass", ADMIN_PASS);
char httpPassword[password.length() + 1];
password.toCharArray(httpPassword, password.length() + 1);
- Serial.println(httpPassword);
if (!request->authenticate(HTTP_USERNAME, httpPassword)) {
return request->requestAuthentication();
}
diff --git a/code/src/wifi.ino b/code/src/wifi.ino
index 56861fb6..5a055020 100644
--- a/code/src/wifi.ino
+++ b/code/src/wifi.ino
@@ -45,13 +45,13 @@ bool createAP() {
void wifiConfigure() {
jw.scanNetworks(true);
- jw.setHostname((char *) getSetting("hostname", HOSTNAME).c_str());
- jw.setSoftAP((char *) getSetting("hostname", HOSTNAME).c_str(), (char *) AP_PASS);
+ jw.setHostname(getSetting("hostname", HOSTNAME).c_str());
+ jw.setSoftAP(getSetting("hostname", HOSTNAME).c_str(), getSetting("adminPass", ADMIN_PASS).c_str());
jw.setAPMode(AP_MODE_ALONE);
jw.cleanNetworks();
- if (getSetting("ssid0").length() > 0) jw.addNetwork((char *) getSetting("ssid0").c_str(), (char *) getSetting("pass0").c_str());
- if (getSetting("ssid1").length() > 0) jw.addNetwork((char *) getSetting("ssid1").c_str(), (char *) getSetting("pass1").c_str());
- if (getSetting("ssid2").length() > 0) jw.addNetwork((char *) getSetting("ssid2").c_str(), (char *) getSetting("pass2").c_str());
+ if (getSetting("ssid0").length() > 0) jw.addNetwork(getSetting("ssid0").c_str(), getSetting("pass0").c_str());
+ if (getSetting("ssid1").length() > 0) jw.addNetwork(getSetting("ssid1").c_str(), getSetting("pass1").c_str());
+ if (getSetting("ssid2").length() > 0) jw.addNetwork(getSetting("ssid2").c_str(), getSetting("pass2").c_str());
}
void wifiSetup() {
@@ -110,6 +110,7 @@ void wifiSetup() {
if (code == MESSAGE_ACCESSPOINT_CREATED) {
DEBUG_MSG("[WIFI] MODE AP --------------------------------------\n");
DEBUG_MSG("[WIFI] SSID %s\n", jw.getAPSSID().c_str());
+ DEBUG_MSG("[WIFI] PASS %s\n", getSetting("adminPass", ADMIN_PASS).c_str());
DEBUG_MSG("[WIFI] IP %s\n", WiFi.softAPIP().toString().c_str());
DEBUG_MSG("[WIFI] MAC %s\n", WiFi.softAPmacAddress().c_str());
DEBUG_MSG("[WIFI] ----------------------------------------------\n");