diff --git a/src/CentralConfig.cpp b/src/CentralConfig.cpp index ffab6b51..ae881a14 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 56ae2e4c..118592d9 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 be006c9d..63bd0afc 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);