Merge pull request #401 from Governa/mqtt_timer
Mqtt timer not sleeping
This commit is contained in:
commit
a0297eb3af
1 changed files with 6 additions and 8 deletions
|
@ -32,7 +32,7 @@ char mqtt_timer_expired(mqtt_timer_t* timer)
|
|||
{
|
||||
TickType_t now = xTaskGetTickCount();
|
||||
int32_t left = timer->end_time - now;
|
||||
return (left < 0);
|
||||
return (left <= 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ int mqtt_timer_left_ms(mqtt_timer_t* timer)
|
|||
{
|
||||
TickType_t now = xTaskGetTickCount();
|
||||
int32_t left = timer->end_time - now;
|
||||
return (left < 0) ? 0 : left / portTICK_PERIOD_MS;
|
||||
return (left < 0) ? 0 : left * portTICK_PERIOD_MS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,9 +72,8 @@ int mqtt_esp_read(mqtt_network_t* n, unsigned char* buffer, int len, int timeou
|
|||
int rcvd = 0;
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(n->my_socket, &fdset);
|
||||
// It seems tv_sec actually means FreeRTOS tick
|
||||
tv.tv_sec = timeout_ms / portTICK_PERIOD_MS;
|
||||
tv.tv_usec = 0;
|
||||
tv.tv_sec = timeout_ms / 1000;
|
||||
tv.tv_usec = (timeout_ms % 1000) * 1000;
|
||||
rc = select(n->my_socket + 1, &fdset, 0, 0, &tv);
|
||||
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
|
||||
{
|
||||
|
@ -97,9 +96,8 @@ int mqtt_esp_write(mqtt_network_t* n, unsigned char* buffer, int len, int timeo
|
|||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(n->my_socket, &fdset);
|
||||
// It seems tv_sec actually means FreeRTOS tick
|
||||
tv.tv_sec = timeout_ms / portTICK_PERIOD_MS;
|
||||
tv.tv_usec = 0;
|
||||
tv.tv_sec = timeout_ms / 1000;
|
||||
tv.tv_usec = (timeout_ms % 1000) * 1000;
|
||||
rc = select(n->my_socket + 1, 0, &fdset, 0, &tv);
|
||||
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue