Skip to content

Commit c05a759

Browse files
authored
[SYS] Change OTAPASSWORD for devices using a part of the MAC as the password (#1834)
To keep the same password as previously, if it was not changed
1 parent 2440c14 commit c05a759

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main/main.ino

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,8 +1732,18 @@ bool loadConfigFromFlash() {
17321732
mqtt_ss_index = json["mqtt_ss_index"].as<uint8_t>();
17331733
if (json.containsKey("gateway_name"))
17341734
strcpy(gateway_name, json["gateway_name"]);
1735-
if (json.containsKey("ota_pass"))
1735+
if (json.containsKey("ota_pass")) {
17361736
strcpy(ota_pass, json["ota_pass"]);
1737+
# ifdef WM_PWD_FROM_MAC // From ESP Mac Address, last 8 digits as the password
1738+
// Compare the existing ota_pass if ota_pass = OTAPASSWORD then replace with the last 8 digits of the mac address
1739+
// This enable user migrating from previous version to have the same WiFi portal password as previously unless they changed it
1740+
if (strcmp(ota_pass, "OTAPASSWORD") == 0) {
1741+
String s = WiFi.macAddress();
1742+
sprintf(ota_pass, "%.2s%.2s%.2s%.2s",
1743+
s.c_str() + 6, s.c_str() + 9, s.c_str() + 12, s.c_str() + 15);
1744+
}
1745+
# endif
1746+
}
17371747
if (json.containsKey("ota_server_cert"))
17381748
ota_server_cert = json["ota_server_cert"].as<const char*>();
17391749
result = true;

0 commit comments

Comments
 (0)