Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13280
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Jan 24, 2024
1 parent 1acabd4 commit 4e7babc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
14 changes: 13 additions & 1 deletion src/RESTObjects/RESTAPI_GWobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ namespace OpenWifi::GWObjects {
Res.value().to_json(SerialNumber,Obj);
#else
if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
#endif
ConState.to_json(SerialNumber,Obj);
#endif
} else {
field_to_json(Obj, "ipAddress", "");
field_to_json(Obj, "txBytes", (uint64_t)0);
Expand Down Expand Up @@ -177,6 +177,18 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj, "recorded", Recorded);
}

bool HealthCheck::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "UUID", UUID);
field_from_json(Obj, "sanity", Sanity);
field_from_json(Obj, "recorded", Recorded);
return true;
} catch(...) {

}
return false;
}

void DefaultConfiguration::to_json(Poco::JSON::Object &Obj) const {
EmbedDocument("configuration", Obj, Configuration);
field_to_json(Obj, "name", Name);
Expand Down
16 changes: 9 additions & 7 deletions src/RESTObjects/RESTAPI_GWobjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ namespace OpenWifi::GWObjects {
};

struct HealthCheck {
std::string SerialNumber;
uint64_t UUID = 0;
std::string Data;
uint64_t Recorded = 0;
uint64_t Sanity = 0;
void to_json(Poco::JSON::Object &Obj) const;
};
std::string SerialNumber;
uint64_t UUID = 0;
std::string Data;
uint64_t Recorded = 0;
uint64_t Sanity = 0;

void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};

struct Capabilities {
std::string Capabilities;
Expand Down
13 changes: 12 additions & 1 deletion src/framework/MicroService.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//
//
// Created by stephane bourque on 2022-10-26.
//

Expand Down Expand Up @@ -480,7 +481,17 @@ namespace OpenWifi {
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
}

void MicroService::initialize([[maybe_unused]] Poco::Util::Application &self) {
void MicroService::StopEverything([[maybe_unused]] Poco::Util::Application &self) {
LoadConfigurationFile();
InitializeLoggingSystem();

Types::TopicNotifyFunction F = [this](const std::string &Key, const std::string &Payload) {
this->BusMessageReceived(Key, Payload);
};
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
}

void MicroService::initialize([[maybe_unused]] Poco::Util::Application &self) {
#ifndef USE_MEDUSA_CLIENT
StartEverything(self);
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/framework/MicroService.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ namespace OpenWifi {
void LoadMyConfig();
void initialize(Poco::Util::Application &self) override;
void StartEverything(Poco::Util::Application &self);
void uninitialize() override;
void StopEverything(Poco::Util::Application &self);
void uninitialize() override;
void reinitialize(Poco::Util::Application &self) override;
void defineOptions(Poco::Util::OptionSet &options) override;
void handleHelp(const std::string &name, const std::string &value);
Expand Down

0 comments on commit 4e7babc

Please sign in to comment.