mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 10:12:29 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -37,7 +37,7 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||||||
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
|
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
|
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT -DBOOST_NO_CXX98_FUNCTION_BASE=1)
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|||||||
@@ -31,6 +31,39 @@ namespace OpenWifi {
|
|||||||
poco_information(Logger(), "Stopped...");
|
poco_information(Logger(), "Stopped...");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void AutoDiscovery::ProcessPing(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
|
||||||
|
std::string &Compat, std::string &Conn, std::string &locale) {
|
||||||
|
if (P->has(uCentralProtocol::CONNECTIONIP))
|
||||||
|
Conn = P->get(uCentralProtocol::CONNECTIONIP).toString();
|
||||||
|
if (P->has(uCentralProtocol::FIRMWARE))
|
||||||
|
FW = P->get(uCentralProtocol::FIRMWARE).toString();
|
||||||
|
if (P->has(uCentralProtocol::SERIALNUMBER))
|
||||||
|
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
|
||||||
|
if (P->has(uCentralProtocol::COMPATIBLE))
|
||||||
|
Compat = P->get(uCentralProtocol::COMPATIBLE).toString();
|
||||||
|
if (P->has("locale")) {
|
||||||
|
locale = P->get("locale").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoDiscovery::ProcessConnect(const Poco::JSON::Object::Ptr &P, std::string &FW, std::string &SN,
|
||||||
|
std::string &Compat, std::string &Conn, std::string &locale) {
|
||||||
|
if (P->has(uCentralProtocol::CONNECTIONIP))
|
||||||
|
Conn = P->get(uCentralProtocol::CONNECTIONIP).toString();
|
||||||
|
if (P->has(uCentralProtocol::FIRMWARE))
|
||||||
|
FW = P->get(uCentralProtocol::FIRMWARE).toString();
|
||||||
|
if (P->has(uCentralProtocol::SERIALNUMBER))
|
||||||
|
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
|
||||||
|
if (P->has("locale")) {
|
||||||
|
locale = P->get("locale").toString();
|
||||||
|
}
|
||||||
|
if(P->has(uCentralProtocol::CAPABILITIES)) {
|
||||||
|
auto CapObj = P->getObject(uCentralProtocol::CAPABILITIES);
|
||||||
|
if (CapObj->has(uCentralProtocol::COMPATIBLE))
|
||||||
|
Compat = CapObj->get(uCentralProtocol::COMPATIBLE).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AutoDiscovery::run() {
|
void AutoDiscovery::run() {
|
||||||
Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
|
Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
|
||||||
Utils::SetThreadName("auto-discovery");
|
Utils::SetThreadName("auto-discovery");
|
||||||
@@ -47,53 +80,18 @@ namespace OpenWifi {
|
|||||||
if (Object->has(uCentralProtocol::PAYLOAD)) {
|
if (Object->has(uCentralProtocol::PAYLOAD)) {
|
||||||
DBGLINE
|
DBGLINE
|
||||||
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
|
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
|
||||||
if (PayloadObj->has("ping")) {
|
std::string ConnectedIP, SerialNumber, Compatible, Firmware, Locale ;
|
||||||
|
if (PayloadObj->has(uCentralProtocol::PING)) {
|
||||||
auto PingObj = PayloadObj->getObject("ping");
|
auto PingObj = PayloadObj->getObject("ping");
|
||||||
std::string ConnectedIP, SerialNumber, DeviceType;
|
ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||||
DBGLINE
|
} else if(PayloadObj->has("capabilities")) {
|
||||||
if (PayloadObj->has(uCentralProtocol::CONNECTIONIP))
|
ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
|
||||||
DBGLINE
|
|
||||||
ConnectedIP =
|
|
||||||
PayloadObj->get(uCentralProtocol::CONNECTIONIP).toString();
|
|
||||||
if (PayloadObj->has(uCentralProtocol::CAPABILITIES)) {
|
|
||||||
DBGLINE
|
|
||||||
auto CapObj = PayloadObj->getObject(uCentralProtocol::CAPABILITIES);
|
|
||||||
if (CapObj->has(uCentralProtocol::COMPATIBLE)) {
|
|
||||||
DBGLINE
|
|
||||||
DeviceType = CapObj->get(uCentralProtocol::COMPATIBLE).toString();
|
|
||||||
SerialNumber = PayloadObj->get(uCentralProtocol::SERIAL).toString();
|
|
||||||
DBGLINE
|
|
||||||
}
|
|
||||||
} else if (PayloadObj->has(uCentralProtocol::PING)) {
|
|
||||||
DBGLINE
|
|
||||||
auto PingMessage = PayloadObj->getObject(uCentralProtocol::PING);
|
|
||||||
DBGLINE
|
|
||||||
if (PingMessage->has(uCentralProtocol::FIRMWARE) &&
|
|
||||||
PingMessage->has(uCentralProtocol::SERIALNUMBER) &&
|
|
||||||
PingMessage->has(uCentralProtocol::COMPATIBLE)) {
|
|
||||||
if (PingMessage->has(uCentralProtocol::CONNECTIONIP))
|
|
||||||
ConnectedIP =
|
|
||||||
PingMessage->get(uCentralProtocol::CONNECTIONIP).toString();
|
|
||||||
SerialNumber =
|
|
||||||
PingMessage->get(uCentralProtocol::SERIALNUMBER).toString();
|
|
||||||
DeviceType =
|
|
||||||
PingMessage->get(uCentralProtocol::COMPATIBLE).toString();
|
|
||||||
DBGLINE
|
|
||||||
}
|
|
||||||
DBGLINE
|
|
||||||
}
|
|
||||||
std::string Locale;
|
|
||||||
if (PayloadObj->has("locale")) {
|
|
||||||
DBGLINE
|
|
||||||
Locale = PayloadObj->get("locale").toString();
|
|
||||||
DBGLINE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SerialNumber.empty()) {
|
if (!SerialNumber.empty()) {
|
||||||
DBGLINE
|
DBGLINE
|
||||||
StorageService()->InventoryDB().CreateFromConnection(
|
StorageService()->InventoryDB().CreateFromConnection(
|
||||||
SerialNumber, ConnectedIP, DeviceType, Locale);
|
SerialNumber, ConnectedIP, Compatible, Locale);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "Poco/Notification.h"
|
#include "Poco/Notification.h"
|
||||||
#include "Poco/NotificationQueue.h"
|
#include "Poco/NotificationQueue.h"
|
||||||
|
#include "Poco/JSON/Object.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -46,6 +47,11 @@ namespace OpenWifi {
|
|||||||
Poco::Thread Worker_;
|
Poco::Thread Worker_;
|
||||||
std::atomic_bool Running_ = false;
|
std::atomic_bool Running_ = false;
|
||||||
|
|
||||||
|
void ProcessPing(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
|
||||||
|
std::string &Compat, std::string &Conn, std::string &locale) ;
|
||||||
|
void ProcessConnect(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
|
||||||
|
std::string &Compat, std::string &Conn, std::string &locale) ;
|
||||||
|
|
||||||
AutoDiscovery() noexcept
|
AutoDiscovery() noexcept
|
||||||
: SubSystemServer("AutoDiscovery", "AUTO-DISCOVERY", "discovery") {}
|
: SubSystemServer("AutoDiscovery", "AUTO-DISCOVERY", "discovery") {}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user