added tx_delay

This commit is contained in:
proddy
2019-04-14 13:17:48 +02:00
parent 71f9057016
commit dc1d797d75
8 changed files with 63 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ 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.7.0 dev] 2019-04-07
## [1.7.0 dev] 2019-04-14
### Added
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- MQTT 'restart' topic to reboot ESP (thanks @balk77)
- Support for multiple thermostat heating circuits like the HC1/HC2 on a RC35, also via MQTT (thanks @lobocobra)
- `boiler flowtemp` command to set the flow temperature [(issue 59)](https://github.com/proddy/EMS-ESP/issues/59)
- `tx_delay` setting for circuits where we needed to slow down Tx transmission
## [1.6.0] 2019-03-24

View File

@@ -357,6 +357,8 @@ The onboard LED will flash if there is no connection with the EMS bus. You can d
If you want to completely erase the ESP and rebuild the firmware then do a `pio run -t erase` which will wipe the onboard flash including the SPIFFs where all the settings are stored.
If you're unable to send commands then the Tx is most likely not working. Check with `info` to see if the Tx is available and that the rx poll is less than 200ms. Then trying putting a delay in the Tx by using `set tx_delay on` and `reboot`. See if that helps.
## Known Issues
Some annoying issues that need fixing:

View File

@@ -854,12 +854,16 @@ void MyESP::showSystemStats() {
if (_boottime != NULL) {
myDebug_P(PSTR(" [APP] Boot time: %s"), _boottime);
}
// uptime
uint32_t t = _getUptime(); // seconds
uint32_t h = (uint32_t)t / (uint32_t)3600L;
uint32_t rem = (uint32_t)t % (uint32_t)3600L;
uint32_t m = rem / 60;
uint32_t s = rem % 60;
myDebug_P(PSTR(" [APP] Uptime: %d seconds (%02d:%02d:%02d)"), t, h, m, s);
uint32_t d = t / 86400L;
uint32_t h = (t / 3600L) % 60;
uint32_t rem = t % 3600L;
uint8_t m = rem / 60;
uint8_t s = rem % 60;
myDebug_P(PSTR(" [APP] Uptime: %d days, %d hours, %d minutes, %d seconds"), d, h, m, s);
myDebug_P(PSTR(" [APP] System Load: %d%%"), getSystemLoadAverage());
if (isAPmode()) {

View File

@@ -101,6 +101,7 @@ command_t PROGMEM project_cmds[] = {
{true, "shower_alert <on | off>", "send a warning of cold water after shower time is exceeded"},
{true, "publish_wait <seconds>", "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 <on | off>", "turn on if Tx not working on newer boilers"},
{false, "info", "show data captured on the EMS bus"},
{false, "log <n | b | t | r | v>", "set logging mode to none, basic, thermostat only, raw or verbose"},
@@ -340,7 +341,7 @@ void showInfo() {
EMS_Sys_Status.emxCrcErr);
if (ems_getTxCapable()) {
myDebug(" Tx: available, # Tx telegrams sent=%d", EMS_Sys_Status.emsTxPkgs);
myDebug(" Tx: available, Tx delay is %s, # Tx telegrams sent=%d", (ems_getTxDelay() ? "on" : "off"), EMS_Sys_Status.emsTxPkgs);
} else {
myDebug(" Tx: no signal");
}
@@ -887,6 +888,9 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
// shower_alert
EMSESP_Status.shower_alert = json["shower_alert"];
// tx delay
ems_setTxDelay(json["tx_delay"]);
// publish_wait
if (!(EMSESP_Status.publish_wait = json["publish_wait"])) {
EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT; // default value
@@ -914,6 +918,7 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
json["shower_alert"] = EMSESP_Status.shower_alert;
json["publish_wait"] = EMSESP_Status.publish_wait;
json["heating_circuit"] = EMSESP_Status.heating_circuit;
json["tx_delay"] = ems_getTxDelay();
return true;
}
@@ -1043,6 +1048,19 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
myDebug("Error. Usage: set heating_circuit <1 | 2>");
}
}
// 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("Error. Usage: set tx_delay <on | off>");
}
}
}
if (action == MYESP_FSACTION_LIST) {
@@ -1069,6 +1087,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
myDebug(" shower_timer=%s", EMSESP_Status.shower_timer ? "on" : "off");
myDebug(" shower_alert=%s", EMSESP_Status.shower_alert ? "on" : "off");
myDebug(" publish_wait=%d", EMSESP_Status.publish_wait);
myDebug(" tx_delay=%s", ems_getTxDelay() ? "on" : "off");
}
return ok;
@@ -1523,7 +1542,7 @@ void setup() {
// start up all the services
myESP.begin(APP_HOSTNAME, APP_NAME, APP_VERSION);
// at this point we have the settings from our internall SPIFFS config file
// at this point we have all the settings from our internall SPIFFS config file
// enable regular checks if not in test mode
if (!EMSESP_Status.silent_mode) {
@@ -1553,7 +1572,7 @@ void loop() {
myESP.loop();
// check Dallas sensors, every 2 seconds
// these values are published to MQTT seperately via the timer publishSensorValuesTimer
// these values are published to MQTT separately via the timer publishSensorValuesTimer
if (EMSESP_Status.dallas_sensors != 0) {
ds18.loop();
}

View File

@@ -189,6 +189,7 @@ void ems_init() {
EMS_Sys_Status.emsTxDisabled = false;
EMS_Sys_Status.emsPollFrequency = 0;
EMS_Sys_Status.txRetryCount = 0;
EMS_Sys_Status.emsTxDelay = false;
// thermostat
EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
@@ -295,6 +296,15 @@ bool ems_getPoll() {
return EMS_Sys_Status.emsPollEnabled;
}
void ems_setTxDelay(bool b) {
EMS_Sys_Status.emsTxDelay = b;
myDebug("EMS Tx delay is %s", EMS_Sys_Status.emsTxDelay ? "enabled" : "disabled");
}
bool ems_getTxDelay() {
return EMS_Sys_Status.emsTxDelay;
}
bool ems_getEmsRefreshed() {
return EMS_Sys_Status.emsRefreshed;
}
@@ -1265,7 +1275,6 @@ void _process_SM10Monitor(uint8_t src, uint8_t * data, uint8_t length) {
* UBASetPoint 0x1A
*/
void _process_SetPoints(uint8_t src, uint8_t * data, uint8_t length) {
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
if (length != 0) {
uint8_t setpoint = data[0]; // flow temp
@@ -1283,7 +1292,6 @@ void _process_SetPoints(uint8_t src, uint8_t * data, uint8_t length) {
myDebug(" Boiler flow temperature is %d C", setpoint);
}
}
}
/**
@@ -1985,7 +1993,6 @@ void ems_setWarmWaterTemp(uint8_t temperature) {
* Set the boiler flow temp
*/
void ems_setFlowTemp(uint8_t temperature) {
myDebug("Setting boiler flow temperature to %d C", temperature);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
@@ -2006,7 +2013,6 @@ void ems_setFlowTemp(uint8_t temperature) {
EMS_TxTelegram.forceRefresh = false;
EMS_TxQueue.push(EMS_TxTelegram);
}
/**

View File

@@ -95,6 +95,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
} _EMS_Sys_Status;
// The Tx send package
@@ -286,6 +287,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_setLogging(_EMS_SYS_LOGGING loglevel);
void ems_setEmsRefreshed(bool b);
void ems_setWarmWaterModeComfort(uint8_t comfort);
@@ -300,6 +302,7 @@ bool ems_getPoll();
bool ems_getTxEnabled();
bool ems_getThermostatEnabled();
bool ems_getBoilerEnabled();
bool ems_getTxDelay();
bool ems_getBusConnected();
_EMS_SYS_LOGGING ems_getLogging();
bool ems_getEmsRefreshed();

View File

@@ -177,7 +177,12 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
for (uint8_t i = 0; i < len; i++) {
USF(EMSUART_UART) = buf[i];
//delayMicroseconds(EMS_TX_BRK_WAIT);
// check if we need to force a delay to slow down Tx
// https://github.com/proddy/EMS-ESP/issues/23#
if (EMS_Sys_Status.emsTxDelay) {
delayMicroseconds(EMS_TX_BRK_WAIT);
}
}
emsuart_tx_brk();
}

View File

@@ -6,5 +6,5 @@
#pragma once
#define APP_NAME "EMS-ESP"
#define APP_VERSION "1.7.0b4"
#define APP_VERSION "1.7.0b5"
#define APP_HOSTNAME "ems-esp"