Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Jan 20, 2022
2 parents b658662 + 02e2b51 commit 29110e9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ 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).

# Changelog
# [3.3.1] January 20 2022

- lastcode broke MQTT JSON structure [#228](https://github.com/emsesp/EMS-ESP32/issues/228)
- overlapping while reading sequence of EMS1.0 telegrams
- redundant telegram readings (because of offset overflow)
- added missing RC30/Moduline400 [#243](https://github.com/emsesp/EMS-ESP32/issues/243)
- check received status before toggling fetch on empty telegram [#268][#282]

# [3.3.0] November 28 2021

Expand Down
9 changes: 5 additions & 4 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,11 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {

// 0xC2
void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram) {
// not sure why this test is in , so removing
// if (telegram->offset > 0 || telegram->message_length < 14) {
// return;
// }
// for decoding "last error code" we need telegram starting with offset 0
if (telegram->offset != 0 || telegram->message_length < 20) {
return;
}

char code[4];
uint16_t codeNo;
char start_time[17];
Expand Down
14 changes: 14 additions & 0 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,17 @@ void Thermostat::register_device_values() {
case EMS_DEVICE_FLAG_RC20:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
break;
case EMS_DEVICE_FLAG_RC30:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
register_device_value(TAG_THERMOSTAT_DATA, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE);
register_device_value(TAG_THERMOSTAT_DATA, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), FL_(ibaLanguage), DeviceValueUOM::NONE);
register_device_value(TAG_THERMOSTAT_DATA,
&ibaClockOffset_,
DeviceValueType::INT,
nullptr,
FL_(ibaClockOffset),
DeviceValueUOM::SECONDS); // offset (in sec) to clock, 0xff=-1s, 0x02=2s
break;
case EMS_DEVICE_FLAG_RC30_N:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
register_device_value(TAG_THERMOSTAT_DATA, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE);
Expand Down Expand Up @@ -2940,6 +2951,9 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->summertemp, DeviceValueType::UINT, nullptr, FL_(summertemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_summertemp));
register_device_value(tag, &hc->summermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::NONE);
break;
case EMS_DEVICE_FLAG_RC30:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode3), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));
break;
case EMS_DEVICE_FLAG_RC30_N:
case EMS_DEVICE_FLAG_RC35:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode3), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));
Expand Down
13 changes: 7 additions & 6 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void EMSdevice::show_mqtt_handlers(uuid::console::Shell & shell) {

// register a callback function for a specific telegram type
void EMSdevice::register_telegram_type(const uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, const process_function_p f) {
telegram_functions_.emplace_back(telegram_type_id, telegram_type_name, fetch, f);
telegram_functions_.emplace_back(telegram_type_id, telegram_type_name, fetch, false, f);
}

// add to device value library, also know now as a "device entity"
Expand Down Expand Up @@ -1156,17 +1156,18 @@ const std::string EMSdevice::telegram_type_name(std::shared_ptr<const Telegram>
// take a telegram_type_id and call the matching handler
// return true if match found
bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
for (const auto & tf : telegram_functions_) {
for (auto & tf : telegram_functions_) {
if (tf.telegram_type_id_ == telegram->type_id) {
// if the data block is empty, assume that this telegram is not recognized by the bus master
// so remove it from the automatic fetch list
if (telegram->message_length == 0 && telegram->offset == 0) {
// if the data block is empty and we have not received data before, assume that this telegram
// is not recognized by the bus master. So remove it from the automatic fetch list
if (telegram->message_length == 0 && telegram->offset == 0 && !tf.received_) {
EMSESP::logger().debug(F("This telegram (%s) is not recognized by the EMS bus"), read_flash_string(tf.telegram_type_name_).c_str());
toggle_fetch(tf.telegram_type_id_, false);
tf.fetch_ = false;
return false;
}

if (telegram->message_length > 0) {
tf.received_ = true;
tf.process_function_(telegram);
}

Expand Down
4 changes: 3 additions & 1 deletion src/emsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,14 @@ class EMSdevice {
uint16_t telegram_type_id_; // it's type_id
const __FlashStringHelper * telegram_type_name_; // e.g. RC20Message
bool fetch_; // if this type_id be queried automatically
bool received_;
process_function_p process_function_;

TelegramFunction(uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, const process_function_p process_function)
TelegramFunction(uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, bool received, const process_function_p process_function)
: telegram_type_id_(telegram_type_id)
, telegram_type_name_(telegram_type_name)
, fetch_(fetch)
, received_(received)
, process_function_(process_function) {
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
txservice_.send_poll(); // close the bus
txservice_.reset_retry_count();
tx_successful = true;
// if telegram is longer read next part with offset + 25 for ems+
// if telegram is longer read next part with offset +25 for ems+ or +27 for ems1.0
if (length == 32) {
if (txservice_.read_next_tx(data[3]) == read_id_) {
read_next_ = true;
Expand Down
13 changes: 12 additions & 1 deletion src/telegram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,24 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
tx_telegrams_.emplace_front(tx_telegram_id_++, std::move(telegram_last_), true, get_post_send_query());
}

// send a request to read the next block of data from longer telegrams
uint16_t TxService::read_next_tx(uint8_t offset) {
// add to the top/front of the queue
uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes
if (telegram_last_->offset != offset) {
return 0;
}
add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, 0, true);

uint8_t add_offset = 25; // for EMS+ telegram increase offset by 25
if (telegram_last_->type_id < 0x100) { // but for EMS1.0 by 27
add_offset = 27;
}

if (UINT8_MAX - telegram_last_->offset < add_offset) { // stop if new offset would overflow
return 0;
}

add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + add_offset, message_data, 1, 0, true);
return telegram_last_->type_id;
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.3.0"
#define EMSESP_APP_VERSION "3.3.1"

0 comments on commit 29110e9

Please sign in to comment.