@@ -52,23 +52,59 @@ HTTPUpdateResult HTTPUpdate::update(NetworkClient &client, const String &url, co
5252 if  (!http.begin (client, url)) {
5353 return  HTTP_UPDATE_FAILED;
5454 }
55-  return  handleUpdate (http, currentVersion, false , requestCB);
55+  return  handleUpdate (http, currentVersion, U_FLASH, requestCB);
56+ }
57+ 
58+ HTTPUpdateResult HTTPUpdate::updateFs (HTTPClient &httpClient, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
59+  return  handleUpdate (httpClient, currentVersion, U_FLASHFS, requestCB);
5660}
5761
5862HTTPUpdateResult HTTPUpdate::updateSpiffs (HTTPClient &httpClient, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
59-  return  handleUpdate (httpClient, currentVersion, true , requestCB);
63+  return  handleUpdate (httpClient, currentVersion, U_SPIFFS, requestCB);
64+ }
65+ 
66+ HTTPUpdateResult HTTPUpdate::updateFatfs (HTTPClient &httpClient, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
67+  return  handleUpdate (httpClient, currentVersion, U_FATFS, requestCB);
68+ }
69+ 
70+ HTTPUpdateResult HTTPUpdate::updateLittlefs (HTTPClient &httpClient, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
71+  return  handleUpdate (httpClient, currentVersion, U_LITTLEFS, requestCB);
72+ }
73+ 
74+ HTTPUpdateResult HTTPUpdate::updateFs (NetworkClient &client, const  String &url, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
75+  HTTPClient http;
76+  if  (!http.begin (client, url)) {
77+  return  HTTP_UPDATE_FAILED;
78+  }
79+  return  handleUpdate (http, currentVersion, U_FLASHFS, requestCB);
6080}
6181
6282HTTPUpdateResult HTTPUpdate::updateSpiffs (NetworkClient &client, const  String &url, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
6383 HTTPClient http;
6484 if  (!http.begin (client, url)) {
6585 return  HTTP_UPDATE_FAILED;
6686 }
67-  return  handleUpdate (http, currentVersion, true , requestCB);
87+  return  handleUpdate (http, currentVersion, U_SPIFFS, requestCB);
88+ }
89+ 
90+ HTTPUpdateResult HTTPUpdate::updateFatfs (NetworkClient &client, const  String &url, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
91+  HTTPClient http;
92+  if  (!http.begin (client, url)) {
93+  return  HTTP_UPDATE_FAILED;
94+  }
95+  return  handleUpdate (http, currentVersion, U_FATFS, requestCB);
96+ }
97+ 
98+ HTTPUpdateResult HTTPUpdate::updateLittlefs (NetworkClient &client, const  String &url, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
99+  HTTPClient http;
100+  if  (!http.begin (client, url)) {
101+  return  HTTP_UPDATE_FAILED;
102+  }
103+  return  handleUpdate (http, currentVersion, U_LITTLEFS, requestCB);
68104}
69105
70106HTTPUpdateResult HTTPUpdate::update (HTTPClient &httpClient, const  String ¤tVersion, HTTPUpdateRequestCB requestCB) {
71-  return  handleUpdate (httpClient, currentVersion, false , requestCB);
107+  return  handleUpdate (httpClient, currentVersion, U_FLASH , requestCB);
72108}
73109
74110HTTPUpdateResult
@@ -77,7 +113,7 @@ HTTPUpdateResult
77113 if  (!http.begin (client, host, port, uri)) {
78114 return  HTTP_UPDATE_FAILED;
79115 }
80-  return  handleUpdate (http, currentVersion, false , requestCB);
116+  return  handleUpdate (http, currentVersion, U_FLASH , requestCB);
81117}
82118
83119/* *
@@ -158,7 +194,7 @@ String getSketchSHA256() {
158194 * @param currentVersion const char * 
159195 * @return HTTPUpdateResult 
160196 */  
161- HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient &http, const  String ¤tVersion, bool  spiffs , HTTPUpdateRequestCB requestCB) {
197+ HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient &http, const  String ¤tVersion, uint8_t  type , HTTPUpdateRequestCB requestCB) {
162198
163199 HTTPUpdateResult ret = HTTP_UPDATE_FAILED;
164200
@@ -187,8 +223,14 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient &http, const String ¤
187223 http.addHeader (" x-ESP32-chip-size" String (ESP.getFlashChipSize ()));
188224 http.addHeader (" x-ESP32-sdk-version" getSdkVersion ());
189225
190-  if  (spiffs ) {
226+  if  (type == U_SPIFFS ) {
191227 http.addHeader (" x-ESP32-mode" " spiffs" 
228+  } else  if  (type == U_FATFS) {
229+  http.addHeader (" x-ESP32-mode" " fatfs" 
230+  } else  if  (type == U_LITTLEFS) {
231+  http.addHeader (" x-ESP32-mode" " littlefs" 
232+  } else  if  (type == U_FLASHFS) {
233+  http.addHeader (" x-ESP32-mode" " flashfs" 
192234 } else  {
193235 http.addHeader (" x-ESP32-mode" " sketch" 
194236 }
@@ -251,8 +293,24 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient &http, const String ¤
251293 case  HTTP_CODE_OK: // /< OK (Start Update)
252294 if  (len > 0 ) {
253295 bool  startUpdate = true ;
254-  if  (spiffs) {
255-  const  esp_partition_t  *_partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL );
296+  if  (type != U_FLASH) {
297+  const  esp_partition_t  *_partition = NULL ;
298+  if  (type == U_SPIFFS) {
299+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL );
300+  } else  if  (type == U_FATFS) {
301+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, NULL );
302+  } else  if  (type == U_LITTLEFS) {
303+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_LITTLEFS, NULL );
304+  } else  if  (type == U_FLASHFS) {
305+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL );
306+  if  (!_partition) {
307+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, NULL );
308+  }
309+  if  (!_partition) {
310+  _partition = esp_partition_find_first (ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_LITTLEFS, NULL );
311+  }
312+  }
313+ 
256314 if  (!_partition) {
257315 _lastError = HTTP_UE_NO_PARTITION;
258316 return  HTTP_UPDATE_FAILED;
@@ -291,17 +349,15 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient &http, const String ¤
291349
292350 delay (100 );
293351
294-  int  command;
352+  int  command = type ;
295353
296-  if  (spiffs) {
297-  command = U_SPIFFS;
298-  log_d (" runUpdate spiffs...\n " 
299-  } else  {
300-  command = U_FLASH;
354+  if  (type == U_FLASH) {
301355 log_d (" runUpdate flash...\n " 
356+  } else  {
357+  log_d (" runUpdate file system...\n " 
302358 }
303359
304-  if  (!spiffs ) {
360+  if  (type == U_FLASH ) {
305361 /*  To do
306362 uint8_t buf[4]; 
307363 if(tcp->peekBytes(&buf[0], 4) != 4) { 
@@ -341,7 +397,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient &http, const String ¤
341397 _cbEnd ();
342398 }
343399
344-  if  (_rebootOnUpdate && !spiffs ) {
400+  if  (_rebootOnUpdate && type == U_FLASH ) {
345401 ESP.restart ();
346402 }
347403
0 commit comments