diff --git a/CHANGELOG.md b/CHANGELOG.md index c374d5a19..268cb9e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,9 +36,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `status` payload on start-up shows the IP and Version of EMS-ESP - `thermostat mode` takes a string like manual,auto,heat,day,night,eco,comfort,holiday,nofrost - `thermostat temp` also takes a mode string, e.g. `thermostat temp 20 heat` +- `queue` renamed to `txqueue` ### Removed - - `autodetect scan` + - `autodetect scan`. Replaced with `devices scan` and `devices scan+` for deep scanning - `mqttlog all` and showing MQTT log in the web interface - no point showing history of previous mqtt publishes in ESP's precious memory. For debugging I recommend using MQTT Explorer or another external tool. ## [1.9.4] 15-12-2019 diff --git a/platformio.ini b/platformio.ini index 837d143fa..971457c81 100644 --- a/platformio.ini +++ b/platformio.ini @@ -4,7 +4,7 @@ [platformio] default_envs = release -;default_envs = debug +; default_envs = debug [common] ; custom build options are: @@ -14,7 +14,7 @@ default_envs = release ; -DFORCE_SERIAL ; -DMYESP_DEBUG ; -DSENSOR_MQTT_USEID -;custom_flags = -DFORCE_SERIAL -DMYESP_DEBUG -DEMSESP_SIMULATE +; custom_flags = -DFORCE_SERIAL -DMYESP_DEBUG -DEMSESP_SIMULATE custom_flags = # Available lwIP variants (macros): @@ -27,7 +27,7 @@ custom_flags = # -DVTABLES_IN_FLASH # -DNO_GLOBAL_EEPROM # -DBEARSSL_SSL_BASIC -#general_flags = -DNO_GLOBAL_EEPROM -DVTABLES_IN_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH +# general_flags = -DNO_GLOBAL_EEPROM -DVTABLES_IN_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH general_flags = -DNO_GLOBAL_EEPROM @@ -40,10 +40,7 @@ build_flags = ${common.general_flags} -std=c++11 -fno-exceptions [env] framework = arduino -;platform = espressif8266@2.2.2 ; arduino core 2.5.2 platform = espressif8266 -;platform = https://github.com/platformio/platform-espressif8266#develop -;platform = https://github.com/platformio/platform-espressif8266#feature/stage lib_compat_mode = strict lib_deps = https://github.com/rlogiacco/CircularBuffer @@ -56,7 +53,7 @@ lib_deps = JustWifi@2.0.2 ; https://github.com/xoseperez/justwifi AsyncMqttClient@0.8.2 ; https://github.com/marvinroger/async-mqtt-client EEPROM_Rotate@0.9.2 ; https://github.com/xoseperez/eeprom_rotate - ArduinoJson@6.14.1 ; https://github.com/bblanchon/ArduinoJson + https://github.com/bblanchon/ArduinoJson ESPAsyncTCP@1.2.2 ; https://github.com/me-no-dev/ESPAsyncTCP upload_speed = 921600 monitor_speed = 115200 diff --git a/src/MyESP.cpp b/src/MyESP.cpp index 3a4958758..c67c4925f 100644 --- a/src/MyESP.cpp +++ b/src/MyESP.cpp @@ -435,7 +435,7 @@ void MyESP::_printMQTTQueue() { bool MyESP::mqttPublish(const char * topic, const char * payload) { return (_mqttQueue(topic, payload, _mqtt_retain)); } -bool MyESP::mqttPublish(const char * topic, JsonDocument payload) { +bool MyESP::mqttPublish(const char * topic, JsonDocument & payload) { return (_mqttQueue(topic, payload, _mqtt_retain)); } @@ -443,7 +443,7 @@ bool MyESP::mqttPublish(const char * topic, JsonDocument payload) { bool MyESP::mqttPublish(const char * topic, const char * payload, bool retain) { return (_mqttQueue(topic, payload, retain)); } -bool MyESP::mqttPublish(const char * topic, JsonDocument payload, bool retain) { +bool MyESP::mqttPublish(const char * topic, JsonDocument & payload, bool retain) { return (_mqttQueue(topic, payload, retain)); } @@ -475,7 +475,7 @@ bool MyESP::_mqttQueue(const char * topic, const char * payload, bool retain) { // convert json doc to a string buffer and place on queue // can't have empty payload or topic // returns false if can't add to queue -bool MyESP::_mqttQueue(const char * topic, JsonDocument payload, bool retain) { +bool MyESP::_mqttQueue(const char * topic, JsonDocument & payload, bool retain) { if (!mqttClient.connected() || _mqtt_queue.size() >= MQTT_QUEUE_MAX_SIZE || !_hasValue(topic)) { return false; } @@ -2753,48 +2753,49 @@ void MyESP::_webserver_setup() { request->send(response); }); - _webServer->on("/update", - HTTP_POST, - [](AsyncWebServerRequest * request) { - AsyncWebServerResponse * response = request->beginResponse(200, "text/plain", _shouldRestart ? "OK" : "FAIL"); - response->addHeader("Connection", "close"); - request->send(response); - }, - [](AsyncWebServerRequest * request, String filename, size_t index, uint8_t * data, size_t len, bool final) { - if (!request->authenticate(MYESP_HTTP_USERNAME, _general_password)) { - return; - } - if (!index) { - ETS_UART_INTR_DISABLE(); // disable all UART interrupts to be safe - //_writeLogEvent(MYESP_SYSLOG_INFO, "Firmware update started"); - Update.runAsync(true); - if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { + _webServer->on( + "/update", + HTTP_POST, + [](AsyncWebServerRequest * request) { + AsyncWebServerResponse * response = request->beginResponse(200, "text/plain", _shouldRestart ? "OK" : "FAIL"); + response->addHeader("Connection", "close"); + request->send(response); + }, + [](AsyncWebServerRequest * request, String filename, size_t index, uint8_t * data, size_t len, bool final) { + if (!request->authenticate(MYESP_HTTP_USERNAME, _general_password)) { + return; + } + if (!index) { + ETS_UART_INTR_DISABLE(); // disable all UART interrupts to be safe + //_writeLogEvent(MYESP_SYSLOG_INFO, "Firmware update started"); + Update.runAsync(true); + if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { //_writeLogEvent(MYESP_SYSLOG_ERROR, "Not enough space to update"); #ifdef MYESP_DEBUG - Update.printError(Serial); + Update.printError(Serial); #endif - } - } - if (!Update.hasError()) { - if (Update.write(data, len) != len) { + } + } + if (!Update.hasError()) { + if (Update.write(data, len) != len) { //_writeLogEvent(MYESP_SYSLOG_ERROR, "Writing to flash failed"); #ifdef MYESP_DEBUG - Update.printError(Serial); + Update.printError(Serial); #endif - } - } - if (final) { - if (Update.end(true)) { - //_writeLogEvent(MYESP_SYSLOG_INFO, "Firmware update finished"); - _shouldRestart = !Update.hasError(); - } else { + } + } + if (final) { + if (Update.end(true)) { + //_writeLogEvent(MYESP_SYSLOG_INFO, "Firmware update finished"); + _shouldRestart = !Update.hasError(); + } else { //_writeLogEvent(MYESP_SYSLOG_ERROR, "Firmware update failed"); #ifdef MYESP_DEBUG - Update.printError(Serial); + Update.printError(Serial); #endif - } - } - }); + } + } + }); _webServer->on("/fonts/glyphicons-halflings-regular.woff", HTTP_GET, [](AsyncWebServerRequest * request) { AsyncWebServerResponse * response = diff --git a/src/MyESP.h b/src/MyESP.h index 1568860d4..5b623a4ef 100644 --- a/src/MyESP.h +++ b/src/MyESP.h @@ -9,7 +9,7 @@ #ifndef MyESP_h #define MyESP_h -#define MYESP_VERSION "1.2.36" +#define MYESP_VERSION "1.2.37" #include #include @@ -281,8 +281,8 @@ class MyESP { void mqttUnsubscribe(const char * topic); bool mqttPublish(const char * topic, const char * payload); bool mqttPublish(const char * topic, const char * payload, bool retain); - bool mqttPublish(const char * topic, JsonDocument payload); - bool mqttPublish(const char * topic, JsonDocument payload, bool retain); + bool mqttPublish(const char * topic, JsonDocument & payload); + bool mqttPublish(const char * topic, JsonDocument & payload, bool retain); void setMQTT(mqtt_callback_f callback); bool mqttUseNestedJson(); @@ -343,7 +343,7 @@ class MyESP { void _sendStart(); char * _mqttTopic(const char * topic); bool _mqttQueue(const char * topic, const char * payload, bool retain); - bool _mqttQueue(const char * topic, JsonDocument payload, bool retain); + bool _mqttQueue(const char * topic, JsonDocument & payload, bool retain); void _printMQTTQueue(); void _mqttPublishQueue(); void _mqttRemoveLastPublish(); diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index 44d113c04..adea4d992 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -109,8 +109,8 @@ static const command_t project_cmds[] PROGMEM = { {false, "log ", "logging: none, basic, thermo, solar, mixing, raw, jabber, verbose, watch a type or device"}, {false, "publish", "publish all values to MQTT"}, {false, "refresh", "fetch values from the EMS devices"}, - {false, "devices [scan] | [scan deep] | [save]", "list detected devices, quick scan or deep scan and save as known devices"}, - {false, "queue", "show current Tx queue"}, + {false, "devices [scan] | [scan+] | [clear] | [save] ", "list detected devices, quick scan, deep scan, clear and and save"}, + {false, "txqueue", "show current Tx queue"}, {false, "send XX ...", "send raw telegram data to EMS bus (XX are hex values)"}, {false, "thermostat read ", "send read request to the thermostat for heating circuit hc 1-4"}, {false, "thermostat temp [mode] [hc]", "set thermostat temperature. mode is manual,auto,heat,day,night,eco,comfort,holiday,nofrost"}, @@ -254,14 +254,17 @@ void showInfo() { ((EMSESP_Settings.shower_timer) ? "enabled" : "disabled"), ((EMSESP_Settings.shower_alert) ? "enabled" : "disabled")); + if (strlen(EMSESP_Settings.known_devices) > 0) { + myDebug_P(PSTR(" Saved known device IDs: %s"), EMSESP_Settings.known_devices); + } else { + myDebug_P(PSTR(" Saved known device IDs: none")); + } + myDebug_P(PSTR("\n%sEMS Bus status:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF); if (ems_getBusConnected()) { myDebug_P(PSTR(" Bus is connected, protocol: %s"), (ems_isHT3() ? "HT3" : "Buderus")); myDebug_P(PSTR(" Rx: # successful read requests=%d, # CRC errors=%d"), EMS_Sys_Status.emsRxPgks, EMS_Sys_Status.emxCrcErr); - if (strlen(EMSESP_Settings.known_devices) > 0) { - myDebug_P(PSTR(" Saved known device IDs: %s"), EMSESP_Settings.known_devices); - } if (ems_getTxCapable()) { char valuestr[8] = {0}; // for formatting floats @@ -1487,6 +1490,11 @@ void TelnetCallback(uint8_t event) { } } +void clearEMSDevices() { + EMSESP_Settings.known_devices = strdup(""); + myESP.saveSettings(); +} + // get the list of know devices, as a string, and save them to the config file void saveEMSDevices() { if (Devices.empty()) { @@ -1539,33 +1547,28 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) { // wc = 2 or more. check for "scan" char * second_cmd = _readWord(); if (strcmp(second_cmd, "scan") == 0) { - if (wc == 2) { - // just scan use UBA 0x07 telegram - myDebug_P(PSTR("Requesting EMS bus master for its device list and scanning for external sensors...")); - scanDallas(); - Devices.clear(); // init the device map - ems_doReadCommand(EMS_TYPE_UBADevices, EMS_Boiler.device_id); - return; - } - - // wc is 3 or more. check for additional "force" argument - char * third_cmd = _readWord(); - if (strcmp(third_cmd, "deep") == 0) { - myDebug_P(PSTR("Started deep scan of EMS bus for our known devices. This can take up to 10 seconds...")); - Devices.clear(); // init the device map - ems_scanDevices(); - return; - } + // just scan use UBA 0x07 telegram + myDebug_P(PSTR("Requesting EMS bus master for its device list and scanning for external sensors...")); + scanDallas(); + Devices.clear(); // init the device map + ems_doReadCommand(EMS_TYPE_UBADevices, EMS_Boiler.device_id); + return; + } else if (strcmp(second_cmd, "scan+") == 0) { + myDebug_P(PSTR("Started deep scan of EMS bus for our known devices. This can take up to 10 seconds...")); + Devices.clear(); // init the device map + ems_scanDevices(); + return; } else if (strcmp(second_cmd, "save") == 0) { saveEMSDevices(); return; + } else if (strcmp(second_cmd, "clear") == 0) { + clearEMSDevices(); + return; } - ok = false; // unknown command } - - if (strcmp(first_cmd, "queue") == 0) { + if (strcmp(first_cmd, "txqueue") == 0) { ems_printTxQueue(); ok = true; } @@ -2278,7 +2281,7 @@ void initEMSESP() { EMSESP_Settings.tx_mode = EMS_TXMODE_DEFAULT; // default tx mode EMSESP_Settings.bus_id = EMS_BUSID_DEFAULT; // Service Key is default EMSESP_Settings.master_thermostat = 0; - EMSESP_Settings.known_devices = nullptr; + EMSESP_Settings.known_devices = strdup(""); // shower settings EMSESP_Shower.timerStart = 0; diff --git a/src/version.h b/src/version.h index bf444aad1..1086d0eba 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "1.9.5b55" +#define APP_VERSION "1.9.5b57"