@@ -49,6 +49,8 @@ static uint16_t const DEFAULT_BROKER_PORT_SECURE_AUTH = 8883;
49
49
static char const DEFAULT_BROKER_ADDRESS_USER_PASS_AUTH[] = " mqtts-up.iot.arduino.cc" ;
50
50
static uint16_t const DEFAULT_BROKER_PORT_USER_PASS_AUTH = 8884 ;
51
51
52
+ typedef bool (*otaConfirmationStatus)(void );
53
+
52
54
/* *****************************************************************************
53
55
* CLASS DECLARATION
54
56
******************************************************************************/
@@ -80,6 +82,15 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
80
82
inline String getBrokerAddress () const { return _brokerAddress; }
81
83
inline uint16_t getBrokerPort () const { return _brokerPort; }
82
84
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
83
94
84
95
private:
85
96
static const int MQTT_TRANSMIT_BUFFER_SIZE = 256 ;
@@ -130,6 +141,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
130
141
String _ota_img_sha256;
131
142
String _ota_url;
132
143
bool _ota_req;
144
+ bool _automatic_ota = true ;
133
145
#endif /* OTA_ENABLED */
134
146
135
147
inline String getTopic_shadowout () { return ( getThingId ().length () == 0 ) ? String (" " ) : String (" /a/t/" + getThingId () + " /shadow/o" ); }
@@ -153,6 +165,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
153
165
#if OTA_ENABLED
154
166
void onOTARequest ();
155
167
#endif
168
+
169
+ otaConfirmationStatus _get_ota_confirmation = {nullptr };
156
170
};
157
171
158
172
/* *****************************************************************************
0 commit comments