@@ -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,27 @@ 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
+
87
+ // The callback is triggered when the OTA is initiated
88
+ // Should return true when the OTA can be applied, false otherwise
89
+
90
+ /*
91
+ static first_run = true;
92
+ bool sample_ota_confirmation() {
93
+ if (first_run) {
94
+ HMI.show(confirmationModal)
95
+ first_run = false;
96
+ }
97
+ return HMI.getConfirmation();
98
+ }
99
+ */
100
+
101
+ void onOTARequestCb (otaConfirmationStatus cb) {
102
+ _get_ota_confirmation = cb;
103
+ _automatic_ota = false ;
104
+ }
105
+ #endif
83
106
84
107
private:
85
108
static const int MQTT_TRANSMIT_BUFFER_SIZE = 256 ;
@@ -130,6 +153,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
130
153
String _ota_img_sha256;
131
154
String _ota_url;
132
155
bool _ota_req;
156
+ bool _automatic_ota = true ;
133
157
#endif /* OTA_ENABLED */
134
158
135
159
inline String getTopic_shadowout () { return ( getThingId ().length () == 0 ) ? String (" " ) : String (" /a/t/" + getThingId () + " /shadow/o" ); }
@@ -153,6 +177,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
153
177
#if OTA_ENABLED
154
178
void onOTARequest ();
155
179
#endif
180
+
181
+ otaConfirmationStatus _get_ota_confirmation = {nullptr };
156
182
};
157
183
158
184
/* *****************************************************************************
0 commit comments