mirror of
https://github.com/Telecominfraproject/wlan-cloud-analytics.git
synced 2026-01-27 10:22:33 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -90,6 +90,13 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int BandToInt(const std::string &band) {
|
||||
if(band=="2G") return 2;
|
||||
if(band=="5G") return 5;
|
||||
if(band=="6G") return 6;
|
||||
return 2;
|
||||
}
|
||||
|
||||
void AP::UpdateStats(const std::shared_ptr<nlohmann::json> &State) {
|
||||
DI_.states++;
|
||||
DI_.connected =true;
|
||||
@@ -126,7 +133,13 @@ namespace OpenWifi {
|
||||
if (radio.contains("channel")) {
|
||||
AnalyticsObjects::RadioTimePoint RTP;
|
||||
GetJSON("channel", radio, RTP.channel, (uint64_t) 2);
|
||||
RTP.band = RTP.channel <= 16 ? 2 : 5;
|
||||
if(radio.contains("band") && radio["band"].is_array()) {
|
||||
auto BandArray = radio["band"];
|
||||
RTP.band = BandToInt(BandArray[0]);
|
||||
std::cout << "BAND (radio): " << BandToInt(BandArray[0]) << std::endl;
|
||||
} else {
|
||||
RTP.band = RTP.channel <= 16 ? 2 : 5;
|
||||
}
|
||||
radio_map[radio_index++] = std::make_pair(RTP.band, RTP.channel);
|
||||
GetJSON("busy_ms", radio, RTP.busy_ms, (uint64_t) 0);
|
||||
GetJSON("receive_ms", radio, RTP.receive_ms, (uint64_t) 0);
|
||||
@@ -209,7 +222,23 @@ namespace OpenWifi {
|
||||
AnalyticsObjects::SSIDTimePoint SSIDTP;
|
||||
uint radio_location=0;
|
||||
SSIDTP.band = 2;
|
||||
if(ssid.contains("radio")) {
|
||||
|
||||
if(ssid.contains("band")) {
|
||||
std::string Band = ssid["band"];
|
||||
SSIDTP.band = BandToInt(Band);
|
||||
std::cout << "BAND (ssid): " << SSIDTP.band << std::endl;
|
||||
auto radio = ssid["radio"];
|
||||
if(radio.contains("$ref")) {
|
||||
auto ref = radio["$ref"];
|
||||
auto radio_parts = Poco::StringTokenizer(ref, "/");
|
||||
if(radio_parts.count()==3) {
|
||||
radio_location = std::strtol(radio_parts[2].c_str(), nullptr, 10);
|
||||
if(radio_map.find(radio_location)!=radio_map.end()) {
|
||||
SSIDTP.channel = radio_map[radio_location].second;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(ssid.contains("radio")) {
|
||||
auto radio = ssid["radio"];
|
||||
if(radio.contains("$ref")) {
|
||||
auto ref = radio["$ref"];
|
||||
|
||||
@@ -304,6 +304,7 @@ namespace OpenWifi::GWObjects {
|
||||
field_to_json(Obj,"serialNumber",serialNumber);
|
||||
field_to_json(Obj,"timeout",timeout);
|
||||
field_to_json(Obj,"type",type);
|
||||
field_to_json(Obj,"scriptId",scriptId);
|
||||
field_to_json(Obj,"script",script);
|
||||
field_to_json(Obj,"when",when);
|
||||
field_to_json(Obj,"signature", signature);
|
||||
@@ -317,6 +318,7 @@ namespace OpenWifi::GWObjects {
|
||||
field_from_json(Obj,"timeout",timeout);
|
||||
field_from_json(Obj,"type",type);
|
||||
field_from_json(Obj,"script",script);
|
||||
field_from_json(Obj,"scriptId",scriptId);
|
||||
field_from_json(Obj,"when",when);
|
||||
field_from_json(Obj,"signature", signature);
|
||||
field_from_json(Obj,"deferred", deferred);
|
||||
@@ -422,5 +424,56 @@ namespace OpenWifi::GWObjects {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScriptEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"id", id);
|
||||
field_to_json(Obj,"name", name);
|
||||
field_to_json(Obj,"description", description);
|
||||
field_to_json(Obj,"uri", uri);
|
||||
field_to_json(Obj,"content", content);
|
||||
field_to_json(Obj,"version", version);
|
||||
field_to_json(Obj,"type", type);
|
||||
field_to_json(Obj,"created", created);
|
||||
field_to_json(Obj,"modified", modified);
|
||||
field_to_json(Obj,"author", author);
|
||||
field_to_json(Obj,"restricted", restricted);
|
||||
field_to_json(Obj,"deferred", deferred);
|
||||
field_to_json(Obj,"timeout", timeout);
|
||||
}
|
||||
|
||||
bool ScriptEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id", id);
|
||||
field_from_json(Obj,"name", name);
|
||||
field_from_json(Obj,"description", description);
|
||||
field_from_json(Obj,"uri", uri);
|
||||
field_from_json(Obj,"content", content);
|
||||
field_from_json(Obj,"version", version);
|
||||
field_from_json(Obj,"type", type);
|
||||
field_from_json(Obj,"created", created);
|
||||
field_from_json(Obj,"modified", modified);
|
||||
field_from_json(Obj,"author", author);
|
||||
field_from_json(Obj,"restricted", restricted);
|
||||
field_from_json(Obj,"deferred", deferred);
|
||||
field_from_json(Obj,"timeout", timeout);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScriptEntryList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"scripts",scripts);
|
||||
}
|
||||
|
||||
bool ScriptEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"scripts",scripts);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -216,11 +216,38 @@ namespace OpenWifi::GWObjects {
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
};
|
||||
|
||||
struct ScriptEntry {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string uri;
|
||||
std::string content;
|
||||
std::string version;
|
||||
std::string type;
|
||||
std::uint64_t created;
|
||||
std::uint64_t modified;
|
||||
std::string author;
|
||||
Types::StringVec restricted;
|
||||
bool deferred=false;
|
||||
std::uint64_t timeout=30;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct ScriptEntryList {
|
||||
std::vector<ScriptEntry> scripts;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct ScriptRequest {
|
||||
std::string serialNumber;
|
||||
uint64_t timeout=30;
|
||||
std::string type;
|
||||
std::string script;
|
||||
std::string scriptId;
|
||||
std::uint64_t when;
|
||||
std::string signature;
|
||||
bool deferred;
|
||||
|
||||
Reference in New Issue
Block a user