Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13104
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Oct 30, 2023
1 parent fd80f02 commit 94ae20c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50
51
11 changes: 11 additions & 0 deletions src/AP_WS_Process_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ namespace OpenWifi {
}
}

if(ParamsObj->has("reason")) {
State_.connectReason = ParamsObj->get("reason").toString();
DeviceInfo.connectReason = State_.connectReason;
++Updated;
}

if(DeviceInfo.DevicePassword!=DevicePassword) {
DeviceInfo.DevicePassword = DevicePassword.empty() ? "openwifi" : DevicePassword ;
++Updated;
Expand Down Expand Up @@ -226,6 +232,11 @@ namespace OpenWifi {
++Updated;
}

if(DeviceInfo.certificateExpiryDate!=State_.certificateExpiryDate) {
DeviceInfo.certificateExpiryDate = State_.certificateExpiryDate;
++Updated;
}

if (Updated) {
StorageService()->UpdateDevice(DeviceInfo);
}
Expand Down
4 changes: 4 additions & 0 deletions src/RESTObjects/RESTAPI_GWobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj, "pendingUUID", pendingUUID);
field_to_json(Obj, "simulated", simulated);
field_to_json(Obj, "lastRecordedContact", lastRecordedContact);
field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate);
field_to_json(Obj, "connectReason", connectReason);
}

void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
Expand Down Expand Up @@ -122,6 +124,8 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj, "pendingUUID", pendingUUID);
field_from_json(Obj, "simulated", simulated);
field_from_json(Obj, "lastRecordedContact", lastRecordedContact);
field_from_json(Obj, "certificateExpiryDate", certificateExpiryDate);
field_from_json(Obj, "connectReason", connectReason);
return true;
} catch (const Poco::Exception &E) {
}
Expand Down
4 changes: 3 additions & 1 deletion src/RESTObjects/RESTAPI_GWobjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ namespace OpenWifi::GWObjects {
DeviceRestrictions restrictionDetails;
std::uint64_t pendingUUID = 0;
bool simulated=false;
std::uint64_t lastRecordedContact=0;
std::uint64_t lastRecordedContact=0;
std::uint64_t certificateExpiryDate = 0;
std::string connectReason;

void to_json(Poco::JSON::Object &Obj) const;
void to_json_with_status(Poco::JSON::Object &Obj) const;
Expand Down
18 changes: 14 additions & 4 deletions src/storage/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ namespace OpenWifi {
"restrictionDetails, "
"pendingUUID, "
"simulated,"
"lastRecordedContact"
"lastRecordedContact,"
"certificateExpiryDate,"
"connectReason "
};

const static std::string DB_DeviceUpdateFields{"SerialNumber=?,"
Expand Down Expand Up @@ -84,16 +86,20 @@ namespace OpenWifi {
"restrictionDetails=?, "
"pendingUUID=?, "
"simulated=?,"
"lastRecordedContact=? "};
"lastRecordedContact=?, "
"certificateExpiryDate=?,"
"connectReason=? "
};

const static std::string DB_DeviceInsertValues{
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "};
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "};

typedef Poco::Tuple<std::string, std::string, std::string, std::string, std::string,
std::string, std::string, std::string, std::string, std::string,
std::string, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, std::string,
std::string, std::string, std::string, uint64_t, std::string, bool,
std::string, std::string, std::string, std::uint64_t, bool, std::uint64_t>
std::string, std::string, std::string, std::uint64_t, bool, std::uint64_t,
std::uint64_t, std::string>
DeviceRecordTuple;
typedef std::vector<DeviceRecordTuple> DeviceRecordList;

Expand Down Expand Up @@ -128,6 +134,8 @@ namespace OpenWifi {
D.pendingUUID = R.get<26>();
D.simulated = R.get<27>();
D.lastRecordedContact = R.get<28>();
D.certificateExpiryDate = R.get<29>();
D.connectReason = R.get<30>();
}

void ConvertDeviceRecord(const GWObjects::Device &D, DeviceRecordTuple &R) {
Expand Down Expand Up @@ -160,6 +168,8 @@ namespace OpenWifi {
R.set<26>(D.pendingUUID);
R.set<27>(D.simulated);
R.set<28>(D.lastRecordedContact);
R.set<29>(D.certificateExpiryDate);
R.set<30>(D.connectReason);
}

bool Storage::GetDeviceCount(uint64_t &Count) {
Expand Down
12 changes: 9 additions & 3 deletions src/storage/storage_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ namespace OpenWifi {
"restrictionDetails TEXT, "
"pendingUUID BIGINT, "
"simulated BOOLEAN,"
"lastRecordedContact BIGINT"
"lastRecordedContact BIGINT,"
"certificateExpiryDate BIGINT,"
"connectReason TEXT"
",INDEX DeviceOwner (Owner ASC),"
"INDEX LocationIndex (Location ASC))",
Poco::Data::Keywords::now;
Expand Down Expand Up @@ -124,7 +126,9 @@ namespace OpenWifi {
"restrictionDetails TEXT,"
"pendingUUID BIGINT, "
"simulated BOOLEAN, "
"lastRecordedContact BIGINT"
"lastRecordedContact BIGINT,"
"certificateExpiryDate BIGINT,"
"connectReason TEXT"
")",
Poco::Data::Keywords::now;
Sess << "CREATE INDEX IF NOT EXISTS DeviceOwner ON Devices (Owner ASC)",
Expand All @@ -145,7 +149,9 @@ namespace OpenWifi {
"alter table devices add column restrictionDetails TEXT",
"alter table devices add column pendingUUID bigint",
"alter table devices add column lastRecordedContact bigint",
"alter table devices add column simulated boolean"
"alter table devices add column simulated boolean",
"alter table devices add column certificateExpiryDate bigint",
"alter table devices add column connectReason TEXT"
};

for (const auto &i : Script) {
Expand Down

0 comments on commit 94ae20c

Please sign in to comment.