Skip to content

Commit f115e42

Browse files
committed
add httpUpdate.ino example
#1021
1 parent 9f0fdd5 commit f115e42

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
WiFiMulti.addAP("SSID", "PASSWORD");
36+
37+
}
38+
39+
void loop() {
40+
// wait for WiFi connection
41+
if((WiFiMulti.run() == WL_CONNECTED)) {
42+
43+
t_httpUpdate_return ret = ESPhttpUpdate.update("http://server/file.bin");
44+
//t_httpUpdate_return ret = ESPhttpUpdate.update("https://server/file.bin");
45+
46+
switch(ret) {
47+
case HTTP_UPDATE_FAILED:
48+
USE_SERIAL.println("HTTP_UPDATE_FAILD");
49+
break;
50+
51+
case HTTP_UPDATE_NO_UPDATES:
52+
SeriUSE_SERIALal.println("HTTP_UPDATE_NO_UPDATES");
53+
break;
54+
55+
case HTTP_UPDATE_OK:
56+
USE_SERIAL.println("HTTP_UPDATE_OK");
57+
break;
58+
}
59+
}
60+
}
61+

0 commit comments

Comments
 (0)