Commit 1503c9ca authored by Minji Park's avatar Minji Park Committed by Uze Choi

Update soft-sensor-manager to use updated OIC Virtual Resource definitions

modify ssm resource finder to use changed OIC Virtual Resource
and to get connectivity type of found resources

Change-Id: Ia91fa7e1aed17f614c1dbc5bae9cc37668091174
Signed-off-by: default avatarMinji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1686Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 5d2956aa
......@@ -57,13 +57,14 @@ class ISSMResource
ISSMResource(const std::string &n, const std::string &t) :
name(n), type(t)
{
location = SENSOR_LOCATION_LOCAL;
location = SENSOR_LOCATION_LOCAL;
}
SENSOR_LOCATION location;
std::string name;
std::string type;
std::string friendlyName;
std::string ip;
int connectivityType;
std::vector<std::string> inputList;
std::vector<std::map<std::string, std::string> > outputProperty;
};
......
......@@ -19,6 +19,8 @@
******************************************************************/
#include "ResourceFinder.h"
OCConnectivityType g_connectivityType = CT_DEFAULT;
SSMRESULT CResourceFinder::finalConstruct()
{
SSMRESULT res = SSM_E_FAIL;
......@@ -76,9 +78,9 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
switch (result)
{
case OC_STACK_OK:
requestURI << "coap://" << hostAddress << "/oc/core?rt=SSManager.Sensor";
requestURI << "coap://" << hostAddress << OC_RSRVD_WELL_KNOWN_URI << "?rt=SSManager.Sensor";
ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
if (ret != OC_STACK_OK)
......@@ -105,7 +107,7 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
case OC_STACK_PRESENCE_TIMEOUT:
break;
case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
case OC_STACK_PRESENCE_DO_NOT_HANDLE:
break;
default:
......@@ -127,14 +129,14 @@ SSMRESULT CResourceFinder::startResourceFinder()
std::ostringstream multicastPresenceURI;
multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(),
"SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
"SSManager.Sensor", g_connectivityType, std::bind(&CResourceFinder::presenceHandler, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
if (ret != OC_STACK_OK)
......@@ -194,7 +196,7 @@ void CResourceFinder::onExecute(void *pArg)
pResourceHandler = new OICResourceHandler();
res = pResourceHandler->initHandler(*pResource, this);
if(res != SSM_S_OK)
if (res != SSM_S_OK)
{
SAFE_DELETE(pResourceHandler);
SSM_CLEANUP_ASSERT(res);
......@@ -222,8 +224,9 @@ void CResourceFinder::onExecute(void *pArg)
m_mapResourcePresenceHandles.end())
{
ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
"SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
"SSManager.Sensor", (OCConnectivityType)(((ISSMResource *)pMessage[1])->connectivityType),
std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
......@@ -233,9 +236,6 @@ void CResourceFinder::onExecute(void *pArg)
m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
break;
case RESOURCE_DISCOVER_UNINSTALL_RESOURCE:
......
......@@ -146,7 +146,7 @@ CLEANUP: return res;
}
void onGetResourceProfile(const OC::HeaderOptions &headerOptions,
const OC::OCRepresentation &representation, const int &eCode)
const OC::OCRepresentation &representation, const int eCode)
{
//unpack attributeMap
......@@ -156,6 +156,7 @@ CLEANUP: return res;
m_SSMResource.name = m_pResource->host() + m_pResource->uri();
m_SSMResource.type = m_pResource->uri().substr(1);
m_SSMResource.ip = m_pResource->host();
m_SSMResource.connectivityType = m_pResource->connectivityType();
//bind default properties
outputProperty["name"] = "lifetime";
......
......@@ -68,8 +68,6 @@ class TemphumidResource
printf("Running thing as %s\n", m_resourceUri.c_str());
m_resourceRep.setUri(m_resourceUri);
m_resourceRep.setResourceTypes(m_resourceTypes);
m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
}
~TemphumidResource()
......
......@@ -68,8 +68,6 @@ class TemphumidResource
printf("Running thing as %s\n", m_resourceUri.c_str());
m_resourceRep.setUri(m_resourceUri);
m_resourceRep.setResourceTypes(m_resourceTypes);
m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
}
~TemphumidResource()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment