Wifi server van SD kaart Langzaam

beste Forumleden,

ben bezig om een tutorialtje te volgen op een website. ik ben bezig om een wifi server te maken met op de SD kaart op dit moment nog een klein HTM filetje.

nu is het laden van de server super langzaam en kan niet ontdekken waar het vandaan komt.

misschien hebben jullie een idee.

met vriendelijke groet,

jeroen

/*--------------------------------------------------------------
  Program:      eth_websrv_SD

  Description:  Arduino web server that serves up a basic web
                page. The web page is stored on the SD card.
  
  Hardware:     Arduino Uno and official Arduino Ethernet
                shield. Should work with other Arduinos and
                compatible Ethernet shields.
                2Gb micro SD card formatted FAT16
                
  Software:     Developed using Arduino 1.0.3 software
                Should be compatible with Arduino 1.0 +
                SD card contains web page called index.htm
  
  References:   - WebServer example by David A. Mellis and 
                  modified by Tom Igoe
                - SD card examples by David A. Mellis and
                  Tom Igoe
                - Ethernet library documentation:
                  http://arduino.cc/en/Reference/Ethernet
                - SD Card library documentation:
                  http://arduino.cc/en/Reference/SD

  Date:         10 January 2013
 
  Author:       W.A. Smith, http://startingelectronics.org
--------------------------------------------------------------*/

#include <SPI.h>
#include <WiFi.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
char ssid[] = "————-";      //  your network SSID (name)
char pass[] = "—————";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;



WiFiServer server(80);

File webFile;

void setup()
{
    Serial.begin(9600);       // for debugging
    if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true);       // don't continue
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }

    while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);
    
     status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();                           // start the web server on port 80
  printWifiStatus();                        // you're connected now, so print out the status
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
          Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    

}

void loop()
{
    WiFiClient client = server.available();  // try to get client

    if (client) {  // got client?
        int clientCount = 0;
        boolean currentLineIsBlank = true;
        Serial.println("new client");           // print a message out the serial port
        String currentLine = "";                // make a String to hold incoming data from the client
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                Serial.write(c);
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    webFile = SD.open("index.htm");        // open web page file
                        if (webFile) {
                            while(webFile.available()) {
                                client.write(webFile.read()); // send web page to clien
                        }
                        webFile.close();
                    }
                    break;

                     
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}
 void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}

Openen en sluiten zijn dure IO operaties. Waarom open je hem niet in de setup? En doe je dat opnieuw als je de dus sluiten en evt reopenen( weet niet of er een rewind() is) na de close()

Beste Nico,

Dit is dus een beetje mijn probleem. Ik ben juist deze tutorial gaan doen. Om te leren hoe het werkt met AJAX en XML en doe hem dan ook stap voor stap. En ga dan testen en zoeken hoe het werkt. Ik zal dan ook eerlijk zijn dat wat je nu zegt over het gedeelte in de setup zetten, ik niet weet hoe ik dat moet doen. Zou je me dat misschien willen uitleggen?

Ik ga nog even verder het internet afstruinen want kan toch niet de enige zijn die hier hinder van heeft ontvangen.

Hoi Jeroen.

Ik mag hopen dat je hier niet je werkelijke SSID en password hebt gepubliceerd.
Doe dat nooit, deze site is openbaar en word veelvuldig en continu doorzocht door bots van zoekmachines.
Je weet maar nooit welk louche type een search gaat doen naar dit soort gegevens, en wat die er dan verder mee kan en dus ook zal gaan doen.
Mocht je vergeten zijn dit te wijzigen, dan raad ik je aan om een nieuw password in je Ziggo router/modem te zetten.
Dat is vervelend en lastig, want dan moeten alle apparaten ook opnieuw worden ingesteld, maar wel noodzakelijk.
En wees je bewust van dit soort gevaren, dus zorg dat je dergelijke gegevens voor jezelf houd en nooit of te nimmer publiceert.