@@ -49,6 +49,8 @@ static uint16_t const DEFAULT_BROKER_PORT_SECURE_AUTH = 8883;
4949static char const DEFAULT_BROKER_ADDRESS_USER_PASS_AUTH[] = " mqtts-up.iot.arduino.cc" ;
5050static uint16_t const DEFAULT_BROKER_PORT_USER_PASS_AUTH = 8884 ;
5151
52+ typedef bool (*otaConfirmationStatus)(void );
53+
5254/* *****************************************************************************
5355 * CLASS DECLARATION
5456 ******************************************************************************/
@@ -80,6 +82,15 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
8082 inline String getBrokerAddress () const { return _brokerAddress; }
8183 inline uint16_t getBrokerPort () const { return _brokerPort; }
8284
85+ #if OTA_ENABLED
86+ /* The callback is triggered when the OTA is initiated and it gets executed until _ota_req flag is cleared.
87+ * It should return true when the OTA can be applied or false otherwise.
88+ */
89+ void onOTARequestCb (otaConfirmationStatus cb) {
90+ _get_ota_confirmation = cb;
91+ _automatic_ota = false ;
92+ }
93+ #endif
8394
8495 private:
8596 static const int MQTT_TRANSMIT_BUFFER_SIZE = 256 ;
@@ -130,6 +141,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
130141 String _ota_img_sha256;
131142 String _ota_url;
132143 bool _ota_req;
144+ bool _automatic_ota = true ;
133145#endif /* OTA_ENABLED */
134146
135147 inline String getTopic_shadowout () { return ( getThingId ().length () == 0 ) ? String (" " ) : String (" /a/t/" + getThingId () + " /shadow/o" ); }
@@ -153,6 +165,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
153165#if OTA_ENABLED
154166 void onOTARequest ();
155167#endif
168+
169+ otaConfirmationStatus _get_ota_confirmation = {nullptr };
156170};
157171
158172/* *****************************************************************************
0 commit comments