eclipse / paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)

Home Page:https://eclipse.org/paho

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

pat1 opened this issue · comments

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


as below:

  int left_ms()
    {
      unsigned long now=millis();
      if(now >= interval_end_ms){
	  return 0;  
	}else{
	  return interval_end_ms - now;
      }
    }