Skip to content

Commit aba4c2c

Browse files
committed
change for update using post
0 parents  commit aba4c2c

File tree

5 files changed

+831
-0
lines changed

5 files changed

+831
-0
lines changed

examples/httpUpdate/httpUpdate.ino

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* httpUpdate.ino
3+
*
4+
* Created on: 27.11.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+
WiFi.mode(WIFI_STA);
36+
WiFiMulti.addAP("SSID", "PASSWORD");
37+
38+
}
39+
40+
void loop() {
41+
// wait for WiFi connection
42+
if((WiFiMulti.run() == WL_CONNECTED)) {
43+
44+
t_httpUpdate_return ret = ESPhttpUpdate.update("http://server/file.bin");
45+
//t_httpUpdate_return ret = ESPhttpUpdate.update("https://server/file.bin");
46+
47+
switch(ret) {
48+
case HTTP_UPDATE_FAILED:
49+
USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
50+
break;
51+
52+
case HTTP_UPDATE_NO_UPDATES:
53+
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
54+
break;
55+
56+
case HTTP_UPDATE_OK:
57+
USE_SERIAL.println("HTTP_UPDATE_OK");
58+
break;
59+
}
60+
}
61+
}
62+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
WiFi.mode(WIFI_STA);
36+
WiFiMulti.addAP("SSID", "PASSWORD");
37+
38+
}
39+
40+
void loop() {
41+
// wait for WiFi connection
42+
if((WiFiMulti.run() == WL_CONNECTED)) {
43+
44+
USE_SERIAL.println("Update SPIFFS...");
45+
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs("http://server/spiffs.bin");
46+
if(ret == HTTP_UPDATE_OK) {
47+
USE_SERIAL.println("Update sketch...");
48+
ret = ESPhttpUpdate.update("http://server/file.bin");
49+
50+
switch(ret) {
51+
case HTTP_UPDATE_FAILED:
52+
USE_SERIAL.printf("HTTP_UPDATE_FAILED Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
53+
break;
54+
55+
case HTTP_UPDATE_NO_UPDATES:
56+
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
57+
break;
58+
59+
case HTTP_UPDATE_OK:
60+
USE_SERIAL.println("HTTP_UPDATE_OK");
61+
break;
62+
}
63+
}
64+
}
65+
}
66+

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=ESP8266httpUpdate
2+
version=1.1
3+
author=Markus Sattler
4+
maintainer=Markus Sattler
5+
sentence=Http Update for ESP8266
6+
paragraph=
7+
category=Data Processing
8+
url=https://github.com/Links2004/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/ESP8266httpUpdate
9+
architectures=esp8266

0 commit comments

Comments
 (0)