0

I am trying to download 1.4 mb file using tinygsm library, and for that i am using FileDownload example. However my device downloads 96,000 bytes and then stops. After debugging the program i found out that client.connected() condition is turning false and that is why i am not be able to download the file further. Hardware being used is esp32 and sim800c module.

I am sharing the code snippet below, Please guide me resolving this issue.

TinyGsmClientSecure client(modemGSM);

if (client.connect(host, port)) {
        
    SerialDebug.println("connected");
    // Make a HTTP GET request:
    SerialDebug.println("Performing HTTP GET request...");
    client.print(String("GET ") + path + " HTTP/1.1\r\n");
    client.print(String("Host: ") + host + "\r\n");
    client.print("Connection: close\r\n\r\n");
    client.println();

}else {

    SerialDebug.println("connection failed");
    return;

}

while (client.connected() && millis() - timeout < 10000L) {
   while (client.available()) {
      char c = client.read();
      readBytes++;
      if(readBytes % 1000 == 0)
          SerialDebug.println(readBytes);
      timeout = millis();
   }
}
java bee
  • 115
  • 3
  • 15

1 Answers1

0

The connection can break. You should monitor it and try to reconnect. You also should use HTTP Get request with Range header in order to resume the download.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests#single_part_ranges