mirror of
https://github.com/espressif/esp-mqtt.git
synced 2026-10-02 13:57:36 +00:00
Add error handling for mqtt, fixed some issues
This commit is contained in:
@@ -2,13 +2,18 @@
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
static const char *TAG = "PLATFORM";
|
||||
|
||||
#define MAX_ID_STRING (32)
|
||||
|
||||
char *platform_create_id_string()
|
||||
{
|
||||
uint8_t mac[6];
|
||||
char *id_string = calloc(1, 32);
|
||||
mem_assert(id_string);
|
||||
char *id_string = calloc(1, MAX_ID_STRING);
|
||||
ESP_MEM_CHECK(TAG, id_string, return NULL);
|
||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||
sprintf(id_string, "ESP32_%02x%02X%02X", mac[3], mac[4], mac[5]);
|
||||
return id_string;
|
||||
@@ -27,4 +32,10 @@ long long platform_tick_get_ms()
|
||||
// printf("milliseconds: %lld\n", milliseconds);
|
||||
return milliseconds;
|
||||
}
|
||||
|
||||
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