Skip to content

Commit

Permalink
Fixing proxy message sending 3
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldn committed Feb 6, 2024
1 parent 2c6d583 commit 0ef3125
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/protocol/haier_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class ProtocolHandler
std::chrono::steady_clock::time_point cooldown_time_point_;
std::chrono::steady_clock::time_point answer_time_point_;
std::chrono::steady_clock::time_point retry_time_point_;
std::chrono::steady_clock::time_point last_message_time_point_;
};


Expand Down
12 changes: 11 additions & 1 deletion src/protocol/haier_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ void ProtocolHandler::loop()
if (this->write_message_(msg.message, msg.use_crc))
{
this->last_message_type_ = msg.message.get_frame_type();
this->state_ = msg.proxy_message ? ProtocolState::WAITING_FOR_PROXY_ANSWER : ProtocolState::WAITING_FOR_ANSWER;
if (msg.proxy_message)
{
this->state_ = ProtocolState::WAITING_FOR_PROXY_ANSWER;
}
else
{
this->state_ = ProtocolState::WAITING_FOR_ANSWER;
last_message_time_point_ = now;
}
this->answer_time_point_ = now + this->answer_timeout_interval_;
this->retry_time_point_ = now + msg.retry_interval;
}
Expand Down Expand Up @@ -126,6 +134,8 @@ void ProtocolHandler::loop()
}
if (this->transport_.available() > 0)
{

HAIER_LOGD("Answer delay: %dms", std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_message_time_point_).count());
TimestampedFrame frame;
this->transport_.pop(frame);
FrameType msg_type = (FrameType) frame.frame.get_frame_type();
Expand Down

0 comments on commit 0ef3125

Please sign in to comment.