Merge branch 'ver4dev' of https://github.com/Mit4el/IoTManager into ver4dev

This commit is contained in:
Mit4el
2023-06-19 22:57:53 +03:00
23 changed files with 788 additions and 159 deletions

View File

@@ -1,9 +1,5 @@
#include "DeviceList.h"
// данная функция не записывает поле status из этого следует что поле равно false и поэтому весь список устройств отдаваемый мк
// уходит со статусом для всех устройств - offline
// приложение svelte хранит свой список и в нем поддерживает корректные статусы, а при получении этого списка
// лишь изменяет в своем те элементы массива которые добавились новые, не трогая остальные
const String getThisDevice() {
String thisDevice = "{}";
// jsonWriteStr_(thisDevice, F("devicelist_"), ""); // метка для парсинга - она не нужна теперь
@@ -11,6 +7,10 @@ const String getThisDevice() {
jsonWriteStr_(thisDevice, F("ip"), jsonReadStr(settingsFlashJson, F("ip")));
jsonWriteStr_(thisDevice, F("id"), jsonReadStr(settingsFlashJson, F("id")));
jsonWriteStr_(thisDevice, F("name"), jsonReadStr(settingsFlashJson, F("name")));
// приложение svelte хранит свой список и в нем поддерживает корректные статусы, а при получении этого списка
// лишь изменяет в своем те элементы массива которые добавились новые, не трогая остальные
jsonWriteBool_(thisDevice, F("status"), false);
jsonWriteInt_(thisDevice, F("fv"), FIRMWARE_VERSION);
thisDevice = "[" + thisDevice + "]";
return thisDevice;
}

View File

@@ -99,7 +99,7 @@ void setup() {
Serial.println(F("--------------started----------------"));
// создание экземпляров классов
// myNotAsyncActions = new NotAsync(do_LAST);
// myNotAsyncActions = new NotAsync(do_LAST);
// инициализация файловой системы
fileSystemInit();
@@ -107,6 +107,9 @@ void setup() {
Serial.println("FIRMWARE NAME " + String(FIRMWARE_NAME));
Serial.println("FIRMWARE VERSION " + String(FIRMWARE_VERSION));
Serial.println("WEB VERSION " + getWebVersion());
const String buildTime = String(BUILD_DAY) + "/" + String(BUILD_MONTH) + "/" + String(BUILD_YEAR) + " " + String(BUILD_HOUR) + ":" + String(BUILD_MIN) + ":" + String(BUILD_SEC);
Serial.println("BUILD TIME " + buildTime);
jsonWriteStr_(errorsHeapJson, F("bt"), buildTime);
Serial.println(F("------------------------"));
// получение chip id

View File

@@ -48,17 +48,19 @@ bool upgradeFS() {
#endif
#ifdef ESP32
httpUpdate.rebootOnUpdate(false);
//обновляем little fs с помощью метода обновления spiffs
// обновляем little fs с помощью метода обновления spiffs
HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, getBinPath("littlefs.bin"));
#endif
//если FS обновилась успешно
// если FS обновилась успешно
if (retFS == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
handleUpdateStatus(true, UPDATE_FS_COMPLETED);
ret = true;
} else {
handleUpdateStatus(true, UPDATE_FS_FAILED);
}
handleUpdateStatus(true, UPDATE_FS_FAILED);
return ret;
}
@@ -72,7 +74,7 @@ bool upgradeBuild() {
handleUpdateStatus(true, PATH_ERROR);
return ret;
}
#if defined (esp8266_4mb) || defined (esp8266_1mb) || defined (esp8266_1mb_ota) || defined (esp8266_2mb) || defined (esp8266_2mb_ota)
#if defined(esp8266_4mb) || defined(esp8266_1mb) || defined(esp8266_1mb_ota) || defined(esp8266_2mb) || defined(esp8266_2mb_ota)
ESPhttpUpdate.rebootOnUpdate(false);
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, getBinPath("firmware.bin"));
#endif
@@ -81,13 +83,14 @@ bool upgradeBuild() {
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, getBinPath("firmware.bin"));
#endif
//если BUILD обновился успешно
// если BUILD обновился успешно
if (retBuild == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
handleUpdateStatus(true, UPDATE_BUILD_COMPLETED);
ret = true;
} else {
handleUpdateStatus(true, UPDATE_BUILD_FAILED);
}
handleUpdateStatus(true, UPDATE_BUILD_FAILED);
return ret;
}
@@ -132,5 +135,5 @@ void saveUserDataToFlash() {
void handleUpdateStatus(bool send, int state) {
jsonWriteInt_(errorsHeapJson, F("upd"), state);
if (!send) sendStringToWs("errors", errorsHeapJson, -1);
if (send) sendStringToWs("errors", errorsHeapJson, -1);
}

View File

@@ -163,9 +163,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
// Страница веб интерфейса list
//----------------------------------------------------------------------//
// отвечаем данными на запрос страницы
// отвечаем данными на запрос страницы list
if (headerStr == "/list|") {
sendStringToWs("settin", settingsFlashJson, num);
// отправим список устройств в зависимости от того что выбрал user
// sendDeviceList(num);
}
// отвечаем на запрос списка устройств (это отдельный запрос который делает приложение при подключении)
if (headerStr == "/devlist|") {
// отправим список устройств в зависимости от того что выбрал user
sendDeviceList(num);
}

View File

@@ -7,6 +7,7 @@ void* getAPI_Timer(String subtype, String params);
void* getAPI_Variable(String subtype, String params);
void* getAPI_VariableColor(String subtype, String params);
void* getAPI_VButton(String subtype, String params);
void* getAPI_A02Distance(String subtype, String params);
void* getAPI_Acs712(String subtype, String params);
void* getAPI_AhtXX(String subtype, String params);
void* getAPI_AnalogAdc(String subtype, String params);
@@ -14,10 +15,13 @@ void* getAPI_Bme280(String subtype, String params);
void* getAPI_Bmp280(String subtype, String params);
void* getAPI_Dht1122(String subtype, String params);
void* getAPI_Ds18b20(String subtype, String params);
void* getAPI_Ds2423(String subtype, String params);
void* getAPI_Impulse(String subtype, String params);
void* getAPI_Ntc(String subtype, String params);
void* getAPI_Pzem004(String subtype, String params);
void* getAPI_RTC(String subtype, String params);
void* getAPI_S8(String subtype, String params);
void* getAPI_Scd40(String subtype, String params);
void* getAPI_Sht20(String subtype, String params);
void* getAPI_Sht30(String subtype, String params);
void* getAPI_Sonar(String subtype, String params);
@@ -31,7 +35,7 @@ void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params);
void* getAPI_Multitouch(String subtype, String params);
void* getAPI_Pcf8574(String subtype, String params);
void* getAPI_Pwm32(String subtype, String params);
void* getAPI_Pwm8266(String subtype, String params);
void* getAPI_TelegramLT(String subtype, String params);
void* getAPI_Lcd2004(String subtype, String params);
@@ -44,6 +48,7 @@ if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_VariableColor(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_A02Distance(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;
@@ -51,10 +56,13 @@ if ((tmpAPI = getAPI_Bme280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ds2423(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Impulse(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ntc(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_RTC(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_S8(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Scd40(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI;
@@ -68,7 +76,7 @@ if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Multitouch(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pwm32(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
return nullptr;

View File

@@ -28,7 +28,7 @@
"esp8266_4mb": 15
},
"title": "Будильник типа Cron",
"moduleDesc": "Планировщик времени для периодического выполнения заданий в определённое время. Генерирует событие в указанное время по формату Cron https://ru.wikipedia.org/wiki/Cron ",
"moduleDesc": "Планировщик времени для периодического выполнения заданий в определённое время. Генерирует событие в указанное время по формату Cron https://ru.wikipedia.org/wiki/Cron . Но в данной реализации есть возможность задавать секундный интервал, поэтому слева необходимо добавить еще один разряд значений секунд - подробнее в базовой библиотеке https://github.com/staticlibs/ccronexpr",
"propInfo": {
"formatNextAlarm": "Формат представления даты и времени срабатывания следующего уведомления. http://cppstudio.com/post/621/",
"needSave": "Требуется сохранять(1) или нет(0) состояние в энерго независимую память."