mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-11-03 00:22:41 +01:00
fix: MQTT tick not starting on connect and switch to esp_timer
- Tick should be updated on connect - Dependency of system timer removed to avoid issues when updating via SNTP Closes https://github.com/espressif/esp-mqtt/issues/225
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_random.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -27,18 +27,9 @@ int platform_random(int max)
|
||||
return esp_random() % max;
|
||||
}
|
||||
|
||||
int64_t platform_tick_get_ms(void)
|
||||
uint64_t platform_tick_get_ms(void)
|
||||
{
|
||||
struct timeval te;
|
||||
gettimeofday(&te, NULL); // get current time
|
||||
long long milliseconds = te.tv_sec * 1000LL + te.tv_usec / 1000; // calculate milliseconds
|
||||
// printf("milliseconds: %lld\n", milliseconds);
|
||||
return milliseconds;
|
||||
return esp_timer_get_time()/(int64_t)1000;
|
||||
}
|
||||
|
||||
void ms_to_timeval(int timeout_ms, struct timeval *tv)
|
||||
{
|
||||
tv->tv_sec = timeout_ms / 1000;
|
||||
tv->tv_usec = (timeout_ms - (tv->tv_sec * 1000)) * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user