mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 11:37:54 +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();
|
FW = P->get(uCentralProtocol::FIRMWARE).toString();
|
||||||
if (P->has(uCentralProtocol::SERIALNUMBER))
|
if (P->has(uCentralProtocol::SERIALNUMBER))
|
||||||
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
|
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
|
||||||
|
else if (P->has(uCentralProtocol::SERIAL))
|
||||||
|
SN = P->get(uCentralProtocol::SERIAL).toString();
|
||||||
if (P->has("locale")) {
|
if (P->has("locale")) {
|
||||||
locale = P->get("locale").toString();
|
locale = P->get("locale").toString();
|
||||||
}
|
}
|
||||||
@@ -83,6 +85,7 @@ namespace OpenWifi {
|
|||||||
Poco::JSON::Parser Parser;
|
Poco::JSON::Parser Parser;
|
||||||
auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
|
auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
|
||||||
bool Connected=true;
|
bool Connected=true;
|
||||||
|
bool isConnection=false;
|
||||||
|
|
||||||
if (Object->has(uCentralProtocol::PAYLOAD)) {
|
if (Object->has(uCentralProtocol::PAYLOAD)) {
|
||||||
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
|
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
|
||||||
@@ -91,6 +94,7 @@ namespace OpenWifi {
|
|||||||
auto PingObj = PayloadObj->getObject("ping");
|
auto PingObj = PayloadObj->getObject("ping");
|
||||||
ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||||
} else if(PayloadObj->has("capabilities")) {
|
} else if(PayloadObj->has("capabilities")) {
|
||||||
|
isConnection=true;
|
||||||
ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||||
} else if(PayloadObj->has("disconnection")) {
|
} else if(PayloadObj->has("disconnection")) {
|
||||||
// we ignore disconnection in provisioning
|
// we ignore disconnection in provisioning
|
||||||
@@ -102,7 +106,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
if (!SerialNumber.empty() && Connected) {
|
if (!SerialNumber.empty() && Connected) {
|
||||||
StorageService()->InventoryDB().CreateFromConnection(
|
StorageService()->InventoryDB().CreateFromConnection(
|
||||||
SerialNumber, ConnectedIP, Compatible, Locale);
|
SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ namespace OpenWifi {
|
|||||||
bool InventoryDB::CreateFromConnection(const std::string &SerialNumberRaw,
|
bool InventoryDB::CreateFromConnection(const std::string &SerialNumberRaw,
|
||||||
const std::string &ConnectionInfo,
|
const std::string &ConnectionInfo,
|
||||||
const std::string &DeviceType,
|
const std::string &DeviceType,
|
||||||
const std::string &Locale) {
|
const std::string &Locale,
|
||||||
|
const bool isConnection) {
|
||||||
|
|
||||||
ProvObjects::InventoryTag ExistingDevice;
|
ProvObjects::InventoryTag ExistingDevice;
|
||||||
auto SerialNumber = Poco::toLower(SerialNumberRaw);
|
auto SerialNumber = Poco::toLower(SerialNumberRaw);
|
||||||
@@ -179,6 +180,28 @@ namespace OpenWifi {
|
|||||||
StorageService()->InventoryDB().UpdateRecord("id", ExistingDevice.info.id,
|
StorageService()->InventoryDB().UpdateRecord("id", ExistingDevice.info.id,
|
||||||
ExistingDevice);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ namespace OpenWifi {
|
|||||||
virtual ~InventoryDB(){};
|
virtual ~InventoryDB(){};
|
||||||
bool CreateFromConnection(const std::string &SerialNumber,
|
bool CreateFromConnection(const std::string &SerialNumber,
|
||||||
const std::string &ConnectionInfo, const std::string &DeviceType,
|
const std::string &ConnectionInfo, const std::string &DeviceType,
|
||||||
const std::string &Locale);
|
const std::string &Locale,
|
||||||
|
const bool isConnection);
|
||||||
|
|
||||||
void InitializeSerialCache();
|
void InitializeSerialCache();
|
||||||
bool GetRRMDeviceList(Types::UUIDvec_t &DeviceList);
|
bool GetRRMDeviceList(Types::UUIDvec_t &DeviceList);
|
||||||
|
|||||||
Reference in New Issue
Block a user