Add error handling for mqtt, fixed some issues

This commit is contained in:
Tuan PM
2018-05-03 21:50:24 +07:00
parent 4bc37bb8db
commit 75d3c65cb6
13 changed files with 414 additions and 234 deletions
+13 -2
View File
@@ -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