Go Down

Topic: SD card html page load time? (Read 2 times) previous topic - next topic

mistergreen

It looks like the client.write for WIFI can't do chunks. oh well


liudr

You should post your complete code.

No, WiFi client write works differently than the rest of write. You should use write(*byte, int) instead.

mistergreen

#7
Mar 07, 2014, 03:32 am Last Edit: Mar 07, 2014, 04:53 am by mistergreen Reason: 1

You should post your complete code.

No, WiFi client write works differently than the rest of write. You should use write(*byte, int) instead.


according to the documentation, there is no second parameter

http://arduino.cc/en/Reference/WiFiClientWrite#.Uxkw3lxdJoo

I deleted the code but it's basically this
Code: [Select]

byte tBuf[64];
int clientCount = 0;

   File myFile = SD.open("index.htm");        // open web page file
   if (myFile) {
            while(myFile.available()) {
                   tBuf[clientCount] = myFile.read();
                   clientCount++;
                   tBuf[clientCount] = 0;

                   if(clientCount > 63) {
                     client.write((byte*)tBuf,64);
                     clientCount = 0;
                   }

           }
                 if(clientCount > 0) {
                   client.write((byte*)tBuf,clientCount);
                 }
       myFile.close();
   }


SurferTim

There is a write with two parameters. This is taken from WiFiClient.h.
Quote
virtual size_t write(uint8_t);
  virtual size_t write(const uint8_t *buf, size_t size);

You will find the wifi shield transfer rate is much more sluggish than the ethernet shield. The wifi shield also has some nasty one to two second delays every few seconds during a large download. It is one of a few bugs in the shield's firmware.

mistergreen

Ah, Yeah, it's weird. The code above resets the wifi shield. It restarts the wifi init process.

Go Up