mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Updating device subscriber record.
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user