mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
версия 404, много исправлений
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
data_svelte/favicon.ico
Normal file
BIN
data_svelte/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -4,9 +4,9 @@
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
|
||||
<title>Svelte app</title>
|
||||
<title>IoT Manager</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='/favicon.ico'>
|
||||
<link rel='stylesheet' href='/build/bundle.css'>
|
||||
|
||||
<script defer src='/build/bundle.js'></script>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"settings": "",
|
||||
"name": "IoTmanagerVer4",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
//Это версия прошивки
|
||||
#define FIRMWARE_VERSION 403
|
||||
#define FIRMWARE_VERSION 404
|
||||
|
||||
#ifdef esp8266_4mb
|
||||
#define FIRMWARE_NAME "esp8266_4mb"
|
||||
#endif
|
||||
|
||||
#ifdef esp32_4mb
|
||||
#define FIRMWARE_NAME "esp32_4mb"
|
||||
#endif
|
||||
|
||||
//Размер буфера json
|
||||
#define JSON_BUFFER_SIZE 1024
|
||||
#define JSON_BUFFER_SIZE 2048
|
||||
|
||||
//выбор сервера
|
||||
//#define ASYNC_WEB_SERVER
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
*****************************************глобальные объекты классов***************************************************
|
||||
**********************************************************************************************************************/
|
||||
|
||||
|
||||
extern TickerScheduler ts;
|
||||
extern WiFiClient espClient;
|
||||
extern PubSubClient mqtt;
|
||||
@@ -104,6 +103,7 @@ extern String mqttUser;
|
||||
extern String mqttPass;
|
||||
|
||||
extern unsigned long mqttUptime;
|
||||
extern unsigned long flashWriteNumber;
|
||||
|
||||
extern String mqttRootDevice;
|
||||
extern String chipId;
|
||||
|
||||
@@ -70,8 +70,8 @@ class Scenario {
|
||||
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||
oneBlock.replace("end", "");
|
||||
|
||||
// SerialPrint("I", "Event done", incommingEvent);
|
||||
SerialPrint("I", F("Scenario"), F("All conditions are matched"));
|
||||
// SerialPrint("i", "Event done", incommingEvent);
|
||||
SerialPrint("i", F("Scenario"), F("All conditions are matched"));
|
||||
spaceCmdExecute(oneBlock);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ class Scenario {
|
||||
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||
oneBlock.replace("end", "");
|
||||
|
||||
// SerialPrint("I", "Event done", incommingEvent);
|
||||
SerialPrint("I", F("Scenario"), F("One of all condition are matched"));
|
||||
// SerialPrint("i", "Event done", incommingEvent);
|
||||
SerialPrint("i", F("Scenario"), F("One of all condition are matched"));
|
||||
spaceCmdExecute(oneBlock);
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ class Scenario {
|
||||
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||
oneBlock.replace("end", "");
|
||||
|
||||
// SerialPrint("I", "Event done", incommingEvent);
|
||||
SerialPrint("I", F("Scenario"), "Condition are matched: " + condition);
|
||||
// SerialPrint("i", "Event done", incommingEvent);
|
||||
SerialPrint("i", F("Scenario"), "Condition are matched: " + condition);
|
||||
spaceCmdExecute(oneBlock);
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ class Scenario {
|
||||
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||
oneBlock.replace("end", "");
|
||||
|
||||
// SerialPrint("I", "Event done", incommingEvent);
|
||||
SerialPrint("I", F("Scenario"), "Condition are matched: " + condition);
|
||||
// SerialPrint("i", "Event done", incommingEvent);
|
||||
SerialPrint("i", F("Scenario"), "Condition are matched: " + condition);
|
||||
spaceCmdExecute(oneBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ extern const String writeFile(const String& filename, const String& str);
|
||||
extern const String readFile(const String& filename, size_t max_size);
|
||||
extern const String filepath(const String& filename);
|
||||
extern bool cutFile(const String& src, const String& dst);
|
||||
extern const String addFileLn(const String& filename, const String& str);
|
||||
extern const String addFileLn(const String& filename, const String& str);
|
||||
extern void onFlashWrite();
|
||||
@@ -8,7 +8,7 @@ void eventGen2(String eventName, String eventValue) {
|
||||
String event = eventName + " " + eventValue + ",";
|
||||
eventBuf += event;
|
||||
|
||||
SerialPrint("I", "Event add", eventName + " " + eventValue);
|
||||
SerialPrint("i", "Event add", eventName + " " + eventValue);
|
||||
|
||||
if (jsonReadBool(settingsFlashJson, "MqttOut")) {
|
||||
if (eventName != "timenow") {
|
||||
@@ -25,7 +25,7 @@ void spaceCmdExecute(String& cmdStr) {
|
||||
String buf = selectToMarker(cmdStr, "\n");
|
||||
if (buf != "") {
|
||||
sCmd.readStr(buf);
|
||||
SerialPrint("I", F("Order done W"), buf);
|
||||
SerialPrint("i", F("Order done W"), buf);
|
||||
}
|
||||
cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ const String getThisDevice() {
|
||||
|
||||
void addThisDeviceToList() {
|
||||
devListHeapJson = getThisDevice();
|
||||
SerialPrint("i", "List", "Add this dev to list");
|
||||
}
|
||||
|
||||
#ifdef UDP_ENABLED
|
||||
@@ -61,7 +62,7 @@ void asyncUdpInit() {
|
||||
},
|
||||
nullptr, true);
|
||||
|
||||
SerialPrint("I", F("UDP"), F("Udp Init"));
|
||||
SerialPrint("i", F("UDP"), F("Udp Init"));
|
||||
}
|
||||
|
||||
bool udpPacketValidation(String& data) {
|
||||
|
||||
@@ -14,27 +14,32 @@ void configure(String path) {
|
||||
if (jsonArrayElement.startsWith(",")) {
|
||||
jsonArrayElement = jsonArrayElement.substring(1, jsonArrayElement.length()); //это нужно оптимизировать в последствии
|
||||
}
|
||||
|
||||
String subtype;
|
||||
if (!jsonRead(jsonArrayElement, F("subtype"), subtype)) { //если нет такого ключа в представленном json или он не валидный
|
||||
SerialPrint(F("E"), F("Config"), "json error " + subtype);
|
||||
continue;
|
||||
} else {
|
||||
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
|
||||
if (myIoTItem) {
|
||||
IoTGpio* tmp = myIoTItem->getGpioDriver();
|
||||
if (tmp) IoTgpio.regDriver(tmp);
|
||||
IoTItems.push_back(myIoTItem);
|
||||
if (jsonArrayElement == "]}") {
|
||||
jsonArrayElement = "";
|
||||
}
|
||||
if (jsonArrayElement != "") {
|
||||
String subtype;
|
||||
if (!jsonRead(jsonArrayElement, F("subtype"), subtype)) { //если нет такого ключа в представленном json или он не валидный
|
||||
SerialPrint(F("E"), F("Config"), "json error " + subtype);
|
||||
continue;
|
||||
} else {
|
||||
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
|
||||
if (myIoTItem) {
|
||||
IoTGpio* tmp = myIoTItem->getGpioDriver();
|
||||
if (tmp) IoTgpio.regDriver(tmp);
|
||||
IoTItems.push_back(myIoTItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
SerialPrint("i", "Config", "Configured");
|
||||
}
|
||||
|
||||
void clearConfigure() {
|
||||
Serial.printf("Start clearing config\n");
|
||||
for (unsigned int i = 0; i < IoTItems.size(); i++) {
|
||||
if (IoTItems[i]) delete IoTItems[i];
|
||||
if (IoTItems[i]) delete IoTItems[i];
|
||||
}
|
||||
IoTItems.clear();
|
||||
}
|
||||
@@ -18,8 +18,6 @@ void globalVarsSync() {
|
||||
jsonWriteStr_(settingsFlashJson, "root", mqttRootDevice);
|
||||
jsonWriteStr_(settingsFlashJson, "id", chipId);
|
||||
|
||||
syncSettingsFlashJson();
|
||||
|
||||
jsonWriteStr_(errorsHeapJson, "errors", ""); //метка для парсинга
|
||||
jsonWriteStr_(ssidListHeapJson, "ssid", ""); //метка для парсинга
|
||||
jsonWriteStr(paramsHeapJson, "params", ""); //метка для парсинга
|
||||
@@ -39,7 +37,7 @@ const String getChipId() {
|
||||
|
||||
void setChipId() {
|
||||
chipId = getChipId();
|
||||
SerialPrint("I", "System", "id: " + chipId);
|
||||
SerialPrint("i", "System", "id: " + chipId);
|
||||
}
|
||||
|
||||
const String getUniqueId(const char* name) {
|
||||
|
||||
@@ -54,7 +54,8 @@ String mqttPrefix = "";
|
||||
String mqttUser = "";
|
||||
String mqttPass = "";
|
||||
|
||||
unsigned long mqttUptime;
|
||||
unsigned long mqttUptime = 0;
|
||||
unsigned long flashWriteNumber = 0;
|
||||
|
||||
String chipId = "";
|
||||
String prex = "";
|
||||
|
||||
@@ -23,9 +23,6 @@ void setup() {
|
||||
//подключаемся к роутеру
|
||||
routerConnect();
|
||||
|
||||
//запустим один раз асинхронное сканирование сетей wifi для веба
|
||||
RouterFind(jsonReadStr(settingsFlashJson, F("routerssid")));
|
||||
|
||||
//инициализация асинхронного веб сервера и веб сокетов
|
||||
#ifdef ASYNC_WEB_SERVER
|
||||
asyncWebServerInit();
|
||||
@@ -51,9 +48,6 @@ void setup() {
|
||||
//инициализация задач переодического выполнения
|
||||
periodicTasksInit();
|
||||
|
||||
//окончательнаясинхронизация настроек
|
||||
syncSettingsFlashJson();
|
||||
|
||||
//синхронизация списка устройств
|
||||
addThisDeviceToList();
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ void mqttInit() {
|
||||
WIFI_MQTT_CONNECTION_CHECK, MQTT_RECONNECT_INTERVAL,
|
||||
[&](void*) {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
SerialPrint("I", F("WIFI"), F("OK"));
|
||||
SerialPrint("i", F("WIFI"), F("OK"));
|
||||
if (mqtt.connected()) {
|
||||
SerialPrint("I", F("MQTT"), "OK");
|
||||
SerialPrint("i", F("MQTT"), "OK");
|
||||
handleMqttStatus(false);
|
||||
|
||||
static unsigned int prevMillis;
|
||||
@@ -48,10 +48,10 @@ boolean mqttConnect() {
|
||||
|
||||
return res;
|
||||
}
|
||||
SerialPrint("I", "MQTT", "connection started");
|
||||
SerialPrint("i", "MQTT", "connection started");
|
||||
|
||||
SerialPrint("I", "MQTT", "broker " + mqttServer + ":" + String(mqttPort, DEC));
|
||||
SerialPrint("I", "MQTT", "topic " + mqttRootDevice);
|
||||
SerialPrint("i", "MQTT", "broker " + mqttServer + ":" + String(mqttPort, DEC));
|
||||
SerialPrint("i", "MQTT", "topic " + mqttRootDevice);
|
||||
|
||||
// setLedStatus(LED_FAST);
|
||||
|
||||
@@ -61,10 +61,10 @@ boolean mqttConnect() {
|
||||
bool connected = false;
|
||||
if (mqttUser != "" && mqttPass != "") {
|
||||
connected = mqtt.connect(chipId.c_str(), mqttUser.c_str(), mqttPass.c_str());
|
||||
SerialPrint("I", F("MQTT"), F("Go to connection with login and password"));
|
||||
SerialPrint("i", F("MQTT"), F("Go to connection with login and password"));
|
||||
} else if (mqttUser == "" && mqttPass == "") {
|
||||
connected = mqtt.connect(chipId.c_str());
|
||||
SerialPrint("I", F("MQTT"), F("Go to connection without login and password"));
|
||||
SerialPrint("i", F("MQTT"), F("Go to connection without login and password"));
|
||||
} else {
|
||||
SerialPrint("E", F("MQTT"), F("✖ Login or password missed"));
|
||||
handleMqttStatus(true, 7);
|
||||
@@ -72,7 +72,7 @@ boolean mqttConnect() {
|
||||
}
|
||||
|
||||
if (mqtt.state() == 0) {
|
||||
SerialPrint("I", F("MQTT"), F("✔ connected"));
|
||||
SerialPrint("i", F("MQTT"), F("✔ connected"));
|
||||
handleMqttStatus(true);
|
||||
// setLedStatus(LED_OFF);
|
||||
mqttSubscribe();
|
||||
@@ -87,7 +87,7 @@ boolean mqttConnect() {
|
||||
}
|
||||
|
||||
void mqttDisconnect() {
|
||||
SerialPrint("I", F("MQTT"), F("disconnected"));
|
||||
SerialPrint("i", F("MQTT"), F("disconnected"));
|
||||
mqtt.disconnect();
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ void getMqttData() {
|
||||
}
|
||||
|
||||
void mqttSubscribe() {
|
||||
SerialPrint("I", F("MQTT"), F("subscribed"));
|
||||
SerialPrint("I", F("MQTT"), mqttRootDevice);
|
||||
SerialPrint("i", F("MQTT"), F("subscribed"));
|
||||
SerialPrint("i", F("MQTT"), mqttRootDevice);
|
||||
mqtt.subscribe(mqttPrefix.c_str());
|
||||
mqtt.subscribe((mqttRootDevice + "/+/control").c_str());
|
||||
mqtt.subscribe((mqttRootDevice + "/update").c_str());
|
||||
@@ -119,17 +119,17 @@ void mqttSubscribe() {
|
||||
|
||||
void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
String topicStr = String(topic);
|
||||
// SerialPrint("I", "=>MQTT", topicStr);
|
||||
// SerialPrint("i", "=>MQTT", topicStr);
|
||||
String payloadStr;
|
||||
payloadStr.reserve(length + 1);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
payloadStr += (char)payload[i];
|
||||
}
|
||||
|
||||
// SerialPrint("I", "=>MQTT", payloadStr);
|
||||
// SerialPrint("i", "=>MQTT", payloadStr);
|
||||
|
||||
if (payloadStr.startsWith("HELLO")) {
|
||||
SerialPrint("I", F("MQTT"), F("Full update"));
|
||||
SerialPrint("i", F("MQTT"), F("Full update"));
|
||||
publishWidgets();
|
||||
publishState();
|
||||
#ifdef GATE_MODE
|
||||
@@ -151,7 +151,7 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
//
|
||||
// loopCmdAdd(order);
|
||||
//
|
||||
// SerialPrint("I", F("=>MQTT"), "Msg from iotmanager app: " + key + " " + payloadStr);
|
||||
// SerialPrint("i", F("=>MQTT"), "Msg from iotmanager app: " + key + " " + payloadStr);
|
||||
//}
|
||||
//
|
||||
// else if (topicStr.indexOf("event") != -1) {
|
||||
@@ -161,7 +161,7 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
// if (topicStr.indexOf(chipId) == -1) {
|
||||
// String devId = selectFromMarkerToMarker(topicStr, "/", 2);
|
||||
// String key = selectFromMarkerToMarker(topicStr, "/", 3);
|
||||
// SerialPrint("I", F("=>MQTT"), "Received event from other device: '" + devId + "' " + key + " " + payloadStr);
|
||||
// SerialPrint("i", F("=>MQTT"), "Received event from other device: '" + devId + "' " + key + " " + payloadStr);
|
||||
// String event = key + " " + payloadStr + ",";
|
||||
// eventBuf += event;
|
||||
// }
|
||||
@@ -173,17 +173,17 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
// }
|
||||
// String devId = selectFromMarkerToMarker(topicStr, "/", 2);
|
||||
// String key = selectFromMarkerToMarker(topicStr, "/", 3);
|
||||
// SerialPrint("I", F("=>MQTT"), "Received direct order " + key + " " + payloadStr);
|
||||
// SerialPrint("i", F("=>MQTT"), "Received direct order " + key + " " + payloadStr);
|
||||
// String order = key + " " + payloadStr + ",";
|
||||
// loopCmdAdd(order);
|
||||
// SerialPrint("I", "Order add", order);
|
||||
// SerialPrint("i", "Order add", order);
|
||||
//}
|
||||
//
|
||||
// else if (topicStr.indexOf("info") != -1) {
|
||||
// if (topicStr.indexOf("scen") != -1) {
|
||||
// writeFile(String(DEVICE_SCENARIO_FILE), payloadStr);
|
||||
// loadScenario();
|
||||
// SerialPrint("I", F("=>MQTT"), F("Scenario received"));
|
||||
// SerialPrint("i", F("=>MQTT"), F("Scenario received"));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,15 @@ void periodicTasksInit() {
|
||||
// uptime
|
||||
jsonWriteStr_(errorsHeapJson, F("upt"), prettyMillis(millis()));
|
||||
jsonWriteStr_(errorsHeapJson, F("uptm"), prettyMillis(mqttUptime));
|
||||
// flash
|
||||
jsonWriteInt_(errorsHeapJson, F("fl"), flashWriteNumber);
|
||||
// build ver
|
||||
jsonWriteStr_(errorsHeapJson, F("bver"), String(FIRMWARE_VERSION));
|
||||
jsonWriteStr_(errorsHeapJson, F("bn"), String(FIRMWARE_NAME));
|
||||
periodicWsSend();
|
||||
},
|
||||
nullptr, true);
|
||||
SerialPrint("i", "Task", "Periodic tasks init");
|
||||
}
|
||||
|
||||
void handleError(String errorId, String errorValue) {
|
||||
@@ -43,7 +47,11 @@ void printGlobalVarSize() {
|
||||
|
||||
size_t halfBuffer = JSON_BUFFER_SIZE / 2;
|
||||
|
||||
if (settingsFlashJsonSize > halfBuffer || errorsHeapJsonSize > halfBuffer || paramsFlashJsonSize > halfBuffer || paramsHeapJsonSize > halfBuffer) {
|
||||
if (settingsFlashJsonSize > halfBuffer ||
|
||||
errorsHeapJsonSize > halfBuffer ||
|
||||
paramsFlashJsonSize > halfBuffer ||
|
||||
paramsHeapJsonSize > halfBuffer ||
|
||||
devListHeapJsonSize > halfBuffer) {
|
||||
SerialPrint(F("EE"), F("Json"), F("Insufficient buffer size!!!"));
|
||||
jsonWriteInt(errorsHeapJson, "jse1", 1);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
sendFileToWs("/items.json", num, 1024);
|
||||
sendFileToWs("/widgets.json", num, 1024);
|
||||
sendFileToWs("/config.json", num, 1024);
|
||||
sendFileToWs("/settings.json", num, 1024);
|
||||
standWebSocket.sendTXT(num, settingsFlashJson);
|
||||
}
|
||||
//**сохранение**//
|
||||
if (headerStr == "/gifnoc|") {
|
||||
@@ -77,7 +77,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
// page connection===================================================================
|
||||
//**отправка**//
|
||||
if (headerStr == "/connection|") {
|
||||
sendFileToWs("/settings.json", num, 1024);
|
||||
standWebSocket.sendTXT(num, settingsFlashJson);
|
||||
standWebSocket.sendTXT(num, ssidListHeapJson);
|
||||
standWebSocket.sendTXT(num, errorsHeapJson);
|
||||
//запуск асинхронного сканирования wifi сетей при переходе на страницу соединений
|
||||
@@ -85,11 +85,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
}
|
||||
//**сохранение**//
|
||||
if (headerStr == "/sgnittes|") {
|
||||
writeFileUint8tByFrames("settings.json", payload, length, headerLenth, 256);
|
||||
writeUint8tToString(payload, length, headerLenth, settingsFlashJson);
|
||||
writeFileUint8tByFrames("settings.json", payload, length, headerLenth, 256);
|
||||
standWebSocket.sendTXT(num, errorsHeapJson);
|
||||
addThisDeviceToList();
|
||||
// settingsFlashJson = readFile(F("settings.json"), 4096);
|
||||
}
|
||||
//**отправка**//
|
||||
if (headerStr == "/scan|") {
|
||||
@@ -99,10 +98,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
}
|
||||
//**сохранение**//
|
||||
if (headerStr == "/mqtt|") {
|
||||
sendFileToWs("/settings.json", num, 1024); //отправляем в ответ новые полученные настройки
|
||||
handleMqttStatus(false, 8); //меняем статус на неопределенный
|
||||
mqttReconnect(); //начинаем переподключение
|
||||
standWebSocket.sendTXT(num, errorsHeapJson); //отправляем что статус неопределен
|
||||
standWebSocket.sendTXT(num, settingsFlashJson); //отправляем в ответ новые полученные настройки
|
||||
handleMqttStatus(false, 8); //меняем статус на неопределенный
|
||||
mqttReconnect(); //начинаем переподключение
|
||||
standWebSocket.sendTXT(num, errorsHeapJson); //отправляем что статус неопределен
|
||||
standWebSocket.sendTXT(num, ssidListHeapJson);
|
||||
}
|
||||
// page list ==========================================================================
|
||||
|
||||
@@ -47,7 +47,7 @@ void IoTItem::regEvent(String value, String consoleInfo = "") {
|
||||
jsonWriteStr(paramsHeapJson, _id, value);
|
||||
publishStatusMqtt(_id, value);
|
||||
publishStatusWs(_id, value);
|
||||
SerialPrint("I", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'");
|
||||
SerialPrint("i", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'");
|
||||
}
|
||||
|
||||
void IoTItem::regEvent(float value, String consoleInfo = "") {
|
||||
@@ -73,13 +73,13 @@ void IoTItem::regEvent(float value, String consoleInfo = "") {
|
||||
|
||||
void IoTItem::doByInterval() {}
|
||||
|
||||
IoTValue IoTItem::execute(String command, std::vector<IoTValue> ¶m) { return {};}
|
||||
IoTValue IoTItem::execute(String command, std::vector<IoTValue>& param) { return {}; }
|
||||
|
||||
IoTItem* findIoTItem(String name) { // поиск элемента модуля в существующей конфигурации
|
||||
for (unsigned int i = 0; i < IoTItems.size(); i++) {
|
||||
if(IoTItems[i]->getID() == name) return IoTItems[i];
|
||||
if (IoTItems[i]->getID() == name) return IoTItems[i];
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ void writeFileUint8tByFrames(const String& filename, uint8_t*& big_buf, size_t l
|
||||
yield();
|
||||
}
|
||||
file.close();
|
||||
onFlashWrite();
|
||||
}
|
||||
|
||||
// void writeStrValueToJsonFile(const String& filename, String key, String value) {
|
||||
@@ -75,6 +76,7 @@ void writeFileUint8tByByte(const String& filename, uint8_t*& payload, size_t len
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
onFlashWrite();
|
||||
}
|
||||
|
||||
File seekFile(const String& filename, size_t position) {
|
||||
@@ -96,6 +98,7 @@ const String writeFile(const String& filename, const String& str) {
|
||||
file.print(str);
|
||||
file.close();
|
||||
return "sucсess";
|
||||
onFlashWrite();
|
||||
}
|
||||
|
||||
const String readFile(const String& filename, size_t max_size) {
|
||||
@@ -139,6 +142,7 @@ bool cutFile(const String& src, const String& dst) {
|
||||
srcFile.close();
|
||||
dstFile.close();
|
||||
FileFS.remove(srcPath);
|
||||
onFlashWrite();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,5 +154,11 @@ const String addFileLn(const String& filename, const String& str) {
|
||||
}
|
||||
file.println(str);
|
||||
file.close();
|
||||
onFlashWrite();
|
||||
return "sucсess";
|
||||
}
|
||||
|
||||
void onFlashWrite() {
|
||||
flashWriteNumber++;
|
||||
SerialPrint(F("->"), F("FS"), F("write data on flash"));
|
||||
}
|
||||
Reference in New Issue
Block a user