Skip to content

Commit 7dfb086

Browse files
committed
Use more meaningful name for _automatic_ota and clarify conditions to run OTA update
1 parent 9cf7523 commit 7dfb086

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/ArduinoIoTCloudTCP.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
9595
, _ota_img_sha256{"Inv."}
9696
, _ota_url{""}
9797
, _ota_req{false}
98+
, _ask_user_before_executing_ota{false}
9899
#endif /* OTA_ENABLED */
99100
{
100101

@@ -506,7 +507,9 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
506507

507508
if (_ota_req)
508509
{
509-
if (_automatic_ota || (_get_ota_confirmation != nullptr && _get_ota_confirmation())) {
510+
bool const ota_execution_allowed_by_user = (_get_ota_confirmation != nullptr && _get_ota_confirmation());
511+
bool const perform_ota_now = ota_execution_allowed_by_user || !_ask_user_before_executing_ota;
512+
if (perform_ota_now) {
510513
/* Clear the error flag. */
511514
_ota_error = static_cast<int>(OTAError::None);
512515
/* Clear the request flag. */

src/ArduinoIoTCloudTCP.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
8989
*/
9090
void onOTARequestCb(otaConfirmationStatus cb) {
9191
_get_ota_confirmation = cb;
92-
_automatic_ota = false;
92+
_ask_user_before_executing_ota = true;
9393
}
9494
#endif
9595

@@ -142,7 +142,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
142142
String _ota_img_sha256;
143143
String _ota_url;
144144
bool _ota_req;
145-
bool _automatic_ota = true;
145+
bool _ask_user_before_executing_ota;
146146
#endif /* OTA_ENABLED */
147147

148148
inline String getTopic_shadowout() { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/shadow/o"); }

0 commit comments

Comments
 (0)