From b45ff0455799201bf1c69cc2475e0de762c1f6c8 Mon Sep 17 00:00:00 2001 From: sergiu_toporjinschi Date: Mon, 7 Oct 2019 20:33:10 +0300 Subject: [PATCH] no message --- examples/ESPManager/ESPManager.ino | 35 ++++++++-------- library.json | 26 +++++++----- library.properties | 2 +- platformio.ini | 65 ++++++++++++------------------ src/ESPManager.cpp | 47 +++++++-------------- src/ESPManager.h | 21 ++++------ src/Macro.h | 20 +++++++++ 7 files changed, 104 insertions(+), 112 deletions(-) diff --git a/examples/ESPManager/ESPManager.ino b/examples/ESPManager/ESPManager.ino index 4da68c4..0776a53 100644 --- a/examples/ESPManager/ESPManager.ino +++ b/examples/ESPManager/ESPManager.ino @@ -1,12 +1,12 @@ -/* - ESPManager +/* + + espManager Copyright (C) 2018 by Sergiu Toporjinschi This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation version 3. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,15 +14,23 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . - Ctrl+k > open data folder, edit settings.json from data folder - Set values from wlan and mqtt + All rights reserved */ + +#ifdef DEBUGGER +# include "debug_macro.h" +Print *dbg = &Serial; +#endif + #include "ESPManager.h" #include "SettingsManager.h" +#include "SoftwareSerial.h" +#include #include + char *readTemp(const char *msg); void onCall(const char *msg); @@ -36,13 +44,9 @@ char *readTemp(const char *msg); void setup() { Serial.begin(115200); -#if defined(DEBUG_SETTINGS) || defined(DEBUG_ESPMANAGER) -# ifdef DEBUG_SETTINGS - conf.setDebugger(&Serial); -# endif -# ifdef DEBUG_ESPMANAGER - man.setDebugger(&Serial); -# endif + +#ifdef DEBUGGER + dbg = &Serial; #endif //Reading configuration from json file @@ -134,5 +138,4 @@ char *onGetConf(JsonVariant params) { char *retSettings = (char *)malloc(1000 * sizeof(char)); strcpy(retSettings, settings); return retSettings; - //man.sendMsg("IOT/espTest/getconf", settings); -}; +}; \ No newline at end of file diff --git a/library.json b/library.json index a95127c..39d5f01 100644 --- a/library.json +++ b/library.json @@ -1,19 +1,25 @@ { "name": "espManager", + "version": "3.1.2", + "license": "GPL-3.0-only", "description": "A wrapper for connection an ESP8266-01 to wifi, mqtt and create a small comunication", + "keywords": "ESP, ESP8266, IOT, WIFI, OTA", "repository": { "type": "git", "url": "https://github.com/SergiuToporjinschi/espmanager" }, - "keywords": "ESP, ESP8266, IOT, WIFI, OTA", - "Authors": "Sergiu Toporjinschi", - "version": "3.1.1", - "frameworks": "*", - "platforms": "espressif8266", - "dependencies": { - "ArduinoJson": "^6.10.0" + "authors": { + "name": "Sergiu Toporjinschi", + "maintainer": true }, - "examples": [ - "examples/*.cpp" - ] + "frameworks": "arduino", + "platforms": [ + "espressif8266", + "espressif32" + ], + "dependencies": { + "ArduinoJson": "^6.10.0", + "SketchLogger": "^1.0.7", + "Settings Manager": "^2.1.0" + } } \ No newline at end of file diff --git a/library.properties b/library.properties index 195a6c3..4da662e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESPManager -version=3.1.1 +version=3.1.2 author=Sergiu Toporjinschi maintainer=Sergiu Toporjinschi sentence=ESP manager diff --git a/platformio.ini b/platformio.ini index 3eaa75f..196c921 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,72 +12,59 @@ ; src_dir = ./.pio_compile [common] -version = "3.1.0" +version = "2.1.2" name = "EspManager" +examples_folder = "examples/ESPManager" +build_flags = + -D VER=\"${common.version}\" + -D EM_UDP_DEBUG + ; !python git_rev_macro.py + +[env] +lib_extra_dirs = + ; E:/IOT/Projects/PlatformIO/SketchLogger + E:/IOT/Projects/PlatformIO + monitor_speed = 115200 -examples_folder = examples/ESPManager +monitor_port = COM3 +upload_speed = 115200 +upload_port = COM3 + framework = arduino platform = espressif8266 -extra_scripts = pre:preRelease.py +; extra_scripts = pre:preRelease.py lib_deps = ArduinoJson@^6.10.1 + SketchLogger@^1.0.0 + 617 Settings Manager@^2.1.0 - MQTT -build_flags = - -D VER=\"${common.version}\" - -D EM_UDP_DEBUG - !python git_rev_macro.py + ; MQTT -############################# -########## ESP-01 ########### -############################# +## ESP-01 ###################################### [env:esp01_1m] -platform = espressif8266 -monitor_speed = ${common.monitor_speed} -framework = ${common.framework} -lib_deps = ${common.lib_deps} -extra_scripts = ${common.extra_scripts} board = esp01_1m -upload_protocol = esptool board_build.flash_mode = dout build_flags = ${common.build_flags} -Wl,-Teagle.flash.1m64.ld - +## Node MCU DEBUG ############################## [env:nodemcuv_DEBUG] -board_build.flash_mode = qio -platform = espressif8266 -monitor_speed = ${common.monitor_speed} -framework = ${common.framework} -lib_deps = ${common.lib_deps} -extra_scripts = ${common.extra_scripts} board = nodemcu -monitor_port = COM11 -monitor_speed = 9600 -; lib_extra_dirs = E:/IOT/Projects/PlatformIO/SettingsManager +board_build.flash_mode = qio build_flags = - -D DEBUG_ESPMANAGER - -D DEBUG_SETTINGS + -D DEBUGGER ${common.build_flags} -Wl,-Teagle.flash.4m1m.ld -############################# -############ MCU ############ -############################# +## Node MCU ###################################### [env:nodemcuv] -board_build.flash_mode = qio -platform = espressif8266 board = nodemcu -monitor_speed = ${common.monitor_speed} -monitor_port = COM3 -framework = ${common.framework} -lib_deps = ${common.lib_deps} -extra_scripts = ${common.extra_scripts} +board_build.flash_mode = qio build_flags = ${common.build_flags} -Wl,-Teagle.flash.4m1m.ld \ No newline at end of file diff --git a/src/ESPManager.cpp b/src/ESPManager.cpp index 458bbab..266ce30 100644 --- a/src/ESPManager.cpp +++ b/src/ESPManager.cpp @@ -1,12 +1,12 @@ -/* - ESPManager +/* + + espManager Copyright (C) 2018 by Sergiu Toporjinschi This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation version 3. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,26 +14,15 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . + + All rights reserved */ -#include "ESPManager.h" -//=================[ DEBUG_ESPMANAGER ]================ -#ifdef DEBUG_ESPMANAGER -# define DBG(x) \ - this->debug->print(x); \ - this->debug->flush(); -# define DBGLN(x, ...) \ - this->debug->printf("[%s](%d): ", __FILE__, __LINE__); \ - this->debug->printf(x, ##__VA_ARGS__); \ - this->debug->println(""); \ - this->debug->flush(); -#else -# define DBG(X) -# define DBGLN(X, ...) -#endif // DEBUG_ESPMANAGER -//=================[ DEBUG_ESPMANAGER ]================ +#include "debug_macro.h" + +#include "ESPManager.h" ADC_MODE(ADC_VCC); @@ -132,7 +121,7 @@ void ESPManager::waitForWiFi() { } int waitingTime = millis(); while (WiFi.status() != WL_CONNECTED && millis() - waitingTime < 30000) { - DBG("#"); + DBGLN("#"); if (this->waitingWiFiCon != nullptr) { this->waitingWiFiCon(); } @@ -142,7 +131,6 @@ void ESPManager::waitForWiFi() { DBGLN("hasAfter"); this->afterWaitingWiFiCon(); } - // DBGLN(""); if (WiFi.status() != WL_CONNECTED) { debugWiFiStatus(); ESP.restart(); @@ -180,7 +168,7 @@ void ESPManager::initDebugUDP() { Is printing connection status to WiFi if is not connected; */ void ESPManager::debugWiFiStatus() { -#ifdef DEBUG_ESPMANAGER +#ifdef DEBUGGER int wiFiStatus = WiFi.status(); DBGLN("WiFi status: %i, %s", wiFiStatus, wiFiStatus == WL_CONNECTED ? " CONNECTED" : (wiFiStatus == WL_CONNECT_FAILED ? " FAILED" : (wiFiStatus == WL_DISCONNECTED ? " DISCONNECTED" : (wiFiStatus == WL_CONNECTION_LOST ? " CONNECTION_LOST " : "")))); #endif @@ -253,7 +241,7 @@ void ESPManager::connectToMQTT() { this->beforeWaitingMQTTCon(); } while (!mqttCli.connect(clientId, user, password)) { - DBG("_"); + DBGLN("_"); if (this->waitingMQTTCon != nullptr) { this->waitingMQTTCon(); } @@ -303,7 +291,6 @@ void ESPManager::subscribeCMD() { void ESPManager::loopIt() { mqttCli.loop(); delay(10); - //delay(settings.getInt("esp.delayTime")); // <- fixes some issues with WiFi stability if (WiFi.status() != WL_CONNECTED || !mqttCli.connected()) { DBGLN("Not connected to MQTT reconnect ..."); @@ -394,7 +381,7 @@ void ESPManager::executeCommands(const char *topic, const char *payload) { } void ESPManager::addIncomingEventHandler(const char *topic, eventIncomingHandler handler) { -#ifndef DEBUG_SERIAL +#ifndef DEBUGER if (topic == nullptr) { DBGLN("To subscribe, topic is mandatory"); } @@ -529,12 +516,6 @@ void ESPManager::cmdUpdate(const char *respTopic, JsonVariant params) { } // ---==[ END Commands ]==--- -#ifdef DEBUG_ESPMANAGER -void ESPManager::setDebugger(Print *print) { - debug = print; -} -#endif //DEBUG_ESPMANAGER - ESPManager::~ESPManager() { // delete cbBind; delete &mqttCli; diff --git a/src/ESPManager.h b/src/ESPManager.h index d591cfb..823febd 100644 --- a/src/ESPManager.h +++ b/src/ESPManager.h @@ -1,12 +1,12 @@ -/* - ESPManager +/* + + espManager Copyright (C) 2018 by Sergiu Toporjinschi This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation version 3. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,9 +14,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . + + All rights reserved */ + #ifndef ESPManager_h #define ESPManager_h #include "Macro.h" @@ -32,7 +35,6 @@ #ifdef EM_UDP_DEBUG # include - static const char DEUBG_UDP_MASK_P[] PROGMEM = "{\"Exception\":%d,\"flag\":%d,\"flagText\":\"%s\",\"epc1\":\"0x%08x\",\"epc2\":\"0x%08x\",\"epc3\":\"0x%08x\",\"excvaddr\":\"0x%08x\",\"depc\":\"0x%08x\"}"; #endif @@ -100,18 +102,11 @@ class ESPManager { void addCommand(const char *cmd, cmdFunction handler); -#ifdef DEBUG_ESPMANAGER - void setDebugger(Print *print); -#endif //DEBUG_ESPMANAGER - private: const char *version = VER; const char *sketchVersion = nullptr; bool retainMsg = false; int qos = 0; -#ifdef DEBUG_ESPMANAGER - Print *debug = &Serial; -#endif //DEBUG_ESPMANAGER #ifdef EM_UDP_DEBUG WiFiUDP Udp; IPAddress udpDebugIP; diff --git a/src/Macro.h b/src/Macro.h index 05ef3b7..f4139cf 100644 --- a/src/Macro.h +++ b/src/Macro.h @@ -1,4 +1,24 @@ +/* + espManager + + Copyright (C) 2018 by Sergiu Toporjinschi + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 3. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + All rights reserved + +*/ //=================[ REVISION ]================ #ifndef REV # define REV (char *)"NONE"