mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-11-03 04:08:03 +00:00
Framework update
This commit is contained in:
@@ -310,6 +310,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
field_to_json( Obj,"state",state);
|
field_to_json( Obj,"state",state);
|
||||||
|
field_to_json( Obj,"devClass",devClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -328,6 +329,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
field_from_json( Obj,"state",state);
|
field_from_json( Obj,"state",state);
|
||||||
|
field_from_json( Obj,"devClass",devClass);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -601,6 +603,30 @@ namespace OpenWifi::ProvObjects {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SignupEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
info.to_json(Obj);
|
||||||
|
RESTAPI_utils::field_to_json( Obj,"email", email);
|
||||||
|
RESTAPI_utils::field_to_json( Obj,"userId", userId);
|
||||||
|
RESTAPI_utils::field_to_json( Obj,"serialNumber", serialNumber);
|
||||||
|
RESTAPI_utils::field_to_json( Obj,"created", created);
|
||||||
|
RESTAPI_utils::field_to_json( Obj,"completed", completed);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
info.from_json(Obj);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"email", email);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"userId", userId);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"serialNumber", serialNumber);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"created", created);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"completed", completed);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||||
uint64_t Now = std::time(nullptr);
|
uint64_t Now = std::time(nullptr);
|
||||||
if(O->has("name"))
|
if(O->has("name"))
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string rrm;
|
std::string rrm;
|
||||||
Types::UUID_t managementPolicy;
|
Types::UUID_t managementPolicy;
|
||||||
std::string state;
|
std::string state;
|
||||||
|
std::string devClass;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -385,6 +386,18 @@ namespace OpenWifi::ProvObjects {
|
|||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SignupEntry {
|
||||||
|
ObjectInfo info;
|
||||||
|
std::string email;
|
||||||
|
std::string userId;
|
||||||
|
std::string serialNumber;
|
||||||
|
uint64_t created = 0 ;
|
||||||
|
uint64_t completed = 0 ;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||||
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2414,7 +2414,7 @@ namespace OpenWifi {
|
|||||||
} else if(format == "uc-mac") {
|
} else if(format == "uc-mac") {
|
||||||
if(std::regex_match(value,mac_regex))
|
if(std::regex_match(value,mac_regex))
|
||||||
return;
|
return;
|
||||||
throw std::invalid_argument(value + " is not a valid MAC: should be something like 2e60:3500::/64.");
|
throw std::invalid_argument(value + " is not a valid MAC: should be something like 11:22:33:44:55:66");
|
||||||
} else if(format == "uc-timeout") {
|
} else if(format == "uc-timeout") {
|
||||||
if(std::regex_match(value,uc_timeout_regex))
|
if(std::regex_match(value,uc_timeout_regex))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ using namespace std::chrono_literals;
|
|||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
inline uint64_t Now() { return std::time(nullptr); };
|
||||||
|
|
||||||
enum UNAUTHORIZED_REASON {
|
enum UNAUTHORIZED_REASON {
|
||||||
SUCCESS=0,
|
SUCCESS=0,
|
||||||
PASSWORD_CHANGE_REQUIRED,
|
PASSWORD_CHANGE_REQUIRED,
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ namespace ORM {
|
|||||||
Cache_->UpdateCache(R);
|
Cache_->UpdateCache(R);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
Logger_.log(E);
|
Logger_.log(E);
|
||||||
}
|
}
|
||||||
@@ -468,8 +467,9 @@ namespace ORM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef std::vector<RecordTuple> RecordList;
|
typedef std::vector<RecordTuple> RecordList;
|
||||||
|
typedef std::vector<RecordType> RecordVec;
|
||||||
|
|
||||||
bool GetRecords( uint64_t Offset, uint64_t HowMany, std::vector<RecordType> & Records, const std::string & Where = "", const std::string & OrderBy = "") {
|
bool GetRecords( uint64_t Offset, uint64_t HowMany, RecordVec & Records, const std::string & Where = "", const std::string & OrderBy = "") {
|
||||||
try {
|
try {
|
||||||
Poco::Data::Session Session = Pool_.get();
|
Poco::Data::Session Session = Pool_.get();
|
||||||
Poco::Data::Statement Select(Session);
|
Poco::Data::Statement Select(Session);
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ namespace OpenWifi::RESTAPI::Errors {
|
|||||||
static const std::string SMSCouldNotBeSentRetry{"SMS could not be sent to validate device, try later or change the phone number."};
|
static const std::string SMSCouldNotBeSentRetry{"SMS could not be sent to validate device, try later or change the phone number."};
|
||||||
static const std::string SMSCouldNotValidate{"Code and number could not be validated"};
|
static const std::string SMSCouldNotValidate{"Code and number could not be validated"};
|
||||||
static const std::string InvalidDeviceClass{"Invalid device class. Must be: any, venue, entity, or subscriber"};
|
static const std::string InvalidDeviceClass{"Invalid device class. Must be: any, venue, entity, or subscriber"};
|
||||||
|
static const std::string SerialNumberAlreadyProvisioned{"This device has already been provisioned to a subscriber."};
|
||||||
|
static const std::string SerialNumberNotTheProperClass{"Device is not available to subscribers. It ahs been assigned to another class of devices."};
|
||||||
|
static const std::string UserAlreadyExists{"Username already exists."};
|
||||||
|
static const std::string NotImplemented{"Function not implemented."};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace OpenWifi::RESTAPI::Protocol {
|
namespace OpenWifi::RESTAPI::Protocol {
|
||||||
@@ -214,6 +218,9 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
static const char *FIRMWARE = "firmware";
|
static const char *FIRMWARE = "firmware";
|
||||||
static const char *CONNECT = "connect";
|
static const char *CONNECT = "connect";
|
||||||
static const char *STATE = "state";
|
static const char *STATE = "state";
|
||||||
|
static const char *STATUS = "status";
|
||||||
|
static const char *ERROR = "error";
|
||||||
|
static const char *TEXT = "text";
|
||||||
static const char *HEALTHCHECK = "healthcheck";
|
static const char *HEALTHCHECK = "healthcheck";
|
||||||
static const char *LOG = "log";
|
static const char *LOG = "log";
|
||||||
static const char *CRASHLOG = "crashlog";
|
static const char *CRASHLOG = "crashlog";
|
||||||
@@ -280,6 +287,20 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
static const char *CONNECTIONIP = "connectionIp";
|
static const char *CONNECTIONIP = "connectionIp";
|
||||||
static const char *TELEMETRY = "telemetry";
|
static const char *TELEMETRY = "telemetry";
|
||||||
static const char *BANDWIDTH = "bandwidth";
|
static const char *BANDWIDTH = "bandwidth";
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace OpenWifi::uCentralProtocol::Events {
|
||||||
|
|
||||||
|
static const char *CONNECT = "connect";
|
||||||
|
static const char *STATE = "state";
|
||||||
|
static const char *HEALTHCHECK = "healthcheck";
|
||||||
|
static const char *LOG = "log";
|
||||||
|
static const char *CRASHLOG = "crashlog";
|
||||||
|
static const char *PING = "ping";
|
||||||
|
static const char *CFGPENDING = "cfgpending";
|
||||||
|
static const char *RECOVERY = "recovery";
|
||||||
|
static const char *TELEMETRY = "telemetry";
|
||||||
|
static const char *DEVICEUPDATE = "deviceupdate";
|
||||||
|
|
||||||
enum EVENT_MSG {
|
enum EVENT_MSG {
|
||||||
ET_UNKNOWN,
|
ET_UNKNOWN,
|
||||||
@@ -296,29 +317,39 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline static EVENT_MSG EventFromString(const std::string & Method) {
|
inline static EVENT_MSG EventFromString(const std::string & Method) {
|
||||||
if (!Poco::icompare(Method, CONNECT)) {
|
static std::vector<std::pair<const char *,EVENT_MSG>> Values{
|
||||||
return ET_CONNECT;
|
{ CFGPENDING , ET_CFGPENDING },
|
||||||
} else if (!Poco::icompare(Method, STATE)) {
|
{ CONNECT, ET_CONNECT },
|
||||||
return ET_STATE;
|
{ CRASHLOG, ET_CRASHLOG },
|
||||||
} else if (!Poco::icompare(Method, HEALTHCHECK)) {
|
{ DEVICEUPDATE, ET_DEVICEUPDATE },
|
||||||
return ET_HEALTHCHECK;
|
{ HEALTHCHECK, ET_HEALTHCHECK },
|
||||||
} else if (!Poco::icompare(Method, LOG)) {
|
{ LOG, ET_LOG },
|
||||||
return ET_LOG;
|
{ PING, ET_PING },
|
||||||
} else if (!Poco::icompare(Method, CRASHLOG)) {
|
{ RECOVERY, ET_RECOVERY },
|
||||||
return ET_CRASHLOG;
|
{ STATE, ET_STATE },
|
||||||
} else if (!Poco::icompare(Method, PING)) {
|
{ TELEMETRY, ET_TELEMETRY }
|
||||||
return ET_PING;
|
};
|
||||||
} else if (!Poco::icompare(Method, CFGPENDING)) {
|
|
||||||
return ET_CFGPENDING;
|
std::string L = Poco::toLower(Method);
|
||||||
} else if (!Poco::icompare(Method, RECOVERY)) {
|
auto hint = std::find_if(cbegin(Values),cend(Values),[&](const std::pair<const char *,EVENT_MSG> &v) ->bool { return strcmp(v.first,L.c_str())==0; });
|
||||||
return ET_RECOVERY;
|
if(hint == cend(Values))
|
||||||
} else if (!Poco::icompare(Method, DEVICEUPDATE)) {
|
|
||||||
return ET_DEVICEUPDATE;
|
|
||||||
} else if (!Poco::icompare(Method, TELEMETRY)) {
|
|
||||||
return ET_TELEMETRY;
|
|
||||||
} else
|
|
||||||
return ET_UNKNOWN;
|
return ET_UNKNOWN;
|
||||||
|
return hint->second;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace OpenWifi::Provisioning::DeviceClass {
|
||||||
|
|
||||||
|
static const char * ANY = "any";
|
||||||
|
static const char * SUBSCRIBER = "subscriber";
|
||||||
|
static const char * VENUE = "venue";
|
||||||
|
static const char * ENTITY = "entity";
|
||||||
|
|
||||||
|
inline bool Validate(const char *s) {
|
||||||
|
static std::vector<const char *> Values{ ANY, ENTITY, SUBSCRIBER, VENUE };
|
||||||
|
return std::find(cbegin(Values), cend(Values), s) != cend(Values);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user