diff --git a/include/Global.h b/include/Global.h index ea549411..38bc36c4 100644 --- a/include/Global.h +++ b/include/Global.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #ifdef ESP32 @@ -60,7 +59,7 @@ extern IoTGpio IoTgpio; extern TickerScheduler ts; extern WiFiClient espClient; extern PubSubClient mqtt; -extern StringCommand sCmd; + #ifdef ASYNC_WEB_SERVER extern AsyncWebServer server; #endif diff --git a/lib/ESP8266-StringCommand/StringCommand.cpp b/lib/ESP8266-StringCommand/StringCommand.cpp deleted file mode 100644 index 3d53dcd7..00000000 --- a/lib/ESP8266-StringCommand/StringCommand.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/** - * SerialCommand - A Wiring/Arduino library to tokenize and parse commands - * received over a serial port. - * - * Copyright (C) 2012 Stefan Rado - * Copyright (C) 2011 Steven Cogswell - * http://husks.wordpress.com - * - * Version 20120522 - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library. If not, see . - */ -#include "StringCommand.h" - -/** - * Constructor makes sure some things are set. - */ -StringCommand::StringCommand() - : commandList(NULL), - commandCount(0), - defaultHandler(NULL), - term('\n'), // default terminator for commands, newline character - last(NULL), - main(NULL) -{ - strcpy(delim, " "); // strtok_r needs a null-terminated string - clearBuffer(); -} - -/** - * Adds a "command" and a handler function to the list of available commands. - * This is used for matching a found token in the buffer, and gives the pointer - * to the handler function to deal with it. - */ -void StringCommand::addCommand(const char *command, void (*function)()) { - #ifdef SERIALCOMMAND_DEBUG - Serial.print("Adding command ("); - Serial.print(commandCount); - Serial.print("): "); - Serial.println(command); - #endif - - commandList = (StringCommandCallback *) realloc(commandList, (commandCount + 1) * sizeof(StringCommandCallback)); - strncpy(commandList[commandCount].command, command, SERIALCOMMAND_MAXCOMMANDLENGTH); - commandList[commandCount].function = function; - commandCount++; -} - -/** - * This sets up a handler to be called in the event that the receveived command string - * isn't in the list of commands. - */ -void StringCommand::setDefaultHandler(void (*function)(const char *)) { - defaultHandler = function; -} - - -/** - * This checks the Serial stream for characters, and assembles them into a buffer. - * When the terminator character (default '\n') is seen, it starts parsing the - * buffer for a prefix command, and calls handlers setup by addCommand() member - */ -void StringCommand::readStr(String sBuffer ) { - sBuffer.toCharArray(buffer, SERIALCOMMAND_BUFFER); - #ifdef SERIALCOMMAND_DEBUG - Serial.print("Received: "); - Serial.println(buffer); - #endif - - char *command = strtok_r(buffer, delim, &last); // Search for command at start of buffer - if (command != NULL) { - boolean matched = false; - for (int i = 0; i < commandCount; i++) { - #ifdef SERIALCOMMAND_DEBUG - Serial.print("Comparing ["); - Serial.print(command); - Serial.print("] to ["); - Serial.print(commandList[i].command); - Serial.println("]"); - #endif - - - - // Compare the found command against the list of known commands for a match - if (strncmp(command, commandList[i].command, SERIALCOMMAND_MAXCOMMANDLENGTH) == 0) { - #ifdef SERIALCOMMAND_DEBUG - Serial.print("Matched Command: "); - Serial.println(command); - #endif - - // Execute the stored handler function for the command - (*commandList[i].function)(); - matched = true; - break; - } - } - - - if (!matched && (defaultHandler != NULL)) { - (*defaultHandler)(command); - } - - - clearBuffer(); - } -} - -/* - * Clear the input buffer. - */ -void StringCommand::clearBuffer() { - buffer[0] = '\0'; - bufPos = 0; -} - -/** - * Retrieve the next token ("word" or "argument") from the command buffer. - * Returns NULL if no more tokens exist. - */ -char *StringCommand::next() { - return strtok_r(NULL, delim, &last); -} - -char *StringCommand::order() { - return strtok_r(buffer, delim, &main); -} diff --git a/lib/ESP8266-StringCommand/StringCommand.h b/lib/ESP8266-StringCommand/StringCommand.h deleted file mode 100644 index b37d5a1a..00000000 --- a/lib/ESP8266-StringCommand/StringCommand.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * SerialCommand - A Wiring/Arduino library to tokenize and parse commands - * received over a serial port. - * - * Copyright (C) 2012 Stefan Rado - * Copyright (C) 2011 Steven Cogswell - * http://husks.wordpress.com - * - * Version 20120522 - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library. If not, see . - */ -#ifndef StringCommand_h -#define StringCommand_h - -#if defined(WIRING) && WIRING >= 100 - #include -#elif defined(ARDUINO) && ARDUINO >= 100 - #include -#else - #include -#endif -#include - -// Size of the input buffer in bytes (maximum length of one command plus arguments) -#define SERIALCOMMAND_BUFFER 128 //256 -// Maximum length of a command excluding the terminating null -#define SERIALCOMMAND_MAXCOMMANDLENGTH 16 - -// Uncomment the next line to run the library in debug mode (verbose messages) -//#define SERIALCOMMAND_DEBUG - - -class StringCommand { - public: - StringCommand(); // Constructor - void addCommand(const char *command, void(*function)()); // Add a command to the processing dictionary. - void setDefaultHandler(void (*function)(const char *)); // A handler to call when no valid command received. - - void readStr(String sBuffer ); // Main entry point. - void clearBuffer(); // Clears the input buffer. - char *next(); // Returns pointer to next token found in command buffer (for getting arguments to commands). - char *order(); - - private: - // Command/handler dictionary - struct StringCommandCallback { - char command[SERIALCOMMAND_MAXCOMMANDLENGTH + 1]; - void (*function)(); - }; // Data structure to hold Command/Handler function key-value pairs - StringCommandCallback *commandList; // Actual definition for command/handler array - byte commandCount; - - // Pointer to the default handler function - void (*defaultHandler)(const char *); - - char delim[2]; // null-terminated list of character to be used as delimeters for tokenizing (default " ") - char term; // Character that signals end of command (default '\n') - - char buffer[SERIALCOMMAND_BUFFER + 1]; // Buffer of stored characters while waiting for terminator character - byte bufPos; // Current position in the buffer - char *last; // State variable used by strtok_r during processing - char *main; -}; - -#endif //StringCommand_h diff --git a/lib/ESP8266-StringCommand/keywords.txt b/lib/ESP8266-StringCommand/keywords.txt deleted file mode 100644 index c9799b2c..00000000 --- a/lib/ESP8266-StringCommand/keywords.txt +++ /dev/null @@ -1,23 +0,0 @@ -####################################### -# Datatypes (KEYWORD1) -####################################### - -StringCommand KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -addCommand KEYWORD2 -setDefaultHandler KEYWORD2 -readString KEYWORD2 -clearBuffer KEYWORD2 -next KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/lib/ESP8266-StringCommand/readme.md b/lib/ESP8266-StringCommand/readme.md deleted file mode 100644 index 731ee5e2..00000000 --- a/lib/ESP8266-StringCommand/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -StringCommand -============= -Библиотека для ESP8266 позволяющая связать запуск пользовательских функций с строковой переменной. - - diff --git a/src/Global.cpp b/src/Global.cpp index c4364e13..cbe0310f 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -7,7 +7,7 @@ TickerScheduler ts(END + 1); WiFiClient espClient; PubSubClient mqtt(espClient); -StringCommand sCmd; + #ifdef ASYNC_WEB_SERVER AsyncWebServer server(80); #endif diff --git a/src/modules/virtual/Loging/Loging.cpp b/src/modules/virtual/Loging/Loging.cpp index 9df1aaa4..57529ca2 100644 --- a/src/modules/virtual/Loging/Loging.cpp +++ b/src/modules/virtual/Loging/Loging.cpp @@ -185,6 +185,7 @@ class Loging : public IoTItem { SerialPrint("i", F("Loging"), "'" + id + "' loging in file http://" + WiFi.localIP().toString() + path); } + //данная функция уже перенесена в ядро и будет удалена в последствии bool hasDayChanged() { bool changed = false; String currentDate = getTodayDateDotFormated();