mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
248
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "LittleFS version: 247"
|
"title": "LittleFS version: 248"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
//=================Firmeare=================
|
//=================Firmeare=================
|
||||||
#define FIRMWARE_NAME "esp8266-iotm"
|
#define FIRMWARE_NAME "esp8266-iotm"
|
||||||
#define FIRMWARE_VERSION 247
|
#define FIRMWARE_VERSION 248
|
||||||
#define FLASH_4MB true
|
#define FLASH_4MB true
|
||||||
|
|
||||||
//=================System===================
|
//=================System===================
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
//#define WEBSOCKET_ENABLED
|
//#define WEBSOCKET_ENABLED
|
||||||
//#define LAYOUT_IN_RAM
|
//#define LAYOUT_IN_RAM
|
||||||
//#define UDP_ENABLED
|
//#define UDP_ENABLED
|
||||||
//#define SSDP_EN
|
#define SSDP_EN
|
||||||
|
|
||||||
//=========Sensors enable/disable===========
|
//=========Sensors enable/disable===========
|
||||||
#define TANK_LEVEL_SAMPLES 10
|
#define TANK_LEVEL_SAMPLES 10
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
@@ -26,18 +27,19 @@ class ButtonInClass : public LineParsing {
|
|||||||
if (but[switch_number]) {
|
if (but[switch_number]) {
|
||||||
buttons[switch_number].update();
|
buttons[switch_number].update();
|
||||||
if (buttons[switch_number].fell()) {
|
if (buttons[switch_number].fell()) {
|
||||||
}
|
|
||||||
if (buttons[switch_number].rose()) {
|
|
||||||
String key = jsonReadStr(configOptionJson, "switch_num_" + String(switch_number));
|
String key = jsonReadStr(configOptionJson, "switch_num_" + String(switch_number));
|
||||||
state = !state;
|
state = !state;
|
||||||
switchChangeVirtual(key, String(state));
|
switchChangeVirtual(key, String(state));
|
||||||
}
|
}
|
||||||
|
if (buttons[switch_number].rose()) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch_number++;
|
switch_number++;
|
||||||
if (switch_number == NUM_BUTTONS) {
|
if (switch_number == NUM_BUTTONS) {
|
||||||
switch_number = 0;
|
switch_number = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchStateSetDefault() {
|
void switchStateSetDefault() {
|
||||||
if (_state != "") {
|
if (_state != "") {
|
||||||
switchChangeVirtual(_key, _state);
|
switchChangeVirtual(_key, _state);
|
||||||
@@ -47,7 +49,7 @@ class ButtonInClass : public LineParsing {
|
|||||||
void switchChangeVirtual(String key, String state) {
|
void switchChangeVirtual(String key, String state) {
|
||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
63
src/Web.cpp
63
src/Web.cpp
@@ -14,32 +14,8 @@ bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void web_init() {
|
void web_init() {
|
||||||
// dnsServer.start(53, "*", WiFi.softAPIP());
|
|
||||||
// server.addHandler(new CaptiveRequestHandler(jsonReadStr(configSetupJson, "name").c_str())).setFilter(ON_AP_FILTER);
|
|
||||||
|
|
||||||
server.on("/restart", HTTP_GET, [](AsyncWebServerRequest* request) {
|
|
||||||
if (request->hasArg("device")) {
|
|
||||||
if (request->getParam("device")->value() == "ok") {
|
|
||||||
ESP.restart();
|
|
||||||
}
|
|
||||||
request->send(200);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/set", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/set", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
//==============================presets===========================================================================================================
|
|
||||||
//uint8_t preset;
|
|
||||||
//if (parseRequestForPreset(request, preset)) {
|
|
||||||
// SerialPrint("I","Web","activate #" + String(preset, DEC));
|
|
||||||
// String configFile = DEVICE_CONFIG_FILE;
|
|
||||||
// String scenarioFile = DEVICE_SCENARIO_FILE;
|
|
||||||
// copyFile(getConfigFile(preset, CT_CONFIG), configFile);
|
|
||||||
// copyFile(getConfigFile(preset, CT_SCENARIO), scenarioFile);
|
|
||||||
// Device_init();
|
|
||||||
// loadScenario();
|
|
||||||
// request->redirect("/?set.device");
|
|
||||||
//}
|
|
||||||
|
|
||||||
//==============================set.device.json====================================================================================================
|
//==============================set.device.json====================================================================================================
|
||||||
if (request->hasArg("addItem")) {
|
if (request->hasArg("addItem")) {
|
||||||
String name = request->getParam("addItem")->value();
|
String name = request->getParam("addItem")->value();
|
||||||
@@ -84,32 +60,14 @@ void web_init() {
|
|||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//==============================udp settings=============================================
|
|
||||||
//if (request->hasArg("udponoff")) {
|
|
||||||
// bool value = request->getParam("udponoff")->value().toInt();
|
|
||||||
// jsonWriteBool(configSetupJson, "udponoff", value);
|
|
||||||
// saveConfig();
|
|
||||||
// loadScenario();
|
|
||||||
// request->send(200);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if (request->hasArg("updatelist")) {
|
|
||||||
// removeFile("/dev.csv");
|
|
||||||
// addFileLn("dev.csv", "device id;device name;ip address");
|
|
||||||
// request->redirect("/?set.udp");
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if (request->hasArg("updatepage")) {
|
|
||||||
// request->redirect("/?set.udp");
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if (request->hasArg("devname")) {
|
|
||||||
// jsonWriteStr(configSetupJson, "name", request->getParam("devname")->value());
|
|
||||||
// saveConfig();
|
|
||||||
// request->send(200);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//==============================wifi settings=============================================
|
//==============================wifi settings=============================================
|
||||||
|
if (request->hasArg("devname")) {
|
||||||
|
jsonWriteStr(configSetupJson, "name", request->getParam("devname")->value());
|
||||||
|
saveConfig();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
|
||||||
if (request->hasArg("routerssid")) {
|
if (request->hasArg("routerssid")) {
|
||||||
jsonWriteStr(configSetupJson, "routerssid", request->getParam("routerssid")->value());
|
jsonWriteStr(configSetupJson, "routerssid", request->getParam("routerssid")->value());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
@@ -169,6 +127,13 @@ void web_init() {
|
|||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request->hasArg("device")) {
|
||||||
|
if (request->getParam("device")->value() == "ok") {
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
|
||||||
//==============================mqtt settings=============================================
|
//==============================mqtt settings=============================================
|
||||||
|
|
||||||
if (request->hasArg("mqttServer")) {
|
if (request->hasArg("mqttServer")) {
|
||||||
@@ -209,7 +174,7 @@ void web_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request->hasArg("mqttcheck")) {
|
if (request->hasArg("mqttcheck")) {
|
||||||
String buf = "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + getStateStr();
|
String buf = "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + getStateStr();
|
||||||
|
|
||||||
String payload = "{}";
|
String payload = "{}";
|
||||||
jsonWriteStr(payload, "title", buf);
|
jsonWriteStr(payload, "title", buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user