Skip to content

Commit 95d53c3

Browse files
committed
add httpUpdateSPIFFS.ino example
1 parent ecce35d commit 95d53c3

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* httpUpdateSPIFFS.ino
3+
*
4+
* Created on: 05.12.2015
5+
*
6+
*/
7+
8+
#include <Arduino.h>
9+
10+
#include <ESP8266WiFi.h>
11+
#include <ESP8266WiFiMulti.h>
12+
13+
#include <ESP8266HTTPClient.h>
14+
#include <ESP8266httpUpdate.h>
15+
16+
#define USE_SERIAL Serial
17+
18+
ESP8266WiFiMulti WiFiMulti;
19+
20+
void setup() {
21+
22+
USE_SERIAL.begin(115200);
23+
// USE_SERIAL.setDebugOutput(true);
24+
25+
USE_SERIAL.println();
26+
USE_SERIAL.println();
27+
USE_SERIAL.println();
28+
29+
for(uint8_t t = 4; t > 0; t--) {
30+
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
31+
USE_SERIAL.flush();
32+
delay(1000);
33+
}
34+
35+
WiFiMulti.addAP("SSID", "PASSWORD");
36+
37+
}
38+
39+
void loop() {
40+
// wait for WiFi connection
41+
if((WiFiMulti.run() == WL_CONNECTED)) {
42+
43+
USE_SERIAL.println("Update SPIFFS...");
44+
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs("https://server/spiffs.bin");
45+
if(ret == HTTP_UPDATE_OK) {
46+
USE_SERIAL.println("Update sketch...");
47+
ret = ESPhttpUpdate.update("https://server/file.bin");
48+
49+
switch(ret) {
50+
case HTTP_UPDATE_FAILED:
51+
USE_SERIAL.println("HTTP_UPDATE_FAILD");
52+
break;
53+
54+
case HTTP_UPDATE_NO_UPDATES:
55+
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
56+
break;
57+
58+
case HTTP_UPDATE_OK:
59+
USE_SERIAL.println("HTTP_UPDATE_OK");
60+
break;
61+
}
62+
}
63+
}
64+
}
65+

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha
143143
if(spiffs) {
144144
size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start);
145145
if(len > (int) spiffsSize) {
146-
DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len);
146+
DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", spiffsSize, len);
147147
}
148148
} else {
149149
if(len > (int) ESP.getFreeSketchSpace()) {

0 commit comments

Comments
 (0)