Skip to content

Commit

Permalink
supprt ota update
Browse files Browse the repository at this point in the history
  • Loading branch information
Caffreyfans committed Apr 9, 2020
1 parent 64b5681 commit 562d71d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/IRbabyMsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "IRbabyMQTT.h"
#include "IRbabyUDP.h"
#include "ESP8266WiFi.h"
#include "../lib/Irext/include/ir_ac_control.h"
#include "IRbabyIR.h"
#include "../lib/Irext/include/ir_ac_control.h"
#include "IRbabyOTA.h"

StaticJsonDocument<1024> send_msg_doc;
StaticJsonDocument<1024> recv_msg_doc;
Expand Down Expand Up @@ -160,6 +161,12 @@ bool msgHandle(StaticJsonDocument<1024> *recv_msg_doc, MsgType msg_type)
sendStatus(file_name, status);
}
}

if (obj["cmd"] == "update") {
JsonObject params = obj["params"];
String url = params["url"];
otaUpdate(url);
}
}
break;

Expand Down
4 changes: 2 additions & 2 deletions src/IRbabyOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void versionCheck()
{
}

void otaUpdate()
void otaUpdate(String url)
{

WiFiClient client;
Expand All @@ -38,7 +38,7 @@ void otaUpdate()
ESPhttpUpdate.onProgress(update_progress);
ESPhttpUpdate.onError(update_error);

t_httpUpdate_return ret = ESPhttpUpdate.update(client, "http://caffreyfans.top/IRbaby/latest/firmware.bin");
t_httpUpdate_return ret = ESPhttpUpdate.update(client, url);

switch (ret)
{
Expand Down
2 changes: 1 addition & 1 deletion src/IRbabyOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#include "IRbabySerial.h"

void otaUpdate();
void otaUpdate(String url);

#endif

0 comments on commit 562d71d

Please sign in to comment.