Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13268
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Jan 4, 2024
1 parent 90f23dc commit 071330d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/AP_WS_ConfigAutoUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

namespace OpenWifi {

int AP_WS_ConfigAutoUpgrader::Start() {
int AP_WS_ConfigAutoUpgradeAgent::Start() {
poco_notice(Logger(), "Starting...");
QueueManager_.start(*this);

return 0;
}

void AP_WS_ConfigAutoUpgrader::Stop() {
void AP_WS_ConfigAutoUpgradeAgent::Stop() {
poco_notice(Logger(), "Stopping...");
Running_ = false;
Queue_.wakeUpAll();
QueueManager_.join();
poco_notice(Logger(), "Stopped...");
}

void AP_WS_ConfigAutoUpgrader::run() {
void AP_WS_ConfigAutoUpgradeAgent::run() {
Utils::SetThreadName("auto:cfgmgr");
Running_ = true;

Expand Down
8 changes: 4 additions & 4 deletions src/AP_WS_ConfigAutoUpgrader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ namespace OpenWifi {
std::uint64_t pending_config_=0;
};

class AP_WS_ConfigAutoUpgrader : public SubSystemServer, Poco::Runnable {
class AP_WS_ConfigAutoUpgradeAgent : public SubSystemServer, Poco::Runnable {
public:
int Start() final;
void Stop() final;
void run() final;

static auto instance() {
static auto instance = new AP_WS_ConfigAutoUpgrader;
static auto instance = new AP_WS_ConfigAutoUpgradeAgent;
return instance;
}

Expand Down Expand Up @@ -126,12 +126,12 @@ namespace OpenWifi {
mutable std::mutex CacheMutex_;
std::map<std::uint64_t, ConfigurationCacheEntry> Cache_;

AP_WS_ConfigAutoUpgrader() noexcept
AP_WS_ConfigAutoUpgradeAgent() noexcept
: SubSystemServer("AutoConfigUpgrade", "AUTO-CFG-MGR", "auto.config.updater") {
}
};

inline auto AP_WS_ConfigAutoUpgrader() { return AP_WS_ConfigAutoUpgrader::instance(); }
inline auto AP_WS_ConfigAutoUpgradeAgent() { return AP_WS_ConfigAutoUpgradeAgent::instance(); }

} // namespace OpenWifi

8 changes: 8 additions & 0 deletions src/AP_WS_LookForUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace OpenWifi {
return false;

uint64_t GoodConfig = ConfigurationCache().CurrentConfig(SerialNumberInt_);
std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl;
if (GoodConfig && (GoodConfig == UUID || GoodConfig == State_.PendingUUID)) {
UpgradedUUID = UUID;
return false;
Expand All @@ -20,17 +21,20 @@ namespace OpenWifi {
GWObjects::Device D;
if (StorageService()->GetDevice(Session,SerialNumber_, D)) {
if(D.pendingUUID!=0 && UUID==D.pendingUUID) {
std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl;
// so we sent an upgrade to a device, and now it is completing now...
UpgradedUUID = D.pendingUUID;
StorageService()->CompleteDeviceConfigurationChange(Session, SerialNumber_);
return true;
}
std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl;

// This is the case where the cache is empty after a restart. So GoodConfig will 0. If
// the device already has the right UUID, we just return.
if (D.UUID == UUID) {
UpgradedUUID = UUID;
ConfigurationCache().Add(SerialNumberInt_, UUID);
std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl;
return false;
}

Expand All @@ -40,6 +44,7 @@ namespace OpenWifi {
// make sure our config is newer.
D.UUID = UUID + 2;
UpgradedUUID = D.UUID;
std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl;
}

Cfg.SetUUID(D.UUID);
Expand Down Expand Up @@ -80,6 +85,9 @@ namespace OpenWifi {
Notification.content.newUUID = UpgradedUUID;
GWWebSocketNotifications::DeviceConfigurationChange(Notification);

std::cout << __LINE__ << " GoodConfig: " << GoodConfig << " UUID:" << UUID <<
" Pending:" << State_.PendingUUID << " Upgraded:" << UpgradedUUID << std::endl;

return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace OpenWifi {
SignatureManager(), AP_WS_Server(),
RegulatoryInfo(),
RADIUSSessionTracker(),
AP_WS_ConfigAutoUpgrader(),
AP_WS_ConfigAutoUpgradeAgent(),
FirmwareRevisionCache()
});
return &instance;
Expand Down

0 comments on commit 071330d

Please sign in to comment.