Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT queue for messages #487

Merged
merged 2 commits into from
Mar 9, 2022
Merged

MQTT queue for messages #487

merged 2 commits into from
Mar 9, 2022

Conversation

matjack1
Copy link
Collaborator

@matjack1 matjack1 commented Mar 6, 2022

With this PR I'm adding a queue for the MQTT messages, so that when a message is received it's added in a queue during the callback. Then the main loop picks up the messages and processes them asyncronously, but in order of arrival.

This avoids the watch dog timer to restart the ESP, which was the cause of occasional restarts when the messages were taking a while to process.

Then I'm adding an acknowledgment MQTT message to be sent after processing the incoming messages. This allows the other party to throttle their calls and avoid going over the available memory. In case we are approaching the end of memory we drop the message and log it.

With this approach and the throttling on the other end I've stopped encountering the random restarts or the messages not received properly, it seems pretty robust now, but a bit more testing would be good!

matjack1 added 2 commits March 6, 2022 22:57
This allows waiting on the other end to avoid sending too many messages, and also sends ACK so that we can be sure that the message has been received properly.
Copy link
Collaborator

@omersiar omersiar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@omersiar omersiar merged commit 0245e01 into dev Mar 9, 2022
@matjack1
Copy link
Collaborator Author

matjack1 commented Mar 9, 2022

Thanks!

@matjack1 matjack1 deleted the mqtt-queue branch March 9, 2022 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants