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

Moderator: igrr

User avatar
By diffstorm
#69945 Hi All,

I have succeeded to realize a web server which shares .bin of the ESP, so I can download it successfully.

What I want is to add some headers for consistency like in the PHP script in the link above.

I'm sending the .bin the following way:

Code: Select all      httpServer.setContentLength(ESP.getSketchSize());
      //httpServer.send_P(200, "application/binary", "");
      httpServer.send_P(200, "application/octet-stream", "");

then
in loop several times :
Code: Select all      httpServer.sendContent_P(buffer, length);


I do not know how to send the MD5 of the file for consistency check in the second ESP.

I guess this code does this in PHP language:
Code: Select all                     response.writeHeader(200,
                        {"Content-Type": "application/octet-stream",
                        "Content-Disposition": "attachment;filename="+path.basename(full_path),
                        "Content-Length": ""+fs.statSync(full_path)["size"],
                        "x-MD5":  md5.sync(full_path)}); 

I understand that ESP8266httpUpdate class checks for "x-MD5" header somehow? is that correct?
So I need to send that header in first ESP?
Could you share some example code for it?

I didn't understand all these headers:
Code: Select all   if (!check_header(request, 'USER-AGENT', 'ESP8266-http-Update') ||
      !check_header(request, 'X-ESP8266-STA-MAC') ||
      !check_header(request, 'X-ESP8266-AP-MAC') ||
       !check_header(request, 'X-ESP8266-FREE-SPACE') ||
       !check_header(request, 'X-ESP8266-SKETCH-SIZE') ||
      !check_header(request, 'X-ESP8266-SKETCH-MD5') ||
       !check_header(request, 'X-ESP8266-CHIP-SIZE') ||
       !check_header(request, 'X-ESP8266-SDK-VERSION' ||
      !check_header(request, "X-ESP8266-VERSION"))) {

What they stand for? Can you redirect me to a documentation about this if exists?

Thanks in advance.
User avatar
By diffstorm
#69972 Thank you all for your help.

I have succeeded it. Second ESP gets firmware of first ESP successfully.

Code: Select allhttpServer.setContentLength(sketch_size);
httpServer.send_P(200, "application/octet-stream", "");
httpServer.sendHeader("Content-Length", String(sketch_size));
httpServer.sendHeader("x-MD5", sketch_MD5);

for (offset = 0; offset < sketch_size;)
{
     /* read sketch data :: getSketch(buffer, &length); */
     httpServer.sendContent_P(buffer, length);
}