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

Question On call backs #117

Closed
germacovitch opened this issue Jul 26, 2018 · 3 comments
Closed

Question On call backs #117

germacovitch opened this issue Jul 26, 2018 · 3 comments

Comments

@germacovitch
Copy link

Hi there
Is it save tô assume that a call back will not occure in berween a function that you call in the loop block of code?
BR
Gilberto

@256dpi
Copy link
Owner

256dpi commented Jul 26, 2018

The callback is usually called as part of client.yield(). However, if you call client.subscribe(), client.unsubscribe() or client.publish() // with qos > 0 it might get called as well, if messages are received while waiting for the acknowledgement.

@germacovitch
Copy link
Author

Thanks
How can I protect some part of my code from being interrupted by a callback? Is it possible?
BR
Gilberto

@256dpi
Copy link
Owner

256dpi commented Aug 31, 2018

In other projects I used a queue to push messages in from the callback. That way you can process them at another point in your program. I don't know if there is a suitable queue implementation for Arduino.

@256dpi 256dpi closed this as completed Oct 11, 2018
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

No branches or pull requests

2 participants