Skip to content

Commit

Permalink
send the ping request a little earlier than needed
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Oct 11, 2017
1 parent a46bb9c commit a991d85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static lwmqtt_err_t lwmqtt_send_packet_in_buffer(lwmqtt_client_t *client, size_t
}

// reset keep alive timer
client->timer_set(client, client->keep_alive_timer, client->keep_alive_interval * 1000);
client->timer_set(client, client->keep_alive_timer, client->keep_alive_interval);

return LWMQTT_SUCCESS;
}
Expand Down Expand Up @@ -359,12 +359,12 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l
// set timer to command timeout
client->timer_set(client, client->command_timer, timeout);

// save keep alive interval
client->keep_alive_interval = options.keep_alive;
// save keep alive interval (take 75% to be a little earlier than actually needed)
client->keep_alive_interval = (uint32_t)(options.keep_alive * 750);

// set keep alive timer
if (client->keep_alive_interval > 0) {
client->timer_set(client, client->keep_alive_timer, client->keep_alive_interval * 1000);
client->timer_set(client, client->keep_alive_timer, client->keep_alive_interval);
}

// encode connect packet
Expand Down

0 comments on commit a991d85

Please sign in to comment.