Probleme de refresh

Bonjour ,
J'utilise la librairie webduino , et j'affiche ma liste de fichier présent dans la SD sur ma page web , Donc une première fois les fichiers sont affichés mais si je refresh la page b sa ne s'affiche plus :cold_sweat: .

Voici mon code :

void setup() {

  /* Hardware initialization */
  Serial.begin(115200);
  pinMode(53, OUTPUT);
  Ethernet.begin(mac, localIp, gateway, submask);
  webserver.begin();

  /* SD card initialization */
  if (!SD.begin(4)) { // si initialisation n'est pas réussie
    Serial.println(F("Echec initialisation!"));
    for(;;); // Boucle infini
  } 

 root = SD.open("/");// ouvre la carte SD a la racine
  if (!root) {
    Serial.println(F("Erreur lors de l'ouverture de /"));
    for (;;);
  } 
  webserver.setDefaultCommand(&defaultCmd);
}

et l'appel de defaultCmd :

void defaultCmd(WebServer &server, WebServer::ConnectionType type, char*, bool) {  

  /* Only accept GET request */
  if (type == WebServer::POST) {
    server.httpFail();
    return;
  }

  /* HTTP 200 OK html/text */
  server.httpSuccess();

  /* No body for HEAD request */
  if (type == WebServer::GET) {

    /* Constants messages of the page */
    P(part1) = 
      "<html><head><title>Simulateur</title></head>"
      "<body style=\"text-align:left;\">"     
      "<div style=\"font-size:200%;font-weight:bold; border: 2px black solid;\">";
    P(part2) =    
      "<span style=\"text-indent:50%;margin-left:150px;margin-top:25px; \">Simulation thermique</span></div>"
      "<center><h2>Historique des campagnes<h2></center>"
      "<center><aside style=\"width : 20%; height: 80%;border:2px black solid;overflow:auto;\">";
    P(part3) =
      "</aside></center>"
      "</body></html>";

    /* Output the page */
    server.printP(part1);
    server.printP(partLedImg);
    server.printP(part2);
    ListFiles(webserver, root, 0); // Recursive call to show directories/file tree
    server.printP(part3);  
  }
}

et enfin ListFiles :

/* Display file CSV */
void ListFiles(WebServer &client, File dir, byte numTabs) {
  char* pstring ;
  /* Start a new html list */
  client.println(F("<ul>"));

  /* Until no more entry in directory */
  for(;;) {
    /* Get next available entry in the current directory */
    File entry = dir.openNextFile();
    if (!entry) {
      break; // No more entry in this directory
    }
    /* Display file link */
    pstring = entry.name() ;
    /* Tri les fichiers et affiche que les fichiers CSV */
    if(strtok_r(pstring, ".", &pstring) != NULL){
      if(strcmp(pstring,"CSV") == 0 ){
        client.print(F("<li><a href=\"courbe?"));
        client.println(entry.name());
        client.print(F("\">"));
       
         client.println(entry.name());
      }
    }
    /* Close the html list entry */
    client.println(F("</li>"));
    entry.close();
  }
  /* Close the html list */
  client.println(F("</ul>"));
}

Si il vous manque quelque chose dites le moi :wink: Merci d'avance

Bonjour,

Erreur toute bête, il manque juste une ligne :wink:

server.printP(part2);
root.rewindDirectory(); // <---- La ligne magique
ListFiles(webserver, root, 0);
server.printP(part3);

Ah oui effectivement !!! x)
Si je reviens jamais au début à chaque fois c'est sur qu'il ne pourra pas trouver les autres fichiers x)
Je te remercie :slight_smile: