@@ -48,46 +48,46 @@ HTTPUpdate::~HTTPUpdate(void)
48
48
{
49
49
}
50
50
51
- HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& url, const String& currentVersion)
51
+ HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& url, const String& currentVersion, HTTPUpdateRequestCB requestCB )
52
52
{
53
53
HTTPClient http;
54
54
if (!http.begin (client, url))
55
55
{
56
56
return HTTP_UPDATE_FAILED;
57
57
}
58
- return handleUpdate (http, currentVersion, false );
58
+ return handleUpdate (http, currentVersion, false , requestCB );
59
59
}
60
60
61
- HTTPUpdateResult HTTPUpdate::updateSpiffs (HTTPClient& httpClient, const String& currentVersion)
61
+ HTTPUpdateResult HTTPUpdate::updateSpiffs (HTTPClient& httpClient, const String& currentVersion, HTTPUpdateRequestCB requestCB )
62
62
{
63
- return handleUpdate (httpClient, currentVersion, true );
63
+ return handleUpdate (httpClient, currentVersion, true , requestCB );
64
64
}
65
65
66
- HTTPUpdateResult HTTPUpdate::updateSpiffs (WiFiClient& client, const String& url, const String& currentVersion)
66
+ HTTPUpdateResult HTTPUpdate::updateSpiffs (WiFiClient& client, const String& url, const String& currentVersion, HTTPUpdateRequestCB requestCB )
67
67
{
68
68
HTTPClient http;
69
69
if (!http.begin (client, url))
70
70
{
71
71
return HTTP_UPDATE_FAILED;
72
72
}
73
- return handleUpdate (http, currentVersion, true );
73
+ return handleUpdate (http, currentVersion, true , requestCB );
74
74
}
75
75
76
76
HTTPUpdateResult HTTPUpdate::update (HTTPClient& httpClient,
77
- const String& currentVersion)
77
+ const String& currentVersion, HTTPUpdateRequestCB requestCB )
78
78
{
79
- return handleUpdate (httpClient, currentVersion, false );
79
+ return handleUpdate (httpClient, currentVersion, false , requestCB );
80
80
}
81
81
82
82
HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& host, uint16_t port, const String& uri,
83
- const String& currentVersion)
83
+ const String& currentVersion, HTTPUpdateRequestCB requestCB )
84
84
{
85
85
HTTPClient http;
86
86
if (!http.begin (client, host, port, uri))
87
87
{
88
88
return HTTP_UPDATE_FAILED;
89
89
}
90
- return handleUpdate (http, currentVersion, false );
90
+ return handleUpdate (http, currentVersion, false , requestCB );
91
91
}
92
92
93
93
/* *
@@ -180,7 +180,7 @@ String getSketchSHA256() {
180
180
* @param currentVersion const char *
181
181
* @return HTTPUpdateResult
182
182
*/
183
- HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient& http, const String& currentVersion, bool spiffs)
183
+ HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient& http, const String& currentVersion, bool spiffs, HTTPUpdateRequestCB requestCB )
184
184
{
185
185
186
186
HTTPUpdateResult ret = HTTP_UPDATE_FAILED;
@@ -216,6 +216,9 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
216
216
if (currentVersion && currentVersion[0 ] != 0x00 ) {
217
217
http.addHeader (" x-ESP32-version" , currentVersion);
218
218
}
219
+ if (requestCB) {
220
+ requestCB (&http);
221
+ }
219
222
220
223
const char * headerkeys[] = { " x-MD5" };
221
224
size_t headerkeyssize = sizeof (headerkeys) / sizeof (char *);
0 commit comments