mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
тесты
This commit is contained in:
@@ -10,5 +10,6 @@ extern void handleFileUpload();
|
|||||||
extern void handleFileDelete();
|
extern void handleFileDelete();
|
||||||
extern void handleFileCreate();
|
extern void handleFileCreate();
|
||||||
extern void handleFileList();
|
extern void handleFileList();
|
||||||
|
void printDirectory(File dir, String& out);
|
||||||
//#endif
|
//#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ void setup() {
|
|||||||
|
|
||||||
// test
|
// test
|
||||||
Serial.println("-------test start--------");
|
Serial.println("-------test start--------");
|
||||||
|
|
||||||
|
// File dir = FileFS.open("/", "r");
|
||||||
|
// String out;
|
||||||
|
// printDirectory(dir, out);
|
||||||
|
// Serial.println(out);
|
||||||
|
|
||||||
//=======проверка очереди из структур=================
|
//=======проверка очереди из структур=================
|
||||||
|
|
||||||
// myDB = new IoTDB;
|
// myDB = new IoTDB;
|
||||||
|
|||||||
@@ -11,42 +11,36 @@ void standWebServerInit() {
|
|||||||
HTTP.serveStatic("/bundle.css.gz", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
HTTP.serveStatic("/bundle.css.gz", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
||||||
HTTP.serveStatic("/favicon.png", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
HTTP.serveStatic("/favicon.png", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
||||||
|
|
||||||
HTTP.on("/devicelist.json", HTTP_GET, []() {
|
// HTTP.on("/devicelist.json", HTTP_GET, []() {
|
||||||
HTTP.send(200, "application/json", devListHeapJson);
|
// HTTP.send(200, "application/json", devListHeapJson);
|
||||||
});
|
// });
|
||||||
|
// HTTP.on("/settings.h.json", HTTP_GET, []() {
|
||||||
HTTP.on("/settings.h.json", HTTP_GET, []() {
|
// HTTP.send(200, "application/json", settingsFlashJson);
|
||||||
HTTP.send(200, "application/json", settingsFlashJson);
|
// });
|
||||||
});
|
// HTTP.on("/settings.f.json", HTTP_GET, []() {
|
||||||
|
// HTTP.send(200, "application/json", readFile(F("settings.json"), 20000));
|
||||||
HTTP.on("/settings.f.json", HTTP_GET, []() {
|
// });
|
||||||
HTTP.send(200, "application/json", readFile(F("settings.json"), 20000));
|
// HTTP.on("/params.json", HTTP_GET, []() {
|
||||||
});
|
// String json = getParamsJson();
|
||||||
|
// HTTP.send(200, "application/json", json);
|
||||||
HTTP.on("/params.json", HTTP_GET, []() {
|
// });
|
||||||
String json = getParamsJson();
|
// HTTP.on("/errors.json", HTTP_GET, []() {
|
||||||
HTTP.send(200, "application/json", json);
|
// HTTP.send(200, "application/json", errorsHeapJson);
|
||||||
});
|
// });
|
||||||
|
// HTTP.on("/config.json", HTTP_GET, []() {
|
||||||
HTTP.on("/errors.json", HTTP_GET, []() {
|
// HTTP.send(200, "application/json", readFile(F("config.json"), 20000));
|
||||||
HTTP.send(200, "application/json", errorsHeapJson);
|
// });
|
||||||
});
|
// HTTP.on("/layout.json", HTTP_GET, []() {
|
||||||
|
// HTTP.send(200, "application/json", readFile(F("layout.json"), 20000));
|
||||||
HTTP.on("/config.json", HTTP_GET, []() {
|
// });
|
||||||
HTTP.send(200, "application/json", readFile(F("config.json"), 20000));
|
// HTTP.on("/restart", HTTP_GET, []() {
|
||||||
});
|
// // ESP.restart();
|
||||||
|
// HTTP.send(200, "text/plain", "ok");
|
||||||
HTTP.on("/layout.json", HTTP_GET, []() {
|
// });
|
||||||
HTTP.send(200, "application/json", readFile(F("layout.json"), 20000));
|
|
||||||
});
|
|
||||||
|
|
||||||
HTTP.on("/restart", HTTP_GET, []() {
|
|
||||||
// ESP.restart();
|
|
||||||
HTTP.send(200, "text/plain", "ok");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Добавляем функцию Update для перезаписи прошивки по WiFi при 1М(256K FileFS) и выше
|
// Добавляем функцию Update для перезаписи прошивки по WiFi при 1М(256K FileFS) и выше
|
||||||
// httpUpdater.setup(&HTTP);
|
// httpUpdater.setup(&HTTP);
|
||||||
|
|
||||||
// Запускаем HTTP сервер
|
// Запускаем HTTP сервер
|
||||||
HTTP.begin();
|
HTTP.begin();
|
||||||
|
|
||||||
@@ -95,7 +89,6 @@ void standWebServerInit() {
|
|||||||
HTTP.send(200, "text/plain", "");
|
HTTP.send(200, "text/plain", "");
|
||||||
},
|
},
|
||||||
handleFileUpload);
|
handleFileUpload);
|
||||||
//#endif
|
|
||||||
|
|
||||||
// called when the url is not defined here
|
// called when the url is not defined here
|
||||||
HTTP.onNotFound([]() {
|
HTTP.onNotFound([]() {
|
||||||
@@ -155,7 +148,6 @@ String getContentType(String filename) {
|
|||||||
return "text/plain";
|
return "text/plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef REST_FILE_OPERATIONS
|
|
||||||
// Здесь функции для работы с файловой системой
|
// Здесь функции для работы с файловой системой
|
||||||
void handleFileUpload() {
|
void handleFileUpload() {
|
||||||
if (HTTP.uri() != "/edit") return;
|
if (HTTP.uri() != "/edit") return;
|
||||||
@@ -205,10 +197,6 @@ void handleFileCreate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleFileList() {
|
void handleFileList() {
|
||||||
if (!HTTP.hasArg("list")) {
|
|
||||||
HTTP.send(500, "text/plain", "BAD ARGS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File dir = FileFS.open("/", "r");
|
File dir = FileFS.open("/", "r");
|
||||||
String output = "[";
|
String output = "[";
|
||||||
File entry;
|
File entry;
|
||||||
@@ -226,5 +214,22 @@ void handleFileList() {
|
|||||||
Serial.println(output);
|
Serial.println(output);
|
||||||
HTTP.send(200, "text/json", output);
|
HTTP.send(200, "text/json", output);
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
|
void printDirectory(File dir, String& out) {
|
||||||
|
while (true) {
|
||||||
|
File entry = dir.openNextFile();
|
||||||
|
if (!entry) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
out += entry.name();
|
||||||
|
out += "/";
|
||||||
|
printDirectory(entry, out);
|
||||||
|
} else {
|
||||||
|
out += entry.name();
|
||||||
|
out += "\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user