Ethernet-Shield als Fileserver - AZ-Delivery

Hola, buenas.

Gracias a nuestro boceto de ayer, muchos clientes que ya habían probado escudos se han sumado a nosotros y han tenido problemas con el uso simultáneo de lectores de tarjetas SDA y w5100.Ya hemos realizado algunos estudios y hemos encontrado una solución, y hoy queremos presentarles a todos.Gerd nos ha mostrado recientemente cómo utilizar el ESP como servidor de documentos con la tarjeta SDA.Hoy utilizamos la solución SHIELD para ajustar uno y presentar el Código de trabajo junto con la base de datos estándar.

Equipo:

  • Unidad unor3.
  • Ethernet bloquea w5100.
  • Micro - sdka con el sistema de archivos fat32.

Código:

 

/*
* Este boceto utiliza el enchufe microsd de la pantalla de Ardino Ethernet.
* Los documentos están disponibles en una interfaz de navegación muy pequeña.
*
* Algunos códigos proceden del ejemplo de sdfatlib de Bill greiman,
* algunos ejemplos de servidores web de arduino Ethernet, 
* Algunos fritos con naranja ácida,
• Algunos "Jurs" del Foro Ardino (Alemania)
Así que puede estar por debajo del GPS
*/

35; incluye <Desviación estándar.Hora>
35; incluye <Proteína de separación.Hora>
35; incluye <Ethernet.Hora>

* * * * * * * * * * * * * * * * *
Intercambio Impermeable[] = { 0xen., Código 0xad, Tipo 0xbe, 0xec., Tipo 0xfe, 0xen. };
Intercambio Socio limitado[] = { 192, 168, 168, 245 };
Ethernet Servidor(80);

* * * * * * * * * * * * * * * * * * * * * * * *
Tarjeta SD2 Tarjeta;
Sdvolume Company Volumen;
Documento sdfile Raíz;
Documento sdfile Documentación;

Guardar la cadena de errores en Flash para guardar Ram
- definición. Error(Empresa s) Error P(Pstr(Empresa s))

