mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
Working version with NotAsinc class
This commit is contained in:
22
src/Cmd.cpp
22
src/Cmd.cpp
@@ -128,6 +128,12 @@ void buttonOut() {
|
||||
void buttonOutSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
|
||||
Serial.println("==");
|
||||
Serial.println(key);
|
||||
Serial.println(state);
|
||||
Serial.println("==");
|
||||
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
if (inv == "") {
|
||||
@@ -461,11 +467,10 @@ void addCommandLoop(const String &cmdStr) {
|
||||
|
||||
void fileExecute(const String &filename) {
|
||||
String cmdStr = readFile(filename, 2048);
|
||||
stringExecute(cmdStr);
|
||||
csvExecute(cmdStr);
|
||||
}
|
||||
|
||||
void stringExecute(String &cmdStr) {
|
||||
cmdStr.replace("x;","");
|
||||
void csvExecute(String &cmdStr) {
|
||||
cmdStr.replace(";"," ");
|
||||
cmdStr += "\r\n";
|
||||
cmdStr.replace("\r\n", "\n");
|
||||
@@ -479,6 +484,17 @@ void stringExecute(String &cmdStr) {
|
||||
}
|
||||
}
|
||||
|
||||
void spaceExecute(String &cmdStr) {
|
||||
cmdStr += "\r\n";
|
||||
cmdStr.replace("\r\n", "\n");
|
||||
cmdStr.replace("\r", "\n");
|
||||
while (cmdStr.length()) {
|
||||
String buf = selectToMarker(cmdStr, "\n");
|
||||
sCmd.readStr(buf);
|
||||
cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void loopCmd() {
|
||||
if (order_loop.length()) {
|
||||
String tmp = selectToMarker(order_loop, ","); //выделяем первую команду rel 5 1,
|
||||
|
||||
@@ -122,6 +122,7 @@ boolean connect() {
|
||||
|
||||
void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
|
||||
String topicStr = String(topic);
|
||||
|
||||
pm.info(topicStr);
|
||||
|
||||
String payloadStr;
|
||||
@@ -142,6 +143,7 @@ void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
|
||||
#endif
|
||||
|
||||
} else if (topicStr.indexOf("control")) {
|
||||
|
||||
//iotTeam/12882830-1458415/light 1
|
||||
|
||||
String key = selectFromMarkerToMarker(topicStr, "/", 3);
|
||||
|
||||
@@ -62,7 +62,7 @@ void loopScenario() {
|
||||
block = deleteBeforeDelimiter(block, "\n");
|
||||
pm.info("do: " + block);
|
||||
// выполняем все команды
|
||||
stringExecute(block);
|
||||
spaceExecute(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
src/Web.cpp
31
src/Web.cpp
@@ -29,37 +29,38 @@ void web_init() {
|
||||
server.on("/set", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
|
||||
//==============================presets===========================================================================================================
|
||||
uint8_t preset;
|
||||
if (parseRequestForPreset(request, preset)) {
|
||||
pm.info("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");
|
||||
}
|
||||
//uint8_t preset;
|
||||
//if (parseRequestForPreset(request, preset)) {
|
||||
// pm.info("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");
|
||||
//}
|
||||
|
||||
//==============================list of items====================================================================================================
|
||||
//==============================set.device.json====================================================================================================
|
||||
if (request->hasArg("addItem")) {
|
||||
String name = request->getParam("addItem")->value();
|
||||
addItem(name);
|
||||
Device_init();
|
||||
request->redirect("/?setn.device");
|
||||
request->redirect("/?set.device");
|
||||
}
|
||||
|
||||
if (request->hasArg("delAllItems")) {
|
||||
delAllItems();
|
||||
Device_init();
|
||||
request->redirect("/?setn.device");
|
||||
request->redirect("/?set.device");
|
||||
}
|
||||
|
||||
if (request->hasArg("saveItems")) {
|
||||
Device_init();
|
||||
request->redirect("/?setn.device");
|
||||
request->redirect("/?set.device");
|
||||
}
|
||||
|
||||
//==============================init====================================================================================================
|
||||
if (request->hasArg("devinit")) {
|
||||
Device_init();
|
||||
request->send(200);
|
||||
|
||||
10
src/main.cpp
10
src/main.cpp
@@ -27,6 +27,8 @@ void setup() {
|
||||
|
||||
setChipId();
|
||||
|
||||
myNotAsincActions = new NotAsinc(do_LAST);
|
||||
|
||||
pm.info("FS");
|
||||
fileSystemInit();
|
||||
|
||||
@@ -51,9 +53,7 @@ void setup() {
|
||||
pm.info("Uptime");
|
||||
uptime_init();
|
||||
|
||||
if (!TELEMETRY_UPDATE_INTERVAL) {
|
||||
pm.info("Telemetry: Disabled");
|
||||
}
|
||||
pm.info("telemetry");
|
||||
telemetry_init();
|
||||
|
||||
pm.info("Updater");
|
||||
@@ -78,8 +78,6 @@ void setup() {
|
||||
|
||||
just_load = false;
|
||||
initialized = true;
|
||||
|
||||
myNotAsincActions = new NotAsinc(5);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -97,9 +95,9 @@ void loop() {
|
||||
#endif
|
||||
timeNow->loop();
|
||||
MqttClient::loop();
|
||||
loopCmd();
|
||||
mySwitch->loop();
|
||||
loopScenario();
|
||||
loopCmd();
|
||||
loopSerial();
|
||||
|
||||
myNotAsincActions->loop();
|
||||
|
||||
Reference in New Issue
Block a user