Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By RichardS
#57718 So I figured out that if you do not send it 32 characters for the MD5 it will ignore it.... would be nice that it throws an error if you do not supply a valid MD5.... that said I am still debugging...

RichardS
User avatar
By RichardS
#57720 Cool so I think its working now.

So let this be a learning lesson!

Creating the hash returns 16 bytes, not characters.... so use: to make it a ASCII string

Code: Select all  for(int i=0; i<16; ++i) {
    sprintf((char*)&buf[i*2], "%02x", hash[i]);
  } 
  buf[32] = 0;


and!! make sure its lower case %02x not upper %02X, does not like that!

and.... 32 ASCII HEX characters!

RichardS
User avatar
By indev2
#57745 @ Richard S,

I was recently wondering if this could be done.

It would be a great asset to finishing off a chunk of my project.

I'd be very grateful if you could reveal how you made it work. I played around some with Updater.h but it's all above my understanding at the moment.

Many thanks

Steve.
User avatar
By RichardS
#57776 Generic version (can not post client code)

Code: Select all 
  File f;
  UpdaterClass u;
  int fileLen;
  int readLen;
  uint8_t buf[64];

  f = SPIFFS.open("/ESP.bin", "r");
  fileLen = f.size();
  u.begin(fileLen, U_FLASH);   
  while (fileLen > 0) {         
    readLen = f.read(buf, 64);
    u.write(buf, readLen);
    fileLen -= readLen;
    if (u.hasError()) {   
      return false;
    }
    yield();
  }
  f.close();
  u.end();