{
RCSResourceAttributes attributesToSet;
std::vector< std::string > scenenames{ name };
-
+
attributesToSet[SCENE_KEY_SCENEVALUES] = scenenames;
RCSRemoteResourceObject::RemoteAttributesSetCallback setRequestCB
m_sceneCollectionResource->get(params, cb);
}
- RCSRemoteResourceObject::Ptr
+ RCSRemoteResourceObject::Ptr
SceneCollectionResourceRequestor::getRemoteResourceObject() const
{
return m_sceneCollectionResource;
std::make_shared< SceneMemberResourceRequestor >(pResource, id);
pMemRequestor->setRemoteResourceObject(target);
-
+
{
std::lock_guard< std::mutex > memberlock(m_memberRequestorLock);
m_memberRequestors[target->getAddress() + target->getUri()] = pMemRequestor;
{
// TODO error code
int resultCode = SCENE_CLIENT_BADREQUEST;
-
- if (eCode == OC_STACK_OK)
+ if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
{
try
{
int result = SCENE_CLIENT_BADREQUEST;
SceneMemberResourceRequestor::Ptr memRequestor = nullptr;
- if (eCode == OC_STACK_OK)
+ if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
{
try
{
const InternalSetNameCallback &internalCB)
{
int result = SCENE_CLIENT_BADREQUEST;
- if (eCode == OC_STACK_OK)
+ if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
{
if (rep.getAttributes().at(SCENE_KEY_NAME).get< std::string >() == name)
{
int result = SCENE_CLIENT_BADREQUEST;
std::string link, id;
- if (eCode == OC_STACK_OK)
+ if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
{
try
{
const InternalSetNameCallback &internalCB)
{
int result = SCENE_CLIENT_BADREQUEST;
- if (eCode == OC_STACK_OK)
+
+ if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
{
if (rep.getAttributes().at(SCENE_KEY_NAME).get< std::string >() == name)
{
result = SCENE_RESPONSE_SUCCESS;
}
-
}
internalCB(result);
std::string SceneUtils::getNetAddress()
{
- CAEndpoint_t ** netInfo = (CAEndpoint_t **)OICMalloc(sizeof(CAEndpoint_t*)*5);
-
- if(netInfo == nullptr)
- {
- throw RCSException("memory allocation fail");
- }
-
+ CAEndpoint_t * netInfo = nullptr;
uint32_t size = 0;
- CAGetNetworkInformation(netInfo, &size);
+ CAGetNetworkInformation(&netInfo, &size);
if (size == 0)
{
OICFree(netInfo);
throw RCSException("Disabled Network");
}
+ std::string address_ipv4 = "", address_ipv6 = "";
for (uint32_t i = 0; i < size; ++i)
{
- if (netInfo[i]->adapter == CATransportAdapter_t::CA_ADAPTER_IP)
+ if (netInfo[i].adapter == CATransportAdapter_t::CA_ADAPTER_IP)
{
- std::string retAddress
- = std::string(netInfo[i]->addr) + ":" + std::to_string(netInfo[i]->port);
-
- OICFree(netInfo);
- return retAddress;
+ if(netInfo[i].flags == CATransportFlags_t::CA_IPV4)
+ {
+ address_ipv4 = std::string(netInfo[i].addr) + ":"
+ + std::to_string(netInfo[i].port);
+ } else if(netInfo[i].flags == CATransportFlags_t::CA_IPV6)
+ {
+ address_ipv6 = "[" + std::string(netInfo[i].addr) + "]:"
+ + std::to_string(netInfo[i].port);
+ }
}
}
+ if(address_ipv4.length() > 0 && address_ipv6.length() == 0)
+ {
+ OICFree(netInfo);
+ return address_ipv4;
+ } else if(address_ipv6.length() > 0)
+ {
+ OICFree(netInfo);
+ return address_ipv6;
+ }
+
OICFree(netInfo);
throw RCSException("Not supported Network");
}
std::string hostaddress, uri;
SceneUtils::getHostUriString(address, &hostaddress, &uri);
- OC::OCResource::Ptr pOCResource =
- OC::OCPlatform::constructResourceObject(
- hostaddress, uri, ct, false, vecRT, vecIF);
+ OC::OCResource::Ptr pOCResource = nullptr;
+
+ if(hostaddress.find("[") != std::string::npos &&
+ hostaddress.find("]") != std::string::npos)
+ {
+ pOCResource = OC::OCPlatform::constructResourceObject(
+ hostaddress,
+ uri,
+ (OCConnectivityType)(ct | CT_IP_USE_V6),
+ false,
+ vecRT,
+ vecIF);
+ }
+ else
+ {
+ pOCResource = OC::OCPlatform::constructResourceObject(
+ hostaddress,
+ uri,
+ (OCConnectivityType)(ct | CT_IP_USE_V4),
+ false,
+ vecRT,
+ vecIF);
+ }
return RCSRemoteResourceObject::fromOCResource(pOCResource);
}