mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Start to make constructor
This commit is contained in:
@@ -94,7 +94,7 @@ void deleteOldDate(const String filename, size_t max_lines_cnt, String payload)
|
||||
}
|
||||
} else {
|
||||
if (timeNow->hasTimeSynced()) {
|
||||
addFile(filename, timeNow->getTimeUnix() + " " + payload);
|
||||
addFileLn(filename, timeNow->getTimeUnix() + " " + payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ const String readFileString(const String& filename, const String& to_find) {
|
||||
return res;
|
||||
}
|
||||
|
||||
const String addFile(const String& filename, const String& str) {
|
||||
const String addFileLn(const String& filename, const String& str) {
|
||||
String path = filepath(filename);
|
||||
auto file = LittleFS.open(path, "a");
|
||||
if (!file) {
|
||||
@@ -62,6 +62,17 @@ const String addFile(const String& filename, const String& str) {
|
||||
return "sucсess";
|
||||
}
|
||||
|
||||
const String addFile(const String& filename, const String& str) {
|
||||
String path = filepath(filename);
|
||||
auto file = LittleFS.open(path, "a");
|
||||
if (!file) {
|
||||
return "failed";
|
||||
}
|
||||
file.print(str);
|
||||
file.close();
|
||||
return "sucсess";
|
||||
}
|
||||
|
||||
bool copyFile(const String& src, const String& dst, bool overwrite) {
|
||||
String srcPath = filepath(src);
|
||||
String dstPath = filepath(dst);
|
||||
|
||||
12
src/Web.cpp
12
src/Web.cpp
@@ -37,6 +37,16 @@ void web_init() {
|
||||
request->redirect("/?set.device");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("element")) {
|
||||
String name = request->getParam("element")->value();
|
||||
String item = readFile("items/" + name + ".txt", 1024);
|
||||
item.replace("\r\n", "");
|
||||
item.replace("\r", "");
|
||||
item.replace("\n", "");
|
||||
addFile("conf.csv", "\n" + item);
|
||||
request->redirect("/?setn.device");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("devinit")) {
|
||||
Device_init();
|
||||
@@ -73,7 +83,7 @@ void web_init() {
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("updatelist")) {
|
||||
removeFile("/dev.csv");
|
||||
addFile("dev.csv", "device id;device name;ip address");
|
||||
addFileLn("dev.csv", "device id;device name;ip address");
|
||||
request->redirect("/?set.udp");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
@@ -29,7 +29,7 @@ void createWidget(String descr, String page, String order, String filename, Stri
|
||||
#ifdef LAYOUT_IN_RAM
|
||||
all_widgets += widget + "\r\n";
|
||||
#else
|
||||
addFile("layout.txt", buf);
|
||||
addFileLn("layout.txt", buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void createWidgetParam(String widget, String page, String pageNumber, String fil
|
||||
#ifdef LAYOUT_IN_RAM
|
||||
all_widgets += widget + "\r\n";
|
||||
#else
|
||||
addFile("layout.txt", buf);
|
||||
addFileLn("layout.txt", buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void createChart(String widget, String page, String pageNumber, String filename,
|
||||
#ifdef LAYOUT_IN_RAM
|
||||
all_widgets += widget + "\r\n";
|
||||
#else
|
||||
addFile("layout.txt", buf);
|
||||
addFileLn("layout.txt", buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ void add_dev_in_list(String fileName, String id, String dev_name, String ip);
|
||||
#ifdef UDP_ENABLED
|
||||
void udp_init() {
|
||||
removeFile("dev.csv");
|
||||
addFile("dev.csv", "device id;device name;ip address");
|
||||
addFileLn("dev.csv", "device id;device name;ip address");
|
||||
|
||||
#ifdef ESP8266
|
||||
udp.begin(udp_port);
|
||||
@@ -130,7 +130,7 @@ void do_udp_data_parse() {
|
||||
void add_dev_in_list(String filename, String id, String dev_name, String ip) {
|
||||
auto file = seekFile("/" + filename);
|
||||
if (!file.find(id.c_str())) {
|
||||
addFile(filename, id + ";" + dev_name + "; <a href=\"http://" + ip + "\" target=\"_blank\"\">" + ip + "</a>");
|
||||
addFileLn(filename, id + ";" + dev_name + "; <a href=\"http://" + ip + "\" target=\"_blank\"\">" + ip + "</a>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user