Outils pour utilisateurs

Outils du site


projets:esp32-cam_timelaps_code

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
projets:esp32-cam_timelaps_code [2020/05/31 15:15] – créée gepetoprojets:esp32-cam_timelaps_code [2024/02/09 16:56] (Version actuelle) – modification externe 127.0.0.1
Ligne 35: Ligne 35:
    "quality":10,    "quality":10,
    "capture_interval":10000,    "capture_interval":10000,
-   "total_frames":180,+   "length":1800,
    "ssid":"wifissid",    "ssid":"wifissid",
    "pass":"trucpass",    "pass":"trucpass",
Ligne 49: Ligne 49:
 //  edit these parameters for your needs //  edit these parameters for your needs
  
-static const char vernum[] = "v9Gepeto"; // modif AccesPoint and http filesystem+static const char vernum[] = "v10Gepeto"; // modif AccesPoint and http filesystem
 // plage horaire // plage horaire
 #include <dummy.h> #include <dummy.h>
Ligne 72: Ligne 72:
 char horaire[80]  = {0};// heures d'enregistrement char horaire[80]  = {0};// heures d'enregistrement
 char conf_horaire[]  = "6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21";// heures d'enregistrement char conf_horaire[]  = "6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21";// heures d'enregistrement
-#define TIMEZONE "GMT0BST,M3.5.0/01,M10.5.0/02            // your timezone   this is GMT +#define TIMEZONE "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00" // de https://remotemonitoringsystems.ca/time-zone-abbreviations.php
 // startup defaults for first recordin // startup defaults for first recordin
 // here are the recording options from the "retart web page" // here are the recording options from the "retart web page"
 +// framesize=UXGA&length=1800&interval=10000&quality=10&repeat=100&speed=1&gray=0
 // VGA 10 fps for 30 min, repeat, realtime                   http://192.168.0.117/start?framesize=VGA&length=1800&interval=100&quality=10&repeat=100&speed=1&gray=0 // VGA 10 fps for 30 min, repeat, realtime                   http://192.168.0.117/start?framesize=VGA&length=1800&interval=100&quality=10&repeat=100&speed=1&gray=0
 // VGA 2 fps, for 30 minutes repeat, 30x playback            http://192.168.0.117/start?framesize=VGA&length=1800&interval=500&quality=10&repeat=300&speed=30&gray=0 // VGA 2 fps, for 30 minutes repeat, 30x playback            http://192.168.0.117/start?framesize=VGA&length=1800&interval=500&quality=10&repeat=300&speed=30&gray=0
Ligne 154: Ligne 154:
 int file_number = 0; int file_number = 0;
 int internet_connected = 0; // 0 non connecté , 1 mode sta , 2 freewifi, 3 mode AP int internet_connected = 0; // 0 non connecté , 1 mode sta , 2 freewifi, 3 mode AP
-bool ntp_ok = false; 
 struct tm timeinfo; struct tm timeinfo;
 time_t now; time_t now;
Ligne 231: Ligne 230:
 FILE *nofile = NULL; FILE *nofile = NULL;
 FILE *configSD = NULL; FILE *configSD = NULL;
 +FILE *ficnofic = NULL;
  
 #define AVIOFFSET 240 // AVI main header length #define AVIOFFSET 240 // AVI main header length
