File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
66
66
, _dataTopicIn(" " )
67
67
#if OTA_ENABLED
68
68
, _ota(&_message_stream)
69
- , _ask_user_before_executing_ota{false }
70
69
, _get_ota_confirmation{nullptr }
71
70
#endif /* OTA_ENABLED */
72
71
{
@@ -320,6 +319,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
320
319
_device.update ();
321
320
322
321
#if OTA_ENABLED
322
+ if (_get_ota_confirmation != nullptr &&
323
+ _ota.getState () == OTACloudProcessInterface::State::OtaAvailable &&
324
+ _get_ota_confirmation ()) {
325
+ _ota.approveOta ();
326
+ }
327
+
323
328
_ota.update ();
324
329
#endif // OTA_ENABLED
325
330
Original file line number Diff line number Diff line change @@ -94,7 +94,12 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
94
94
*/
95
95
void onOTARequestCb (onOTARequestCallbackFunc cb) {
96
96
_get_ota_confirmation = cb;
97
- _ask_user_before_executing_ota = true ;
97
+
98
+ if (_get_ota_confirmation) {
99
+ _ota.setOtaPolicies (OTACloudProcessInterface::ApprovalRequired);
100
+ } else {
101
+ _ota.setOtaPolicies (OTACloudProcessInterface::None);
102
+ }
98
103
}
99
104
#endif
100
105
@@ -145,7 +150,6 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
145
150
#if OTA_ENABLED
146
151
TLSClientOta _otaClient;
147
152
OTACloudProcess _ota;
148
- bool _ask_user_before_executing_ota;
149
153
onOTARequestCallbackFunc _get_ota_confirmation;
150
154
#endif /* OTA_ENABLED */
151
155
You can’t perform that action at this time.
0 commit comments