mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Fixing discovery.
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "uCentralProtocol.h"
|
||||
#include "KafkaManager.h"
|
||||
#include "Kafka_topics.h"
|
||||
#include "storage_inventory.h"
|
||||
#include "StorageService.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
@@ -49,14 +51,15 @@ namespace OpenWifi {
|
||||
if( PingMessage->has(uCentralProtocol::FIRMWARE) &&
|
||||
PingMessage->has(uCentralProtocol::SERIALNUMBER) &&
|
||||
PingMessage->has(uCentralProtocol::COMPATIBLE)) {
|
||||
if(PayloadObj->has(uCentralProtocol::CONNECTIONIP) )
|
||||
ConnectedIP = PayloadObj->get(uCentralProtocol::CONNECTIONIP).toString();
|
||||
if(PingMessage->has(uCentralProtocol::CONNECTIONIP) )
|
||||
ConnectedIP = PingMessage->get(uCentralProtocol::CONNECTIONIP).toString();
|
||||
SerialNumber = PingMessage->get( uCentralProtocol::SERIALNUMBER).toString();
|
||||
DeviceType = PingMessage->get( uCentralProtocol::COMPATIBLE).toString();
|
||||
}
|
||||
}
|
||||
if(!SerialNumber.empty()) {
|
||||
std::cout << "SerialNUmber: " << SerialNumber << " CID: " << ConnectedIP << " DeviceType: " << DeviceType << std::endl;
|
||||
Storage()->InventoryDB().CreateFromInventory(SerialNumber,ConnectedIP,DeviceType);
|
||||
}
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
|
||||
@@ -61,6 +61,10 @@ namespace OpenWifi {
|
||||
uint64_t Now = std::time(nullptr);
|
||||
|
||||
auto Tokens = Poco::StringTokenizer(ConnectionInfo,"@:");
|
||||
std::string IP;
|
||||
if(Tokens.count()==3) {
|
||||
IP = Tokens[1];
|
||||
}
|
||||
|
||||
NewDevice.info.id = Daemon()->CreateUUID();
|
||||
NewDevice.info.name = SerialNumber;
|
||||
@@ -70,7 +74,7 @@ namespace OpenWifi {
|
||||
NewDevice.deviceType = DeviceType;
|
||||
|
||||
if(CreateRecord(NewDevice)) {
|
||||
std::cout << "Added " << SerialNumber << " to DB with IP=" << Tokens[1] << std::endl;
|
||||
std::cout << "Added " << SerialNumber << " to DB with IP=" << IP << std::endl;
|
||||
Logger().information(Poco::format("Adding %s to inventory.",SerialNumber));
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user