Ligne 281: Ligne 281:
  
 void Test_horaires() {   // cherche si heure maintenant contenue dans horaires void Test_horaires() {   // cherche si heure maintenant contenue dans horaires
-  Serial.println(F("test horaire")); +  Serial.print ( timeinfo.tm_year) ; 
-  int heure = 0 ; +  if ( timeinfo.tm_year < 110)  { // date year deouis 1900 
-  int taille_plages = strlen(horaire); +    return; 
-  if (taille_plages > 3 ) { +  } else { 
-    char buf[3] = "00"; +    Serial.println(F(" test horaire")); 
-    for (int i = 0; i < taille_plages; i++) { +    int heure = 0 ; 
-      buf[0] = horaire[i++]; +    int taille_plages = strlen(horaire); 
-      if (horaire[i] != ',' && horaire[i] != ';' && horaire[i] != ' ') buf[1] = horaire[i++]; +    if (taille_plages > 3 ) { 
-      else buf[1] = '\0'; +      char buf[3] = "00"; 
-      buf[2] = '\0'; +      for (int i = 0; i < taille_plages; i++) { 
-      heure = atoi(buf); +        buf[0] = horaire[i++]; 
-      time(&now); +        if (horaire[i] != ',' && horaire[i] != ';' && horaire[i] != ' ') buf[1] = horaire[i++]; 
-      localtime_r(&now, &timeinfo); +        else buf[1] = '\0'; 
-      //Serial.print ( timeinfo.tm_hour) ; +        buf[2] = '\0'; 
-      //Serial.print(F("heures ")); +        heure = atoi(buf); 
-      //Serial.println(heure); +        time(&now); 
-      if ((int)timeinfo.tm_hour  == heure) { +        localtime_r(&now, &timeinfo); 
-        //Serial.print(F("  ")); +        //Serial.print(F("heures ")); 
-        //Serial.println(strftime_buf); +        //Serial.println(heure); 
-        heure = 99; +        if ((int)timeinfo.tm_hour  == heure) { 
-        break;+          //Serial.print(F("  ")); 
 +          //Serial.println(strftime_buf); 
 +          heure = 99; 
 +          break; 
 +        }
       }       }
-    } +      int reste = 58 - (int)timeinfo.tm_min; 
-    strftime(strftime_buf, sizeof(strftime_buf), "%M", &timeinfo); +      if (reste > 3 && heure < 90) { 
-    int reste = 58 - (int)timeinfo.tm_min; +        //end_avi(); 
-    if (reste > 3 && heure < 90) { +        Serial.print(F("Sleep ")); 
-      end_avi(); +        Serial.println(reste); 
-      Serial.print(F("Sleep ")); +        esp_sleep_enable_timer_wakeup(1000000 * 60 * (uint64_t)reste); 
-      Serial.println(reste); +        esp_deep_sleep_start(); 
-      esp_sleep_enable_timer_wakeup(1000000 * 60 * (uint64_t)reste); +        delay(1000); 
-      esp_deep_sleep_start(); +      
-      delay(1000); +    } else Serial.println(F("ok")); 
-    +  }
-  } else Serial.println(F("ok"));+
 } }
 /// ///
Ligne 349: Ligne 352:
   json["repeat"            = repeat;   json["repeat"            = repeat;
   json["xspeed"            = xspeed;   json["xspeed"            = xspeed;
-  json["total_frames"      total_frames;+  json["length"            xlength;
   json["gray"              = gray;   json["gray"              = gray;
   json["ssid"              = ssid;   json["ssid"              = ssid;
Ligne 358: Ligne 361:
   fclose(configSD);   fclose(configSD);
 } }
 +
 bool loadSPIFFSConfigFile(void) bool loadSPIFFSConfigFile(void)
 { {
Ligne 367: Ligne 371:
     Serial.println(F("Mounting FS..."));     Serial.println(F("Mounting FS..."));
     if (readFileconfig() == true) {     if (readFileconfig() == true) {
-      Serial.print(F("flash config ")); +      //Serial.print(F("flash config ")); 
-      Serial.println(buf_config);+      //Serial.println(buf_config);
       File configFile = SPIFFS.open("/config.jsn", "w");       File configFile = SPIFFS.open("/config.jsn", "w");
       configFile.print(buf_config);       configFile.print(buf_config);
Ligne 408: Ligne 412:
           if (json["quality"])          quality   = json["quality"] | quality ;           if (json["quality"])          quality   = json["quality"] | quality ;
           if (json["capture_interval"]) capture_interval =  json["capture_interval"] | capture_interval;           if (json["capture_interval"]) capture_interval =  json["capture_interval"] | capture_interval;
-          if (json["total_frames"])     total_frames =  json["total_frames"] | total_frames;+          if (json["length"])           xlength =  json["length"] | xlength;
           if (json["ssid"])             strlcpy (ssid , json["ssid"], sizeof(ssid));           if (json["ssid"])             strlcpy (ssid , json["ssid"], sizeof(ssid));
           else strlcpy (ssid , ssid_ap, sizeof(ssid));           else strlcpy (ssid , ssid_ap, sizeof(ssid));
Ligne 424: Ligne 428:
         configFile.close();         configFile.close();
         Serial.println(F("OK"));         Serial.println(F("OK"));
 +        total_frames = xlength * 1000 / capture_interval;
  
       }       }
Ligne 562: Ligne 567:
             skipping = 0;             skipping = 0;
             Serial.println(" Queue cleared. ");             Serial.println(" Queue cleared. ");
 +            delay(100);
           }           }
  
Ligne 630: Ligne 636:
   card_err = init_sdcard();   card_err = init_sdcard();
   if (card_err != true) {   if (card_err != true) {
-    Serial.printf("SD Card init failed with error 0x%x", card_err);+    Serial.printf("init sd error 0x%x", card_err);
     major_fail();     major_fail();
-    return; 
   }   }
   loadSPIFFSConfigFile();   loadSPIFFSConfigFile();
  
-  Serial.printf(" http://%s.local - to access the camera\n", devname);+  //Serial.printf(" http://%s.local - to access the camera\n", devname);
  
   pinMode(33, OUTPUT);    // little red led on back of chip   pinMode(33, OUTPUT);    // little red led on back of chip
   digitalWrite(33, LOW);           // turn on the red LED on the back of chip   digitalWrite(33, LOW);           // turn on the red LED on the back of chip
-  init_wifi(); 
-  if (internet_connected == 2) { 
-    Serial.print(F("Passage en Point d acces...")); 
-    WiFi.disconnect(); 
-    delay(500); 
-    WiFi.mode(WIFI_AP); 
-    delay(500); 
-    WiFi.softAP(ssid_ap, pass_ap, canal_wifi, invisible, max_connexion); 
-    delay(1000); 
-    Serial.print(F("ouverture paswd de ")); 
-    Serial.print(ssid_ap); 
-    Serial.print(F(" ")); 
-    Serial.println(pass_ap); 
-    internet_connected = 3; 
-    delay(1000); 
-    Serial.print(F("AP IP ")); 
-    Serial.println(WiFi.softAPIP()); 
-  } 
-  if (internet_connected < 3) { 
-    sprintf(localip, "%s", WiFi.localIP().toString().c_str()); 
-    Serial.println("mDNS"); 
-    //uint64_t chipid = ESP.getEfuseMac(); 
-    //char mdnsname[12] = {0}; 
-    //sprintf(mdnsname, "ESPCAM-%04X", (uint16_t)(chipid >> 32)); 
-    if (!MDNS.begin(devname)) { 
-      Serial.println("Error setting up MDNS responder!"); 
-    } else { 
-      Serial.printf("mDNS responder started '%s'\n", devname); 
-    } 
-  }  else { 
-    sprintf(localip, "%s", WiFi.softAPIP().toString().c_str()); 
-  } 
   if (!psramFound()) {   if (!psramFound()) {
     Serial.println("paraFound wrong - major fail");     Serial.println("paraFound wrong - major fail");
     //major_fail();     //major_fail();
   }   }
 +  init_wifi();
   Test_horaires();   Test_horaires();
   startCameraServer();   startCameraServer();
Ligne 730: Ligne 704:
 bool init_wifi() bool init_wifi()
 { {
-  WiFi.disconnect(true); +  if (internet_connected < 3) { // que si pas deja en AP 
-  WiFi.mode(WIFI_STA); +    WiFi.disconnect(true); 
-  WiFi.setHostname(devname); +    WiFi.mode(WIFI_STA); 
-  //WiFi.printDiag(Serial); +    WiFi.setHostname(devname); 
- +    WiFi.begin(ssid, pass); 
-  WiFi.begin(ssid, pass); +    delay(1000); 
-  delay(1000); +    while (WiFi.status() != WL_CONNECTED ) {
-  while (WiFi.status() != WL_CONNECTED ) { +
-    delay(500); +
-    Serial.print(F(".")); +
-    if (connAttempts == 10) { +
-      Serial.println(F("tentative FreeWifi")); +
-      WiFi.begin("FreeWifi"); +
-      WiFi.printDiag(Serial); +
-      internet_connected = 2;+
       delay(1000);       delay(1000);
-    else if (connAttempts > 11) { // AP +      Serial.print(F(".")); 
-      return (false);+      if (connAttempts == 10) { 
 +        Serial.println(F("tentative FreeWifi ntp")); // juste pour ntp 
 +        WiFi.begin("FreeWifi"); 
 +        delay(2000); 
 +        if (WiFi.SSID() == (String)"FreeWifi") { 
 +          Serial.println(F("Temps FreeWifi")); 
 +          internet_connected = 2; 
 +        } 
 +        delay(1000); 
 +      }  
 +      if(connAttempts > 13) { // laisse tomber, passage AP 
 +        internet_connected = 3; 
 +        break; 
 +      
 +      connAttempts++;
     }     }
-    connAttempts++; 
   }   }
   if (internet_connected == 0) internet_connected = 1;   if (internet_connected == 0) internet_connected = 1;
-  Serial.println(F("Internet connected")); +  if (internet_connected < 3) { 
-  WiFi.printDiag(Serial); +    Serial.println(WiFi.SSID()); 
-  char pool[] = "pool.ntp.org"; +    char pool[16] = ""; 
-  if ( internet_connected == 2) sprintf(pool, "%s", WiFi.gatewayIP().toString().c_str()); +    if ( internet_connected == 2) 
-  configTime(0, 0, pool); +      sprintf(pool, "%s", WiFi.gatewayIP().toString().c_str()); 
-  setenv("TZ", TIMEZONE, 1);  // mountain time zone from #define at top +    } else { 
-  tzset(); +      sprintf(pool, "pool.ntp.org"); 
- +    } 
-  time_t now ; +    Serial.print(F("Attente ntp de ")); 
-  timeinfo = { 0 }; +    Serial.print(pool); 
-  int retry = 0; +    configTime(0, 0, pool); 
-  const int retry_count = 10+    setenv("TZ", TIMEZONE, 1);  // Paris time zone from #define at top 
-  delay(1000); +    tzset(); 
-  time(&now); +    time_t now ; 
-  localtime_r(&now, &timeinfo); +    timeinfo = { 0 }; 
-  while (timeinfo.tm_year < (2016 - 1900) && ++retry < retry_count) { +    int retry = 0; 
-    Serial.printf("Waiting for system time to be set... (%d/%d) -- %d\n", retry, retry_count, timeinfo.tm_year)+    const int retry_count = 10; 
-    delay(1000);+    delay(2000);
     time(&now);     time(&now);
     localtime_r(&now, &timeinfo);     localtime_r(&now, &timeinfo);
-    ntp_ok = true+    Serial.print(F(" : "))
-  }+    Serial.println(ctime(&now)); 
 +    Serial.print(F(" - "));
  
-  Serial.println(ctime(&now)); +    while (!time(nullptr) && ++retry < retry_count) { 
-  if (internet_connected < 3{+      Serial.printf("... (%d/%d) -- %d\n", retry, retry_count, timeinfo.tm_year); 
 +      delay(1000); 
 +      time(&now); 
 +      localtime_r(&now, &timeinfo); 
 +      Serial.println(ctime(&now)); 
 +      Serial.print(F(" ok ntp ")); 
 +    }
     sprintf(localip, "%s", WiFi.localIP().toString().c_str());     sprintf(localip, "%s", WiFi.localIP().toString().c_str());
-  }  else {+  } 
 +  if (internet_connected >= 2) { 
 +    Serial.print(F("\nPassage en Point d acces...")); 
 +    WiFi.disconnect(); 
 +    delay(500); 
 +    WiFi.mode(WIFI_AP); 
 +    delay(1000); 
 +    WiFi.softAP(ssid_ap, pass_ap, canal_wifi, invisible, max_connexion); 
 +    delay(1000); 
 +    Serial.print(F("ouverture paswd de ")); 
 +    Serial.print(ssid_ap); 
 +    Serial.print(F(" ")); 
 +    Serial.println(pass_ap); 
 +    internet_connected = 3; 
 +    delay(1000);
     sprintf(localip, "%s", WiFi.softAPIP().toString().c_str());     sprintf(localip, "%s", WiFi.softAPIP().toString().c_str());
 +    Serial.println(WiFi.softAPIP());
 +    Serial.println(WiFi.localIP());
 +    if (!MDNS.begin(devname)) {
 +      Serial.println(F("Error MDNS !"));
 +    } else {
 +      Serial.printf("mDNS started '%s'\n", devname);
 +    }
   }   }
-  ntp_ok = true; 
   Serial.println(localip);   Serial.println(localip);
   return true;   return true;
Ligne 803: Ligne 809:
   sdmmc_card_t *card;   sdmmc_card_t *card;
  
-  Serial.println(F("Mounting SD card..."));+  //Serial.println(F("Mounting SD card..."));
   ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);   ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
  
   if (ret == ESP_OK) {   if (ret == ESP_OK) {
-    Serial.println(F("SD card mount successfully!"));+    Serial.println(F("SD mount ok!"));
   }  else  {   }  else  {
-    Serial.printf("Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));+    Serial.printf("err mount SD card VFAT Error: %s", esp_err_to_name(ret));
     major_fail();     major_fail();
     return false;     return false;
Ligne 825: Ligne 831:
   File root = fs.open(dirname);   File root = fs.open(dirname);
   if (!root) {   if (!root) {
-    Serial.println(F("Failed to open directory"));+    Serial.println(F("err open directory"));
     return;     return;
   }   }
   if (!root.isDirectory()) {   if (!root.isDirectory()) {
-    Serial.println(F("Not a directory"));+    Serial.println(F("Not a dir"));
     return;     return;
   }   }
Ligne 892: Ligne 898:
       digitalWrite(33, LOW);       digitalWrite(33, LOW);
       end_avi();       end_avi();
-      Serial.println(F("Done capture due to command"));+      Serial.println(F("ok capture command"));
       frames_so_far = total_frames;       frames_so_far = total_frames;
       newfile = 0;    // file is closed       newfile = 0;    // file is closed
Ligne 900: Ligne 906:
       if (newfile == 1 && recording == 1) {                            // regular recording       if (newfile == 1 && recording == 1) {                            // regular recording
         if (frames_so_far >= total_frames)  {                                // we are done the recording         if (frames_so_far >= total_frames)  {                                // we are done the recording
-          Serial.println(F("Done capture for total frames!"));+          Serial.println(F("ok capture for total frames!"));
           digitalWrite(33, LOW);                                                       // close the file           digitalWrite(33, LOW);                                                       // close the file
           end_avi();           end_avi();
Ligne 977: Ligne 983:
     cam_err = esp_camera_init(&config);     cam_err = esp_camera_init(&config);
     if (cam_err != ESP_OK) {     if (cam_err != ESP_OK) {
-      Serial.printf("Camera init failed with error 0x%x", cam_err);+      Serial.printf("Camera init error 0x%x", cam_err);
       major_fail();       major_fail();
     }     }
Ligne 997: Ligne 1003:
   }   }
 } }
 +void nofichiersave(fs::FS & fs, const char * nomfic) { 
 +  File ficnofic = fs.open(nomfic, FILE_WRITE); 
 +  if (!ficnofic) { 
 +    Serial.println(F("err open /nofic.jsn writing")); 
 +  } 
 +  DynamicJsonDocument json(32); 
 +  json["nofichier" = numero_fichier; 
 +  serializeJson(json, ficnofic); 
 +
 +int nofichierread(fs::FS & fs, const char * nomfic) { 
 +  File ficnofic = fs.open(nomfic, FILE_READ); 
 +  if (!ficnofic) { 
 +    Serial.println(F("err open /nofic.jsn reading")); 
 +  } 
 +  DynamicJsonDocument json(32); 
 +  DeserializationError error = deserializeJson(json, ficnofic); 
 +  if (error) { 
 +    Serial.println(F("err json /nofic.jsn")); 
 +    ficnofic.println(); 
 +    return (numero_fichier); 
 +  } 
 +  numero_fichier = json["nofichier"]; 
 +}
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // //
Ligne 1004: Ligne 1032:
  
 static esp_err_t start_avi() { static esp_err_t start_avi() {
-  Serial.println("Starting an avi ");+  Serial.println(F("Starting an avi "));
   config_camera();   config_camera();
-  if ( ntp_ok == true) {+  if ( (int)timeinfo.tm_year > 110 ) {
     time(&now);     time(&now);
     localtime_r(&now, &timeinfo);     localtime_r(&now, &timeinfo);
     strftime(strftime_buf, sizeof(strftime_buf), "%F_%H.%M.%S", &timeinfo);     strftime(strftime_buf, sizeof(strftime_buf), "%F_%H.%M.%S", &timeinfo);
   } else {   } else {
-    nofile = fopen("/sdcard/nofile.txt", "w"); +    nofichierread(SD_MMC, "/nofic.jsn");
-    if (nofile != NULL)  { +
-      Serial.printf("File open: %s\n", "/sdcard/nofile.txt"); +
-      if (fread(&numero_fichier, sizeof(int), 1, nofile) != 1) { +
-        numero_fichier++; +
-      } else { +
-        numero_fichier = 1; +
-      } +
-    } else  { +
-      //sprintf(nofile, "%d", numero_fichier); // init a 1 +
-      size_t dc_err = fwrite(&numero_fichier, sizeof(int), 1, nofile); +
-    }+
     sprintf(strftime_buf, "%d", numero_fichier);     sprintf(strftime_buf, "%d", numero_fichier);
   }   }
 +
   char fname[100];   char fname[100];
  
Ligne 1048: Ligne 1066:
     //Serial.printf("File open: %s\n", fname);     //Serial.printf("File open: %s\n", fname);
   }  else  {   }  else  {
-    Serial.println("Could not open file");+    Serial.println("err open file");
     major_fail();     major_fail();
   }   }
Ligne 1054: Ligne 1072:
     //Serial.printf("File open: %s\n", "/sdcard/idx.tmp");     //Serial.printf("File open: %s\n", "/sdcard/idx.tmp");
   }  else  {   }  else  {
-    Serial.println("Could not open file");+    Serial.println(F("err open file"));
     major_fail();     major_fail();
   }   }
Ligne 1158: Ligne 1176:
     size_t err = fwrite(fb_q[fb_out]->buf, 1, fb_q[fb_out]->len, avifile);     size_t err = fwrite(fb_q[fb_out]->buf, 1, fb_q[fb_out]->len, avifile);
     if (err == 0 ) {     if (err == 0 ) {
-      Serial.println("Error on avi write");+      Serial.println(F("Err avi write"));
       major_fail();       major_fail();
     }     }
Ligne 1207: Ligne 1225:
   //Serial.print(" Write Q: "); Serial.print((fb_in + fb_max - fb_out) % fb_max); Serial.print(" in/out  "); Serial.print(fb_in); Serial.print(" / "); Serial.println(fb_out);   //Serial.print(" Write Q: "); Serial.print((fb_in + fb_max - fb_out) % fb_max); Serial.print(" in/out  "); Serial.print(fb_in); Serial.print(" / "); Serial.println(fb_out);
   current_end = ftell (avifile);   current_end = ftell (avifile);
-  Serial.println(F("End of avi - closing the files"));+  Serial.println(F("End of avi - close files"));
   elapsedms = millis() - startms;   elapsedms = millis() - startms;
   float fRealFPS = (1000.0f * (float)frame_cnt) / ((float)elapsedms) * xspeed;   float fRealFPS = (1000.0f * (float)frame_cnt) / ((float)elapsedms) * xspeed;
Ligne 1237: Ligne 1255:
   print_quartet(movi_size + frame_cnt * 8 + 4, avifile);   print_quartet(movi_size + frame_cnt * 8 + 4, avifile);
  
-  Serial.println(F("\n*** Video recorded and saved ***\n"));+  Serial.println(F("\n*** Video ok,saved ***\n"));
   Serial.print(F("Recorded "));   Serial.print(F("Recorded "));
   Serial.print(elapsedms / 1000);   Serial.print(elapsedms / 1000);
Ligne 1271: Ligne 1289:
  
   }  else  {   }  else  {
-    Serial.println(F("Could not open file"));+    Serial.println(F("err open file"));
     //major_fail();     //major_fail();
   }   }
Ligne 1293: Ligne 1311:
  
   // incremente le numero_fichier   // incremente le numero_fichier
-  if ( ntp_ok == false) { +  if ( (int)timeinfo.tm_year < 110) { 
-    nofile = fopen("/sdcard/nofile.txt", "w")+    numero_fichier++; 
-    if (nofile != NULL)  { +    nofichiersave(SD_MMC, "/nofic.jsn"); 
-      Serial.printf("File open: %s\n", "/sdcard/nofile.txt"); +    sprintf(strftime_buf, "%d", numero_fichier);
-      if (fread(&numero_fichier, sizeof(int), 1, nofile) != 1) { +
-        numero_fichier++; +
-      } else { +
-        numero_fichier = 1; +
-      } +
-      Serial.printf("numero_fichier %d\n", numero_fichier ); +
-      size_t dc_err = fwrite(&numero_fichiersizeof(int), 1, nofile); +
-      fclose(nofile); +
-    } else  { +
-      Serial.printf("pb ecriture numero_fichier %d\n", numero_fichier ); +
-    }+
   }   }
 } }
Ligne 1355: Ligne 1362:
       init_wifi();       init_wifi();
     }     }
-    if (internet_connected == 2) { 
-      Serial.print(F("Passage en Point d acces...")); 
-      WiFi.disconnect(); 
-      delay(500); 
-      WiFi.mode(WIFI_AP); 
-      delay(1000); 
-      WiFi.softAP(ssid_ap, pass_ap, canal_wifi, invisible, max_connexion); 
-      delay(1000); 
-      Serial.print(F("ouverture paswd de ")); 
-      Serial.print(ssid_ap); 
-      Serial.print(F(" ")); 
-      Serial.println(pass_ap); 
-      internet_connected = 3; 
-      delay(1000); 
-      Serial.println(WiFi.softAPIP()); 
-      Serial.println(WiFi.localIP()); 
-      if (!MDNS.begin(devname)) { 
-        Serial.println(F("Error setting up MDNS responder!")); 
-      } else { 
-        Serial.printf("mDNS responder started '%s'\n", devname); 
-      } 
-    } 
-    if (internet_connected < 3) { 
-      sprintf(localip, "%s", WiFi.localIP().toString().c_str()); 
-    } else { 
-      sprintf(localip, "%s", WiFi.softAPIP().toString().c_str()); 
-    } 
-    Serial.println(localip); 
   }   }
   Test_horaires();   Test_horaires();
Ligne 1421: Ligne 1400:
     Serial.printf("File saved: %s\n", filename);     Serial.printf("File saved: %s\n", filename);
   }  else  {   }  else  {
-    Serial.println(F("Could not open file"));+    Serial.println(F("err open file"));
   }   }
   fclose(file);   fclose(file);
Ligne 1469: Ligne 1448:
     Serial.printf("File saved: %s\n", filename);     Serial.printf("File saved: %s\n", filename);
   }  else  {   }  else  {
-    Serial.println(F("Could not open file"));+    Serial.println(F("err open file"));
   }   }
   fclose(file);   fclose(file);
Ligne 1523: Ligne 1502:
   } else {   } else {
     //recording = 1;     //recording = 1;
-    Serial.println(F("starting recording"));+    Serial.println(F("start recording"));
  
     sensor_t * s = esp_camera_sensor_get();     sensor_t * s = esp_camera_sensor_get();
Ligne 1682: Ligne 1661:
 Gray      = 1 ou 0<br> Gray      = 1 ou 0<br>
  
-Fichier sur la microSD /config.json <br> +
-ex: {"devname":"esp32-cam","framesize":6,"repeat":100,"xspeed":1,"gray":0,"quality":10,"capture_interval":10000,"total_frames":180,"ssid":"SNHACK","pass":"1234567890","horaire":"10 11,12,13,14,15,16,17,18,19,20"}+
 <br>mis a jour dela config initiale par  <br>mis a jour dela config initiale par 
 <h3><a href="http://%s/saveconfig"> saveconfig</a></h3> <h3><a href="http://%s/saveconfig"> saveconfig</a></h3>
  
 +Fichier sur la microSD /config.jsn <br>
 +%s
 </body> </body>
 </html>)rawliteral"; </html>)rawliteral";
 +  //ex: {"devname":"esp32-cam","framesize":6,"repeat":100,"xspeed":1,"gray":0,"quality":10,"capture_interval":10000,"length":180,"ssid":"SNHACK","pass":"1234567890","horaire":"10 11,12,13,14,15,16,17,18,19,20"}
  
-  sprintf(the_page, msg, devname, devname, vernum, the_message, localip, localip, localip, localip, localip, localip, localip, localip, localip, localip);+  sprintf(the_page, msg, devname, devname, vernum, the_message, localip, localip, localip, localip, localip, localip, localip, localip, localip, localip, buf_config);
   Serial.println(the_page);   Serial.println(the_page);
 } }
Ligne 1699: Ligne 1680:
  
   recording = 0;   recording = 0;
-  Serial.println(F("stopping recording"));+  Serial.println(F("stop recording"));
  
   do_stop("Stopping previous recording");   do_stop("Stopping previous recording");
Ligne 1741: Ligne 1722:
  <h3><a href="http://%s/saveconfig"> saveconfig</a></h3>  <h3><a href="http://%s/saveconfig"> saveconfig</a></h3>
  
-Fichier sur la microSD /config.json ex: {"framesize":6,"repeat":100,"xspeed":1,"gray":0,"quality":10,"capture_interval":10000,"total_frames":180},+Fichier sur la microSD /config.json ex: {"framesize":6,"repeat":100,"xspeed":1,"gray":0,"quality":10,"capture_interval":10000,"length":180},
 cf list<br> cf list<br>
  LED flash sur une frame, SOS flash si pas de microSD<br>  LED flash sur une frame, SOS flash si pas de microSD<br>
