From 9ade160fce6097cfb6a0988996dc201edf9a0a95 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 13 Jun 2024 13:20:26 +0300 Subject: [PATCH] fix(ota): Allow password and partition change while idle Previously it was allowed only once before begin() was called --- libraries/ArduinoOTA/src/ArduinoOTA.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/ArduinoOTA/src/ArduinoOTA.cpp b/libraries/ArduinoOTA/src/ArduinoOTA.cpp index 6fa482e1335..769193efb69 100644 --- a/libraries/ArduinoOTA/src/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/src/ArduinoOTA.cpp @@ -57,25 +57,28 @@ String ArduinoOTAClass::getHostname() { } ArduinoOTAClass &ArduinoOTAClass::setPassword(const char *password) { - if (!_initialized && !_password.length() && password) { + if (_state == OTA_IDLE && password) { MD5Builder passmd5; passmd5.begin(); passmd5.add(password); passmd5.calculate(); + _password.clear(); _password = passmd5.toString(); } return *this; } ArduinoOTAClass &ArduinoOTAClass::setPasswordHash(const char *password) { - if (!_initialized && !_password.length() && password) { + if (_state == OTA_IDLE && password) { + _password.clear(); _password = password; } return *this; } ArduinoOTAClass &ArduinoOTAClass::setPartitionLabel(const char *partition_label) { - if (!_initialized && !_partition_label.length() && partition_label) { + if (_state == OTA_IDLE && partition_label) { + _partition_label.clear(); _partition_label = partition_label; } return *this;