Junkers modes sorted.

This commit is contained in:
MichaelDvP
2020-06-30 16:36:45 +02:00
parent 876489494f
commit 1b00a4405b
5 changed files with 63 additions and 43 deletions

View File

@@ -261,6 +261,12 @@ void Thermostat::thermostat_cmd(const char * message) {
if (float f = doc[hc_name]["nofrosttemp"]) { if (float f = doc[hc_name]["nofrosttemp"]) {
set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num); set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num);
} }
if (float f = doc[hc_name]["ecotemp"]) {
set_temperature(f, HeatingCircuit::Mode::ECO, hc_num);
}
if (float f = doc[hc_name]["heattemp"]) {
set_temperature(f, HeatingCircuit::Mode::HEAT, hc_num);
}
if (float f = doc[hc_name]["summertemp"]) { if (float f = doc[hc_name]["summertemp"]) {
set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num); set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num);
} }
@@ -341,6 +347,12 @@ void Thermostat::thermostat_cmd(const char * message) {
if (float f = doc["nofrosttemp"]) { if (float f = doc["nofrosttemp"]) {
set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num); set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num);
} }
if (float f = doc["ecotemp"]) {
set_temperature(f, HeatingCircuit::Mode::ECO, hc_num);
}
if (float f = doc["heattemp"]) {
set_temperature(f, HeatingCircuit::Mode::HEAT, hc_num);
}
if (float f = doc["summertemp"]) { if (float f = doc["summertemp"]) {
set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num); set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num);
} }
@@ -785,6 +797,8 @@ uint8_t Thermostat::HeatingCircuit::get_mode(uint8_t flags) const {
return HeatingCircuit::Mode::MANUAL; return HeatingCircuit::Mode::MANUAL;
} else if (mode == 2) { } else if (mode == 2) {
return HeatingCircuit::Mode::AUTO; return HeatingCircuit::Mode::AUTO;
} else if (mode == 3) {
return HeatingCircuit::Mode::HOLIDAY;
} }
} else { // default for all other thermostats } else { // default for all other thermostats
if (mode == 0) { if (mode == 0) {
@@ -806,9 +820,11 @@ uint8_t Thermostat::HeatingCircuit::get_mode_type(uint8_t flags) const {
if (flags == EMS_DEVICE_FLAG_JUNKERS) { if (flags == EMS_DEVICE_FLAG_JUNKERS) {
if (mode_type == 3) { if (mode_type == 3) {
return HeatingCircuit::Mode::DAY; return HeatingCircuit::Mode::HEAT;
} else if (mode == 2) { } else if (mode == 2) {
return HeatingCircuit::Mode::NIGHT; return HeatingCircuit::Mode::ECO;
} else if (mode == 1) {
return HeatingCircuit::Mode::NOFROST;
} }
} else if ((flags == EMS_DEVICE_FLAG_RC35) || (flags == EMS_DEVICE_FLAG_RC30_1)) { } else if ((flags == EMS_DEVICE_FLAG_RC35) || (flags == EMS_DEVICE_FLAG_RC30_1)) {
if (mode_type == 0) { if (mode_type == 0) {
@@ -1130,7 +1146,7 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr<const Telegram> telegram
telegram->read_value(hc->curr_roomTemp, 4); // value is * 10 telegram->read_value(hc->curr_roomTemp, 4); // value is * 10
telegram->read_value(hc->setpoint_roomTemp, 2); // value is * 10 telegram->read_value(hc->setpoint_roomTemp, 2); // value is * 10
telegram->read_bitvalue(hc->mode_type, 0, 0); // first bit 1=day, 0=night telegram->read_value(hc->mode_type, 0); // 1 = nofrost, 2 = eco, 3 = heat
telegram->read_value(hc->mode, 1); // 1 = manual, 2 = auto telegram->read_value(hc->mode, 1); // 1 = manual, 2 = auto
} }
@@ -1458,7 +1474,7 @@ void Thermostat::set_mode(const uint8_t mode, const uint8_t hc_num) {
validate_typeid = monitor_typeids[hc_p]; validate_typeid = monitor_typeids[hc_p];
if (mode == HeatingCircuit::Mode::NOFROST) { if (mode == HeatingCircuit::Mode::NOFROST) {
set_mode_value = 0x01; set_mode_value = 0x01;
} else if (mode == HeatingCircuit::Mode::ECO) { } else if (mode == HeatingCircuit::Mode::ECO || (mode == HeatingCircuit::Mode::NIGHT)) {
set_mode_value = 0x02; set_mode_value = 0x02;
} else if ((mode == HeatingCircuit::Mode::DAY) || (mode == HeatingCircuit::Mode::HEAT)) { } else if ((mode == HeatingCircuit::Mode::DAY) || (mode == HeatingCircuit::Mode::HEAT)) {
set_mode_value = 0x03; // comfort set_mode_value = 0x03; // comfort
@@ -1603,15 +1619,17 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp; offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp;
break; break;
case HeatingCircuit::Mode::NIGHT: case HeatingCircuit::Mode::NIGHT:
case HeatingCircuit::Mode::ECO:
offset = EMS_OFFSET_JunkersSetMessage_night_temp; offset = EMS_OFFSET_JunkersSetMessage_night_temp;
break; break;
case HeatingCircuit::Mode::HEAT:
case HeatingCircuit::Mode::DAY: case HeatingCircuit::Mode::DAY:
offset = EMS_OFFSET_JunkersSetMessage_day_temp; offset = EMS_OFFSET_JunkersSetMessage_day_temp;
break; break;
default: default:
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
uint8_t mode_type = hc->get_mode_type(flags()); uint8_t mode_type = hc->get_mode_type(flags());
offset = (mode_type == HeatingCircuit::Mode::NIGHT) ? EMS_OFFSET_JunkersSetMessage_night_temp : EMS_OFFSET_JunkersSetMessage_day_temp; offset = (mode_type == HeatingCircuit::Mode::NIGHT || mode_type == HeatingCircuit::Mode::ECO) ? EMS_OFFSET_JunkersSetMessage_night_temp : EMS_OFFSET_JunkersSetMessage_day_temp;
break; break;
} }
@@ -1622,10 +1640,12 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp; offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp;
break; break;
case HeatingCircuit::Mode::ECO: case HeatingCircuit::Mode::ECO:
case HeatingCircuit::Mode::NIGHT:
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp; offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
break; break;
default: default:
case HeatingCircuit::Mode::HEAT: case HeatingCircuit::Mode::HEAT:
case HeatingCircuit::Mode::DAY:
offset = EMS_OFFSET_JunkersSetMessage3_heat; offset = EMS_OFFSET_JunkersSetMessage3_heat;
break; break;
} }

View File

@@ -188,7 +188,7 @@ class Thermostat : public EMSdevice {
static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_setpoint = 8; // temp setpoint, when changing of templevel (in auto) value is reset to FF static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_setpoint = 8; // temp setpoint, when changing of templevel (in auto) value is reset to FF
static constexpr uint8_t EMS_OFFSET_RCPLUSSet_manual_setpoint = 10; // manual setpoint static constexpr uint8_t EMS_OFFSET_RCPLUSSet_manual_setpoint = 10; // manual setpoint
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_daymode = 0; // 3 = day, 2 = night static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_daymode = 0; // 3 = day, 2 = night, 1 = nofrost
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_mode = 1; // current mode, 1 = manual, 2 = auto static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_mode = 1; // current mode, 1 = manual, 2 = auto
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_setpoint = 2; // setpoint temp static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_setpoint = 2; // setpoint temp
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_curr = 4; // current temp static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_curr = 4; // current temp

View File

@@ -868,7 +868,7 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
uint8_t watch = emsesp::EMSESP::watch(); uint8_t watch = emsesp::EMSESP::watch();
if (watch == WATCH_OFF) { if (watch == WATCH_OFF) {
shell.printfln(F("Watch is off")); shell.printfln(F("Watching telegrams is off"));
return; return;
} }

View File

@@ -85,19 +85,38 @@ std::string Telegram::to_string() const {
if (message_length == 0) { if (message_length == 0) {
return read_flash_string(F("<empty>")); return read_flash_string(F("<empty>"));
} }
uint8_t data[EMS_MAX_TELEGRAM_LENGTH];
std::string str(160, '\0'); uint8_t length = 0;
char buffer[4]; data[0] = this->src ^ RxService::ems_mask();
char * p = &str[0]; if (this->operation == Telegram::Operation::TX_READ) {
for (uint8_t i = 0; i < this->message_length; i++) { data[1] = this->dest | 0x80;
Helpers::hextoa(buffer, this->message_data[i]); data[4] = this->message_data[0];
*p++ = buffer[0]; if (this->type_id > 0xFF) {
*p++ = buffer[1]; data[2] = 0xFF;
*p++ = ' '; // space data[5] = (this->type_id >> 8) - 1;
data[6] = this->type_id & 0xFF;
length = 7;
} else {
data[2] = this->type_id;
length = 5;
} }
*--p = '\0'; // null terminate just in case, loosing the trailing space }
if (this->operation == Telegram::Operation::TX_WRITE) {
return str; data[1] = this->dest;
if (this->type_id > 0xFF) {
data[2] = 0xFF;
data[4] = (this->type_id >> 8) - 1;
data[5] = this->type_id & 0xFF;
length = 6;
} else {
data[2] = this->type_id;
length = 4;
}
for (uint8_t i = 0; i < this->message_length; i++) {
data[length++] = this->message_data[i];
}
}
return Helpers::data_to_hex(data, length);
} }
// returns telegram's full telegram message in hex // returns telegram's full telegram message in hex
@@ -538,7 +557,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
return; return;
} }
LOG_DEBUG(F("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message data: %s, received: %s"), LOG_DEBUG(F("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s"),
(operation == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"), (operation == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"),
retry_count_, retry_count_,
telegram_last_->to_string().c_str(), telegram_last_->to_string().c_str(),

View File

@@ -60,7 +60,7 @@ void EMSuart::emsuart_recvTask(void * para) {
void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) { void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) {
static uint8_t rxbuf[EMS_MAXBUFFERSIZE]; static uint8_t rxbuf[EMS_MAXBUFFERSIZE];
static uint8_t length; static uint8_t length;
UART_MUTEX_LOCK();
if (EMS_UART.int_st.rxfifo_full) { if (EMS_UART.int_st.rxfifo_full) {
EMS_UART.int_clr.rxfifo_full = 1; EMS_UART.int_clr.rxfifo_full = 1;
emsTxBufIdx++; emsTxBufIdx++;
@@ -93,7 +93,6 @@ void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) {
xRingbufferSendFromISR(buf_handle, rxbuf, length - 1, &baseType); xRingbufferSendFromISR(buf_handle, rxbuf, length - 1, &baseType);
} }
drop_next_rx = false; drop_next_rx = false;
UART_MUTEX_UNLOCK();
} }
} }
@@ -102,17 +101,16 @@ void IRAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() {
if (emsTxBufIdx > EMS_MAXBUFFERSIZE) { if (emsTxBufIdx > EMS_MAXBUFFERSIZE) {
return; return;
} }
UART_MUTEX_LOCK();
emsTxBufIdx++; emsTxBufIdx++;
if (emsTxBufIdx < emsTxBufLen) { if (emsTxBufIdx < emsTxBufLen) {
EMS_UART.fifo.rw_byte = emsTxBuf[emsTxBufIdx]; EMS_UART.fifo.rw_byte = emsTxBuf[emsTxBufIdx];
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false); timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer); timerAlarmEnable(timer);
} else if (emsTxBufIdx == emsTxBufLen) { } else if (emsTxBufIdx == emsTxBufLen) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send EMS_UART.conf0.txd_brk = 1; // <brk> after send
} }
UART_MUTEX_UNLOCK();
} }
/* /*
@@ -126,7 +124,6 @@ void EMSuart::start(uint8_t tx_mode) {
return; return;
} }
tx_mode_ = tx_mode; tx_mode_ = tx_mode;
UART_MUTEX_LOCK();
uart_config_t uart_config = { uart_config_t uart_config = {
.baud_rate = EMSUART_BAUD, .baud_rate = EMSUART_BAUD,
@@ -151,24 +148,20 @@ void EMSuart::start(uint8_t tx_mode) {
emsTxBufLen = 0; emsTxBufLen = 0;
timer = timerBegin(1, 80, true); // timer prescale to 1 µs, countup timer = timerBegin(1, 80, true); // timer prescale to 1 µs, countup
timerAttachInterrupt(timer, &emsuart_tx_timer_intr_handler, true); // Timer with edge interrupt timerAttachInterrupt(timer, &emsuart_tx_timer_intr_handler, true); // Timer with edge interrupt
UART_MUTEX_UNLOCK();
} }
/* /*
* Stop, disables interrupt * Stop, disables interrupt
*/ */
void EMSuart::stop() { void EMSuart::stop() {
UART_MUTEX_LOCK();
EMS_UART.int_ena.val = 0; // disable all intr. EMS_UART.int_ena.val = 0; // disable all intr.
// timerAlarmDisable(timer); // timerAlarmDisable(timer);
UART_MUTEX_UNLOCK();
}; };
/* /*
* Restart Interrupt * Restart Interrupt
*/ */
void EMSuart::restart() { void EMSuart::restart() {
UART_MUTEX_LOCK();
if (EMS_UART.int_raw.brk_det) { if (EMS_UART.int_raw.brk_det) {
EMS_UART.int_clr.brk_det = 1; // clear flag EMS_UART.int_clr.brk_det = 1; // clear flag
drop_next_rx = true; // and drop first frame drop_next_rx = true; // and drop first frame
@@ -176,7 +169,6 @@ void EMSuart::restart() {
EMS_UART.int_ena.brk_det = 1; // activate only break EMS_UART.int_ena.brk_det = 1; // activate only break
emsTxBufIdx = 0; emsTxBufIdx = 0;
emsTxBufLen = 0; emsTxBufLen = 0;
UART_MUTEX_UNLOCK();
} }
/* /*
@@ -184,12 +176,10 @@ void EMSuart::restart() {
*/ */
void EMSuart::send_poll(uint8_t data) { void EMSuart::send_poll(uint8_t data) {
// if (tx_mode_ >= 6 || tx_mode_ < 4) { // modes 1, 2, 3 also here // if (tx_mode_ >= 6 || tx_mode_ < 4) { // modes 1, 2, 3 also here
UART_MUTEX_LOCK();
if (tx_mode_ >= 5) { if (tx_mode_ >= 5) {
EMS_UART.fifo.rw_byte = data; EMS_UART.fifo.rw_byte = data;
emsTxBufIdx = 0; emsTxBufIdx = 0;
emsTxBufLen = 1; emsTxBufLen = 1;
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false); timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer); timerAlarmEnable(timer);
} else if (tx_mode_ == 5) { } else if (tx_mode_ == 5) {
@@ -222,7 +212,6 @@ void EMSuart::send_poll(uint8_t data) {
} }
EMS_UART.conf0.txd_brk = 1; // <brk> EMS_UART.conf0.txd_brk = 1; // <brk>
} }
UART_MUTEX_UNLOCK();
} }
/* /*
@@ -234,7 +223,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
if (len == 0 || len >= EMS_MAXBUFFERSIZE) { if (len == 0 || len >= EMS_MAXBUFFERSIZE) {
return EMS_TX_STATUS_ERR; return EMS_TX_STATUS_ERR;
} }
UART_MUTEX_LOCK();
// if (tx_mode_ >= 6 || tx_mode_ < 4) { // timer controlled modes, also modes 1, 2, 3 because delays not working // if (tx_mode_ >= 6 || tx_mode_ < 4) { // timer controlled modes, also modes 1, 2, 3 because delays not working
if (tx_mode_ >= 5) { // timer controlled modes if (tx_mode_ >= 5) { // timer controlled modes
@@ -244,10 +232,8 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.fifo.rw_byte = buf[0]; EMS_UART.fifo.rw_byte = buf[0];
emsTxBufIdx = 0; emsTxBufIdx = 0;
emsTxBufLen = len; emsTxBufLen = len;
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false); timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer); timerAlarmEnable(timer);
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }
@@ -260,7 +246,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
emsTxBufLen = len; emsTxBufLen = len;
EMS_UART.conf1.rxfifo_full_thrhd = 1; EMS_UART.conf1.rxfifo_full_thrhd = 1;
EMS_UART.int_ena.rxfifo_full = 1; EMS_UART.int_ena.rxfifo_full = 1;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }
@@ -269,7 +254,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.fifo.rw_byte = buf[i]; EMS_UART.fifo.rw_byte = buf[i];
} }
EMS_UART.conf0.txd_brk = 1; // <brk> after send EMS_UART.conf0.txd_brk = 1; // <brk> after send
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }
@@ -281,7 +265,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK); // delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0; // EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }
@@ -293,7 +276,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK); // delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0; // EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }
@@ -312,7 +294,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK); // delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0; // EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK; return EMS_TX_STATUS_OK;
} }