Read long telegrams complete

This commit is contained in:
MichaelDvP
2020-10-12 17:54:21 +02:00
parent 7dca8dfe2d
commit a9041b7818
4 changed files with 11 additions and 1 deletions

View File

@@ -162,7 +162,6 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
for (uint8_t i = 0; i < set_typeids.size(); i++) {
EMSESP::send_read_request(set_typeids[i], device_id);
EMSESP::send_read_request(set_typeids[i], device_id, 0x1B);
}
for (uint8_t i = 0; i < summer_typeids.size(); i++) {

View File

@@ -790,6 +790,10 @@ 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 (length == 32) {
txservice_.read_next_tx();
}
}
}

View File

@@ -567,6 +567,12 @@ 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);
}
void TxService::read_next_tx() {
// add to the top of the queue
uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes
add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, true);
}
// checks if a telegram is sent to us matches the last Tx request
// incoming Rx src must match the last Tx dest
// and incoming Rx dest must be us (our ems_bus_id)

View File

@@ -284,6 +284,7 @@ class TxService : public EMSbus {
void retry_tx(const uint8_t operation, const uint8_t * data, const uint8_t length);
bool is_last_tx(const uint8_t src, const uint8_t dest) const;
uint16_t post_send_query();
void read_next_tx();
uint8_t retry_count() const {
return retry_count_;