From 364ef260ffbaab6e98acd47c273d483dd4797958 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Tue, 23 Aug 2016 10:16:08 +0900 Subject: [PATCH] Update resource types of easy setup Rather than "ocf.wk." prefix, "oic.wk." is decided to be used. Change-Id: Ic140b82fdc987da0d95491abe9985febf1e6b544 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/10757 Reviewed-by: Heewon Park Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../enrollee/unittests/ESMediatorSimulator.h | 39 ++++++++++------------ service/easy-setup/inc/escommon.h | 8 ++--- .../service/easysetup/mediator/ESConstants.java | 8 ++--- .../service/easysetup/mediator/EasySetup.java | 5 ++- .../easy-setup/mediator/richsdk/inc/EasySetup.h | 2 +- .../richsdk/unittests/ESEnrolleeSimulator.h | 2 -- .../mediator/richsdk/unittests/ESMediatorTest.cpp | 8 ++--- .../service/easysetup/EasysetupActivity.java | 3 +- 8 files changed, 33 insertions(+), 42 deletions(-) mode change 100644 => 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java mode change 100644 => 100755 service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h diff --git a/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h b/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h index f6f8049..9efd51d 100755 --- a/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h +++ b/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h @@ -34,11 +34,6 @@ #include "cainterface.h" #include "OCPlatform.h" -#define PROV_RESOURCE_TYPE "ocf.wk.prov" -#define WIFI_RESOURCE_TYPE "ocf.wk.wifi" -#define DEV_RESOURCE_TYPE "ocf.wk.devconf" -#define CLOUD_RESOURCE_TYPE "ocf.wk.cloudserver" - using namespace OIC::Service; class ESMediatorSimulator @@ -73,7 +68,7 @@ public: void discoverRemoteEnrollee(std::function resource)> cb) { m_discoveryCb = cb; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCb, @@ -85,7 +80,7 @@ public: { m_getConfigurationCb = cb; m_remoteEnrollee = NULL; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToGetConfiguration, @@ -95,7 +90,7 @@ public: void getWifiRsrc(std::function cb) { m_getWifiCb = cb; - std::string uri = std::string("/oic/res?rt=") + WIFI_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_WIFI; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToGetWifiRsrc, @@ -105,7 +100,7 @@ public: void getCloudRsrc(std::function cb) { m_getCloudCb = cb; - std::string uri = std::string("/oic/res?rt=") + CLOUD_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_CLOUDSERVER; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToGetCloudRsrc, @@ -115,7 +110,7 @@ public: void getDevConfiguration(std::function cb) { m_getDevConfCb = cb; - std::string uri = std::string("/oic/res?rt=") + DEV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_DEVCONF; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToGetDevConf, @@ -126,7 +121,7 @@ public: { m_getStatusCb = cb; m_remoteEnrollee = NULL; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToGetStatus, @@ -137,7 +132,7 @@ public: { m_DevicePropProvisioningCb = cb; m_remoteEnrollee = NULL; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToProvisionDeviceProperties, @@ -148,7 +143,7 @@ public: { m_CloudPropProvisioningCb = cb; m_remoteEnrollee = NULL; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToProvisionCloudProperties, @@ -159,7 +154,7 @@ public: { m_provPutCb = cb; m_remoteEnrollee = NULL; - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&ESMediatorSimulator::discoverRemoteEnrolleeCbToPutProvRsrc, @@ -206,7 +201,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_discoveryCb) + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV) && m_discoveryCb) { m_discoveryCb(resource); m_discoveryCb = NULL; @@ -229,7 +224,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_getConfigurationCb + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV) && m_getConfigurationCb && !m_remoteEnrollee) { m_remoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource); @@ -270,7 +265,7 @@ private: void discoverRemoteEnrolleeCbToGetWifiRsrc(std::shared_ptr resource) { - if(!resource->getResourceTypes().at(0).compare(WIFI_RESOURCE_TYPE) && m_getWifiCb) + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_WIFI) && m_getWifiCb) { QueryParamsMap test; resource->get(test, std::bind( @@ -308,7 +303,7 @@ private: void discoverRemoteEnrolleeCbToGetCloudRsrc(std::shared_ptr resource) { - if(!resource->getResourceTypes().at(0).compare(CLOUD_RESOURCE_TYPE) && m_getCloudCb) + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_CLOUDSERVER) && m_getCloudCb) { QueryParamsMap test; resource->get(test, std::bind( @@ -345,7 +340,7 @@ private: void discoverRemoteEnrolleeCbToGetDevConf(std::shared_ptr resource) { - if(!resource->getResourceTypes().at(0).compare(DEV_RESOURCE_TYPE) && m_getDevConfCb) + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_DEVCONF) && m_getDevConfCb) { QueryParamsMap test; resource->get(test, std::bind( @@ -370,7 +365,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_getStatusCb + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV) && m_getStatusCb && !m_remoteEnrollee) { m_remoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource); @@ -400,7 +395,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV) && m_DevicePropProvisioningCb && !m_remoteEnrollee) { m_remoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource); @@ -438,7 +433,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV) && m_CloudPropProvisioningCb && !m_remoteEnrollee) { m_remoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource); diff --git a/service/easy-setup/inc/escommon.h b/service/easy-setup/inc/escommon.h index 15933c2..f65325a 100755 --- a/service/easy-setup/inc/escommon.h +++ b/service/easy-setup/inc/escommon.h @@ -59,13 +59,13 @@ extern "C" /** * Easysetup defined resoruce types and uris. */ -#define OC_RSRVD_ES_RES_TYPE_PROV "ocf.wk.prov" +#define OC_RSRVD_ES_RES_TYPE_PROV "oic.wk.prov" #define OC_RSRVD_ES_URI_PROV "/ProvisioningResURI" -#define OC_RSRVD_ES_RES_TYPE_WIFI "ocf.wk.wifi" +#define OC_RSRVD_ES_RES_TYPE_WIFI "oic.wk.wifi" #define OC_RSRVD_ES_URI_WIFI "/WiFiProvisioningResURI" -#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "ocf.wk.cloudserver" +#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "oic.wk.cloudserver" #define OC_RSRVD_ES_URI_CLOUDSERVER "/CloudServerProvisioningResURI" -#define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.wk.devconf" +#define OC_RSRVD_ES_RES_TYPE_DEVCONF "oic.wk.devconf" #define OC_RSRVD_ES_URI_DEVCONF "/DevConfProvisioningResURI" diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java old mode 100644 new mode 100755 index 5f88ae6..3928cb6 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java @@ -27,13 +27,13 @@ public class ESConstants { /** * Easysetup defined resoruce types and uris */ - public static final String OC_RSRVD_ES_RES_TYPE_PROV = "ocf.wk.prov"; + public static final String OC_RSRVD_ES_RES_TYPE_PROV = "oic.wk.prov"; public static final String OC_RSRVD_ES_URI_PROV = "/ProvisioningResURI"; - public static final String OC_RSRVD_ES_RES_TYPE_WIFI = "ocf.wk.wifi"; + public static final String OC_RSRVD_ES_RES_TYPE_WIFI = "oic.wk.wifi"; public static final String OC_RSRVD_ES_URI_WIFI = "/WiFiProvisioningResURI"; - public static final String OC_RSRVD_ES_RES_TYPE_CLOUDSERVER = "ocf.wk.cloudserver"; + public static final String OC_RSRVD_ES_RES_TYPE_CLOUDSERVER = "oic.wk.cloudserver"; public static final String OC_RSRVD_ES_URI_CLOUDSERVER = "/CloudServerProvisioningResURI"; - public static final String OC_RSRVD_ES_RES_TYPE_DEVCONF = "ocf.wk.devconf"; + public static final String OC_RSRVD_ES_RES_TYPE_DEVCONF = "oic.wk.devconf"; public static final String OC_RSRVD_ES_URI_DEVCONF = "/DevConfProvisioningResURI"; } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java index 56a7d80..a4ed96e 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java @@ -40,7 +40,6 @@ import java.util.List; public class EasySetup { private static final String TAG = EasySetup.class.getName(); - public static final String PROV_RESOURCE_TYPE = "ocf.wk.prov"; private static EasySetup sInstance; private static Context mContext; @@ -88,14 +87,14 @@ public class EasySetup { * discovered in a network. The OcResource object can be obtained by calling * OcPlatform.findResource() API. What resource you have to discover with * the OcPlatform.findResource() API is a "provisioning" resource with a certain - * resource type, i.e. ocf.wk.prov + * resource type, i.e. oic.wk.prov * * @return Pointer to RemoteEnrollee instance */ public synchronized RemoteEnrollee createRemoteEnrollee(OcResource enrolleeResource) { // native call - if(!enrolleeResource.getResourceTypes().contains(PROV_RESOURCE_TYPE) + if(!enrolleeResource.getResourceTypes().contains(ESConstants.OC_RSRVD_ES_RES_TYPE_PROV) || !enrolleeResource.getResourceInterfaces().contains(OcPlatform.BATCH_INTERFACE)) { Log.e(TAG, "Validation check for OcResource is failed."); diff --git a/service/easy-setup/mediator/richsdk/inc/EasySetup.h b/service/easy-setup/mediator/richsdk/inc/EasySetup.h index 68eb295..531971d 100755 --- a/service/easy-setup/mediator/richsdk/inc/EasySetup.h +++ b/service/easy-setup/mediator/richsdk/inc/EasySetup.h @@ -54,7 +54,7 @@ namespace OIC * discovered in a network. The OCResource object can be obtained by calling * OCPlatform.findResource() API. What resource you have to discover with * the OCPlatform.findResource() API is a "provisioning" resource with a certain - * resource type, i.e. ocf.wk.prov + * resource type, i.e. oic.wk.prov * * @throws ESBadRequestException If createEnrolleeDevice is invoked with the same * provisioning information. diff --git a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h old mode 100644 new mode 100755 index 80220be..026dec7 --- a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h +++ b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h @@ -31,8 +31,6 @@ #include "ESEnrolleeCommon.h" #include "easysetup.h" -#define PROV_RESOURCE_TYPE "ocf.wk.prov" - class ESEnrolleeSimulator { public: diff --git a/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp b/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp index 86d83bd..4cc18ab 100755 --- a/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp +++ b/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp @@ -39,8 +39,6 @@ #include "cainterface.h" #include "OCPlatform.h" -#define PROV_RESOURCE_TYPE "ocf.wk.prov" - using namespace OC; using namespace OIC::Service; @@ -93,7 +91,7 @@ public: std::shared_ptr CreateNotProvResource() { OCConnectivityType connectivityType = CT_DEFAULT; - std::vector types = {"ocf.wk.notprov"}; + std::vector types = {"oic.wk.notprov"}; std::vector ifaces = {DEFAULT_INTERFACE}; return OCPlatform::constructResourceObject("coap://192.168.1.2:5000", @@ -106,7 +104,7 @@ public: void discoverRemoteEnrollee() { - std::string uri = std::string("/oic/res?rt=") + PROV_RESOURCE_TYPE; + std::string uri = std::string("/oic/res?rt=") + OC_RSRVD_ES_RES_TYPE_PROV; OC::OCPlatform::findResource("", uri, OCConnectivityType::CT_DEFAULT, std::bind(&EasysetupMediatorTest::discoverRemoteEnrolleeCb, @@ -177,7 +175,7 @@ private: return ; } - if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE)) + if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_PROV)) { m_enrolleeResource = resource; } diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java index 5105710..e9f2cc7 100755 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java @@ -54,6 +54,7 @@ import org.iotivity.base.OcResource; import org.iotivity.base.PlatformConfig; import org.iotivity.base.QualityOfService; import org.iotivity.base.ServiceType; +import org.iotivity.service.easysetup.mediator.ESConstants; import org.iotivity.service.easysetup.mediator.CloudProp; import org.iotivity.service.easysetup.mediator.CloudPropProvisioningCallback; import org.iotivity.service.easysetup.mediator.CloudPropProvisioningStatus; @@ -440,7 +441,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence }); try { - String requestUri = OcPlatform.WELL_KNOWN_QUERY + "?rt=ocf.wk.prov"; + String requestUri = OcPlatform.WELL_KNOWN_QUERY + "?rt=" + ESConstants.OC_RSRVD_ES_RES_TYPE_PROV; OcPlatform.findResource("", requestUri, EnumSet.of(OcConnectivityType.CT_DEFAULT), -- 2.7.4