mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
post-send-query delay for some telegrams
This commit is contained in:
@@ -278,11 +278,12 @@ void TxService::send() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there's nothing in the queue to transmit, send back a poll and quit
|
// if there's nothing in the queue to transmit or sending should be delayed, send back a poll and quit
|
||||||
if (tx_telegrams_.empty()) {
|
if (tx_telegrams_.empty() || (delayed_send_ && uuid::get_uptime() < (delayed_send_ + POST_SEND_DELAY))) {
|
||||||
send_poll();
|
send_poll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
delayed_send_ = 0;
|
||||||
|
|
||||||
// auto telegram = tx_telegrams_.pop(); // get the Telegram, also removes from queue
|
// auto telegram = tx_telegrams_.pop(); // get the Telegram, also removes from queue
|
||||||
|
|
||||||
@@ -662,7 +663,9 @@ uint16_t TxService::post_send_query() {
|
|||||||
// read_request(telegram_last_post_send_query_, dest, 0); // no offset
|
// read_request(telegram_last_post_send_query_, dest, 0); // no offset
|
||||||
LOG_DEBUG(F("Sending post validate read, type ID 0x%02X to dest 0x%02X"), post_typeid, dest);
|
LOG_DEBUG(F("Sending post validate read, type ID 0x%02X to dest 0x%02X"), post_typeid, dest);
|
||||||
set_post_send_query(0); // reset
|
set_post_send_query(0); // reset
|
||||||
}
|
// delay the request if we have a different type_id for post_send_query
|
||||||
|
delayed_send_ = (this->telegram_last_->type_id == post_typeid) ? 0 : uuid::get_uptime();
|
||||||
|
}
|
||||||
|
|
||||||
return post_typeid;
|
return post_typeid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,6 +376,7 @@ class TxService : public EMSbus {
|
|||||||
#else
|
#else
|
||||||
static constexpr uint8_t MAXIMUM_TX_RETRIES = 3;
|
static constexpr uint8_t MAXIMUM_TX_RETRIES = 3;
|
||||||
#endif
|
#endif
|
||||||
|
static constexpr uint32_t POST_SEND_DELAY = 2000;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<QueuedTxTelegram> tx_telegrams_; // the Tx queue
|
std::deque<QueuedTxTelegram> tx_telegrams_; // the Tx queue
|
||||||
@@ -387,7 +388,8 @@ class TxService : public EMSbus {
|
|||||||
|
|
||||||
std::shared_ptr<Telegram> telegram_last_;
|
std::shared_ptr<Telegram> telegram_last_;
|
||||||
uint16_t telegram_last_post_send_query_; // which type ID to query after a successful send, to read back the values just written
|
uint16_t telegram_last_post_send_query_; // which type ID to query after a successful send, to read back the values just written
|
||||||
uint8_t retry_count_ = 0; // count for # Tx retries
|
uint8_t retry_count_ = 0; // count for # Tx retries
|
||||||
|
uint32_t delayed_send_ = 0; // manage delay for post send query
|
||||||
|
|
||||||
uint8_t tx_telegram_id_ = 0; // queue counter
|
uint8_t tx_telegram_id_ = 0; // queue counter
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user