[uponor_smatrix] Modifies sending algorithm (#7326)

Co-authored-by: Rafa Treviño <rafael.trevino@bbva.com>
This commit is contained in:
Rafael Treviño 2024-09-11 07:16:52 +02:00 committed by GitHub
parent 04248b6840
commit e3ae8cd31e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -45,11 +45,8 @@ void UponorSmatrixComponent::loop() {
// Read incoming data
while (this->available()) {
// The controller polls devices every 10 seconds, with around 200 ms between devices.
// Remember timestamps so we can send our own packets when the bus is expected to be silent.
if (now - this->last_rx_ > 500) {
this->last_poll_start_ = now;
}
// The controller polls devices every 10 seconds in some units or continuously in others with around 200 ms between
// devices. Remember timestamps so we can send our own packets when the bus is expected to be silent.
this->last_rx_ = now;
uint8_t byte;
@ -60,7 +57,8 @@ void UponorSmatrixComponent::loop() {
}
// Send packets during bus silence
if ((now - this->last_rx_ > 300) && (now - this->last_poll_start_ < 9500) && (now - this->last_tx_ > 200)) {
if (this->rx_buffer_.empty() && (now - this->last_rx_ > 50) && (now - this->last_rx_ < 100) &&
(now - this->last_tx_ > 200)) {
#ifdef USE_TIME
// Only build time packet when bus is silent and queue is empty to make sure we can send it right away
if (this->send_time_requested_ && this->tx_queue_.empty() && this->do_send_time_())

View file

@ -93,7 +93,6 @@ class UponorSmatrixComponent : public uart::UARTDevice, public Component {
std::queue<std::vector<uint8_t>> tx_queue_;
uint32_t last_rx_;
uint32_t last_tx_;
uint32_t last_poll_start_;
#ifdef USE_TIME
time::RealTimeClock *time_id_{nullptr};