Skip to content

setTimeCallback is not working for ESP8266 with both SD.h and SDFS too #7682

Closed
@akoro

Description

@akoro

Basic Infos

  • [x ] This issue complies with the issue POLICY doc.
  • [x ] I have read the documentation at readthedocs and the issue is not addressed there.
  • [x ] I have tested that the issue is present in current master branch (aka latest git).
  • [x ] I have searched the issue tracker for a similar issue.
  • [x ] If there is a stack dump, I have decoded it.
  • [x ] I have filled out all fields below.

Platform

  • Hardware: ESP-12
  • Core Version: 2.6.2
  • Development Env: Platformio
  • Operating System: Windows

Settings in IDE

  • Module: Generic ESP8266 Module
  • Flash Mode: dio
  • Flash Size: 4MB
  • lwip Variant: v1.4
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 460800

Problem Description

setTimeCallback is not working for ESP8266 with both SD.h and SDFS too
TimeCallback function isn't calling at all

#include <SPI.h>
#include <time.h>
#include <SDFS.h>
using namespace sdfs;

SDFSConfig cfg(SS);

// TimeCallback function:
time_t my_time(void)
{
  struct tm t;
  t.tm_year = 120;
  t.tm_mon  = 9;
  t.tm_mday = 22;
  t.tm_hour = 12;
  t.tm_min  = 13;
  t.tm_sec  = 14;
  Serial.print("*");
  return mktime(&t);
}

void setup()
{
  Serial.begin(115200);
  while (!Serial) yield();
...
  // SD card init
  SDFS.setConfig(cfg);
  SDFS.setTimeCallback(my_time); // does not work!!!
  SDFS.begin();
...
  String fname = "new_file.txt"

  File file = SDFS.open(fname, "w");
  if (file)
  {
    file.write("12457845122\r\n");
    file.write("12457845122\r\n");
    file.write("12457845122\r\n");
    file.write("12457845122\r\n");
    file.write("12457845122\r\n");
    file.close();
    Serial.printf("create %s OK\n", fname.c_str());
  }
  else
    Serial.printf("create %s failed\n", fname.c_str());
...
    
}

The file created normal but his timestamp is not expected.
And "*" is not printing, so my_time() does not call.

The part of the directory list output:
1961-11-25 17:32:20 new_file.txt 65

Similar issue

Metadata

Metadata

Labels

waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions