Skip to content

Commit 9ade160

Browse files
committed
fix(ota): Allow password and partition change while idle
Previously it was allowed only once before begin() was called
1 parent 1d895e5 commit 9ade160

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: libraries/ArduinoOTA/src/ArduinoOTA.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,28 @@ String ArduinoOTAClass::getHostname() {
5757
}
5858

5959
ArduinoOTAClass &ArduinoOTAClass::setPassword(const char *password) {
60-
if (!_initialized && !_password.length() && password) {
60+
if (_state == OTA_IDLE && password) {
6161
MD5Builder passmd5;
6262
passmd5.begin();
6363
passmd5.add(password);
6464
passmd5.calculate();
65+
_password.clear();
6566
_password = passmd5.toString();
6667
}
6768
return *this;
6869
}
6970

7071
ArduinoOTAClass &ArduinoOTAClass::setPasswordHash(const char *password) {
71-
if (!_initialized && !_password.length() && password) {
72+
if (_state == OTA_IDLE && password) {
73+
_password.clear();
7274
_password = password;
7375
}
7476
return *this;
7577
}
7678

7779
ArduinoOTAClass &ArduinoOTAClass::setPartitionLabel(const char *partition_label) {
78-
if (!_initialized && !_partition_label.length() && partition_label) {
80+
if (_state == OTA_IDLE && partition_label) {
81+
_partition_label.clear();
7982
_partition_label = partition_label;
8083
}
8184
return *this;

0 commit comments

Comments
 (0)