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

Moderator: igrr

User avatar
By RichardS
#45060 Code below has a webserver at wserver, and its requested a file which I send to it, but slowly, approx 500 bytes per second. How can this be made to go faster?

Code: Select allvoid send() {
  int i;

  WiFiClient client = wserver.client();
  makeHeader();
  client.write((uint8_t*)buffer, 50);
  for (i = 0; i < 100; ++i) {
    client.write((uint8_t*)buffer, 1024);
  }
}
User avatar
By RichardS
#45063 Not sure Arduino 1.6.4 with board package 2.1.0.

RichardS
User avatar
By martinayotte
#45064 Strange ! Because the packet maximum size is define as HTTP_DOWNLOAD_UNIT_SIZE at 1460.
No other clue to provide other than showing my piece of code :

Code: Select all  if (!SPIFFS.begin()) {
    Serial.println("SPIFFS failed to mount !\r\n");
  }
  File f = SPIFFS.open(filename.c_str(), "r");
  if (!f) {
    String str = "Can't open '" + filename + "' !\r\n";
    Serial.println(str);
  }
  else {
    char buf[1024];
    int siz = f.size();
    webserver.setContentLength(str.length() + siz);
    webserver.send(200, "text/plain", str);
    while(siz > 0) {
      size_t len = std::min((int)(sizeof(buf) - 1), siz);
      f.read((uint8_t *)buf, len);
      buf[len] = 0;
      webserver.client().write((const char*)buf, len);
      siz -= len;
    }
    f.close();
  }