mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-31 02:59:10 +03:00
add tx_mode back as new tx code can cause resets
This commit is contained in:
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Added back -DCRASH in Debug build target for capturing any ESP8266 stack dumps during crashes
|
- Added back -DCRASH in Debug build target for capturing any ESP8266 stack dumps during crashes
|
||||||
- Web Interface, for checking stats and setting wifi credentials. See wiki for more details.
|
- Web Interface, for checking stats and setting wifi credentials. See wiki for more details.
|
||||||
- reset firmware option. If the reset button on the ESP is pressed during boot up sequence (the LED is flashing very fast) all settings are erased and goes into AP mode.
|
- reset firmware option. If the reset button on the ESP is pressed during boot up sequence (the LED is flashing very fast) all settings are erased and goes into AP mode.
|
||||||
|
- Added tx_mode back with options 0,1 and 2 until we've fixed option 2 that works for everyone and doesn't reset ESP
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef MyEMS_h
|
#ifndef MyEMS_h
|
||||||
#define MyEMS_h
|
#define MyEMS_h
|
||||||
|
|
||||||
#define MYESP_VERSION "1.1.18"
|
#define MYESP_VERSION "1.1.19"
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ command_t project_cmds[] = {
|
|||||||
{true, "shower_alert <on | off>", "stop hot water to send 3 cold burst warnings after max shower time is exceeded"},
|
{true, "shower_alert <on | off>", "stop hot water to send 3 cold burst warnings after max shower time is exceeded"},
|
||||||
{true, "publish_time <seconds>", "set frequency for publishing data to MQTT (0=off)"},
|
{true, "publish_time <seconds>", "set frequency for publishing data to MQTT (0=off)"},
|
||||||
{true, "heating_circuit <1 | 2>", "set the main thermostat HC to work with (if using multiple heating circuits)"},
|
{true, "heating_circuit <1 | 2>", "set the main thermostat HC to work with (if using multiple heating circuits)"},
|
||||||
|
{true, "tx_mode <n>", "0=classic ems logic, 1=@kwertie01 ems+ logic, 2=@susisstrolch logic, 3=@philrich logic for Junkers"},
|
||||||
|
|
||||||
{false, "info", "show current captured on the devices"},
|
{false, "info", "show current captured on the devices"},
|
||||||
{false, "log <n | b | t | r | v>", "set logging mode to none, basic, thermostat only, raw or verbose"},
|
{false, "log <n | b | t | r | v>", "set logging mode to none, basic, thermostat only, raw or verbose"},
|
||||||
@@ -323,7 +324,7 @@ void showInfo() {
|
|||||||
myDebug_P(PSTR(" System logging set to Verbose"));
|
myDebug_P(PSTR(" System logging set to Verbose"));
|
||||||
} else if (sysLog == EMS_SYS_LOGGING_THERMOSTAT) {
|
} else if (sysLog == EMS_SYS_LOGGING_THERMOSTAT) {
|
||||||
myDebug_P(PSTR(" System logging set to Thermostat only"));
|
myDebug_P(PSTR(" System logging set to Thermostat only"));
|
||||||
} else if (sysLog == EMS_SYS_LOGGING_SOLARMODULE ) {
|
} else if (sysLog == EMS_SYS_LOGGING_SOLARMODULE) {
|
||||||
myDebug_P(PSTR(" System logging set to Solar Module only"));
|
myDebug_P(PSTR(" System logging set to Solar Module only"));
|
||||||
} else {
|
} else {
|
||||||
myDebug_P(PSTR(" System logging set to None"));
|
myDebug_P(PSTR(" System logging set to None"));
|
||||||
@@ -1032,6 +1033,8 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
|
|||||||
EMSESP_Status.shower_alert = json["shower_alert"];
|
EMSESP_Status.shower_alert = json["shower_alert"];
|
||||||
EMSESP_Status.publish_time = json["publish_time"] | DEFAULT_PUBLISHTIME;
|
EMSESP_Status.publish_time = json["publish_time"] | DEFAULT_PUBLISHTIME;
|
||||||
|
|
||||||
|
ems_setTxMode(json["tx_mode"]);
|
||||||
|
|
||||||
EMSESP_Status.listen_mode = json["listen_mode"];
|
EMSESP_Status.listen_mode = json["listen_mode"];
|
||||||
ems_setTxDisabled(EMSESP_Status.listen_mode);
|
ems_setTxDisabled(EMSESP_Status.listen_mode);
|
||||||
|
|
||||||
@@ -1053,6 +1056,7 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
|
|||||||
json["shower_alert"] = EMSESP_Status.shower_alert;
|
json["shower_alert"] = EMSESP_Status.shower_alert;
|
||||||
json["publish_time"] = EMSESP_Status.publish_time;
|
json["publish_time"] = EMSESP_Status.publish_time;
|
||||||
json["heating_circuit"] = EMSESP_Status.heating_circuit;
|
json["heating_circuit"] = EMSESP_Status.heating_circuit;
|
||||||
|
json["tx_mode"] = ems_getTxMode();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1182,6 +1186,12 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
|
|||||||
myDebug_P(PSTR("Error. Usage: set heating_circuit <1 | 2>"));
|
myDebug_P(PSTR("Error. Usage: set heating_circuit <1 | 2>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tx delay/ tx mode
|
||||||
|
if (((strcmp(setting, "tx_mode") == 0) || (strcmp(setting, "tx_delay") == 0)) && (wc == 2)) {
|
||||||
|
ems_setTxMode(atoi(value));
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == MYESP_FSACTION_LIST) {
|
if (action == MYESP_FSACTION_LIST) {
|
||||||
@@ -1208,6 +1218,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_timer=%s"), EMSESP_Status.shower_timer ? "on" : "off");
|
||||||
myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Status.shower_alert ? "on" : "off");
|
myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Status.shower_alert ? "on" : "off");
|
||||||
myDebug_P(PSTR(" publish_time=%d"), EMSESP_Status.publish_time);
|
myDebug_P(PSTR(" publish_time=%d"), EMSESP_Status.publish_time);
|
||||||
|
myDebug_P(PSTR(" tx_mode=%d"), ems_getTxMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -1301,9 +1312,9 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
|
|||||||
ems_setLogging(EMS_SYS_LOGGING_THERMOSTAT);
|
ems_setLogging(EMS_SYS_LOGGING_THERMOSTAT);
|
||||||
ok = true;
|
ok = true;
|
||||||
} else if (strcmp(second_cmd, "s") == 0) {
|
} else if (strcmp(second_cmd, "s") == 0) {
|
||||||
ems_setLogging(EMS_SYS_LOGGING_SOLARMODULE );
|
ems_setLogging(EMS_SYS_LOGGING_SOLARMODULE);
|
||||||
ok = true;
|
ok = true;
|
||||||
}else if (strcmp(second_cmd, "r") == 0) {
|
} else if (strcmp(second_cmd, "r") == 0) {
|
||||||
ems_setLogging(EMS_SYS_LOGGING_RAW);
|
ems_setLogging(EMS_SYS_LOGGING_RAW);
|
||||||
ok = true;
|
ok = true;
|
||||||
} else if (strcmp(second_cmd, "n") == 0) {
|
} else if (strcmp(second_cmd, "n") == 0) {
|
||||||
|
|||||||
22
src/ems.cpp
22
src/ems.cpp
@@ -234,6 +234,7 @@ void ems_init() {
|
|||||||
EMS_Sys_Status.emsPollFrequency = 0;
|
EMS_Sys_Status.emsPollFrequency = 0;
|
||||||
EMS_Sys_Status.txRetryCount = 0;
|
EMS_Sys_Status.txRetryCount = 0;
|
||||||
EMS_Sys_Status.emsReverse = false;
|
EMS_Sys_Status.emsReverse = false;
|
||||||
|
EMS_Sys_Status.emsTxMode = 0;
|
||||||
|
|
||||||
// thermostat
|
// thermostat
|
||||||
EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
||||||
@@ -353,6 +354,23 @@ bool ems_getPoll() {
|
|||||||
return EMS_Sys_Status.emsPollEnabled;
|
return EMS_Sys_Status.emsPollEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ems_setTxMode(uint8_t mode) {
|
||||||
|
EMS_Sys_Status.emsTxMode = mode;
|
||||||
|
|
||||||
|
// special case for Junkers. If tx_mode is 3 then set the reverse poll flag
|
||||||
|
// https://github.com/proddy/EMS-ESP/issues/103#issuecomment-495945850
|
||||||
|
if (mode == 3) {
|
||||||
|
EMS_Sys_Status.emsReverse = true;
|
||||||
|
myDebug_P(PSTR("Forcing emsReverse for Junkers"));
|
||||||
|
} else {
|
||||||
|
EMS_Sys_Status.emsReverse = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ems_getTxMode() {
|
||||||
|
return EMS_Sys_Status.emsTxMode;
|
||||||
|
}
|
||||||
|
|
||||||
bool ems_getEmsRefreshed() {
|
bool ems_getEmsRefreshed() {
|
||||||
return EMS_Sys_Status.emsRefreshed;
|
return EMS_Sys_Status.emsRefreshed;
|
||||||
}
|
}
|
||||||
@@ -428,7 +446,7 @@ void ems_setLogging(_EMS_SYS_LOGGING loglevel) {
|
|||||||
myDebug_P(PSTR("System Logging set to Thermostat only"));
|
myDebug_P(PSTR("System Logging set to Thermostat only"));
|
||||||
} else if (loglevel == EMS_SYS_LOGGING_SOLARMODULE) {
|
} else if (loglevel == EMS_SYS_LOGGING_SOLARMODULE) {
|
||||||
myDebug_P(PSTR("System Logging set to Solar Module only"));
|
myDebug_P(PSTR("System Logging set to Solar Module only"));
|
||||||
}else if (loglevel == EMS_SYS_LOGGING_RAW) {
|
} else if (loglevel == EMS_SYS_LOGGING_RAW) {
|
||||||
myDebug_P(PSTR("System Logging set to Raw mode"));
|
myDebug_P(PSTR("System Logging set to Raw mode"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1506,8 +1524,6 @@ void _process_ISM1StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
* Junkers ISM1 Solar Module - type 0x0001 EMS+ for setting values
|
* Junkers ISM1 Solar Module - type 0x0001 EMS+ for setting values
|
||||||
*/
|
*/
|
||||||
void _process_ISM1Set(_EMS_RxTelegram * EMS_RxTelegram) {
|
void _process_ISM1Set(_EMS_RxTelegram * EMS_RxTelegram) {
|
||||||
|
|
||||||
|
|
||||||
if (EMS_RxTelegram->offset == 6) {
|
if (EMS_RxTelegram->offset == 6) {
|
||||||
// e.g. 90 30 FF 06 00 01 50 (CRC=2C)
|
// e.g. 90 30 FF 06 00 01 50 (CRC=2C)
|
||||||
// to implement: change max solar boiler temperature
|
// to implement: change max solar boiler temperature
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ typedef struct {
|
|||||||
bool emsTxDisabled; // true to prevent all Tx
|
bool emsTxDisabled; // true to prevent all Tx
|
||||||
uint8_t txRetryCount; // # times the last Tx was re-sent
|
uint8_t txRetryCount; // # times the last Tx was re-sent
|
||||||
bool emsReverse; // if true, poll logic is reversed
|
bool emsReverse; // if true, poll logic is reversed
|
||||||
|
uint8_t emsTxMode; // handles Tx logic
|
||||||
} _EMS_Sys_Status;
|
} _EMS_Sys_Status;
|
||||||
|
|
||||||
// The Tx send package
|
// The Tx send package
|
||||||
@@ -331,6 +332,7 @@ void ems_testTelegram(uint8_t test_num);
|
|||||||
void ems_startupTelegrams();
|
void ems_startupTelegrams();
|
||||||
bool ems_checkEMSBUSAlive();
|
bool ems_checkEMSBUSAlive();
|
||||||
void ems_clearDeviceList();
|
void ems_clearDeviceList();
|
||||||
|
void ems_setTxMode(uint8_t mode);
|
||||||
|
|
||||||
void ems_setThermostatTemp(float temperature, uint8_t temptype = 0);
|
void ems_setThermostatTemp(float temperature, uint8_t temptype = 0);
|
||||||
void ems_setThermostatMode(uint8_t mode);
|
void ems_setThermostatMode(uint8_t mode);
|
||||||
@@ -345,6 +347,7 @@ void ems_setEmsRefreshed(bool b);
|
|||||||
void ems_setWarmWaterModeComfort(uint8_t comfort);
|
void ems_setWarmWaterModeComfort(uint8_t comfort);
|
||||||
void ems_setModels();
|
void ems_setModels();
|
||||||
void ems_setTxDisabled(bool b);
|
void ems_setTxDisabled(bool b);
|
||||||
|
uint8_t ems_getTxMode();
|
||||||
|
|
||||||
char * ems_getThermostatDescription(char * buffer);
|
char * ems_getThermostatDescription(char * buffer);
|
||||||
char * ems_getBoilerDescription(char * buffer);
|
char * ems_getBoilerDescription(char * buffer);
|
||||||
|
|||||||
@@ -159,6 +159,35 @@ void ICACHE_FLASH_ATTR emsuart_start() {
|
|||||||
ETS_UART_INTR_ENABLE();
|
ETS_UART_INTR_ENABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a BRK signal
|
||||||
|
* Which is a 11-bit set of zero's (11 cycles)
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR emsuart_tx_brk() {
|
||||||
|
uint32_t tmp;
|
||||||
|
|
||||||
|
// must make sure Tx FIFO is empty
|
||||||
|
while (((USS(EMSUART_UART) >> USTXC) & 0xFF) != 0)
|
||||||
|
;
|
||||||
|
|
||||||
|
tmp = ((1 << UCRXRST) | (1 << UCTXRST)); // bit mask
|
||||||
|
USC0(EMSUART_UART) |= (tmp); // set bits
|
||||||
|
USC0(EMSUART_UART) &= ~(tmp); // clear bits
|
||||||
|
|
||||||
|
// To create a 11-bit <BRK> we set TXD_BRK bit so the break signal will
|
||||||
|
// automatically be sent when the tx fifo is empty
|
||||||
|
tmp = (1 << UCBRK);
|
||||||
|
USC0(EMSUART_UART) |= (tmp); // set bit
|
||||||
|
|
||||||
|
if (EMS_Sys_Status.emsTxMode <= 1) { // classic mode and ems+ (0, 1)
|
||||||
|
delayMicroseconds(EMSUART_TX_BRK_WAIT);
|
||||||
|
} else if (EMS_Sys_Status.emsTxMode == 3) { // junkers mode
|
||||||
|
delayMicroseconds(EMSUART_TX_WAIT_BRK - EMSUART_TX_LAG); // 1144 (11 Bits)
|
||||||
|
}
|
||||||
|
|
||||||
|
USC0(EMSUART_UART) &= ~(tmp); // clear bit
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send to Tx, ending with a <BRK>
|
* Send to Tx, ending with a <BRK>
|
||||||
*/
|
*/
|
||||||
@@ -166,6 +195,32 @@ void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// temp code until we get mode 2 working without resets
|
||||||
|
|
||||||
|
if (EMS_Sys_Status.emsTxMode == 0) { // classic mode logic
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
USF(EMSUART_UART) = buf[i];
|
||||||
|
}
|
||||||
|
emsuart_tx_brk(); // send <BRK>
|
||||||
|
} else if (EMS_Sys_Status.emsTxMode == 1) { // With extra tx delay for EMS+
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
USF(EMSUART_UART) = buf[i];
|
||||||
|
delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23#
|
||||||
|
}
|
||||||
|
emsuart_tx_brk(); // send <BRK>
|
||||||
|
} else if (EMS_Sys_Status.emsTxMode == 3) { // Junkers logic by @philrich
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
USF(EMSUART_UART) = buf[i];
|
||||||
|
|
||||||
|
// just to be safe wait for tx fifo empty (needed?)
|
||||||
|
while (((USS(EMSUART_UART) >> USTXC) & 0xff) != 0)
|
||||||
|
;
|
||||||
|
|
||||||
|
// wait until bits are sent on wire
|
||||||
|
delayMicroseconds(EMSUART_TX_WAIT_BYTE - EMSUART_TX_LAG + EMSUART_TX_WAIT_GAP);
|
||||||
|
}
|
||||||
|
emsuart_tx_brk(); // send <BRK>
|
||||||
|
} else if (EMS_Sys_Status.emsTxMode == 2) {
|
||||||
/*
|
/*
|
||||||
* based on code from https://github.com/proddy/EMS-ESP/issues/103 by @susisstrolch
|
* based on code from https://github.com/proddy/EMS-ESP/issues/103 by @susisstrolch
|
||||||
* we emit the whole telegram, with Rx interrupt disabled, collecting busmaster response in FIFO.
|
* we emit the whole telegram, with Rx interrupt disabled, collecting busmaster response in FIFO.
|
||||||
@@ -210,6 +265,7 @@ void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ETS_UART_INTR_ENABLE(); // receive anything from FIFO...
|
ETS_UART_INTR_ENABLE(); // receive anything from FIFO...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
|
|
||||||
#define EMSUART_BIT_TIME 104 // bit time @9600 baud
|
#define EMSUART_BIT_TIME 104 // bit time @9600 baud
|
||||||
|
|
||||||
|
#define EMSUART_TX_BRK_WAIT 2070 // the BRK from Boiler master is roughly 1.039ms, so accounting for hardware lag using around 2078 (for half-duplex) - 8 (lag)
|
||||||
|
#define EMSUART_TX_WAIT_BYTE EMSUART_BIT_TIME * 10 // Time to send one Byte (8 Bits, 1 Start Bit, 1 Stop Bit)
|
||||||
|
#define EMSUART_TX_WAIT_BRK EMSUART_BIT_TIME * 11 // Time to send a BRK Signal (11 Bit)
|
||||||
|
#define EMSUART_TX_WAIT_GAP EMSUART_BIT_TIME * 7 // Gap between to Bytes
|
||||||
|
#define EMSUART_TX_LAG 8
|
||||||
|
|
||||||
#define EMSUART_recvTaskPrio 1
|
#define EMSUART_recvTaskPrio 1
|
||||||
#define EMSUART_recvTaskQueueLen 64
|
#define EMSUART_recvTaskQueueLen 64
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define APP_NAME "EMS-ESP"
|
#define APP_NAME "EMS-ESP"
|
||||||
#define APP_VERSION "1.8.1b4"
|
#define APP_VERSION "1.8.1b5"
|
||||||
#define APP_HOSTNAME "ems-esp"
|
#define APP_HOSTNAME "ems-esp"
|
||||||
|
|||||||
Reference in New Issue
Block a user