mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
post-send-query delay for some telegrams
This commit is contained in:
@@ -278,11 +278,12 @@ void TxService::send() {
|
||||
return;
|
||||
}
|
||||
|
||||
// if there's nothing in the queue to transmit, send back a poll and quit
|
||||
if (tx_telegrams_.empty()) {
|
||||
// if there's nothing in the queue to transmit or sending should be delayed, send back a poll and quit
|
||||
if (tx_telegrams_.empty() || (delayed_send_ && uuid::get_uptime() < (delayed_send_ + POST_SEND_DELAY))) {
|
||||
send_poll();
|
||||
return;
|
||||
}
|
||||
delayed_send_ = 0;
|
||||
|
||||
// auto telegram = tx_telegrams_.pop(); // get the Telegram, also removes from queue
|
||||
|
||||
@@ -662,6 +663,8 @@ uint16_t TxService::post_send_query() {
|
||||
// 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);
|
||||
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;
|
||||
|
||||
@@ -376,6 +376,7 @@ class TxService : public EMSbus {
|
||||
#else
|
||||
static constexpr uint8_t MAXIMUM_TX_RETRIES = 3;
|
||||
#endif
|
||||
static constexpr uint32_t POST_SEND_DELAY = 2000;
|
||||
|
||||
private:
|
||||
std::deque<QueuedTxTelegram> tx_telegrams_; // the Tx queue
|
||||
@@ -388,6 +389,7 @@ class TxService : public EMSbus {
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user