From 310495e61c5bb51a073d0086db919220aa325719 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 27 Dec 2020 13:09:10 +0100 Subject: [PATCH] mqttclient.cpp bugfix hash MAC --- src/mqttclient.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mqttclient.cpp b/src/mqttclient.cpp index 6dd5a89a..36da3c1c 100644 --- a/src/mqttclient.cpp +++ b/src/mqttclient.cpp @@ -41,9 +41,13 @@ esp_err_t mqtt_init(void) { int mqtt_connect(const char *my_host, const uint16_t my_port) { IPAddress mqtt_server_ip; - const uint16_t hashed = hash(Ð.macAddress()[0], 4); // hash MAC to 4 digits + uint8_t mac[6]; char clientId[16]; - snprintf(clientId, 16, "paxcounter_%d", hashed); + + // hash 6 digit MAC to 4 digits + esp_eth_get_mac(mac); + const uint16_t hashedmac = hash((const char *)mac, 4); + snprintf(clientId, 16, "paxcounter_%04x", hashedmac); ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);