From c649ec1d8c6d07cc7a4899ba1dbd5ba9cb6aac1f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 17 Nov 2025 17:40:09 +0000 Subject: [PATCH] Update wled00/json.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- wled00/json.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 5661d0bd..e0be0580 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -700,6 +700,9 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme // Generate a device ID based on SHA1 hash of MAC address String getDeviceId() { + static String cachedDeviceId = ""; + if (cachedDeviceId.length() > 0) return cachedDeviceId; + uint8_t mac[6]; WiFi.macAddress(mac); @@ -708,7 +711,8 @@ String getDeviceId() { char macStr[18]; sprintf(macStr, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); String macString = String(macStr); - return sha1(macString); + cachedDeviceId = sha1(macString); + return cachedDeviceId; #endif #ifdef ESP32 @@ -726,8 +730,11 @@ String getDeviceId() { for (int i = 0; i < 20; i++) { sprintf(&buf[i*2], "%02x", shaResult[i]); } - return String(buf); + cachedDeviceId = String(buf); + return cachedDeviceId; #endif + + return String(""); } void serializeInfo(JsonObject root)