From 1aace72255ffdd0191803333acd301da41360125 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 30 Sep 2019 23:19:21 +0200 Subject: [PATCH] added 'autodetect quick' option --- CHANGELOG.md | 3 ++- src/ems-esp.cpp | 10 ++++++---- src/ems.cpp | 12 +++++++----- src/ems.h | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af06484fb..37a1b519d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.9.1 beta] 2019-09-27 +## [1.9.1 beta] 2019-09-30 ### Added - Support for multiple Heating Circuits - https://github.com/proddy/EMS-ESP/issues/162 - new `mqttlog` command also shows which MQTT topics it is subscribed too - Optimized event log loading in web and added integrity checks on all config and log files during boot +- `autodetect quick` ### Fixed diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index 4cebd5c83..253adad12 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -134,7 +134,7 @@ static const command_t project_cmds[] PROGMEM = { {false, "refresh", "fetch values from the EMS devices"}, {false, "devices [all]", "list all supported and detected EMS devices"}, {false, "queue", "show current Tx queue"}, - {false, "autodetect [deep]", "detect EMS devices and attempt to automatically set boiler and thermostat types"}, + {false, "autodetect [quick | deep]", "detect EMS devices and attempt to automatically set boiler and thermostat types"}, {false, "shower ", "toggle either timer or alert on/off"}, {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"}, @@ -1460,10 +1460,12 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) { char * second_cmd = _readWord(); if (strcmp(second_cmd, "deep") == 0) { startDeviceScan(); - ok = true; + } else if (strcmp(second_cmd, "quick") == 0) { + ems_clearDeviceList(); + ems_doReadCommand(EMS_TYPE_UBADevices, EMS_Boiler.device_id); + } else { + ems_scanDevices(); } - } else { - ems_scanDevices(); ok = true; } } diff --git a/src/ems.cpp b/src/ems.cpp index c1063a984..21a48371e 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -223,12 +223,10 @@ const uint8_t TX_WRITE_TIMEOUT_COUNT = 2; // 3 retries before timeout const uint32_t EMS_BUS_TIMEOUT = 15000; // timeout in ms before recognizing the ems bus is offline (15 seconds) const uint32_t EMS_POLL_TIMEOUT = 5000000; // timeout in microseconds before recognizing the ems bus is offline (5 seconds) + // init stats and counters and buffers void ems_init() { - // init the device map - for (uint8_t i = 0; i < EMS_SYS_DEVICEMAP_LENGTH; i++) { - EMS_Sys_Status.emsDeviceMap[i] = 0x00; - } + ems_clearDeviceList(); // init the device map // overall status EMS_Sys_Status.emsRxPgks = 0; @@ -1844,6 +1842,10 @@ void _process_RCTime(_EMS_RxTelegram * EMS_RxTelegram) { */ void ems_clearDeviceList() { Devices.clear(); + + for (uint8_t i = 0; i < EMS_SYS_DEVICEMAP_LENGTH; i++) { + EMS_Sys_Status.emsDeviceMap[i] = 0x00; + } } /* @@ -1856,7 +1858,7 @@ void _addDevice(uint8_t model_type, uint8_t src, uint8_t product_id, char * vers // check for duplicates bool found = false; for (std::list<_Generic_Device>::iterator it = Devices.begin(); it != Devices.end(); ++it) { - if (((it)->product_id == product_id) && ((it)->device_id == src) ) { + if (((it)->product_id == product_id) && ((it)->device_id == src)) { found = true; // it already exists in the list } } diff --git a/src/ems.h b/src/ems.h index 5e01398e7..46720d9a1 100644 --- a/src/ems.h +++ b/src/ems.h @@ -268,8 +268,8 @@ typedef struct { uint8_t model_id; uint8_t product_id; uint8_t device_id; - char model_string[50]; - bool write_supported; + char model_string[50]; + bool write_supported; } _Thermostat_Device; // for consolidating all types