mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 23:22:19 +03:00
Updates
This commit is contained in:
@@ -54,6 +54,32 @@ String addFile(const String filename, const String str) {
|
||||
return "Sucсess";
|
||||
}
|
||||
|
||||
bool copyFile(const String src, const String dst, bool overwrite) {
|
||||
String source = filepath(src);
|
||||
String destination = filepath(dst);
|
||||
if (!LittleFS.exists(source)) {
|
||||
pm.error("source not exist: " + source);
|
||||
return false;
|
||||
}
|
||||
if (LittleFS.exists(destination)) {
|
||||
if (!overwrite) {
|
||||
pm.error("destination already exist: " + destination);
|
||||
return false;
|
||||
}
|
||||
LittleFS.remove(destination);
|
||||
}
|
||||
auto srcFile = LittleFS.open(source, "r");
|
||||
auto dstFile = LittleFS.open(destination, "w");
|
||||
|
||||
static uint8_t buf[512];
|
||||
while (srcFile.read(buf, 512)) {
|
||||
dstFile.write(buf, 512);
|
||||
}
|
||||
srcFile.close();
|
||||
dstFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
String writeFile(const String filename, const String str) {
|
||||
auto file = LittleFS.open(filepath(filename), "w");
|
||||
if (!file) {
|
||||
|
||||
@@ -35,16 +35,23 @@ String selectToMarkerPlus(String str, String found, int plus) {
|
||||
return str.substring(0, p + plus);
|
||||
}
|
||||
|
||||
String selectFromMarkerToMarker(String str, String found, int number) {
|
||||
if (str.indexOf(found) == -1) return "not found"; // если строки поиск нет сразу выход
|
||||
str += found; // добавим для корректного поиска
|
||||
uint8_t i = 0; // Индекс перебора
|
||||
String selectFromMarkerToMarker(String str, String tofind, int number) {
|
||||
if (str.indexOf(tofind) == -1) {
|
||||
return "not found";
|
||||
}
|
||||
str += tofind; // добавим для корректного поиска
|
||||
uint8_t i = 0; // Индекс перебора
|
||||
do {
|
||||
if (i == number) return selectToMarker(str, found); // если индекс совпал с позицией законцим вернем резултат
|
||||
str = deleteBeforeDelimiter(str, found); // отбросим проверенный блок до разделителя
|
||||
i++; // увеличим индекс
|
||||
} while (str.length() != 0); // повторим пока строка не пустая
|
||||
return "not found"; // Достигли пустой строки и ничего не нашли
|
||||
if (i == number) {
|
||||
// если индекс совпал с позицией
|
||||
return selectToMarker(str, tofind);
|
||||
}
|
||||
// отбросим проверенный блок до разделителя
|
||||
str = deleteBeforeDelimiter(str, tofind);
|
||||
i++;
|
||||
} while (str.length() != 0);
|
||||
|
||||
return "not found";
|
||||
}
|
||||
|
||||
uint8_t hexStringToUint8(String hex) {
|
||||
|
||||
@@ -44,7 +44,7 @@ void startSTAMode() {
|
||||
} while (keepConnecting && tries--);
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
MQTT_init();
|
||||
initMQTT();
|
||||
setLedStatus(LED_OFF);
|
||||
} else {
|
||||
startAPMode();
|
||||
@@ -105,4 +105,8 @@ boolean scanWiFi(String ssid) {
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isNetworkActive() {
|
||||
return WiFi.status() == WL_CONNECTED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user