mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 04:19:15 +03:00
Progress of renew of class
This commit is contained in:
@@ -1 +1 @@
|
|||||||
0;input;id;inputDigit;Ввод;Введите#цифру;order
|
0;inoutput;id;inputDigit;Ввод;Введите#цифру;order
|
||||||
@@ -1 +1 @@
|
|||||||
0;input;id;inputTime;Ввод;Введите#время;order
|
0;inoutput;id;inputTime;Ввод;Введите#время;order
|
||||||
@@ -1 +1 @@
|
|||||||
0;output-text;id;anydata;Вывод;Сигнализация;order
|
0;inoutput;id;anydata;Вывод;Сигнализация;order
|
||||||
@@ -4,4 +4,4 @@
|
|||||||
0;button-out;button-out-4;toggle;Кнопки;Прихожая;4;pin[14]
|
0;button-out;button-out-4;toggle;Кнопки;Прихожая;4;pin[14]
|
||||||
0;pwm-out;pwm-out-5;range;Кнопки;Яркость;5;pin[15]
|
0;pwm-out;pwm-out-5;range;Кнопки;Яркость;5;pin[15]
|
||||||
0;pwm-out;pwm-out-6;range;Кнопки;Яркость;6;pin[16]
|
0;pwm-out;pwm-out-6;range;Кнопки;Яркость;6;pin[16]
|
||||||
0;output-text;output-text-7;anydata;Кнопки;Статус;7
|
0;inoutput;output-text-7;anydata;Кнопки;Статус;7
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
0;dallas-temp;temp;anydataTemp;Термостат;Температура;1;pin[2];index[0];int[10]
|
0;dallas-temp;temp;anydataTemp;Термостат;Температура;1;pin[2];index[0];int[10]
|
||||||
0;logging;log;chart;Термостат;История;2;val[temp];int[60];cnt[100]
|
0;logging;log;chart;Термостат;История;2;val[temp];int[60];cnt[100]
|
||||||
0;input;inputU;inputDigit;Термостат;Верхний#порог;3
|
0;inoutput;inputU;inputDigit;Термостат;Верхний#порог;3
|
||||||
0;input;inputL;inputDigit;Термостат;Нижний#порог;4
|
0;inoutput;inputL;inputDigit;Термостат;Нижний#порог;4
|
||||||
0;button-out;button;toggle;Термостат;Нагрев;5;pin[12]
|
0;button-out;button;toggle;Термостат;Нагрев;5;pin[12]
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
|
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
|
||||||
0;logging;log;chart;Теплица;История;2;val[hum];int[60];cnt[100]
|
0;logging;log;chart;Теплица;История;2;val[hum];int[60];cnt[100]
|
||||||
0;input;inputU;inputDigit;Теплица;Верхний#порог;3
|
0;inoutput;inputU;inputDigit;Теплица;Верхний#порог;3
|
||||||
0;input;inputL;inputDigit;Теплица;Нижний#порог;4
|
0;inoutput;inputL;inputDigit;Теплица;Нижний#порог;4
|
||||||
0;button-out;button;toggle;Теплица;Полив;5;pin[12]
|
0;button-out;button;toggle;Теплица;Полив;5;pin[12]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
0;button-out;button1;toggle;Реле;Освещение;1;pin[12]
|
0;button-out;button1;toggle;Реле;Освещение;1;pin[12]
|
||||||
0;button-out;button2;toggle;Реле;Освещение;2;pin[13]
|
0;button-out;button2;toggle;Реле;Освещение;2;pin[13]
|
||||||
0;input;T1;inputTime;Реле;Введите#время#включения;3
|
0;inoutput;T1;inputTime;Реле;Введите#время#включения;3
|
||||||
0;input;T2;inputTime;Реле;Введите#время#выключения;4
|
0;inoutput;T2;inputTime;Реле;Введите#время#выключения;4
|
||||||
@@ -23,15 +23,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "Device ID: {{chipID}}"
|
"title": "ID устройства: {{chipID}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "IP address: {{ip}}"
|
"title": "IP адрес: {{ip}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "Time: {{timenow}}"
|
"title": "Время: {{timenow}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
@@ -39,15 +39,26 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "WiFi Signal: {{signal}}"
|
"title": "Версия прошивки: {{firmware_version}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "Build version: {{firmware_version}}"
|
"title": "Версия файловой системы: 267"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "LittleFS version: 267"
|
"title": "{{signal}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"title": "{{warning1}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"title": "{{warning2}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
|
|||||||
@@ -9,21 +9,9 @@ extern void loopCmdExecute();
|
|||||||
extern void addKey(String& key, String& keyNumberTable, int number);
|
extern void addKey(String& key, String& keyNumberTable, int number);
|
||||||
extern int getKeyNum(String& key, String& keyNumberTable);
|
extern int getKeyNum(String& key, String& keyNumberTable);
|
||||||
|
|
||||||
extern void pwmOut();
|
|
||||||
extern void pwmOutSet();
|
|
||||||
|
|
||||||
extern void buttonIn();
|
extern void buttonIn();
|
||||||
extern void buttonInSet();
|
extern void buttonInSet();
|
||||||
|
|
||||||
extern void input();
|
|
||||||
extern void inputDigitSet();
|
|
||||||
|
|
||||||
extern void inputTime();
|
|
||||||
extern void inputTimeSet();
|
|
||||||
|
|
||||||
extern void textOut();
|
|
||||||
extern void textOutSet();
|
|
||||||
|
|
||||||
extern void analogAdc();
|
extern void analogAdc();
|
||||||
extern void analogReading();
|
extern void analogReading();
|
||||||
|
|
||||||
@@ -56,6 +44,4 @@ extern void bmp280ReadingPress();
|
|||||||
extern void sysUptime();
|
extern void sysUptime();
|
||||||
extern void uptimeReading();
|
extern void uptimeReading();
|
||||||
|
|
||||||
extern void logging();
|
|
||||||
|
|
||||||
extern void impuls();
|
extern void impuls();
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ class Scenario {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String allBlocks = scenario;
|
String allBlocks = scenario;
|
||||||
allBlocks.replace("\r\n", "\n");
|
allBlocks.replace("\r\n", "\n");
|
||||||
allBlocks.replace("\r", "\n");
|
allBlocks.replace("\r", "\n");
|
||||||
|
|||||||
@@ -118,3 +118,7 @@ enum ConfigType_t {
|
|||||||
//15.11.2020 (SSDP OFF, UDP OFF)
|
//15.11.2020 (SSDP OFF, UDP OFF)
|
||||||
//RAM: [===== ] 46.1% (used 37780 bytes from 81920 bytes)
|
//RAM: [===== ] 46.1% (used 37780 bytes from 81920 bytes)
|
||||||
//Flash: [===== ] 54.3% (used 566656 bytes from 1044464 bytes)
|
//Flash: [===== ] 54.3% (used 566656 bytes from 1044464 bytes)
|
||||||
|
|
||||||
|
//17.11.2020 (SSDP OFF, UDP OFF)
|
||||||
|
//RAM: [===== ] 45.7% (used 37476 bytes from 81920 bytes)
|
||||||
|
//Flash: [===== ] 54.5% (used 569296 bytes from 1044464 bytes)
|
||||||
@@ -75,8 +75,11 @@ extern int impuls_EnterCounter;
|
|||||||
extern String buttonOut_KeyList;
|
extern String buttonOut_KeyList;
|
||||||
extern int buttonOut_EnterCounter;
|
extern int buttonOut_EnterCounter;
|
||||||
//=========================================
|
//=========================================
|
||||||
extern String input_KeyList;
|
extern String inOutput_KeyList;
|
||||||
extern int input_EnterCounter;
|
extern int inOutput_EnterCounter;
|
||||||
|
//=========================================
|
||||||
|
extern String pwmOut_KeyList;
|
||||||
|
extern int pwmOut_EnterCounter;
|
||||||
//=========================================
|
//=========================================
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ bool startAPMode();
|
|||||||
|
|
||||||
boolean RouterFind(String ssid);
|
boolean RouterFind(String ssid);
|
||||||
|
|
||||||
String RSSIquality();
|
uint8_t RSSIquality();
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "Class/LineParsing.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
class OutputTextClass : public LineParsing {
|
|
||||||
public:
|
|
||||||
OutputTextClass() : LineParsing(){};
|
|
||||||
|
|
||||||
void OutputModuleStateSetDefault() {
|
|
||||||
if (_state != "") {
|
|
||||||
OutputModuleChange(_key, _state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputModuleChange(String key, String state) {
|
|
||||||
state.replace("#", " ");
|
|
||||||
eventGen2(key, state);
|
|
||||||
jsonWriteStr(configLiveJson, key, state);
|
|
||||||
publishStatus(key, state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
extern OutputTextClass myOutputText;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "Class/LineParsing.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
class PwmOutClass : public LineParsing {
|
|
||||||
public:
|
|
||||||
PwmOutClass() : LineParsing(){};
|
|
||||||
|
|
||||||
void pwmModeSet() {
|
|
||||||
if (_pin != "") {
|
|
||||||
pinMode(_pin.toInt(), INPUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void pwmStateSetDefault() {
|
|
||||||
if (_state != "") {
|
|
||||||
pwmChange(_key, _pin, _state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void pwmChange(String key, String pin, String state) {
|
|
||||||
int pinInt = pin.toInt();
|
|
||||||
analogWrite(pinInt, state.toInt());
|
|
||||||
eventGen2(key, state);
|
|
||||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
|
||||||
publishStatus(key, state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern PwmOutClass myPwmOut;
|
|
||||||
@@ -22,7 +22,6 @@ class ButtonOut {
|
|||||||
boolean _inv;
|
boolean _inv;
|
||||||
String _key;
|
String _key;
|
||||||
|
|
||||||
void addNewDelOldData(const String filename, size_t maxPoints, String payload);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MyButtonOutVector* myButtonOut;
|
extern MyButtonOutVector* myButtonOut;
|
||||||
|
|||||||
27
include/items/vInOutput.h
Normal file
27
include/items/vInOutput.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class InOutput;
|
||||||
|
|
||||||
|
typedef std::vector<InOutput> MyInOutputVector;
|
||||||
|
|
||||||
|
class InOutput {
|
||||||
|
public:
|
||||||
|
|
||||||
|
InOutput(String key, String widget);
|
||||||
|
~InOutput();
|
||||||
|
|
||||||
|
void execute(String value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
String _key;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MyInOutputVector* myInOutput;
|
||||||
|
|
||||||
|
extern void inOutput();
|
||||||
|
extern void inOutputExecute();
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
class Input;
|
|
||||||
|
|
||||||
typedef std::vector<Input> MyInputVector;
|
|
||||||
|
|
||||||
class Input {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Input(String key, String widget);
|
|
||||||
~Input();
|
|
||||||
|
|
||||||
void execute(String value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
String _key;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
extern MyInputVector* myInput;
|
|
||||||
|
|
||||||
extern void input();
|
|
||||||
extern void inputExecute();
|
|
||||||
@@ -29,6 +29,7 @@ class LoggingClass {
|
|||||||
|
|
||||||
extern MyLoggingVector* myLogging;
|
extern MyLoggingVector* myLogging;
|
||||||
|
|
||||||
|
extern void logging();
|
||||||
extern void choose_log_date_and_send();
|
extern void choose_log_date_and_send();
|
||||||
extern void sendLogData(String file, String topic);
|
extern void sendLogData(String file, String topic);
|
||||||
extern void cleanLogAndData();
|
extern void cleanLogAndData();
|
||||||
|
|||||||
29
include/items/vPwmOut.h
Normal file
29
include/items/vPwmOut.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class PwmOut;
|
||||||
|
|
||||||
|
typedef std::vector<PwmOut> MyPwmOutVector;
|
||||||
|
|
||||||
|
class PwmOut {
|
||||||
|
public:
|
||||||
|
|
||||||
|
PwmOut(unsigned int pin, String key);
|
||||||
|
|
||||||
|
~PwmOut();
|
||||||
|
|
||||||
|
void execute(String state);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
unsigned int _pin;
|
||||||
|
String _key;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MyPwmOutVector* myPwmOut;
|
||||||
|
|
||||||
|
extern void pwmOut();
|
||||||
|
extern void pwmOutExecute();
|
||||||
@@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
#include "items/vSensorDallas.h"
|
#include "items/vSensorDallas.h"
|
||||||
#include "items/vButtonOut.h"
|
#include "items/vButtonOut.h"
|
||||||
|
#include "items/vPwmOut.h"
|
||||||
|
#include "items/vInOutput.h"
|
||||||
|
#include "items/vLogging.h"
|
||||||
|
|
||||||
void loopCmdAdd(const String& cmdStr) {
|
void loopCmdAdd(const String& cmdStr) {
|
||||||
orderBuf += cmdStr;
|
orderBuf += cmdStr;
|
||||||
@@ -43,11 +44,8 @@ void csvCmdExecute(String& cmdStr) {
|
|||||||
else if (order == F("button-in")) {
|
else if (order == F("button-in")) {
|
||||||
sCmd.addCommand(order.c_str(), buttonIn);
|
sCmd.addCommand(order.c_str(), buttonIn);
|
||||||
}
|
}
|
||||||
else if (order == F("input")) {
|
else if (order == F("inoutput")) {
|
||||||
sCmd.addCommand(order.c_str(), input);
|
sCmd.addCommand(order.c_str(), inOutput);
|
||||||
}
|
|
||||||
else if (order == F("output-text")) {
|
|
||||||
sCmd.addCommand(order.c_str(), textOut);
|
|
||||||
}
|
}
|
||||||
else if (order == F("analog-adc")) {
|
else if (order == F("analog-adc")) {
|
||||||
sCmd.addCommand(order.c_str(), analogAdc);
|
sCmd.addCommand(order.c_str(), analogAdc);
|
||||||
|
|||||||
@@ -46,8 +46,11 @@ int impuls_EnterCounter = -1;
|
|||||||
String buttonOut_KeyList = "";
|
String buttonOut_KeyList = "";
|
||||||
int buttonOut_EnterCounter = -1;
|
int buttonOut_EnterCounter = -1;
|
||||||
//=========================================
|
//=========================================
|
||||||
String input_KeyList = "";
|
String inOutput_KeyList = "";
|
||||||
int input_EnterCounter = -1;
|
int inOutput_EnterCounter = -1;
|
||||||
|
//=========================================
|
||||||
|
String pwmOut_KeyList = "";
|
||||||
|
int pwmOut_EnterCounter = -1;
|
||||||
//=========================================
|
//=========================================
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
|
|||||||
45
src/Init.cpp
45
src/Init.cpp
@@ -6,7 +6,8 @@
|
|||||||
#include "items/vImpulsOut.h"
|
#include "items/vImpulsOut.h"
|
||||||
#include "items/vButtonOut.h"
|
#include "items/vButtonOut.h"
|
||||||
#include "items/vSensorDallas.h"
|
#include "items/vSensorDallas.h"
|
||||||
#include "items/vInput.h"
|
#include "items/vInOutput.h"
|
||||||
|
#include "items/vPwmOut.h"
|
||||||
|
|
||||||
void loadConfig() {
|
void loadConfig() {
|
||||||
configSetupJson = readFile("config.json", 4096);
|
configSetupJson = readFile("config.json", 4096);
|
||||||
@@ -15,6 +16,9 @@ void loadConfig() {
|
|||||||
configStoreJson = readFile("store.json", 4096);
|
configStoreJson = readFile("store.json", 4096);
|
||||||
configStoreJson.replace("\r\n", "");
|
configStoreJson.replace("\r\n", "");
|
||||||
|
|
||||||
|
jsonWriteStr(configSetupJson, "warning1", "");
|
||||||
|
jsonWriteStr(configSetupJson, "warning2", "");
|
||||||
|
|
||||||
jsonWriteStr(configSetupJson, "chipID", chipId);
|
jsonWriteStr(configSetupJson, "chipID", chipId);
|
||||||
jsonWriteInt(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
jsonWriteInt(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
||||||
|
|
||||||
@@ -57,11 +61,17 @@ void Device_init() {
|
|||||||
buttonOut_KeyList = "";
|
buttonOut_KeyList = "";
|
||||||
buttonOut_EnterCounter = -1;
|
buttonOut_EnterCounter = -1;
|
||||||
//======clear input params=======
|
//======clear input params=======
|
||||||
if (myInput != nullptr) {
|
if (myInOutput != nullptr) {
|
||||||
myInput->clear();
|
myInOutput->clear();
|
||||||
}
|
}
|
||||||
input_KeyList = "";
|
inOutput_KeyList = "";
|
||||||
input_EnterCounter = -1;
|
inOutput_EnterCounter = -1;
|
||||||
|
//======clear pwm params=======
|
||||||
|
if (myPwmOut != nullptr) {
|
||||||
|
myPwmOut->clear();
|
||||||
|
}
|
||||||
|
pwmOut_KeyList = "";
|
||||||
|
pwmOut_EnterCounter = -1;
|
||||||
//===================================
|
//===================================
|
||||||
|
|
||||||
|
|
||||||
@@ -94,28 +104,3 @@ void handle_uptime() {
|
|||||||
jsonWriteStr(configSetupJson, "uptime", timeNow->getUptime());
|
jsonWriteStr(configSetupJson, "uptime", timeNow->getUptime());
|
||||||
}
|
}
|
||||||
|
|
||||||
//void handle_statistics() {
|
|
||||||
// if (isNetworkActive()) {
|
|
||||||
// String urls = "http://backup.privet.lv/visitors/?";
|
|
||||||
// //-----------------------------------------------------------------
|
|
||||||
// urls += WiFi.macAddress().c_str();
|
|
||||||
// urls += "&";
|
|
||||||
// //-----------------------------------------------------------------
|
|
||||||
//#ifdef ESP8266
|
|
||||||
// urls += "iot-manager_esp8266";
|
|
||||||
//#endif
|
|
||||||
//#ifdef ESP32
|
|
||||||
// urls += "iot-manager_esp32";
|
|
||||||
//#endif
|
|
||||||
// urls += "&";
|
|
||||||
//#ifdef ESP8266
|
|
||||||
// urls += ESP.getResetReason();
|
|
||||||
//#endif
|
|
||||||
//#ifdef ESP32
|
|
||||||
// urls += "Power on";
|
|
||||||
//#endif
|
|
||||||
// urls += "&";
|
|
||||||
// urls += String(FIRMWARE_VERSION);
|
|
||||||
// String stat = getURL(urls);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -61,7 +61,7 @@ void telegramMsgParse(String msg) {
|
|||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value");
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ void upgradeInit() {
|
|||||||
getLastVersion();
|
getLastVersion();
|
||||||
if (lastVersion > 0) {
|
if (lastVersion > 0) {
|
||||||
SerialPrint("I", "Update", "available version: " + String(lastVersion));
|
SerialPrint("I", "Update", "available version: " + String(lastVersion));
|
||||||
|
if (lastVersion > FIRMWARE_VERSION) {
|
||||||
|
jsonWriteStr(configSetupJson, "warning2", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Вышла новая версия прошивки, нажмите <b>обновить прошивку</b></p></font></div>"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -39,10 +42,12 @@ void getLastVersion() {
|
|||||||
#endif
|
#endif
|
||||||
if (tmp == "error") {
|
if (tmp == "error") {
|
||||||
lastVersion = -1;
|
lastVersion = -1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lastVersion = tmp.toInt();
|
lastVersion = tmp.toInt();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lastVersion = -2;
|
lastVersion = -2;
|
||||||
}
|
}
|
||||||
jsonWriteInt(configSetupJson, "last_version", lastVersion);
|
jsonWriteInt(configSetupJson, "last_version", lastVersion);
|
||||||
|
|||||||
@@ -111,27 +111,27 @@ boolean isNetworkActive() {
|
|||||||
return WiFi.status() == WL_CONNECTED;
|
return WiFi.status() == WL_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
String RSSIquality() {
|
uint8_t RSSIquality() {
|
||||||
String res = "not connected";
|
uint8_t res = 0;
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
int rssi = WiFi.RSSI();
|
int rssi = WiFi.RSSI();
|
||||||
if (rssi >= -50) {
|
if (rssi >= -50) {
|
||||||
res = "Excellent";
|
res = 6; //"Excellent";
|
||||||
}
|
}
|
||||||
else if (rssi < -50 && rssi >= -60) {
|
else if (rssi < -50 && rssi >= -60) {
|
||||||
res = "Very good";
|
res = 5; //"Very good";
|
||||||
}
|
}
|
||||||
else if (rssi < -60 && rssi >= -70) {
|
else if (rssi < -60 && rssi >= -70) {
|
||||||
res = "Good";
|
res = 4; //"Good";
|
||||||
}
|
}
|
||||||
else if (rssi < -70 && rssi >= -80) {
|
else if (rssi < -70 && rssi >= -80) {
|
||||||
res = "Low";
|
res = 3; //"Low";
|
||||||
}
|
}
|
||||||
else if (rssi < -80 && rssi > -100) {
|
else if (rssi < -80 && rssi > -100) {
|
||||||
res = "Very low";
|
res = 2; //"Very low";
|
||||||
}
|
}
|
||||||
else if (rssi <= -100) {
|
else if (rssi <= -100) {
|
||||||
res = "No signal";
|
res = 1; //"No signal";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ void web_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request->hasArg("delChoosingItems")) {
|
if (request->hasArg("delChoosingItems")) {
|
||||||
|
jsonWriteStr(configSetupJson, "warning1", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||||
myNotAsyncActions->make(do_delChoosingItems);
|
myNotAsyncActions->make(do_delChoosingItems);
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
@@ -37,6 +38,7 @@ void web_init() {
|
|||||||
if (request->hasArg("delAllItems")) {
|
if (request->hasArg("delAllItems")) {
|
||||||
delAllItems();
|
delAllItems();
|
||||||
cleanLogAndData();
|
cleanLogAndData();
|
||||||
|
jsonWriteStr(configSetupJson, "warning1", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||||
request->redirect("/?set.device");
|
request->redirect("/?set.device");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#include "BufferExecute.h"
|
|
||||||
#include "items/OutputTextClass.h"
|
|
||||||
//===============================================Модуль вывода текста============================================
|
|
||||||
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
|
||||||
//===============================================================================================================
|
|
||||||
OutputTextClass myOutputText;
|
|
||||||
void textOut() {
|
|
||||||
myOutputText.update();
|
|
||||||
String key = myOutputText.gkey();
|
|
||||||
sCmd.addCommand(key.c_str(), textOutSet);
|
|
||||||
myOutputText.OutputModuleStateSetDefault();
|
|
||||||
myOutputText.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void textOutSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
myOutputText.OutputModuleChange(key, state);
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#include "BufferExecute.h"
|
|
||||||
#include "items/PwmOutClass.h"
|
|
||||||
//==========================================Модуль управления ШИМ===================================================
|
|
||||||
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
|
||||||
//==================================================================================================================
|
|
||||||
PwmOutClass myPwmOut;
|
|
||||||
void pwmOut() {
|
|
||||||
myPwmOut.update();
|
|
||||||
String key = myPwmOut.gkey();
|
|
||||||
String pin = myPwmOut.gpin();
|
|
||||||
String inv = myPwmOut.ginv();
|
|
||||||
sCmd.addCommand(key.c_str(), pwmOutSet);
|
|
||||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
|
||||||
myPwmOut.pwmModeSet();
|
|
||||||
myPwmOut.pwmStateSetDefault();
|
|
||||||
myPwmOut.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void pwmOutSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
|
||||||
myPwmOut.pwmChange(key, pin, state);
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "items/vButtonOut.h"
|
#include "items/vButtonOut.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
//this class save date to flash
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
//this class save data to flash
|
||||||
ButtonOut::ButtonOut(unsigned int pin, boolean inv, String key) {
|
ButtonOut::ButtonOut(unsigned int pin, boolean inv, String key) {
|
||||||
_pin = pin;
|
_pin = pin;
|
||||||
_inv = inv;
|
_inv = inv;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "items/vInput.h"
|
#include "items/vInOutput.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
//this class save date to flash
|
//this class save date to flash
|
||||||
Input::Input(String key, String widget) {
|
InOutput::InOutput(String key, String widget) {
|
||||||
_key = key;
|
_key = key;
|
||||||
String value = jsonReadStr(configStoreJson, key);
|
String value = jsonReadStr(configStoreJson, key);
|
||||||
|
|
||||||
@@ -21,43 +21,43 @@ Input::Input(String key, String widget) {
|
|||||||
|
|
||||||
this->execute(value);
|
this->execute(value);
|
||||||
}
|
}
|
||||||
Input::~Input() {}
|
InOutput::~InOutput() {}
|
||||||
|
|
||||||
void Input::execute(String value) {
|
void InOutput::execute(String value) {
|
||||||
eventGen2(_key, value);
|
eventGen2(_key, value);
|
||||||
jsonWriteStr(configStoreJson, _key, value);
|
jsonWriteStr(configStoreJson, _key, value);
|
||||||
saveStore();
|
saveStore();
|
||||||
publishStatus(_key, value);
|
publishStatus(_key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyInputVector* myInput = nullptr;
|
MyInOutputVector* myInOutput = nullptr;
|
||||||
|
|
||||||
void input() {
|
void inOutput() {
|
||||||
myLineParsing.update();
|
myLineParsing.update();
|
||||||
String widget = myLineParsing.gfile();
|
String widget = myLineParsing.gfile();
|
||||||
String key = myLineParsing.gkey();
|
String key = myLineParsing.gkey();
|
||||||
myLineParsing.clear();
|
myLineParsing.clear();
|
||||||
|
|
||||||
input_EnterCounter++;
|
inOutput_EnterCounter++;
|
||||||
addKey(key, input_KeyList, input_EnterCounter);
|
addKey(key, inOutput_KeyList, inOutput_EnterCounter);
|
||||||
|
|
||||||
static bool firstTime = true;
|
static bool firstTime = true;
|
||||||
if (firstTime) myInput = new MyInputVector();
|
if (firstTime) myInOutput = new MyInOutputVector();
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
myInput->push_back(Input(key, widget));
|
myInOutput->push_back(InOutput(key, widget));
|
||||||
|
|
||||||
sCmd.addCommand(key.c_str(), inputExecute);
|
sCmd.addCommand(key.c_str(), inOutputExecute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputExecute() {
|
void inOutputExecute() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String value = sCmd.next();
|
String value = sCmd.next();
|
||||||
|
|
||||||
int number = getKeyNum(key, input_KeyList);
|
int number = getKeyNum(key, inOutput_KeyList);
|
||||||
|
|
||||||
if (myInput != nullptr) {
|
if (myInOutput != nullptr) {
|
||||||
if (number != -1) {
|
if (number != -1) {
|
||||||
myInput->at(number).execute(value);
|
myInOutput->at(number).execute(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
55
src/items/vPwmOut.cpp
Normal file
55
src/items/vPwmOut.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include "items/vPwmOut.h"
|
||||||
|
#include "Class/LineParsing.h"
|
||||||
|
#include "Global.h"
|
||||||
|
#include "BufferExecute.h"
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
//this class save data to flash
|
||||||
|
PwmOut::PwmOut(unsigned int pin, String key) {
|
||||||
|
_pin = pin;
|
||||||
|
_key = key;
|
||||||
|
pinMode(_pin, OUTPUT);
|
||||||
|
int state = jsonReadInt(configStoreJson, key);
|
||||||
|
this->execute(String(state));
|
||||||
|
}
|
||||||
|
PwmOut::~PwmOut() {}
|
||||||
|
|
||||||
|
void PwmOut::execute(String state) {
|
||||||
|
analogWrite(_pin, state.toInt());
|
||||||
|
eventGen2(_key, state);
|
||||||
|
jsonWriteInt(configStoreJson, _key, state.toInt());
|
||||||
|
saveStore();
|
||||||
|
publishStatus(_key, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
MyPwmOutVector* myPwmOut = nullptr;
|
||||||
|
|
||||||
|
void pwmOut() {
|
||||||
|
myLineParsing.update();
|
||||||
|
String key = myLineParsing.gkey();
|
||||||
|
String pin = myLineParsing.gpin();
|
||||||
|
myLineParsing.clear();
|
||||||
|
|
||||||
|
pwmOut_EnterCounter++;
|
||||||
|
addKey(key, pwmOut_KeyList, pwmOut_EnterCounter);
|
||||||
|
|
||||||
|
static bool firstTime = true;
|
||||||
|
if (firstTime) myPwmOut = new MyPwmOutVector();
|
||||||
|
firstTime = false;
|
||||||
|
myPwmOut->push_back(PwmOut(pin.toInt(), key));
|
||||||
|
|
||||||
|
sCmd.addCommand(key.c_str(), pwmOutExecute);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pwmOutExecute() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
|
||||||
|
int number = getKeyNum(key, pwmOut_KeyList);
|
||||||
|
|
||||||
|
if (myPwmOut != nullptr) {
|
||||||
|
if (number != -1) {
|
||||||
|
myPwmOut->at(number).execute(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/main.cpp
60
src/main.cpp
@@ -32,7 +32,7 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("--------------started----------------");
|
Serial.println(F("--------------started----------------"));
|
||||||
|
|
||||||
setChipId();
|
setChipId();
|
||||||
|
|
||||||
@@ -40,57 +40,57 @@ void setup() {
|
|||||||
myScenario = new Scenario();
|
myScenario = new Scenario();
|
||||||
|
|
||||||
fileSystemInit();
|
fileSystemInit();
|
||||||
SerialPrint("I", "FS", "FS Init");
|
SerialPrint("I", F("FS"), F("FS Init"));
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
SerialPrint("I", "Conf", "Config Init");
|
SerialPrint("I", F("Conf"), F("Config Init"));
|
||||||
|
|
||||||
clock_init();
|
clock_init();
|
||||||
SerialPrint("I", "Time", "Clock Init");
|
SerialPrint("I", F("Time"), F("Clock Init"));
|
||||||
|
|
||||||
handle_time_init();
|
handle_time_init();
|
||||||
SerialPrint("I", "Time", "Handle time init(");
|
SerialPrint("I", F("Time"), F("Handle time init"));
|
||||||
|
|
||||||
sensorsInit();
|
sensorsInit();
|
||||||
SerialPrint("I", "Sensors", "Sensors Init");
|
SerialPrint("I", F("Sensors"), F("Sensors Init"));
|
||||||
|
|
||||||
itemsListInit();
|
itemsListInit();
|
||||||
SerialPrint("I", "Items", "Items Init");
|
SerialPrint("I", F("Items"), F("Items Init"));
|
||||||
|
|
||||||
all_init();
|
all_init();
|
||||||
SerialPrint("I", "Init", "Init Init");
|
SerialPrint("I", F("Init"), F("Init Init"));
|
||||||
|
|
||||||
routerConnect();
|
routerConnect();
|
||||||
SerialPrint("I", "WIFI", "Network Init");
|
SerialPrint("I", F("WIFI"), F("Network Init"));
|
||||||
|
|
||||||
telegramInit();
|
telegramInit();
|
||||||
SerialPrint("I", "Telegram", "Telegram Init");
|
SerialPrint("I", F("Telegram"), F("Telegram Init"));
|
||||||
|
|
||||||
uptime_init();
|
uptime_init();
|
||||||
SerialPrint("I", "Uptime", "Uptime Init");
|
SerialPrint("I", F("Uptime"), F("Uptime Init"));
|
||||||
|
|
||||||
upgradeInit();
|
upgradeInit();
|
||||||
SerialPrint("I", "Update", "Updater Init");
|
SerialPrint("I", F("Update"), F("Updater Init"));
|
||||||
|
|
||||||
HttpServer::init();
|
HttpServer::init();
|
||||||
SerialPrint("I", "HTTP", "HttpServer Init");
|
SerialPrint("I", F("HTTP"), F("HttpServer Init"));
|
||||||
|
|
||||||
web_init();
|
web_init();
|
||||||
SerialPrint("I", "Web", "WebAdmin Init");
|
SerialPrint("I", F("Web"), F("WebAdmin Init"));
|
||||||
|
|
||||||
initSt();
|
initSt();
|
||||||
SerialPrint("I", "Stat", "Stat Init");
|
SerialPrint("I", F("Stat"), F("Stat Init"));
|
||||||
|
|
||||||
#ifdef UDP_ENABLED
|
#ifdef UDP_ENABLED
|
||||||
SerialPrint("I", "UDP", "Udp Init");
|
SerialPrint("I", F("UDP"), "Udp Init");
|
||||||
asyncUdpInit();
|
asyncUdpInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SerialPrint("I", "Bus", "Bus Init");
|
SerialPrint("I", F("Bus"), F("Bus Init"));
|
||||||
busInit();
|
busInit();
|
||||||
|
|
||||||
#ifdef SSDP_ENABLED
|
#ifdef SSDP_ENABLED
|
||||||
SerialPrint("I", "SSDP", "Ssdp Init");
|
SerialPrint("I", F("SSDP"), F("Ssdp Init"));
|
||||||
SsdpInit();
|
SsdpInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -99,7 +99,29 @@ void setup() {
|
|||||||
ts.add(
|
ts.add(
|
||||||
TEST, 1000 * 60, [&](void*) {
|
TEST, 1000 * 60, [&](void*) {
|
||||||
SerialPrint("I", "System", printMemoryStatus());
|
SerialPrint("I", "System", printMemoryStatus());
|
||||||
jsonWriteStr(configSetupJson, "signal", RSSIquality());
|
switch (RSSIquality()) {
|
||||||
|
case 0:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>не подключено к роутеру</font>"));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>нет сигнала</font>"));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>очень низкий</font>"));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='orange'>низкий</font>"));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>хороший</font>"));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>очень хороший</font>"));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>отличный</font>"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user