mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
Start to make constructor
This commit is contained in:
1
data/conf.csv
Normal file
1
data/conf.csv
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||||
|
1
data/items/button-in.txt
Normal file
1
data/items/button-in.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;button-in;switch1;toggle;Кнопки;Свет;1;pin[2];db[20]
|
||||||
1
data/items/button-out-i.txt
Normal file
1
data/items/button-out-i.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;button-out;light1;toggle;Кнопки;Свет;1;pin[12];inv[1];st[1]
|
||||||
1
data/items/button-out.txt
Normal file
1
data/items/button-out.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;button-out;light1;toggle;Кнопки;Свет;1;pin[12];st[0]
|
||||||
1
data/items/pwm-out.txt
Normal file
1
data/items/pwm-out.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;pwm-out;volume;range;Кнопки;Свет;1;pin[12];st[500]
|
||||||
@@ -91,6 +91,7 @@
|
|||||||
"action": "/set?devinit",
|
"action": "/set?devinit",
|
||||||
"class": "btn btn-block btn-default"
|
"class": "btn btn-block btn-default"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": "h2",
|
"type": "h2",
|
||||||
"title": "Сценарии"
|
"title": "Сценарии"
|
||||||
|
|||||||
65
data/setn.device.json
Normal file
65
data/setn.device.json
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"configs": [
|
||||||
|
"/config.setup.json",
|
||||||
|
"/config.option.json",
|
||||||
|
"/config.live.json",
|
||||||
|
"/lang/lang.ru.json"
|
||||||
|
],
|
||||||
|
"class": "col-sm-offset-1 col-sm-10",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "h5",
|
||||||
|
"title": "{{name}}",
|
||||||
|
"class": "alert-default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"title": "{{ButMainPage}}",
|
||||||
|
"action": "/",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dropdown",
|
||||||
|
"name": "help-url",
|
||||||
|
"class": "btn btn-default",
|
||||||
|
"style": "display:inline",
|
||||||
|
"title": {
|
||||||
|
"#": "Выберите элемент из списка<span class=\"caret\"></span>",
|
||||||
|
"/set?element=button-out": "1.Кнопка управляющая пином",
|
||||||
|
"/set?element=button-out-i": "2.Кнопка управляющая пином с инверсией",
|
||||||
|
"/set?element=pwm-out": "3.Широтно импульсная подуляция",
|
||||||
|
"/set?element=button-in": "4.Физическая кнопка"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "csv",
|
||||||
|
"title": [
|
||||||
|
"checkbox",
|
||||||
|
"html",
|
||||||
|
"text",
|
||||||
|
"text",
|
||||||
|
"text",
|
||||||
|
"text",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"state": "conf.csv",
|
||||||
|
"style": "width:100%;",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"title": "Удалить все",
|
||||||
|
"action": "/set?cleanconf",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -135,7 +135,7 @@ class LineParsing {
|
|||||||
#ifdef LAYOUT_IN_RAM
|
#ifdef LAYOUT_IN_RAM
|
||||||
all_widgets += widget + "\r\n";
|
all_widgets += widget + "\r\n";
|
||||||
#else
|
#else
|
||||||
addFile("layout.txt", buf);
|
addFileLn("layout.txt", buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ File seekFile(const String& filename, size_t position = 0);
|
|||||||
*/
|
*/
|
||||||
const String readFileString(const String& filename, const String& to_find);
|
const String readFileString(const String& filename, const String& to_find);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Добовление строки в файл
|
||||||
|
*/
|
||||||
|
const String addFileLn(const String& filename, const String& str);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Добовление строки в файл
|
* Добовление строки в файл
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void deleteOldDate(const String filename, size_t max_lines_cnt, String payload)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (timeNow->hasTimeSynced()) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String addFile(const String& filename, const String& str) {
|
const String addFileLn(const String& filename, const String& str) {
|
||||||
String path = filepath(filename);
|
String path = filepath(filename);
|
||||||
auto file = LittleFS.open(path, "a");
|
auto file = LittleFS.open(path, "a");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -62,6 +62,17 @@ const String addFile(const String& filename, const String& str) {
|
|||||||
return "sucсess";
|
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) {
|
bool copyFile(const String& src, const String& dst, bool overwrite) {
|
||||||
String srcPath = filepath(src);
|
String srcPath = filepath(src);
|
||||||
String dstPath = filepath(dst);
|
String dstPath = filepath(dst);
|
||||||
|
|||||||
12
src/Web.cpp
12
src/Web.cpp
@@ -37,6 +37,16 @@ void web_init() {
|
|||||||
request->redirect("/?set.device");
|
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")) {
|
if (request->hasArg("devinit")) {
|
||||||
Device_init();
|
Device_init();
|
||||||
@@ -73,7 +83,7 @@ void web_init() {
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
if (request->hasArg("updatelist")) {
|
if (request->hasArg("updatelist")) {
|
||||||
removeFile("/dev.csv");
|
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");
|
request->redirect("/?set.udp");
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void createWidget(String descr, String page, String order, String filename, Stri
|
|||||||
#ifdef LAYOUT_IN_RAM
|
#ifdef LAYOUT_IN_RAM
|
||||||
all_widgets += widget + "\r\n";
|
all_widgets += widget + "\r\n";
|
||||||
#else
|
#else
|
||||||
addFile("layout.txt", buf);
|
addFileLn("layout.txt", buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ void createWidgetParam(String widget, String page, String pageNumber, String fil
|
|||||||
#ifdef LAYOUT_IN_RAM
|
#ifdef LAYOUT_IN_RAM
|
||||||
all_widgets += widget + "\r\n";
|
all_widgets += widget + "\r\n";
|
||||||
#else
|
#else
|
||||||
addFile("layout.txt", buf);
|
addFileLn("layout.txt", buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ void createChart(String widget, String page, String pageNumber, String filename,
|
|||||||
#ifdef LAYOUT_IN_RAM
|
#ifdef LAYOUT_IN_RAM
|
||||||
all_widgets += widget + "\r\n";
|
all_widgets += widget + "\r\n";
|
||||||
#else
|
#else
|
||||||
addFile("layout.txt", buf);
|
addFileLn("layout.txt", buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void add_dev_in_list(String fileName, String id, String dev_name, String ip);
|
|||||||
#ifdef UDP_ENABLED
|
#ifdef UDP_ENABLED
|
||||||
void udp_init() {
|
void udp_init() {
|
||||||
removeFile("dev.csv");
|
removeFile("dev.csv");
|
||||||
addFile("dev.csv", "device id;device name;ip address");
|
addFileLn("dev.csv", "device id;device name;ip address");
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
udp.begin(udp_port);
|
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) {
|
void add_dev_in_list(String filename, String id, String dev_name, String ip) {
|
||||||
auto file = seekFile("/" + filename);
|
auto file = seekFile("/" + filename);
|
||||||
if (!file.find(id.c_str())) {
|
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