mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
@@ -129,11 +129,12 @@ void restartEsp() {
|
||||
// return path;
|
||||
// }
|
||||
|
||||
// https://t.me/IoTmanager/128814/164752 - убрал ограничение
|
||||
void putUserDataToRam() {
|
||||
update.configJson = readFile("config.json", 4096);
|
||||
update.settingsFlashJson = readFile("settings.json", 4096);
|
||||
update.layoutJson = readFile("layout.json", 4096);
|
||||
update.scenarioTxt = readFile("scenario.txt", 4096);
|
||||
update.configJson = readFile("config.json", 4096 * 4);
|
||||
update.settingsFlashJson = readFile("settings.json", 4096 * 4);
|
||||
update.layoutJson = readFile("layout.json", 4096 * 4);
|
||||
update.scenarioTxt = readFile("scenario.txt", 4096 * 4);
|
||||
// update.chartsData = createDataBaseSting();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
void* getAPI_Cron(String subtype, String params);
|
||||
void* getAPI_Loging(String subtype, String params);
|
||||
void* getAPI_LogingDaily(String subtype, String params);
|
||||
void* getAPI_owmWeather(String subtype, String params);
|
||||
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);
|
||||
@@ -43,9 +43,9 @@ void* tmpAPI;
|
||||
if ((tmpAPI = getAPI_Cron(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_owmWeather(subtype, params)) != nullptr) return tmpAPI;
|
||||
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;
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
|
||||
#define DEBUG_SERIAL_ENABLE
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
#include "ESPNexUpload.h"
|
||||
bool updated = false;
|
||||
// const char *host = "live-control.com";
|
||||
// const char *url = "/iotm/Live-Control.tft";
|
||||
extern IoTGpio IoTgpio;
|
||||
|
||||
class NextionUpload : public IoTItem
|
||||
{
|
||||
private:
|
||||
String _url;
|
||||
String _host;
|
||||
int _NEXT_RX;
|
||||
int _NEXT_TX;
|
||||
|
||||
public:
|
||||
NextionUpload(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
_url = jsonReadStr(parameters, "url");
|
||||
_host = jsonReadStr(parameters, "host");
|
||||
|
||||
_NEXT_RX = jsonReadInt(parameters, "NEXT_RX");
|
||||
_NEXT_TX = jsonReadInt(parameters, "NEXT_TX");
|
||||
#define NEXT_RX _NEXT_RX // Nextion RX pin | Default 16
|
||||
#define NEXT_TX _NEXT_TX // Nextion TX pin | Default 17
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
|
||||
if (command == "Update")
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "Update .... ");
|
||||
|
||||
if (!updated)
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "connecting to " + (String)_host);
|
||||
HTTPClient http;
|
||||
|
||||
#if defined ESP8266
|
||||
if (!http.begin(_host, 80, _url))
|
||||
{
|
||||
// Serial.println("connection failed");
|
||||
SerialPrint("I", F("NextionUpdate"), "connection failed ");
|
||||
}
|
||||
#elif defined ESP32
|
||||
if (!http.begin(String("http://") + _host + _url))
|
||||
{
|
||||
// Serial.println("connection failed");
|
||||
SerialPrint("I", F("NextionUpdate"), "connection failed ");
|
||||
}
|
||||
#endif
|
||||
|
||||
SerialPrint("I", F("NextionUpdate"), "Requesting file: " + (String)_url);
|
||||
int code = http.GET();
|
||||
int contentLength = http.getSize();
|
||||
|
||||
// Update the nextion display
|
||||
if (code == 200)
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "File received. Update Nextion... ");
|
||||
bool result;
|
||||
ESPNexUpload nextion(115200);
|
||||
nextion.setUpdateProgressCallback([]()
|
||||
{ SerialPrint("I", F("NextionUpdate"), "... "); });
|
||||
|
||||
result = nextion.prepareUpload(contentLength);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "Error: " + (String)nextion.statusMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "Start upload. File size is: " + (String)contentLength);
|
||||
result = nextion.upload(*http.getStreamPtr());
|
||||
|
||||
if (result)
|
||||
{
|
||||
updated = true;
|
||||
SerialPrint("I", F("NextionUpdate"), "Succesfully updated Nextion! ");
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "Error updating Nextion: " + (String)nextion.statusMessage);
|
||||
}
|
||||
|
||||
nextion.end();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialPrint("I", F("NextionUpdate"), "HTTP error: " + (String)http.errorToString(code).c_str());
|
||||
}
|
||||
|
||||
http.end();
|
||||
SerialPrint("I", F("NextionUpdate"), "Closing connection ");
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
~NextionUpload(){};
|
||||
};
|
||||
|
||||
void *getAPI_NextionUpload(String subtype, String param)
|
||||
{
|
||||
if (subtype == F("NextionUpload"))
|
||||
{
|
||||
return new NextionUpload(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"menuSection": "screens",
|
||||
"configItem": [
|
||||
{
|
||||
"global": 0,
|
||||
"name": "Nextion Uploud",
|
||||
"type": "Reading",
|
||||
"subtype": "NextionUpload",
|
||||
"id": "Nextion",
|
||||
"widget": "",
|
||||
"page": "",
|
||||
"descr": "",
|
||||
"host": "192.168.1.10",
|
||||
"url": "castom_nextion.tif",
|
||||
"NEXT_TX": 16,
|
||||
"NEXT_RX": 17
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "AVAKS",
|
||||
"authorContact": "https://t.me/@avaks_dev",
|
||||
"authorGit": "https://github.com/avaksru",
|
||||
"specialThanks": "",
|
||||
"moduleName": "NextionUpload",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
"esp8266_4mb": 15
|
||||
},
|
||||
"title": "Nextion Upload",
|
||||
"moduleDesc": "загрузка прошивки в дисплей Nextion. Команда для запуска обновления дисплея: Nextion.Update(); ",
|
||||
"propInfo": {
|
||||
"host": "Сервер обновления",
|
||||
"url": "файл прошивки"
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp32_4mb3f": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp32cam_4mb": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp8266_1mb": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp8266_1mb_ota": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp8285_1mb": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
],
|
||||
"esp8285_1mb_ota": [
|
||||
"https://github.com/avaksru/ESPNexUpload.git"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -59,35 +59,15 @@
|
||||
},
|
||||
"defActive": true,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp32_4mb3f": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp32cam_4mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8266_1mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8266_1mb_ota": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8285_1mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8285_1mb_ota": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8266_2mb": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
],
|
||||
"esp8266_2mb_ota": [
|
||||
"https://github.com/tremaru/iarduino_RTC"
|
||||
]
|
||||
"esp32_4mb": [],
|
||||
"esp32_4mb3f": [],
|
||||
"esp32cam_4mb": [],
|
||||
"esp8266_4mb": [],
|
||||
"esp8266_1mb": [],
|
||||
"esp8266_1mb_ota": [],
|
||||
"esp8285_1mb": [],
|
||||
"esp8285_1mb_ota": [],
|
||||
"esp8266_2mb": [],
|
||||
"esp8266_2mb_ota": []
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
// дочь - родитель
|
||||
class VariableColor : public IoTItem
|
||||
{
|
||||
private:
|
||||
public:
|
||||
VariableColor(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
}
|
||||
|
||||
void doByInterval()
|
||||
{
|
||||
}
|
||||
|
||||
// событие когда пользователь подключается приложением или веб интерфейсом к усройству
|
||||
void onMqttWsAppConnectEvent()
|
||||
{
|
||||
SerialPrint("i", "Connecting", "Dashbord open ");
|
||||
regEvent(value.valS, "VariableColor", false, true);
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
if (command == "widget" && param.size() == 2)
|
||||
{
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, param[0].valS, param[1].valS);
|
||||
sendSubWidgetsValues(_id, json);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
void *getAPI_VariableColor(String subtype, String param)
|
||||
{
|
||||
if (subtype == F("VariableColor"))
|
||||
{
|
||||
return new VariableColor(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"menuSection": "virtual_elments",
|
||||
"configItem": [
|
||||
{
|
||||
"global": 0,
|
||||
"name": "Цветной текст",
|
||||
"type": "Reading",
|
||||
"subtype": "VariableColor",
|
||||
"id": "color",
|
||||
"needSave": 0,
|
||||
"widget": "anydataDef",
|
||||
"page": "Вывод",
|
||||
"descr": "Цветной текст",
|
||||
"val": "...",
|
||||
"round": 0
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "AVAKS",
|
||||
"authorContact": "https://t.me/@avaks_dev",
|
||||
"authorGit": "https://github.com/avaksru",
|
||||
"specialThanks": "",
|
||||
"moduleName": "VariableColor",
|
||||
"moduleVersion": "1",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
"esp8266_4mb": 15
|
||||
},
|
||||
"title": "Цветной текст",
|
||||
"moduleDesc": "Текст с возможностью динамического изменения цвета",
|
||||
"propInfo": {
|
||||
"val": "Значение при старте"
|
||||
}
|
||||
},
|
||||
"defActive": true,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [],
|
||||
"esp32_4mb3f": [],
|
||||
"esp32cam_4mb": [],
|
||||
"esp32_16mb": [],
|
||||
"esp32s2_4mb": [],
|
||||
"esp32s3_16mb": [],
|
||||
"esp32c3m_4mb": [],
|
||||
"esp8266_4mb": [],
|
||||
"esp8266_16mb": [],
|
||||
"esp8266_1mb": [],
|
||||
"esp8266_1mb_ota": [],
|
||||
"esp8285_1mb": [],
|
||||
"esp8285_1mb_ota": [],
|
||||
"esp8266_2mb": [],
|
||||
"esp8266_2mb_ota": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user