mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 23:22:19 +03:00
platformio esp8266, esp32
This commit is contained in:
@@ -1,6 +1,29 @@
|
||||
#include "Utils/FileUtils.h"
|
||||
|
||||
#include <LittleFS.h>
|
||||
|
||||
bool fileSystemInit() {
|
||||
if (!LittleFS.begin()) {
|
||||
Serial.println("[E] LittleFS");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void removeFile(const String filename) {
|
||||
if (!LittleFS.remove(filename)) {
|
||||
Serial.printf("[E] on remove %s", filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
File seekFile(const String filename, size_t position) {
|
||||
auto file = LittleFS.open(filename, "r");
|
||||
if (!file) {
|
||||
Serial.printf("[E] on open %s", filename.c_str());
|
||||
}
|
||||
// поставим курсор в начало файла
|
||||
file.seek(position, SeekSet);
|
||||
return file;
|
||||
}
|
||||
|
||||
String readFileString(const String filename, const String to_find) {
|
||||
String res = "Failed";
|
||||
|
||||
@@ -22,9 +22,9 @@ void reconfigTime() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
String ntp = jsonReadStr(configSetupJson, "ntp");
|
||||
configTime(0, 0, ntp.c_str());
|
||||
int i = 0;
|
||||
Serial.println("[I] Start time sync");
|
||||
Serial.println("[I] Time sync");
|
||||
#ifdef ESP32
|
||||
uint8_t i = 0;
|
||||
struct tm timeinfo;
|
||||
while (!getLocalTime(&timeinfo) && i <= 4) {
|
||||
Serial.print(".");
|
||||
@@ -33,6 +33,7 @@ void reconfigTime() {
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
//uint8_t i = 0;
|
||||
//while (!time(nullptr) && i < 4) {
|
||||
// Serial.print(".");
|
||||
// i++;
|
||||
|
||||
Reference in New Issue
Block a user