Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Rudolf
#33882
robotmaker42 wrote:I mashed the web update example, the FSwebBrowser example, and some code I wrote myself. when a file is downloaded to the esp8266( has to be some form of text EX: .txt , .html) it prints it to serial

Hello robotmaker42,
Thank you very much for this good program. The GUI form is excellent.

I extended it, to show in the setup block the contents of the SPIFFS. I added:
Code: Select all// outside of the Arduino blocks
#define DBG_OUTPUT_PORT Serial

//format bytes
String formatBytes(size_t bytes){
  if (bytes < 1024){
    return String(bytes)+"B";
  } else if(bytes < (1024 * 1024)){
    return String(bytes/1024.0)+"KB";
  } else if(bytes < (1024 * 1024 * 1024)){
    return String(bytes/1024.0/1024.0)+"MB";
  } else {
    return String(bytes/1024.0/1024.0/1024.0)+"GB";
  }
}

// in Arduino setup(), at the end
if (!SPIFFS.begin()) { DBG_OUTPUT_PORT.println("SPIFFS failed");
  } else {
    Dir dir = SPIFFS.openDir("/");
    while (dir.next()) {   
      String fileName = dir.fileName();
      size_t fileSize = dir.fileSize();
      DBG_OUTPUT_PORT.printf("FS File: %s, size: %s\n", fileName.c_str(), formatBytes(fileSize).c_str());
      }
    DBG_OUTPUT_PORT.printf("\n");
  }

Unfortunately after flashing the file, I got always a watchdog reset, in Seriell Monitor I can read:
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
see: http://bbs.espressif.com/viewtopic.php?t=1069

Regards, Rudolf
User avatar
By Rudolf
#34291 ESP.restart() is a problem. In Arduino Serial Monitor it will give the following message, and stops:
Code: Select all ets Jan  8 2013,rst cause:2, boot mode:(1,7)


 ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

For that message you can find:
http://bbs.espressif.com/viewtopic.php?t=1069

So, better do not use ESP.restart()

Regards, Rudolf
User avatar
By robotmaker42
#35539
Rudolf wrote:
robotmaker42 wrote:I mashed the web update example, the FSwebBrowser example, and some code I wrote myself. when a file is downloaded to the esp8266( has to be some form of text EX: .txt , .html) it prints it to serial

Hello robotmaker42,
Thank you very much for this good program. The GUI form is excellent.

I extended it, to show in the setup block the contents of the SPIFFS. I added:
Code: Select all// outside of the Arduino blocks
#define DBG_OUTPUT_PORT Serial

//format bytes
String formatBytes(size_t bytes){
  if (bytes < 1024){
    return String(bytes)+"B";
  } else if(bytes < (1024 * 1024)){
    return String(bytes/1024.0)+"KB";
  } else if(bytes < (1024 * 1024 * 1024)){
    return String(bytes/1024.0/1024.0)+"MB";
  } else {
    return String(bytes/1024.0/1024.0/1024.0)+"GB";
  }
}

// in Arduino setup(), at the end
if (!SPIFFS.begin()) { DBG_OUTPUT_PORT.println("SPIFFS failed");
  } else {
    Dir dir = SPIFFS.openDir("/");
    while (dir.next()) {   
      String fileName = dir.fileName();
      size_t fileSize = dir.fileSize();
      DBG_OUTPUT_PORT.printf("FS File: %s, size: %s\n", fileName.c_str(), formatBytes(fileSize).c_str());
      }
    DBG_OUTPUT_PORT.printf("\n");
  }

Unfortunately after flashing the file, I got always a watchdog reset, in Seriell Monitor I can read:
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
see: http://bbs.espressif.com/viewtopic.php?t=1069

Regards, Rudolf


thats cool!