From fa6d0aa714dfb54b4f24a7bb7eb378d3888c70e6 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Thu, 4 Jan 2024 13:27:10 -0800 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-13268 Signed-off-by: stephb9959 --- src/CentralConfig.cpp | 11 +++++++++++ src/CentralConfig.h | 1 + src/storage/storage_device.cpp | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/src/CentralConfig.cpp b/src/CentralConfig.cpp index ffab6b51f..ae881a140 100644 --- a/src/CentralConfig.cpp +++ b/src/CentralConfig.cpp @@ -204,6 +204,17 @@ namespace OpenWifi::Config { return false; } + std::uint64_t Config::UUID() { + try { + Poco::JSON::Parser Parser; + auto object = Parser.parse(Config_).extract(); + if (object->has("uuid")) + return object->get("uuid"); + } catch (...) { + } + return 0; + } + bool Config::Valid() { try { Poco::JSON::Parser Parser; diff --git a/src/CentralConfig.h b/src/CentralConfig.h index 56ae2e4c6..118592d9a 100644 --- a/src/CentralConfig.h +++ b/src/CentralConfig.h @@ -23,6 +23,7 @@ namespace OpenWifi::Config { [[nodiscard]] std::string get() { return Config_; }; [[nodiscard]] std::string Default(); [[nodiscard]] Poco::JSON::Object::Ptr to_json(); + [[nodiscard]] std::uint64_t UUID(); private: void Init(); diff --git a/src/storage/storage_device.cpp b/src/storage/storage_device.cpp index be006c9de..63bd0afc7 100644 --- a/src/storage/storage_device.cpp +++ b/src/storage/storage_device.cpp @@ -311,6 +311,15 @@ namespace OpenWifi { D.UUID = D.pendingUUID; D.pendingUUID = 0; } + + // if this is a broken device, fix it... + if(D.UUID==0) { + Config::Config Cfg(D.Configuration); + if(Cfg.Valid()) { + D.UUID = Cfg.UUID(); + } + } + D.LastConfigurationChange = Utils::Now(); ConfigurationCache().Add(Utils::SerialNumberToInt(SerialNumber), D.UUID);