From 9a025e552862b1930e4eb42dcb34560f4197b0e2 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Mon, 17 Oct 2016 14:31:09 +0900 Subject: [PATCH] Update a logic to check an availability of cloud server resource Rather than URI, resource type of the cloud server resource is more confirmable to check the availability. Change-Id: I61f3b63412b39fc56e993a3041ac007d0886368b Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/13331 Tested-by: jenkins-iotivity Reviewed-by: Heewon Park Reviewed-by: Madan Lanka --- service/easy-setup/enrollee/src/resourcehandler.c | 18 ++++++++++++++++++ service/easy-setup/mediator/richsdk/inc/ESRichCommon.h | 7 +++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index be8232b..c2ffa4a 100755 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -502,6 +502,12 @@ OCRepPayload* constructResponseOfWiFi() return NULL; } + if(gWiFiResource.handle == NULL) + { + OIC_LOG(ERROR, ES_RH_TAG, "WiFi resource is not created"); + return NULL; + } + OIC_LOG(INFO, ES_RH_TAG, "constructResponse wifi res"); OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI); OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT); @@ -538,6 +544,12 @@ OCRepPayload* constructResponseOfCloud() return NULL; } + if(gCloudResource.handle == NULL) + { + OIC_LOG(ERROR, ES_RH_TAG, "CloudServer resource is not created"); + return NULL; + } + OIC_LOG(INFO, ES_RH_TAG, "constructResponse cloudserver res"); OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_CLOUDSERVER); OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT); @@ -564,6 +576,12 @@ OCRepPayload* constructResponseOfDevConf() return NULL; } + if(gDevConfResource.handle == NULL) + { + OIC_LOG(ERROR, ES_RH_TAG, "DevConf resource is not created"); + return NULL; + } + OIC_LOG(INFO, ES_RH_TAG, "constructResponse devconf res"); OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_DEVCONF); OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT); diff --git a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h index 0eb7f36..9bafeae 100755 --- a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h +++ b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h @@ -616,9 +616,12 @@ namespace OIC std::vector children = m_ProvRep.getChildren(); for(auto child = children.begin(); child != children.end(); ++child) { - if(child->getUri().find(OC_RSRVD_ES_URI_CLOUDSERVER) != std::string::npos) + for(auto rt : child->getResourceTypes()) { - return true; + if(0 == rt.compare(OC_RSRVD_ES_RES_TYPE_CLOUDSERVER)) + { + return true; + } } } return false; -- 2.7.4