Unable to write the complete data to SPIFFS file from the server using TinyGSM

I am trying to perform an OTA Update over my ESP32 with a SIM800L module.
This is the reference code that I am using: Github Thread.

And here is my full code for reference: My Code

The part of the code I use for writing data coming from the server of the binary file to my SPIFFS file -

  printPercent(readLength, contentLength);
  while (!(readLength > contentLength) && client.connected() /*&& millis() - timeout < 10000L*/) {
      if (client.available()) {
       if (!file.print(char(client.read())))
          Serial.println("error writing character to SPIFFS");


The data from the server has 267648 bytes and the amount that is actually written to the file is only 267008
In no operation am I able to completely write the entire contents of the .bin file over to the SPIFFS file.
What am I doing wrong? Is there a better way to copy over binary files coming to the client stream?
@Juraj could you please help?

use flow control with DTR and RTS. esp32 Serial supports it

Thanks for the reply. Why do I have to use flow control here exactly?

so you don't lose bytes with Serial buffer overflow

@Juraj Okay! Just one last request, is this the (Link) correct resource to be looking at for the job? If not, could you please direct me to a resource that could help me do that?

it looks like there is no support at Arduino level for flow control. so yes. the IDF level is then the only way.
sorry, I don't use esp32 much so I can only give you generic advises, not esp32 specific.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.