Updating device subscriber record.

This commit is contained in:
stephb9959
2022-02-23 09:31:02 -08:00
parent 8f7f381ae0
commit 3a1c51c252
5 changed files with 53 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ namespace OpenWifi::GWObjects {
void Device::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber", SerialNumber);
#ifdef TIP_GATEWAY_SERVICE
field_to_json(Obj,"deviceType", CapabilitiesCache::instance()->Get(Compatible));
field_to_json(Obj,"deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
#endif
field_to_json(Obj,"macAddress", MACAddress);
field_to_json(Obj,"manufacturer", Manufacturer);
@@ -45,6 +45,9 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"compatible", Compatible);
field_to_json(Obj,"fwUpdatePolicy", FWUpdatePolicy);
field_to_json(Obj,"devicePassword", DevicePassword);
field_to_json(Obj,"subscriber", subscriber);
field_to_json(Obj,"entity", entity);
field_to_json(Obj,"modified", modified);
}
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
@@ -81,6 +84,8 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"location",Location);
field_from_json(Obj,"venue",Venue);
field_from_json(Obj,"compatible",Compatible);
field_from_json(Obj,"subscriber", subscriber);
field_from_json(Obj,"entity", entity);
return true;
} catch (const Poco::Exception &E) {
}

View File

@@ -59,6 +59,10 @@ namespace OpenWifi::GWObjects {
uint64_t LastFWUpdate = 0 ;
std::string Venue;
std::string DevicePassword;
std::string subscriber;
std::string entity;
uint64_t modified=0;
void to_json(Poco::JSON::Object &Obj) const;
void to_json_with_status(Poco::JSON::Object &Obj) const;
bool from_json(Poco::JSON::Object::Ptr &Obj);

View File

@@ -4,6 +4,7 @@
#include "Signup.h"
#include "StorageService.h"
#include "sdks/SDK_gw.h"
namespace OpenWifi {
@@ -66,6 +67,7 @@ namespace OpenWifi {
SE.info.modified = OpenWifi::Now();
SE.error = 0 ;
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
SDK::GW::Device::SetSubscriber( SE.serialNumber, IT.subscriber );
}
}
}

View File

@@ -117,6 +117,42 @@ namespace OpenWifi::SDK::GW {
return false;
}
bool SetEntity(RESTAPIHandler *client, const std::string & SerialNumber, const std::string &uuid) {
Poco::JSON::Object Body;
Body.set("serialNumber", SerialNumber);
Body.set("entity", uuid);
OpenWifi::OpenAPIRequestPut R(OpenWifi::uSERVICE_GATEWAY,
"/api/v1/device/" +SerialNumber,
{},
Body,
10000);
Poco::JSON::Object::Ptr Response;
auto ResponseStatus = R.Do(Response, client ? client->UserInfo_.webtoken.access_token_ : "");
if(ResponseStatus == Poco::Net::HTTPResponse::HTTP_OK) {
return true;
}
return false;
}
bool SetSubscriber(RESTAPIHandler *client, const std::string & SerialNumber, const std::string &uuid) {
Poco::JSON::Object Body;
Body.set("serialNumber", SerialNumber);
Body.set("subscriber", uuid);
OpenWifi::OpenAPIRequestPut R(OpenWifi::uSERVICE_GATEWAY,
"/api/v1/device/" +SerialNumber,
{},
Body,
10000);
Poco::JSON::Object::Ptr Response;
auto ResponseStatus = R.Do(Response, client ? client->UserInfo_.webtoken.access_token_ : "");
if(ResponseStatus == Poco::Net::HTTPResponse::HTTP_OK) {
return true;
}
return false;
}
bool Configure(RESTAPIHandler *client, const std::string &Mac, Poco::JSON::Object::Ptr & Configuration, Poco::JSON::Object::Ptr & Response) {
Poco::JSON::Object Body;

View File

@@ -17,6 +17,11 @@ namespace OpenWifi::SDK::GW {
bool Configure(RESTAPIHandler *client, const std::string &Mac, Poco::JSON::Object::Ptr & Configuration, Poco::JSON::Object::Ptr & Response);
bool SetVenue(RESTAPIHandler *client, const std::string & SerialNumber, const std::string &uuid);
bool SetSubscriber(RESTAPIHandler *client, const std::string & SerialNumber, const std::string &uuid);
inline bool SetSubscriber(const std::string & SerialNumber, const std::string &uuid) {
return SetSubscriber(nullptr, SerialNumber, uuid);
}
bool SetEntity(RESTAPIHandler *client, const std::string & SerialNumber, const std::string &uuid);
}
}