Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/OLS-84
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Jun 5, 2024
1 parent cca3619 commit 8382818
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
3
6 changes: 5 additions & 1 deletion src/CentralConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ namespace OpenWifi::Config {
Model_ = Caps->get("model").toString();

if (Caps->has("platform"))
Platform_ = Caps->get("platform").toString();
Platform_ = Poco::toLower(Caps->get("platform").toString());

if(Compatible_.empty()) {
Compatible_ = Model_;
}

std::ostringstream OS;
Caps->stringify(OS);
Expand Down
2 changes: 1 addition & 1 deletion src/RESTObjects/RESTAPI_GWobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace OpenWifi::GWObjects {
void Device::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "serialNumber", SerialNumber);
#ifdef TIP_GATEWAY_SERVICE
field_to_json(Obj, "deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
field_to_json(Obj, "deviceType", StorageService()->GetPlatform(SerialNumber));
field_to_json(Obj, "blackListed", StorageService()->IsBlackListed(Utils::MACToInt(SerialNumber)));
#endif
field_to_json(Obj, "macAddress", MACAddress);
Expand Down
1 change: 1 addition & 0 deletions src/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ namespace OpenWifi {
bool DeleteDevice(std::string &SerialNumber);
bool DeleteDevices(std::string &SerialPattern, bool SimulatedOnly);
bool DeleteDevices(std::uint64_t OlderContact, bool SimulatedOnly);
std::string GetPlatform(const std::string &SerialNumber);

bool UpdateDevice(GWObjects::Device &);
bool UpdateDevice(LockedDbSession &Session, GWObjects::Device &);
Expand Down
20 changes: 19 additions & 1 deletion src/storage/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ namespace OpenWifi {
D.locale = InsertRadiosCountyRegulation(D.Configuration, IPAddress);
D.SerialNumber = Poco::toLower(SerialNumber);
D.Compatible = Caps.Compatible();
D.DeviceType = Caps.Platform();
if(D.Compatible.empty())
D.Compatible = Caps.Model();
D.DeviceType = Poco::toLower(Caps.Platform());
D.MACAddress = Utils::SerialToMAC(SerialNumber);
D.Manufacturer = Caps.Model();
D.Firmware = Firmware;
Expand Down Expand Up @@ -664,6 +666,22 @@ namespace OpenWifi {
return false;
}

std::string Storage::GetPlatform(const std::string &SerialNumber) {
try {
Poco::Data::Session Sess = Pool_->get();
Poco::Data::Statement Select(Sess);

std::string St = fmt::format("SELECT DeviceType FROM Devices WHERE SerialNumber='{}'", SerialNumber);
std::string Platform;
Select << ConvertParams(St), Poco::Data::Keywords::into(Platform);
Select.execute();
return Platform;
} catch (const Poco::Exception &E) {
Logger().log(E);
}
return "";
}

bool Storage::DeleteDevice(std::string &SerialNumber) {
try {
std::vector<std::string> TableNames{"Devices", "Statistics", "CommandList",
Expand Down

0 comments on commit 8382818

Please sign in to comment.