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

arduino version have a non atomic Timer implementation and block publish forever sometimes #220

Open
pat1 opened this issue Mar 26, 2021 · 0 comments

Comments

@pat1
Copy link

pat1 commented Mar 26, 2021

The timer is not atomic as used in the library
first is called timer.expired() and after timer.left_ms()
so sometimes when time left is small timer.left_ms() return a very big value.

I think the best solution is to make timer atomic
https://github.com/eclipse/paho.mqtt.embedded-c/blob/29ab2aa29c5e47794284376d7f8386cfd54c3eed/MQTTClient/src/arduino/Countdown.h#L48
as below:

  int left_ms()
    {
      unsigned long now=millis();
      if(now >= interval_end_ms){
	  return 0;  
	}else{
	  return interval_end_ms - now;
      }
    }
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

1 participant