-->
Page 3 of 4

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 5:59 pm
by RichardS
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

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 6:13 pm
by RichardS
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

Re: Update ESP8266 from SPIFFS file

PostPosted: Sun Nov 06, 2016 3:09 pm
by indev2
@ 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.

Re: Update ESP8266 from SPIFFS file

PostPosted: Mon Nov 07, 2016 12:37 pm
by RichardS
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();