Vacío. Error P(Constante Chamuscar* Derecha) {   Impresión de PGM("Error:);   Impresión en serie(Derecha);   Si (Tarjeta.Error()) {     Impresión de PGM(Error del SD);     Transporte.Imprimir(Tarjeta.Error(), Sistema hexadecimal);     Transporte.Imprimir(',');     Transporte.Imprimir(Tarjeta.Error(), Sistema hexadecimal);   }   Aunque(1);
}

Chamuscar* Calcetín( Chamuscar* Empresa s )
/ / / carácter de la función de ayuda
{   Para (Chamuscar* Página 2 = Empresa s; *Página 2; ++Página 2)     *Página 2 = Grupo( *Página 2 );   Regreso Empresa s;
}

Chamuscar* Strlower.( Chamuscar* Empresa s )
La función de ayuda char cuenta hasta escribir letras pequeñas
{   Para (Chamuscar* Página 2 = Empresa s; *Página 2; ++Página 2)     *Página 2 = Escritura( *Página 2 );   Regreso Empresa s;
}

Vacío. Configuración() {   Transporte.Iniciar(9600);   Impresión de PGM("Memoria disponible:);   Transporte.Imprimir(Espacio libre.());        Iniciar la SDA a media velocidad para evitar   PAN.Usar toda la velocidad del SPI para obtener mejores resultados.   Modo pinmode(10, Salida);                       / / fijar el encabezamiento SS como salida (necesaria)   Escritura digital(10, Alto);                    ¡Pero apaga el w5100!   Si (!Tarjeta.Inicialización(SPI semivelocidad, 4)) Error("Fracaso card.init!");      / / volumen inicial de grasa   Si (!Volumen.Inicialización(&Tarjeta)) Error("T.T. falló!");   Impresión de PGM("Demasiado grande".);   Transporte.Imprimir(Volumen.Tipo de grasa(),Diciembre);   Transporte.Imprimir();      Si (!Raíz.¡Ábrelo!(&Volumen)) Error("Openroot falló.");   Añadir archivos con fecha y tamaño en el directorio raíz   Impresión de PGM("Archivos encontrados en el directorio raíz:);   Raíz.Uno(Fecha: | Tamaño de lsu);   Transporte.Imprimir();      / / / lista regresiva de todos los directorios   Impresión de PGM("Archivos encontrados en todos los directorios:);   Raíz.Uno(Inducción de carga);      Transporte.Imprimir();   Impresión de PGM(Don.);      ¡Cambio y activado el servidor!   Ethernet.Iniciar(Impermeable, Socio limitado);   Servidor.Iniciar();
}

Vacío. Archivo de lista(Cliente de Ethernet Cliente, Reino Bandera) {   / / / este Código sólo se ha copiado de sdfile.cpp de la base de datos sdfat.   ¡/ / / y ajustar la impresión a la salida html del cliente!   Índice t Página 2;      Raíz.Volver();   Cliente.Imprimir("; ul & gt;");   Aunque (Raíz.Leer directorio(Página 2) > 0) {     / / / si se supera la entrada anterior se completa     Si (Página 2.Nombre[0] == Nombre de catálogo disponible) Romper;     / / artículos suprimidos que se han omitido.Y... Y...     Si (Página 2.Nombre[0] == Nombre de directorio borrado || Página 2.Nombre[0] == '.') Persistencia;     / / / lista de subcategorías y archivos únicamente     Si (!Dir es un archivo o un sub - dir.(&Página 2)) Persistencia;     Imprimir cualquier espacio de sangrado     Cliente.Imprimir("& lt; Li & gt; & lt; A href =");     Para (Reino Yo = 0; Yo < 11; Yo++) {       Si (Página 2.Nombre[Yo] == ' ') Persistencia;       Si (Yo == 8) {         Cliente.Imprimir('.');       }       Cliente.Imprimir((Chamuscar)Página 2.Nombre[Yo]);     }     Cliente.Imprimir("\">");          Rellenar el nombre del archivo de impresión con posibles espacios en blanco     Para (Reino Yo = 0; Yo < 11; Yo++) {       Si (Página 2.Nombre[Yo] == ' ') Persistencia;       Si (Yo == 8) {         Cliente.Imprimir('.');       }       Cliente.Imprimir((Chamuscar)Página 2.Nombre[Yo]);     }          Cliente.Imprimir("/ a & gt;");          Si (Dir es sumdir.(&Página 2)) {       Cliente.Imprimir('/');     }     Imprimir la fecha / hora de modificación si es necesario     Si (Bandera & Fecha:) {        Raíz.Fecha de impresión(Página 2.última vez);        Cliente.Imprimir(' ');        Raíz.Tiempo de impresión(Página 2.Tiempo transcurrido);     }     / / / tamaño de impresión, si es necesario     Si (!Dir es sumdir.(&Página 2) && (Bandera & Tamaño de lsu)) {       Cliente.Imprimir(' ');       Cliente.Imprimir(Página 2.Tamaño del archivo);     }     Cliente.Imprimir("/ Li & gt;");   }   Cliente.Imprimir("/ ul & gt;");
}

¿Cuál debería ser el tamaño de nuestra zona de amortiguación?¡Cien es suficiente!
- definición. Sapo 100

Vacío. Correr()
{   Chamuscar Cliente[Sapo];   Interior Índice = 0;      Cliente de Ethernet Cliente = Servidor.Disponible adj.();   Si (Cliente) {     Http: / / request to End with a Free Line     Tipo booleano Comportamiento actual = ¿En serio?;          Reiniciar zona de amortiguación     Índice = 0;          Aunque (Cliente.Está relacionado.()) {       Si (Cliente.Disponible adj.()) {         Chamuscar Categoría C = Cliente.Leer();                  Añadir caracteres a la zona de amortiguación si no es una nueva fila         Si (Categoría C != - Sí. && Categoría C != - Sí.) {           Cliente[Índice] = Categoría C;           Índice++;           ¿Somos demasiado grandes para la zona de amortiguación?Iniciando lanzamiento de datos           Si (Índice >= Sapo)              Índice = Sapo -1;                      ¡Sigue leyendo más datos!           Persistencia;         }                  / / / adquisición de una línea o línea nueva, lo que significa que la cadena está completa         Cliente[Índice] = 0;                  Imprimir tr.         Transporte.Imprimir(Cliente);                  Búsqueda de cadenas, como la solicitud de acceso al archivo raíz         Si (Str.(Cliente, "Adquirir / adquirir") != 0) {           Http: / / Response Head standard of transmission           Cliente.Imprimir("Http / 1.1.200 sí");           Cliente.Imprimir("Tipo de contenido: texto / html");           Cliente.Imprimir();                      Imprimir todos los archivos, usar ayudantes para mantener limpio           Cliente.Imprimir("& lt; h2 & gt; documentación: & lt; / H2 & gt;");           Archivo de lista(Cliente, Tamaño de lsu);         } Hora prevista de despegue Si (Str.(Cliente, "Adquirir / adquirir") != 0) {           ¡Esta vez no hay archivos vacíos!           Chamuscar *Nombre del archivo;                      Nombre del archivo = Cliente + 5; Cuidar "Get /" (cinco caracteres)           / / / una pequeña técnica para buscar la cadena http / 1.1            Convertir el primer carácter de la cadena a 0 para borrarla.           (Str.(Cliente, Protocolo de transferencia de hipertexto))[0] = 0;                      Imprimir el archivo que queremos           Transporte.Imprimir(Nombre del archivo);           Si (! Documentación.Abrir(&Raíz, Nombre del archivo, O lectura)) {             Cliente.Imprimir("No se ha encontrado http / 1.1.404");             Cliente.Imprimir("Tipo de contenido: texto / html");             Cliente.Imprimir();             Cliente.Imprimir(¡"& lt; h2 & gt; no encuentro el archivo!- H2 & gt.);             Romper;           }                      Transporte.Imprimir(¡Ábrelo!);           Strlower.(Nombre del archivo);                     Cliente.Imprimir("Http / 1.1.200 sí");           Si (Str.(Nombre del archivo,"Calor".)!=No válido)             Cliente.Imprimir("Tipo de contenido: texto / html");           Hora prevista de despegue Si (Str.(Nombre del archivo,"Gobierno del Japón")!=No válido)             Cliente.Imprimir("Tipo de contenido: Image / jpg");           Hora prevista de despegue               Cliente.Imprimir("Tipo de contenido: texto / texto puro");           Cliente.Imprimir();                      International 16u t Categoría C;           Aunque ((Categoría C = Documentación.Leer()) >= 0) {               Cancela las notas para la secuencia que se va a ajustar.               / / / impresión en serie (char) c);               Cliente.Imprimir((Chamuscar)Categoría C);           }           Documentación.Cerrar();         } Hora prevista de despegue {           El resto es 404.           Cliente.Imprimir("No se ha encontrado http / 1.1.404");           Cliente.Imprimir("Tipo de contenido: texto / html");           Cliente.Imprimir();           Cliente.Imprimir(¡"& lt; h2 & gt; no encuentro el archivo!(En miles de dólares EE.UU.);         }         Romper;       }     }     / / / dar tiempo al navegador web para recibir datos     Retraso(1);     Cliente.Stop();   }
}

¡Maquillaje, maquillaje!

Espero con interés su respuesta y decir adiós antes de la próxima vez.
Moritz Springer.


Für arduinoProjekte für anfänger

3 comentarios

H3

H3

Oh wartet! im vorherigen war ein kleiner fehler! Dieser code funktioniert.

/*
This sketch uses the microSD card slot on the Arduino Ethernet shield
to serve up files over a very minimal browsing interface

Some code is from Bill Greiman’s SdFatLib examples, some is from the Arduino Ethernet WebServer example, some is from Limor Fried (Adafruit), some is from “jurs” for German Arduino forum, so its probably under GPL

*/

#include
#include
#include

/************ ETHERNET STUFF ************/
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 178, 177 };
EthernetServer server(80);

/************ SDCARD STUFF ************/
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

// store error strings in flash to save RAM
#define error(s) error_P(PSTR)

void error_P(const char* str) {
PgmPrint("error: “);
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint(”SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(‘,’);
Serial.println(card.errorData(), HEX);
}
while (1);
}

char* strupper( char* s )
// helper function char array to uppercase letters
{
for (char* p = s; *p; ++p)
*p = toupper( *p );
return s;
}

char* strlower( char* s )
// helper function char array to lowercase letters
{
for (char* p = s; *p; ++p)
*p = tolower( *p );
return s;
}

void setup() {
Serial.begin(115200);

PgmPrint("Free RAM: "); Serial.println(FreeRam()); // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with // breadboards. use SPI_FULL_SPEED for better performance. pinMode(10, OUTPUT); // set the SS pin as an output (necessary!) pinMode(4, OUTPUT); digitalWrite(10, HIGH); // but turn off the W5100 chip! digitalWrite(4, HIGH); if (!card.init(SPI_FULL_SPEED, 4)) error(“card.init failed!”); // initialize a FAT volume if (!volume.init(&card)) error(“vol.init failed!”); PgmPrint(“Volume is FAT”); Serial.println(volume.fatType(), DEC); Serial.println(); if (!root.openRoot(&volume)) error(“openRoot failed”); // list file in root with date and size PgmPrintln(“Files found in root:”); root.ls(LS_DATE | LS_SIZE); Serial.println(); // Recursive list of all directories PgmPrintln(“Files found in all dirs:”); root.ls(LS_R); Serial.println(); PgmPrintln(“Done”); // Debugging complete, we start the server! Ethernet.begin(mac, ip); server.begin(); delay(1000); digitalWrite(8, LOW);

}

void ListFiles(EthernetClient client, uint8_t flags) {
// This code is just copied from SdFile.cpp in the SDFat library
// and tweaked to print to the client output in html!
dir_t p;

root.rewind(); client.println(“”); while (root.readDir(p) > 0) { // done if past last used entry if (p.name0 == DIR_NAME_FREE) break; // skip deleted entry and entries for . and .. if (p.name0 == DIR_NAME_DELETED || p.name0 == ‘.’) continue; // only list subdirectories and files if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; // print any indent spaces client.print( for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ’ ’) continue; if (i == 8) { client.print(‘.’); } client.print((char)p.name[i]); } client.print(“\”>"); // print file name with possible blank fill for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ’ ’) continue; if (i == 8) { client.print(‘.’); } client.print((char)p.name[i]); } client.print(“”); if (DIR_IS_SUBDIR(&p)) { client.print(‘/’); } // print modify date/time if requested if (flags & LS_DATE) { root.printFatDate(p.lastWriteDate); client.print(’ ’); root.printFatTime(p.lastWriteTime); } // print size if requested if (!DIR_IS_SUBDIR(&p) && (flags & LS_SIZE)) { client.print(’ ’); client.print(p.fileSize); } client.println(“”); } client.println(“”);

}

// How big our line buffer should be. 100 is plenty!
#define BUFSIZ 100

void loop()
{
char clientline[BUFSIZ];
int index = 0;

EthernetClient client = server.available(); if (client) { digitalWrite(8, HIGH); // an http request ends with a blank line boolean current_line_is_blank = true; // reset the input buffer index = 0; while (client.connected()) { if (client.available()) { char c = client.read(); // If it isn’t a new line, add the character to the buffer if (c != ‘\n’ && c != ‘\r’) { clientline[index] = c; index++; // are we too big for the buffer? start tossing out data if (index >= BUFSIZ) index = BUFSIZ – 1; // continue to read more data! continue; } // got a \n or \r new line, which means the string is done clientline[index] = 0; // Print it out for debugging Serial.println(clientline); // Look for substring such as a request to get the root file if (strstr(clientline, "GET / ") != 0) { // send a standard http response header client.println(“HTTP/1.1 200 OK”); client.println(“Content-Type: text/html”); client.println(); // print all the files, use a helper to keep it clean client.println(“Files:”); ListFiles(client, LS_SIZE); } else if (strstr(clientline, “GET /”) != 0) { // this time no space after the /, so a sub-file! char *filename; filename = clientline + 5; // look after the “GET /” (5 chars) // a little trick, look for the " HTTP/1.1" string and // turn the first character of the substring into a 0 to clear it out. (strstr(clientline, " HTTP"))0 = 0; // print the file we want Serial.println(filename); if (! file.open(&root, filename, O_READ)) { client.println(“HTTP/1.1 404 Not Found”); client.println(“Content-Type: text/html”); client.println(); client.println(“File Not Found!”); break; } Serial.println(“Opened!”); strlower(filename); client.println(“HTTP/1.1 200 OK”); if (strstr(filename, “.html”) != NULL) client.println(“Content-Type: text/html”); else if (strstr(filename, “.jpg”) != NULL) client.println(“Content-Type: image/jpg”); else if (strstr(filename, “.png”) != NULL) client.println(“Content-Type: image/png”); else if (strstr(filename, “.mp3”) != NULL) client.println(“Content-Type: audio/mpeg”); else if (strstr(filename, “.ogg”) != NULL) client.println(“Content-Type: audio/ogg”); else if (strstr(filename, “.wav”) != NULL) client.println(“Content-Type: audio/wav”); else if (strstr(filename, “.m4a”) != NULL) client.println(“Content-Type: audio/mp4”); else if (strstr(filename, “.mp4”) != NULL) client.println(“Content-Type: video/mp4”); else client.println(“Content-Type: text/plain”); client.println(); int16_t c; while ((c = file.read()) >= 0) { // uncomment the serial to debug (slow!) //Serial.print((char)c); client.print((char)c); digitalWrite(8, !digitalRead(8)); if (!client.connected()) { break; } if (!client.available()) { break; } } file.close(); Serial.println(F(“Closed.”)); } else { // everything else is a 404 client.println(“HTTP/1.1 404 Not Found”); client.println(“Content-Type: text/html”); client.println(); client.println(“File Not Found!”); } break; } } // give the web browser time to receive the data delay(1); client.stop(); digitalWrite(8, LOW); }

}

H3

H3

Hab ein paar verbesserungen getätigt.
u.a. stoppt die übertragung jetzt wenn der client disconnected. außerdem gibt es jetzt eine Info LED auf pin 8 die aktivität anzeigt.

/*
This sketch uses the microSD card slot on the Arduino Ethernet shield
to serve up files over a very minimal browsing interface

Some code is from Bill Greiman’s SdFatLib examples, some is from the Arduino Ethernet WebServer example, some is from Limor Fried (Adafruit), some is from “jurs” for German Arduino forum, so its probably under GPL

*/

#include
#include
#include

/************ ETHERNET STUFF ************/
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 178, 177 };
EthernetServer server(80);

/************ SDCARD STUFF ************/
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

// store error strings in flash to save RAM
#define error(s) error_P(PSTR)

void error_P(const char* str) {
PgmPrint("error: “);
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint(”SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(‘,’);
Serial.println(card.errorData(), HEX);
}
while (1);
}

char* strupper( char* s )
// helper function char array to uppercase letters
{
for (char* p = s; *p; ++p)
*p = toupper( *p );
return s;
}

char* strlower( char* s )
// helper function char array to lowercase letters
{
for (char* p = s; *p; ++p)
*p = tolower( *p );
return s;
}

void setup() {
Serial.begin(115200);

PgmPrint("Free RAM: "); Serial.println(FreeRam()); // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with // breadboards. use SPI_FULL_SPEED for better performance. pinMode(10, OUTPUT); // set the SS pin as an output (necessary!) pinMode(4, OUTPUT); digitalWrite(10, HIGH); // but turn off the W5100 chip! digitalWrite(4, HIGH); if (!card.init(SPI_FULL_SPEED, 4)) error(“card.init failed!”); // initialize a FAT volume if (!volume.init(&card)) error(“vol.init failed!”); PgmPrint(“Volume is FAT”); Serial.println(volume.fatType(), DEC); Serial.println(); if (!root.openRoot(&volume)) error(“openRoot failed”); // list file in root with date and size PgmPrintln(“Files found in root:”); root.ls(LS_DATE | LS_SIZE); Serial.println(); // Recursive list of all directories PgmPrintln(“Files found in all dirs:”); root.ls(LS_R); Serial.println(); PgmPrintln(“Done”); // Debugging complete, we start the server! Ethernet.begin(mac, ip); server.begin(); delay(1000); digitalWrite(8, LOW);

}

void ListFiles(EthernetClient client, uint8_t flags) {
// This code is just copied from SdFile.cpp in the SDFat library
// and tweaked to print to the client output in html!
dir_t p;

root.rewind(); client.println(“”); while (root.readDir(p) > 0) { // done if past last used entry if (p.name0 == DIR_NAME_FREE) break; // skip deleted entry and entries for . and .. if (p.name0 == DIR_NAME_DELETED || p.name0 == ‘.’) continue; // only list subdirectories and files if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; // print any indent spaces client.print( for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ’ ’) continue; if (i == 8) { client.print(‘.’); } client.print((char)p.name[i]); } client.print(“\”>"); // print file name with possible blank fill for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ’ ’) continue; if (i == 8) { client.print(‘.’); } client.print((char)p.name[i]); } client.print(“”); if (DIR_IS_SUBDIR(&p)) { client.print(‘/’); } // print modify date/time if requested if (flags & LS_DATE) { root.printFatDate(p.lastWriteDate); client.print(’ ’); root.printFatTime(p.lastWriteTime); } // print size if requested if (!DIR_IS_SUBDIR(&p) && (flags & LS_SIZE)) { client.print(’ ’); client.print(p.fileSize); } client.println(“”); } client.println(“”);

}

// How big our line buffer should be. 100 is plenty!
#define BUFSIZ 100

void loop()
{
char clientline[BUFSIZ];
int index = 0;

EthernetClient client = server.available(); if (client) { digitalWrite(8, HIGH); // an http request ends with a blank line boolean current_line_is_blank = true; // reset the input buffer index = 0; while (client.connected()) { if (client.available()) { char c = client.read(); // If it isn’t a new line, add the character to the buffer if (c != ‘\n’ && c != ‘\r’) { clientline[index] = c; index++; // are we too big for the buffer? start tossing out data if (index >= BUFSIZ) index = BUFSIZ – 1; // continue to read more data! continue; } // got a \n or \r new line, which means the string is done clientline[index] = 0; // Print it out for debugging Serial.println(clientline); // Look for substring such as a request to get the root file if (strstr(clientline, "GET / ") != 0) { // send a standard http response header client.println(“HTTP/1.1 200 OK”); client.println(“Content-Type: text/html”); client.println(); // print all the files, use a helper to keep it clean client.println(“Files:”); ListFiles(client, LS_SIZE); } else if (strstr(clientline, “GET /”) != 0) { // this time no space after the /, so a sub-file! char *filename; filename = clientline + 5; // look after the “GET /” (5 chars) // a little trick, look for the " HTTP/1.1" string and // turn the first character of the substring into a 0 to clear it out. (strstr(clientline, " HTTP"))0 = 0; // print the file we want Serial.println(filename); if (! file.open(&root, filename, O_READ)) { client.println(“HTTP/1.1 404 Not Found”); client.println(“Content-Type: text/html”); client.println(); client.println(“File Not Found!”); break; } Serial.println(“Opened!”); strlower(filename); client.println(“HTTP/1.1 200 OK”); if (strstr(filename, “.html”) != NULL) client.println(“Content-Type: text/html”); else if (strstr(filename, “.jpg”) != NULL) client.println(“Content-Type: image/jpg”); else if (strstr(filename, “.png”) != NULL) client.println(“Content-Type: image/png”); else if (strstr(filename, “.mp3”) != NULL) client.println(“Content-Type: audio/mpeg”); else if (strstr(filename, “.ogg”) != NULL) client.println(“Content-Type: audio/ogg”); else if (strstr(filename, “.wav”) != NULL) client.println(“Content-Type: audio/wav”); else if (strstr(filename, “.m4a”) != NULL) client.println(“Content-Type: audio/mp4”); else if (strstr(filename, “.mp4”) != NULL) client.println(“Content-Type: video/mp4”); else client.println(“Content-Type: text/plain”); client.println(); int16_t c; while ((c = file.read()) >= 0) { // uncomment the serial to debug (slow!) //Serial.print((char)c); client.print((char)c); digitalWrite(8, !digitalRead(8)); if (!client.connected()) { return; } if (!client.available()) { return; } } file.close(); Serial.println(F(“Closed.”)); } else { // everything else is a 404 client.println(“HTTP/1.1 404 Not Found”); client.println(“Content-Type: text/html”); client.println(); client.println(“File Not Found!”); } break; } } // give the web browser time to receive the data delay(1); client.stop(); digitalWrite(8, LOW); }

}

Magnus

Magnus

I just bought from you a EthernetShield W5100 and wanted to test it with your code but I always get SD error: 1, FF with the code in the blog.
I have tried the code in the eBook. The WebServer example code works well, but the “Serving the web page from SD card, with AJAX” gives always a SD error.
Any clue to sort this out ?

Deja un comentario

Todos los comentarios son moderados antes de ser publicados