mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Merge pull request #1245 from Links2004/httpUpdate
fix #1244 - MD5 handling
This commit is contained in:
commit
a07838a19c
@ -57,7 +57,7 @@ bool UpdaterClass::begin(size_t size, int command) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ESP.checkFlashConfig(false)) {
|
if(!ESP.checkFlashConfig(false)) {
|
||||||
_error = UPDATE_ERROR_FLASH_CONFIG;
|
_error = UPDATE_ERROR_FLASH_CONFIG;
|
||||||
#ifdef DEBUG_UPDATER
|
#ifdef DEBUG_UPDATER
|
||||||
printError(DEBUG_UPDATER);
|
printError(DEBUG_UPDATER);
|
||||||
@ -124,9 +124,13 @@ bool UpdaterClass::begin(size_t size, int command) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdaterClass::setMD5(const char * expected_md5){
|
bool UpdaterClass::setMD5(const char * expected_md5){
|
||||||
if(strlen(expected_md5) != 32) return;
|
if(strlen(expected_md5) != 32)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
_target_md5 = expected_md5;
|
_target_md5 = expected_md5;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdaterClass::end(bool evenIfRemaining){
|
bool UpdaterClass::end(bool evenIfRemaining){
|
||||||
@ -160,6 +164,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
|
|||||||
#ifdef DEBUG_UPDATER
|
#ifdef DEBUG_UPDATER
|
||||||
DEBUG_UPDATER.printf("MD5 Failed: expected:%s, calculated:%s\n", _target_md5.c_str(), _md5.toString().c_str());
|
DEBUG_UPDATER.printf("MD5 Failed: expected:%s, calculated:%s\n", _target_md5.c_str(), _md5.toString().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
_reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_UPDATER
|
#ifdef DEBUG_UPDATER
|
||||||
|
@ -65,7 +65,7 @@ class UpdaterClass {
|
|||||||
/*
|
/*
|
||||||
sets the expected MD5 for the firmware (hexString)
|
sets the expected MD5 for the firmware (hexString)
|
||||||
*/
|
*/
|
||||||
void setMD5(const char * expected_md5);
|
bool setMD5(const char * expected_md5);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
returns the MD5 String of the sucessfully ended firmware
|
returns the MD5 String of the sucessfully ended firmware
|
||||||
|
@ -296,7 +296,11 @@ bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int com
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(md5.length()) {
|
if(md5.length()) {
|
||||||
Update.setMD5(md5.c_str());
|
if(!Update.setMD5(md5.c_str())) {
|
||||||
|
lastError = HTTP_UE_SERVER_FAULTY_MD5;
|
||||||
|
DEBUG_HTTP_UPDATE("[httpUpdate] Update.setMD5 failed! (%s)\n", md5.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Update.writeStream(in) != size) {
|
if(Update.writeStream(in) != size) {
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#define HTTP_UE_SERVER_FILE_NOT_FOUND (-102)
|
#define HTTP_UE_SERVER_FILE_NOT_FOUND (-102)
|
||||||
#define HTTP_UE_SERVER_FORBIDDEN (-103)
|
#define HTTP_UE_SERVER_FORBIDDEN (-103)
|
||||||
#define HTTP_UE_SERVER_WRONG_HTTP_CODE (-104)
|
#define HTTP_UE_SERVER_WRONG_HTTP_CODE (-104)
|
||||||
|
#define HTTP_UE_SERVER_FAULTY_MD5 (-105)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HTTP_UPDATE_FAILED,
|
HTTP_UPDATE_FAILED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user