mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-31 19:25:14 +02:00
Keppalive issue
There is no keepalive packget if current time is very large. Caused by integer overflow.
This commit is contained in:
@@ -27,5 +27,5 @@
|
|||||||
|
|
||||||
char *platform_create_id_string();
|
char *platform_create_id_string();
|
||||||
int platform_random(int max);
|
int platform_random(int max);
|
||||||
int platform_tick_get_ms();
|
long long platform_tick_get_ms();
|
||||||
#endif
|
#endif
|
||||||
|
@@ -19,7 +19,7 @@ int platform_random(int max)
|
|||||||
return esp_random()%max;
|
return esp_random()%max;
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_tick_get_ms()
|
long long platform_tick_get_ms()
|
||||||
{
|
{
|
||||||
struct timeval te;
|
struct timeval te;
|
||||||
gettimeofday(&te, NULL); // get current time
|
gettimeofday(&te, NULL); // get current time
|
||||||
|
@@ -61,8 +61,8 @@ struct esp_mqtt_client {
|
|||||||
mqtt_state_t mqtt_state;
|
mqtt_state_t mqtt_state;
|
||||||
mqtt_connect_info_t connect_info;
|
mqtt_connect_info_t connect_info;
|
||||||
mqtt_client_state_t state;
|
mqtt_client_state_t state;
|
||||||
int keepalive_tick;
|
long long keepalive_tick;
|
||||||
int reconnect_tick;
|
long long reconnect_tick;
|
||||||
int wait_timeout_ms;
|
int wait_timeout_ms;
|
||||||
int auto_reconnect;
|
int auto_reconnect;
|
||||||
esp_mqtt_event_t event;
|
esp_mqtt_event_t event;
|
||||||
@@ -310,8 +310,8 @@ esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *co
|
|||||||
client->config->scheme = create_string("mqtt", 4);
|
client->config->scheme = create_string("mqtt", 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
client->keepalive_tick = 0;
|
client->keepalive_tick = platform_tick_get_ms();
|
||||||
client->reconnect_tick = 0;
|
client->reconnect_tick = platform_tick_get_ms();
|
||||||
|
|
||||||
int buffer_size = config->buffer_size;
|
int buffer_size = config->buffer_size;
|
||||||
if (buffer_size <= 0) {
|
if (buffer_size <= 0) {
|
||||||
|
Reference in New Issue
Block a user