V2.0.3
This commit is contained in:
@ -4,37 +4,37 @@ void UpDateClassByme::performUpdate(Stream &updateSource, size_t updateSize)
|
||||
{
|
||||
if (Update.begin(updateSize))
|
||||
{
|
||||
Serial.println("Writes : ");
|
||||
//Serial.println("Writes : ");
|
||||
size_t written = Update.writeStream(updateSource);
|
||||
if (written == updateSize)
|
||||
{
|
||||
Serial.println("Writes : " + String(written) + " successfully");
|
||||
//Serial.println("Writes : " + String(written) + " successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
//Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
}
|
||||
if (Update.end())
|
||||
{
|
||||
Serial.println("OTA finished!");
|
||||
//Serial.println("OTA finished!");
|
||||
if (Update.isFinished())
|
||||
{
|
||||
Serial.println("Restart ESP device!");
|
||||
//Serial.println("Restart ESP device!");
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("OTA not fiished");
|
||||
//Serial.println("OTA not fiished");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Error occured #: " + String(Update.getError()));
|
||||
//Serial.println("Error occured #: " + String(Update.getError()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Cannot beggin update");
|
||||
//Serial.println("Cannot beggin update");
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
int err = http->get(url.c_str());
|
||||
if (err != 0)
|
||||
{
|
||||
Serial.println(F("Date failed to connect"));
|
||||
//Serial.println(F("Date failed to connect"));
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
@ -55,15 +55,15 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
Serial.print(F("Response status code: "));
|
||||
Serial.println(status);
|
||||
//Serial.print(F("Response status code: "));
|
||||
//Serial.println(status);
|
||||
// SerialMon.println(F("Response Headers:"));
|
||||
size_t count=0;
|
||||
while (http->headerAvailable())
|
||||
{
|
||||
String headerName = http->readHeaderName();
|
||||
String headerValue = http->readHeaderValue();
|
||||
Serial.println("Date: " + headerName + " : " + headerValue);
|
||||
//Serial.println("Date: " + headerName + " : " + headerValue);
|
||||
if (headerName=="Content-Length")
|
||||
{
|
||||
count=headerValue.toInt();
|
||||
@ -72,10 +72,10 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
|
||||
|
||||
}
|
||||
Serial.println("lenth is "+String(count));
|
||||
//Serial.println("lenth is "+String(count));
|
||||
if (http->isResponseChunked())
|
||||
{
|
||||
Serial.println(F("Date The response is chunked"));
|
||||
//Serial.println(F("Date The response is chunked"));
|
||||
}
|
||||
char *str=new char[1000];
|
||||
int lent=count/1000;
|
||||
@ -87,8 +87,8 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
{
|
||||
http->readBytes(str,1000);
|
||||
file.write((const byte *)str,1000);
|
||||
Serial.print("download ");
|
||||
Serial.println(String(i*100/lent));
|
||||
//Serial.print("download ");
|
||||
//Serial.println(String(i*100/lent));
|
||||
/* code */
|
||||
}
|
||||
http->readBytes(str,count%1000);
|
||||
@ -99,7 +99,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
|
||||
|
||||
// http->readBytes
|
||||
Serial.println("adfasdfsadfsdfsd");
|
||||
//Serial.println("adfasdfsadfsdfsd");
|
||||
//Serial.write(str,cout);
|
||||
//Serial.println(body.length());
|
||||
http->stop();
|
||||
@ -124,7 +124,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
return true;
|
||||
|
||||
}
|
||||
Serial.println("targetvesion is:"+Targetversion);
|
||||
//Serial.println("targetvesion is:"+Targetversion);
|
||||
|
||||
//size_t countdownload1=375584;
|
||||
size_t countdownload1=DownloadFirmwareForurl(Targetversion);
|
||||
@ -132,7 +132,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Serial.println("count download is:"+String(countdownload1));
|
||||
//Serial.println("count download is:"+String(countdownload1));
|
||||
|
||||
String MD5=GetValueFromNet("/weather/php/GetMD5Value.php",Targetversion);
|
||||
|
||||
@ -153,8 +153,8 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
md5my.addStream(file,countdownload1);
|
||||
md5my.calculate();
|
||||
String md5com=md5my.toString();
|
||||
Serial.println("md5 comput is:"+md5my.toString());
|
||||
Serial.println("md5 should is:"+MD5);
|
||||
//Serial.println("md5 comput is:"+md5my.toString());
|
||||
//Serial.println("md5 should is:"+MD5);
|
||||
file.close();
|
||||
if (MD5==md5com)
|
||||
{
|
||||
@ -189,8 +189,8 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
||||
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, Key.length());
|
||||
http->endRequest();
|
||||
int err = http->write((const byte *)Key.c_str(), Key.length());
|
||||
Serial.print("send date size");
|
||||
Serial.println(err);
|
||||
//Serial.print("send date size");
|
||||
//Serial.println(err);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
@ -213,7 +213,7 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
||||
}
|
||||
|
||||
String body = http->responseBody();
|
||||
Serial.println("body:"+body);
|
||||
//Serial.println("body:"+body);
|
||||
|
||||
http->stop();
|
||||
return body;
|
||||
|
||||
Reference in New Issue
Block a user