File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
6666, _dataTopicIn(" " )
6767#if OTA_ENABLED
6868, _ota(&_message_stream)
69- , _ask_user_before_executing_ota{false }
7069, _get_ota_confirmation{nullptr }
7170#endif /* OTA_ENABLED */
7271{
@@ -320,6 +319,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
320319 _device.update ();
321320
322321#if OTA_ENABLED
322+ if (_get_ota_confirmation != nullptr &&
323+ _ota.getState () == OTACloudProcessInterface::State::OtaAvailable &&
324+ _get_ota_confirmation ()) {
325+ _ota.approveOta ();
326+ }
327+
323328 _ota.update ();
324329#endif // OTA_ENABLED
325330
Original file line number Diff line number Diff line change @@ -94,7 +94,12 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
9494 */
9595 void onOTARequestCb (onOTARequestCallbackFunc cb) {
9696 _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+ }
98103 }
99104#endif
100105
@@ -145,7 +150,6 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
145150#if OTA_ENABLED
146151 TLSClientOta _otaClient;
147152 OTACloudProcess _ota;
148- bool _ask_user_before_executing_ota;
149153 onOTARequestCallbackFunc _get_ota_confirmation;
150154#endif /* OTA_ENABLED */
151155
You can’t perform that action at this time.
0 commit comments