esp32固件改进ota升级

This commit is contained in:
kerwincui
2022-06-17 01:42:01 +08:00
parent 1b11ffc4c8
commit 5fca93c76a

View File

@@ -141,6 +141,18 @@ void callback(char *topic, byte *payload, unsigned int length)
if (strcmp(topic, sOtaTopic.c_str()) == 0)
{
printMsg("订阅到设备升级指令...");
StaticJsonDocument<256> doc;
DeserializationError error = deserializeJson(doc, payload);
if (error)
{
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
String newVersion = doc["version"];
String downloadUrl = doc["downloadUrl"];
printMsg("固件版本:"+newVersion);
printMsg("下载地址:"+downloadUrl);
}
else if (strcmp(topic, sNtpTopic.c_str()) == 0)
{