Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Tran-Luyen committed Oct 17, 2023
1 parent 2e57315 commit 1bec04a
Show file tree
Hide file tree
Showing 9 changed files with 20,022 additions and 19,951 deletions.
Binary file modified ESP32/Build/ESP32.ino.bin
Binary file not shown.
Binary file modified ESP32/Build/ESP32.ino.elf
Binary file not shown.
39,751 changes: 19,905 additions & 19,846 deletions ESP32/Build/ESP32.ino.map

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions ESP32/Build/compile_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiScan.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiUdp.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiScan.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiUdp.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiScan.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiUdp.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -764,11 +764,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiUdp.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiSTA.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiUdp.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiSTA.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiUdp.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiSTA.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -1021,11 +1021,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiGeneric.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFi.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiGeneric.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFi.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiGeneric.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFi.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -1278,11 +1278,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFi.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiAP.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFi.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiAP.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFi.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiAP.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -1535,11 +1535,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiAP.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiClient.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiAP.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiClient.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiAP.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiClient.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -1792,11 +1792,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiServer.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiScan.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiServer.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiScan.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiServer.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiScan.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -2049,11 +2049,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiSTA.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiMulti.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiSTA.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiMulti.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiSTA.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiMulti.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -2306,11 +2306,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiClient.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiServer.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiClient.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiServer.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiClient.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiServer.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down Expand Up @@ -2563,11 +2563,11 @@
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFiClientSecure\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\HTTPUpdate\\src",
"-IC:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\Update\\src",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiMulti.cpp",
"C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiGeneric.cpp",
"-o",
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiMulti.cpp.o"
"C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\Build\\libraries\\WiFi\\WiFiGeneric.cpp.o"
],
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiMulti.cpp"
"file": "C:\\Users\\Tran_Luyen\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.6\\libraries\\WiFi\\src\\WiFiGeneric.cpp"
},
{
"directory": "c:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32",
Expand Down
56 changes: 30 additions & 26 deletions ESP32/Build/preproc/ctags_target_for_gcc_minus_e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const char *password = "khongcopass";


String new_url = "";
float new_version = 2.0;
float new_version = 2.3;

WiFiMulti WiFiMulti;
WiFiClientSecure client;
Expand Down Expand Up @@ -164,42 +164,46 @@ void setup() {
delay(1000);
}
}
WiFiMulti.addAP(ssid, password);
Serial.println("WiFi connected");
setClock();
client.setCACert(rootCACertificate);
client.setTimeout(12000 / 1000);

Serial.print("current version: ");
Serial.println(2.0);
Serial.println(2.3);
}

void loop() {
if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > 2.0) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
if ((WiFiMulti.run() == WL_CONNECTED)) {

if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > 2.3) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
}
}
else { Serial.println("No Update Available"); }
}
else { Serial.println("No Update Available"); }
}
}
}
56 changes: 30 additions & 26 deletions ESP32/Build/sketch/ESP32.ino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const char *ssid = "Tenda RD";
const char *password = "khongcopass";

#define FW_VERSION 2.0
#define FW_VERSION 2.3

String new_url = "";
float new_version = FW_VERSION;
Expand Down Expand Up @@ -89,7 +89,7 @@ void update_progress(int cur, int total);
void update_error(int err);
#line 153 "C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\ESP32.ino"
void setup();
#line 175 "C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\ESP32.ino"
#line 176 "C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\ESP32.ino"
void loop();
#line 77 "C:\\Users\\Tran_Luyen\\Documents\\delete\\GitOTA\\TranLuyen-dev.github.io\\ESP32\\ESP32.ino"
void setClock() {
Expand Down Expand Up @@ -181,6 +181,7 @@ void setup() {
delay(1000);
}
}
WiFiMulti.addAP(ssid, password);
Serial.println("WiFi connected");
setClock();
client.setCACert(rootCACertificate);
Expand All @@ -191,32 +192,35 @@ void setup() {
}

void loop() {
if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > FW_VERSION) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
if ((WiFiMulti.run() == WL_CONNECTED)) {

if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > FW_VERSION) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
}
}
else { Serial.println("No Update Available"); }
}
else { Serial.println("No Update Available"); }
}
}
}
Binary file modified ESP32/Build/sketch/ESP32.ino.cpp.o
Binary file not shown.
54 changes: 29 additions & 25 deletions ESP32/ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const char *ssid = "Tenda RD";
const char *password = "khongcopass";

#define FW_VERSION 2.1
#define FW_VERSION 2.3

String new_url = "";
float new_version = FW_VERSION;
Expand Down Expand Up @@ -163,6 +163,7 @@ void setup() {
delay(1000);
}
}
WiFiMulti.addAP(ssid, password);
Serial.println("WiFi connected");
setClock();
client.setCACert(rootCACertificate);
Expand All @@ -173,32 +174,35 @@ void setup() {
}

void loop() {
if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > FW_VERSION) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
if ((WiFiMulti.run() == WL_CONNECTED)) {

if (Serial.available()) {
String s = Serial.readString();
if (s.indexOf("get") != -1) { get_version(); }
else if (s.indexOf("update") != -1) {
if (new_version > FW_VERSION) {
Serial.println("Update Available");
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);

t_httpUpdate_return ret = httpUpdate.update(client, new_url);
// Or:
// t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break;

case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break;
}
}
else { Serial.println("No Update Available"); }
}
else { Serial.println("No Update Available"); }
}
}
}
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ver" : 2.1,
"ver" : 2.3,
"url" : "https://TranLuyen-dev.github.io/ESP32/Build/ESP32.ino.bin"
}

0 comments on commit 1bec04a

Please sign in to comment.