From 5e3abd4b8c6dc9aa1b9ed74553a8c89571c16edf Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Thu, 28 Mar 2024 09:04:40 +0100 Subject: [PATCH] fix: Cover the case for SOC without MAC address We need to cover for the case where the available MAC isn't defined in soc caps. E.g. A new target is being introduced but the support isn't complete yet. --- lib/platform_esp32_idf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/platform_esp32_idf.c b/lib/platform_esp32_idf.c index 215820b..e424db1 100644 --- a/lib/platform_esp32_idf.c +++ b/lib/platform_esp32_idf.c @@ -25,8 +25,13 @@ char *platform_create_id_string(void) uint8_t mac[6]; char *id_string = calloc(1, MAX_ID_STRING); ESP_MEM_CHECK(TAG, id_string, return NULL); + #ifndef MAC_TYPE + ESP_LOGW(TAG, "Soc doesn't provide MAC, client could be disconnected in case of device with same name in the broker."); + sprintf(id_string, "esp_mqtt_client_id"); + #else esp_read_mac(mac, MAC_TYPE); sprintf(id_string, "ESP32_%02x%02X%02X", mac[3], mac[4], mac[5]); + #endif return id_string; }