mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 09:42:38 +00:00
Fix bug where process capabilities does not update serial number, bug where venue is not updated in GW for pre-provisioned device on capability event. (#8)
Signed-off-by: Adam Capparelli <adam.capparelli@kinarasystems.com> Co-authored-by: Adam Capparelli <adam.capparelli@kinarasystems.com>
This commit is contained in:
committed by
Ivan Chvets
parent
4ded8997cd
commit
a619c0dbe1
@@ -54,6 +54,8 @@ namespace OpenWifi {
|
||||
FW = P->get(uCentralProtocol::FIRMWARE).toString();
|
||||
if (P->has(uCentralProtocol::SERIALNUMBER))
|
||||
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
|
||||
else if (P->has(uCentralProtocol::SERIAL))
|
||||
SN = P->get(uCentralProtocol::SERIAL).toString();
|
||||
if (P->has("locale")) {
|
||||
locale = P->get("locale").toString();
|
||||
}
|
||||
@@ -83,6 +85,7 @@ namespace OpenWifi {
|
||||
Poco::JSON::Parser Parser;
|
||||
auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
|
||||
bool Connected=true;
|
||||
bool isConnection=false;
|
||||
|
||||
if (Object->has(uCentralProtocol::PAYLOAD)) {
|
||||
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
|
||||
@@ -91,6 +94,7 @@ namespace OpenWifi {
|
||||
auto PingObj = PayloadObj->getObject("ping");
|
||||
ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||
} else if(PayloadObj->has("capabilities")) {
|
||||
isConnection=true;
|
||||
ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||
} else if(PayloadObj->has("disconnection")) {
|
||||
// we ignore disconnection in provisioning
|
||||
@@ -102,7 +106,7 @@ namespace OpenWifi {
|
||||
|
||||
if (!SerialNumber.empty() && Connected) {
|
||||
StorageService()->InventoryDB().CreateFromConnection(
|
||||
SerialNumber, ConnectedIP, Compatible, Locale);
|
||||
SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
|
||||
}
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace OpenWifi {
|
||||
bool InventoryDB::CreateFromConnection(const std::string &SerialNumberRaw,
|
||||
const std::string &ConnectionInfo,
|
||||
const std::string &DeviceType,
|
||||
const std::string &Locale) {
|
||||
const std::string &Locale,
|
||||
const bool isConnection) {
|
||||
|
||||
ProvObjects::InventoryTag ExistingDevice;
|
||||
auto SerialNumber = Poco::toLower(SerialNumberRaw);
|
||||
@@ -179,6 +180,28 @@ namespace OpenWifi {
|
||||
StorageService()->InventoryDB().UpdateRecord("id", ExistingDevice.info.id,
|
||||
ExistingDevice);
|
||||
}
|
||||
|
||||
// Push entity and venue down to GW but only on connect (not ping)
|
||||
if (isConnection && !ExistingDevice.venue.empty()) {
|
||||
if (SDK::GW::Device::SetVenue(nullptr, ExistingDevice.serialNumber, ExistingDevice.venue)) {
|
||||
Logger().information(Poco::format("%s: GW set venue property.",
|
||||
ExistingDevice.serialNumber));
|
||||
} else {
|
||||
Logger().information(Poco::format(
|
||||
"%s: could not set GW venue property.", ExistingDevice.serialNumber));
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnection && !ExistingDevice.entity.empty()) {
|
||||
if (SDK::GW::Device::SetEntity(nullptr, ExistingDevice.serialNumber, ExistingDevice.entity)) {
|
||||
Logger().information(Poco::format("%s: GW set entity property.",
|
||||
ExistingDevice.serialNumber));
|
||||
} else {
|
||||
Logger().information(Poco::format(
|
||||
"%s: could not set GW entity property.", ExistingDevice.serialNumber));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace OpenWifi {
|
||||
virtual ~InventoryDB(){};
|
||||
bool CreateFromConnection(const std::string &SerialNumber,
|
||||
const std::string &ConnectionInfo, const std::string &DeviceType,
|
||||
const std::string &Locale);
|
||||
const std::string &Locale,
|
||||
const bool isConnection);
|
||||
|
||||
void InitializeSerialCache();
|
||||
bool GetRRMDeviceList(Types::UUIDvec_t &DeviceList);
|
||||
|
||||
Reference in New Issue
Block a user