From 03d9e6547f9e6f2cd65fbf2fe10880262beef716 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 22 May 2019 00:01:59 +0200 Subject: [PATCH] txDelay change from bool to int --- src/ems-esp.cpp | 17 +++++------------ src/ems.cpp | 10 +++++----- src/ems.h | 6 +++--- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index c059bcf20..243c03e63 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -106,7 +106,7 @@ command_t project_cmds[] = { {true, "shower_alert ", "send a warning of cold water after shower time is exceeded"}, {true, "publish_wait ", "set frequency for publishing to MQTT"}, {true, "heating_circuit <1 | 2>", "set the thermostat HC to work with if using multiple heating circuits"}, - {true, "tx_delay ", "turn on if Tx not working on newer boilers"}, + {true, "tx_delay ", "0=normal, 1=ems+, 2=new logic"}, {false, "info", "show data captured on the EMS bus"}, {false, "log ", "set logging mode to none, basic, thermostat only, raw or verbose"}, @@ -342,7 +342,7 @@ void showInfo() { myDebug_P(PSTR(" Rx: Poll=%d ms, # Rx telegrams read=%d, # CRC errors=%d"), ems_getPollFrequency(), EMS_Sys_Status.emsRxPgks, EMS_Sys_Status.emxCrcErr); if (ems_getTxCapable()) { - myDebug_P(PSTR(" Tx: available, Tx delay is %s, # Tx telegrams sent=%d"), (ems_getTxDelay() ? "on" : "off"), EMS_Sys_Status.emsTxPkgs); + myDebug_P(PSTR(" Tx: available, Tx delay is %d, # Tx telegrams sent=%d"), ems_getTxDelay(), EMS_Sys_Status.emsTxPkgs); } else { myDebug_P(PSTR(" Tx: no signal")); } @@ -1182,15 +1182,8 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c // tx delay if ((strcmp(setting, "tx_delay") == 0) && (wc == 2)) { - if (strcmp(value, "on") == 0) { - ems_setTxDelay(true); - ok = true; - } else if (strcmp(value, "off") == 0) { - ems_setTxDelay(false); - ok = true; - } else { - myDebug_P(PSTR("Error. Usage: set tx_delay ")); - } + ems_setTxDelay(atoi(value)); + ok = true; } } @@ -1218,7 +1211,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c myDebug_P(PSTR(" shower_timer=%s"), EMSESP_Status.shower_timer ? "on" : "off"); myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Status.shower_alert ? "on" : "off"); myDebug_P(PSTR(" publish_wait=%d"), EMSESP_Status.publish_wait); - myDebug_P(PSTR(" tx_delay=%s"), ems_getTxDelay() ? "on" : "off"); + myDebug_P(PSTR(" tx_delay=%d"), ems_getTxDelay()); } return ok; diff --git a/src/ems.cpp b/src/ems.cpp index a30541216..2e5f55e07 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -220,7 +220,7 @@ void ems_init() { EMS_Sys_Status.emsTxDisabled = false; EMS_Sys_Status.emsPollFrequency = 0; EMS_Sys_Status.txRetryCount = 0; - EMS_Sys_Status.emsTxDelay = false; + EMS_Sys_Status.emsTxDelay = 0; // thermostat EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET; @@ -329,12 +329,12 @@ bool ems_getPoll() { return EMS_Sys_Status.emsPollEnabled; } -void ems_setTxDelay(bool b) { - EMS_Sys_Status.emsTxDelay = b; - myDebug_P(PSTR("EMS Tx delay is %s"), EMS_Sys_Status.emsTxDelay ? "enabled" : "disabled"); +void ems_setTxDelay(uint8_t delay) { + EMS_Sys_Status.emsTxDelay = delay; + myDebug_P(PSTR("EMS Tx delay is %d"), EMS_Sys_Status.emsTxDelay); } -bool ems_getTxDelay() { +uint8_t ems_getTxDelay() { return EMS_Sys_Status.emsTxDelay; } diff --git a/src/ems.h b/src/ems.h index 702f1a793..edb8fbd1e 100644 --- a/src/ems.h +++ b/src/ems.h @@ -94,7 +94,7 @@ typedef struct { bool emsTxCapable; // able to send via Tx bool emsTxDisabled; // true to prevent all Tx uint8_t txRetryCount; // # times the last Tx was re-sent - bool emsTxDelay; // if true, slows down the Tx transmit + uint8_t emsTxDelay; // handles Tx logic } _EMS_Sys_Status; // The Tx send package @@ -301,7 +301,7 @@ void ems_setFlowTemp(uint8_t temperature); void ems_setWarmWaterActivated(bool activated); void ems_setWarmTapWaterActivated(bool activated); void ems_setPoll(bool b); -void ems_setTxDelay(bool b); +void ems_setTxDelay(uint8_t delay); void ems_setLogging(_EMS_SYS_LOGGING loglevel); void ems_setEmsRefreshed(bool b); void ems_setWarmWaterModeComfort(uint8_t comfort); @@ -316,7 +316,7 @@ bool ems_getPoll(); bool ems_getTxEnabled(); bool ems_getThermostatEnabled(); bool ems_getBoilerEnabled(); -bool ems_getTxDelay(); +uint8_t ems_getTxDelay(); bool ems_getBusConnected(); _EMS_SYS_LOGGING ems_getLogging(); bool ems_getEmsRefreshed();