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

@@ -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;
}
@@ -718,19 +728,19 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) {
uint8_t * telegram = EMS_RxTelegram->telegram;
// header info
uint8_t src = telegram[0] & 0x7F;
uint8_t dest = telegram[1] & 0x7F; // remove 8th bit to handle both reads and writes
uint8_t type;
bool emsp;
uint8_t src = telegram[0] & 0x7F;
uint8_t dest = telegram[1] & 0x7F; // remove 8th bit to handle both reads and writes
uint8_t type;
bool emsp;
// check if EMS or EMS+ by checking 3rd byte of telegram
if (telegram[2] >= 0xF0) {
// EMS+
type = telegram[3];
emsp = true;
type = telegram[3];
emsp = true;
} else {
type = telegram[2];
emsp = false;
type = telegram[2];
emsp = false;
}
char output_str[200] = {0};
@@ -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"