| ... | ... |
@@ -6,6 +6,8 @@ |
| 6 | 6 |
#include <WiFiClient.h> |
| 7 | 7 |
#include <OneWire.h> |
| 8 | 8 |
#include <DallasTemperature.h> |
| 9 |
+#include <ESP8266HTTPClient.h> |
|
| 10 |
+#include <ESP8266httpUpdate.h> |
|
| 9 | 11 |
|
| 10 | 12 |
char mqtt_user[9]; //le va lua din FS |
| 11 | 13 |
char mqtt_devid[5]; //le va lua din FS |
| ... | ... |
@@ -179,6 +181,31 @@ void getMessage(char* topic, byte* payload, unsigned int length) {
|
| 179 | 179 |
Serial.println(json); |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 |
+// procedura de software update via WEB |
|
| 183 |
+ if (mqttMessage == "update") |
|
| 184 |
+ {
|
|
| 185 |
+ String msg="Software update: "; |
|
| 186 |
+ t_httpUpdate_return ret; |
|
| 187 |
+ //ESPhttpUpdate.rebootOnUpdate(false); |
|
| 188 |
+ ret = ESPhttpUpdate.update("http://update.clickhome.ro/senzor/dallas/arduino.bin");
|
|
| 189 |
+ //ret = ESPhttpUpdate.update("update.clickhome.ro", 80, "/senzor/dallas/arduino.bin");
|
|
| 190 |
+ switch(ret) {
|
|
| 191 |
+ case HTTP_UPDATE_FAILED: |
|
| 192 |
+ msg.concat(" eroare:");
|
|
| 193 |
+ msg.concat(ESPhttpUpdate.getLastError()); |
|
| 194 |
+ msg.concat(" motiv:");
|
|
| 195 |
+ msg.concat(ESPhttpUpdate.getLastErrorString().c_str()); |
|
| 196 |
+ break; |
|
| 197 |
+ case HTTP_UPDATE_NO_UPDATES: |
|
| 198 |
+ msg.concat(" no update.");
|
|
| 199 |
+ break; |
|
| 200 |
+ case HTTP_UPDATE_OK: |
|
| 201 |
+ msg.concat(" success.");
|
|
| 202 |
+ break; |
|
| 203 |
+ } |
|
| 204 |
+ Serial.println(msg); |
|
| 205 |
+ } |
|
| 206 |
+ |
|
| 182 | 207 |
// daca a primit valoarea in minute seteaza loopTimer si-l trimite in DB |
| 183 | 208 |
|
| 184 | 209 |
if (mqttMessage == "debug") |