Ligne 1775: Ligne 1756:
   File root = fs.open(dirname);   File root = fs.open(dirname);
   if (!root) {   if (!root) {
-    Serial.println(F("Failed to open directory"));+    Serial.println(F("err open dir"));
     return;     return;
   }   }
   if (!root.isDirectory()) {   if (!root.isDirectory()) {
-    Serial.println(F("Not a directory"));+    Serial.println(F("Not a dir"));
     return;     return;
   }   }
Ligne 1785: Ligne 1766:
  
   while (file) {   while (file) {
 +    delay(100);
     if (file.isDirectory()) {     if (file.isDirectory()) {
       output += "<br><h2><a href=\"http://";       output += "<br><h2><a href=\"http://";
Ligne 1794: Ligne 1776:
       output += "</a></h2>";       output += "</a></h2>";
       output += "\n";       output += "\n";
-      Serial.println((String)file.name()); +      //Serial.println((String)file.name());
       if (levels) {       if (levels) {
         listDir(fs, file.name(), levels - 1);         listDir(fs, file.name(), levels - 1);
Ligne 1809: Ligne 1790:
       output += "  : ";       output += "  : ";
       output += file.size();       output += file.size();
-      Serial.println((String)file.name()); +      //Serial.println((String)file.name());
     }     }
     file = root.openNextFile();     file = root.openNextFile();
Ligne 1823: Ligne 1803:
   output += "</body></html>";   output += "</body></html>";
   server.send(200, "text/html", output);   server.send(200, "text/html", output);
-  Serial.println(F("fin"));+  //Serial.println(F("fin"));
   return;   return;
 } }
Ligne 1829: Ligne 1809:
 bool listDir_handler() { bool listDir_handler() {
   listDir(SD_MMC, "/", 0);   listDir(SD_MMC, "/", 0);
-  Serial.println(F("listDir fin"));+  //Serial.println(F("listDir fin"));
  
   return true;   return true;
 } }
 /// ///
-/// SDCARD +/// SDCARD
 /// ///
 bool loadFromSdCard(fs::FS & fs, String path) { bool loadFromSdCard(fs::FS & fs, String path) {
Ligne 1913: Ligne 1893:
 bool saveSPIFFSConfigFile(void) bool saveSPIFFSConfigFile(void)
 { {
-  Serial.println(F("Saving config"));+  Serial.println(F("Save config"));
   recording = 0;   recording = 0;
   DynamicJsonDocument json(512);   DynamicJsonDocument json(512);
Ligne 1922: Ligne 1902:
   json["repeat"            = repeat;   json["repeat"            = repeat;
   json["xspeed"            = xspeed;   json["xspeed"            = xspeed;
-  json["total_frames"      total_frames;+  json["length"            xlength;
   json["gray"              = gray;   json["gray"              = gray;
   json["ssid"              = ssid;   json["ssid"              = ssid;
Ligne 1974: Ligne 1954:
 //// ////
 void startCameraServer() { void startCameraServer() {
-  +
   //server.on("/", index_handler);   //server.on("/", index_handler);
   server.on("/capture",    capture_handler);   server.on("/capture",    capture_handler);
projets/esp32-cam_timelaps_code.1590930924.txt.gz · Dernière modification : 2024/02/09 16:55 (modification externe)