tx_mode changes for EMS+

This commit is contained in:
Paul
2019-09-25 21:49:12 +02:00
parent e546f34a3e
commit 92d6337876
4 changed files with 14 additions and 10 deletions

View File

@@ -369,7 +369,7 @@ void MyESP::mqttSubscribe(const char * topic) {
//char topic_s[MQTT_MAX_TOPIC_SIZE]; //char topic_s[MQTT_MAX_TOPIC_SIZE];
//strlcpy(topic_s, _mqttTopic(topic), sizeof(topic_s)); //strlcpy(topic_s, _mqttTopic(topic), sizeof(topic_s));
(void)mqttClient.subscribe(topic_s, _mqtt_qos); (void)mqttClient.subscribe(topic_s, _mqtt_qos);
myDebug_P(PSTR("[MQTT] Subscribing to %s"), topic_s); // myDebug_P(PSTR("[MQTT] Subscribing to %s"), topic_s);
// add to mqtt log // add to mqtt log
_addMQTTLog(topic_s, "", 2); // type of 2 means Subscribe. Has an empty payload for now _addMQTTLog(topic_s, "", 2); // type of 2 means Subscribe. Has an empty payload for now

View File

@@ -1211,7 +1211,7 @@ bool LoadSaveCallback(MYESP_FSACTION action, JsonObject settings) {
EMSESP_Settings.listen_mode = settings["listen_mode"]; EMSESP_Settings.listen_mode = settings["listen_mode"];
ems_setTxDisabled(EMSESP_Settings.listen_mode); ems_setTxDisabled(EMSESP_Settings.listen_mode);
EMSESP_Settings.tx_mode = settings["tx_mode"] | 1; // default to 1 (generic) EMSESP_Settings.tx_mode = settings["tx_mode"] | EMS_TXMODE_DEFAULT; // default to 1 (generic)
ems_setTxMode(EMSESP_Settings.tx_mode); ems_setTxMode(EMSESP_Settings.tx_mode);
return true; return true;
@@ -1336,7 +1336,7 @@ bool SetListCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, co
// tx_mode // tx_mode
if ((strcmp(setting, "tx_mode") == 0) && (wc == 2)) { if ((strcmp(setting, "tx_mode") == 0) && (wc == 2)) {
uint8_t mode = atoi(value); uint8_t mode = atoi(value);
if ((mode >= 1) && (mode <= 3)) { if ((mode >= 1) && (mode <= 3)) { // see ems.h for definitions
EMSESP_Settings.tx_mode = mode; EMSESP_Settings.tx_mode = mode;
ems_setTxMode(mode); ems_setTxMode(mode);
ok = true; ok = true;
@@ -1979,7 +1979,7 @@ void initEMSESP() {
EMSESP_Settings.dallas_sensors = 0; EMSESP_Settings.dallas_sensors = 0;
EMSESP_Settings.led_gpio = EMSESP_LED_GPIO; EMSESP_Settings.led_gpio = EMSESP_LED_GPIO;
EMSESP_Settings.dallas_gpio = EMSESP_DALLAS_GPIO; EMSESP_Settings.dallas_gpio = EMSESP_DALLAS_GPIO;
EMSESP_Settings.tx_mode = 1; // default tx mode EMSESP_Settings.tx_mode = EMS_TXMODE_DEFAULT; // default tx mode
// shower settings // shower settings
EMSESP_Shower.timerStart = 0; EMSESP_Shower.timerStart = 0;

View File

@@ -72,6 +72,11 @@
#endif #endif
// clang-format on // clang-format on
// EMS tx_mode types
#define EMS_TXMODE_DEFAULT 1 // Default (was previously known as tx_mode 2)
#define EMS_TXMODE_EMSPLUS 2 // EMS+
#define EMS_TXMODE_HT3 3 // Junkers HT3
#define EMS_ID_NONE 0x00 // used as a dest in broadcast messages and empty device IDs #define EMS_ID_NONE 0x00 // used as a dest in broadcast messages and empty device IDs
// Fixed EMS IDs // Fixed EMS IDs
@@ -98,7 +103,6 @@
#define EMS_VALUE_USHORT_NOTSET 0x8000 // for 2-byte unsigned shorts #define EMS_VALUE_USHORT_NOTSET 0x8000 // for 2-byte unsigned shorts
#define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs #define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs
// thermostat specific // thermostat specific
#define EMS_THERMOSTAT_MAXHC 4 // max number of heating circuits #define EMS_THERMOSTAT_MAXHC 4 // max number of heating circuits
#define EMS_THERMOSTAT_DEFAULTHC 1 // default heating circuit is 1 #define EMS_THERMOSTAT_DEFAULTHC 1 // default heating circuit is 1

View File

@@ -191,9 +191,9 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
GPIO_H(TX_MARK_MASK); GPIO_H(TX_MARK_MASK);
USC0(EMSUART_UART) |= (tmp); // set bit USC0(EMSUART_UART) |= (tmp); // set bit
if (EMS_Sys_Status.emsTxMode <= 1) { // classic mode and ems+ (0, 1) if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // EMS+ mode
delayMicroseconds(EMSUART_TX_BRK_WAIT); delayMicroseconds(EMSUART_TX_BRK_WAIT);
} else if (EMS_Sys_Status.emsTxMode == 3) { // junkers mode } else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_HT3) { // junkers mode
delayMicroseconds(EMSUART_TX_WAIT_BRK - EMSUART_TX_LAG); // 1144 (11 Bits) delayMicroseconds(EMSUART_TX_WAIT_BRK - EMSUART_TX_LAG); // 1144 (11 Bits)
} }
@@ -214,14 +214,14 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
if (len) { if (len) {
LA_PULSE(50); LA_PULSE(50);
if (EMS_Sys_Status.emsTxMode == 2) { // With extra tx delay for EMS+ if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // With extra tx delay for EMS+
for (uint8_t i = 0; i < len; i++) { for (uint8_t i = 0; i < len; i++) {
TX_PULSE(EMSUART_BIT_TIME / 4); TX_PULSE(EMSUART_BIT_TIME / 4);
USF(EMSUART_UART) = buf[i]; USF(EMSUART_UART) = buf[i];
delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23# delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23#
} }
emsuart_tx_brk(); // send <BRK> emsuart_tx_brk(); // send <BRK>
} else if (EMS_Sys_Status.emsTxMode == 3) { // Junkers logic by @philrich } else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_HT3) { // Junkers logic by @philrich
for (uint8_t i = 0; i < len; i++) { for (uint8_t i = 0; i < len; i++) {
TX_PULSE(EMSUART_BIT_TIME / 4); TX_PULSE(EMSUART_BIT_TIME / 4);
USF(EMSUART_UART) = buf[i]; USF(EMSUART_UART) = buf[i];
@@ -234,7 +234,7 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
delayMicroseconds(EMSUART_TX_WAIT_BYTE - EMSUART_TX_LAG + EMSUART_TX_WAIT_GAP); delayMicroseconds(EMSUART_TX_WAIT_BYTE - EMSUART_TX_LAG + EMSUART_TX_WAIT_GAP);
} }
emsuart_tx_brk(); // send <BRK> emsuart_tx_brk(); // send <BRK>
} else if (EMS_Sys_Status.emsTxMode == 1) { } else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_DEFAULT) {
/* /*
* 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.