From 17b7f943079e5bb9f895f440133fbd7fd3c7ce4f Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Wed, 12 Apr 2017 19:49:52 +0900 Subject: [PATCH] Remove some properties in oic.r.devconf resource Problem: Some of properties in oic.r.devconf resource has a duplicated meaning with other existing resource's one like oic.wk.con and oic.wk.p. For OCF spec, such a duplication should be avoided as possible. Way to resolve: All properties EXCEPT device name("dn") property are removed. Later, some properties can be defined in oic.r.devconf with spec update. Change-Id: I935b3d46773aa97a846335ad36f4f866269e05d0 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/18793 Reviewed-by: Uze Choi Tested-by: Uze Choi --- service/easy-setup/enrollee/inc/ESEnrolleeCommon.h | 5 +- service/easy-setup/enrollee/src/resourcehandler.c | 42 +--------- .../enrollee/unittests/ESEnrolleeTest.cpp | 13 +--- .../enrollee/unittests/ESMediatorSimulator.h | 1 - service/easy-setup/inc/escommon.h | 4 - .../easy-setup/mediator/richsdk/inc/ESRichCommon.h | 89 ---------------------- .../richsdk/unittests/ESEnrolleeSimulator.h | 2 +- .../mediator/richsdk/unittests/ESMediatorTest.cpp | 6 +- .../sampleapp/enrollee/linux/enrolleewifi.c | 5 +- .../mediator/linux/richsdk_sample/mediator.cpp | 2 - .../mediator/linux/richsdk_sample/submediator.cpp | 2 - 11 files changed, 9 insertions(+), 162 deletions(-) diff --git a/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h b/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h index 95b6d2d..8e6931b 100755 --- a/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h +++ b/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h @@ -55,9 +55,7 @@ typedef struct */ typedef struct { - char location[OIC_STRING_MAX_VALUE]; /**< GPS information of device. Longitude and latitude in json format **/ - char language[OIC_STRING_MAX_VALUE]; /**< IETF language tag using ISO 639X **/ - char country[OIC_STRING_MAX_VALUE]; /**< ISO Country Code (ISO 3166-1 Alpha-2) **/ + // TODO: variables can be added when some properties in oic.r.devconf resource are specified. void *userdata; /**< Vender-specific data**/ } ESDevConfData; @@ -94,7 +92,6 @@ typedef struct struct { char deviceName[OIC_STRING_MAX_VALUE]; - char modelNumber[OIC_STRING_MAX_VALUE]; } DevConf; } ESDeviceProperty; diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index cdbef4f..892d08e 100755 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -271,10 +271,6 @@ OCStackResult initDevConfResource(bool isSecured) OCStackResult res = OC_STACK_ERROR; OICStrcpy(g_ESDevConfResource.devName, sizeof(g_ESDevConfResource.devName), ""); - OICStrcpy(g_ESDevConfResource.modelNumber, sizeof(g_ESDevConfResource.modelNumber), ""); - OICStrcpy(g_ESDevConfResource.location, sizeof(g_ESDevConfResource.location), ""); - OICStrcpy(g_ESDevConfResource.country, sizeof(g_ESDevConfResource.country), ""); - OICStrcpy(g_ESDevConfResource.language, sizeof(g_ESDevConfResource.language), ""); if (isSecured) { @@ -527,40 +523,16 @@ void updateDevConfResource(OCRepPayload* input) OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed"); return; } - memset(devConfData->language, 0, OIC_STRING_MAX_VALUE); - memset(devConfData->country, 0, OIC_STRING_MAX_VALUE); devConfData->userdata = NULL; - char *location = NULL; - if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LOCATION, &location)) - { - OICStrcpy(g_ESDevConfResource.location, sizeof(g_ESDevConfResource.location), location); - OICStrcpy(devConfData->location, sizeof(devConfData->location), location); - OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.location %s", g_ESDevConfResource.location); - } - - char *country = NULL; - if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_COUNTRY, &country)) - { - OICStrcpy(g_ESDevConfResource.country, sizeof(g_ESDevConfResource.country), country); - OICStrcpy(devConfData->country, sizeof(devConfData->country), country); - OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.country %s", g_ESDevConfResource.country); - } - - char *language = NULL; - if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LANGUAGE, &language)) - { - OICStrcpy(g_ESDevConfResource.language, sizeof(g_ESDevConfResource.language), language); - OICStrcpy(devConfData->language, sizeof(devConfData->language), language); - OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.language %s", g_ESDevConfResource.language); - } - if (gReadUserdataCb) { gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, &devConfData->userdata); } - if (country || language) + // If a writable property in oic.r.devconf is added later, + // a condition for calling a resistered callback should be implemented also. + if( devConfData->userdata != NULL ) { OIC_LOG(DEBUG, ES_RH_TAG, "Send DevConfRsrc Callback To ES"); @@ -824,10 +796,6 @@ OCRepPayload* constructResponseOfDevConf(char *interface) } OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, g_ESDevConfResource.devName); - OCRepPayloadSetPropString(payload, OC_RSRVD_ES_MODELNUMBER, g_ESDevConfResource.modelNumber); - OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LOCATION, g_ESDevConfResource.location); - OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, g_ESDevConfResource.language); - OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, g_ESDevConfResource.country); if (gWriteUserdataCb) { @@ -1630,10 +1598,6 @@ OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty) OICStrcpy(g_ESDevConfResource.devName, OIC_STRING_MAX_VALUE, (deviceProperty->DevConf).deviceName); OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Device Name : %s", g_ESDevConfResource.devName); - OICStrcpy(g_ESDevConfResource.modelNumber, OIC_STRING_MAX_VALUE, - (deviceProperty->DevConf).modelNumber); - OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Model Number : %s", g_ESDevConfResource.modelNumber); - if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS)) { OIC_LOG(DEBUG, ES_RH_TAG, "wifiResource doesn't have any observers."); diff --git a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp index 6efd924..b041d1f 100755 --- a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp +++ b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp @@ -159,7 +159,7 @@ public: ESResult setDeviceProperty() { ESDeviceProperty deviceProperty = { - {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"} + {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"} }; return ESSetDeviceProperty(&deviceProperty); @@ -393,15 +393,6 @@ TEST_F(EasysetupEnrolleeTest, WiFiAndDevConfProperiesProvisionedWithSuccess) cntForReceivedCallbackWithSuccess++; } }); - mocks.OnCallFunc(DevConfProvCbInApp).Do( - [& cntForReceivedCallbackWithSuccess](ESDevConfData *data) - { - if(!strcmp(data->language, "korean") && - !strcmp(data->country, "Korea")) - { - cntForReceivedCallbackWithSuccess++; - } - }); startEnrollee(); @@ -410,7 +401,7 @@ TEST_F(EasysetupEnrolleeTest, WiFiAndDevConfProperiesProvisionedWithSuccess) std::unique_lock< std::mutex > lock{ mutexForCondition }; responseCon.wait_for(lock, g_waitForResponse); - EXPECT_EQ(cntForReceivedCallbackWithSuccess, 3); + EXPECT_EQ(cntForReceivedCallbackWithSuccess, 2); ESTerminateEnrollee(); } diff --git a/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h b/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h index a20ac33..48b28d5 100755 --- a/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h +++ b/service/easy-setup/enrollee/unittests/ESMediatorSimulator.h @@ -420,7 +420,6 @@ private: { DeviceProp devProp; devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES); - devProp.setDevConfProp("korean", "Korea", "Location"); m_remoteEnrollee->provisionDeviceProperties(devProp, std::bind(&ESMediatorSimulator::deviceProvisioningStatusCallback, diff --git a/service/easy-setup/inc/escommon.h b/service/easy-setup/inc/escommon.h index 713ee0f..bc3a889 100755 --- a/service/easy-setup/inc/escommon.h +++ b/service/easy-setup/inc/escommon.h @@ -59,10 +59,6 @@ extern "C" #define OC_RSRVD_ES_CISERVER "cis" #define OC_RSRVD_ES_SERVERID "sid" #define OC_RSRVD_ES_DEVNAME "dn" -#define OC_RSRVD_ES_LANGUAGE "lang" -#define OC_RSRVD_ES_COUNTRY "ctry" -#define OC_RSRVD_ES_MODELNUMBER "mnmo" -#define OC_RSRVD_ES_LOCATION "loc" #define OC_RSRVD_ES_HREF "href" #define OC_RSRVD_ES_CONNECT "cn" diff --git a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h index c66cf67..20b79f1 100755 --- a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h +++ b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h @@ -372,20 +372,6 @@ namespace OIC } /** - * Set DevConf resource properties to be delivered to Enrollee - * - * @param language IETF language tag using ISO 639X - * @param country ISO Country Code (ISO 3166-1 Alpha-2) - * @param location location information - */ - void setDevConfProp(string language, string country, string location) - { - m_rep.setValue(OC_RSRVD_ES_LANGUAGE, language); - m_rep.setValue(OC_RSRVD_ES_COUNTRY, country); - m_rep.setValue(OC_RSRVD_ES_LOCATION, location); - } - - /** * Get a SSID of Enroller * * @return a SSID of enroller @@ -446,50 +432,6 @@ namespace OIC } /** - * Get a language to be set. A language is expressed in IETF language tag - * using ISO 639X. - * - * @return a language to be set - */ - std::string getLanguage() const - { - if(m_rep.hasAttribute(OC_RSRVD_ES_LANGUAGE)) - { - return m_rep.getValue(OC_RSRVD_ES_LANGUAGE); - } - return std::string(""); - } - - /** - * Get a country to be set. A country is expressed in ISO Country Code - * (ISO 3166-1 Alpha-2) - * - * @return a country to be set - */ - std::string getCountry() const - { - if(m_rep.hasAttribute(OC_RSRVD_ES_COUNTRY)) - { - return m_rep.getValue(OC_RSRVD_ES_COUNTRY); - } - return std::string(""); - } - - /** - * Get a location to be set. A location is GPS information - * - * @return a country to be set - */ - std::string getLocation() const - { - if(m_rep.hasAttribute(OC_RSRVD_ES_LOCATION)) - { - return m_rep.getValue(OC_RSRVD_ES_LOCATION); - } - return std::string(""); - } - - /** * Get OCRepresentation object * * @return OCRepresentation object @@ -663,37 +605,6 @@ namespace OIC } /** - * Get a model number of Enrollee. - * - * @return a model number of Enrollee - */ - std::string getModelNumber() const - { - std::vector children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(OC_RSRVD_ES_MODELNUMBER)) - { - return rep.getValue(OC_RSRVD_ES_MODELNUMBER); - } - } - } - return std::string(""); - } - - /** * Get a set of WiFi supported modes of Enrollee * * @return a set of WiFi supported modes of Enrollee diff --git a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h index 20f522e..ac097fa 100755 --- a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h +++ b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h @@ -62,7 +62,7 @@ public: ESResult setDeviceProperty() { ESDeviceProperty deviceProperty = { - {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"} + {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"} }; return ESSetDeviceProperty(&deviceProperty); diff --git a/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp b/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp index bd29087..8b50705 100755 --- a/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp +++ b/service/easy-setup/mediator/richsdk/unittests/ESMediatorTest.cpp @@ -240,13 +240,11 @@ TEST_F(GetConfigurationTest, GetConfigurationSucceed) { if(conf.getWiFiModes().at(0) == WIFI_11G && conf.getWiFiFreq() == WIFI_5G && - !strcmp(conf.getDeviceName().c_str(), "Test Device") && - !strcmp(conf.getModelNumber().c_str(), "Test Model Number")) + !strcmp(conf.getDeviceName().c_str(), "Test Device")) { isWellConstructed = true; } cout << "getDeviceName : " << conf.getDeviceName().c_str() << endl; - cout << "getModelNumber : " << conf.getModelNumber().c_str() << endl; } } }); @@ -345,7 +343,6 @@ TEST_F(ProvisionDevicePropertiesTest, { DeviceProp devProp; devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES); - devProp.setDevConfProp("korean", "Korea", "Location"); EXPECT_ANY_THROW(g_remoteEnrollee->provisionDeviceProperties(devProp, nullptr)); } @@ -355,7 +352,6 @@ TEST_F(ProvisionDevicePropertiesTest, { DeviceProp devProp; devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES); - devProp.setDevConfProp("korean", "Korea", "Location"); int cntForReceivedCallbackWithSuccess = 0; diff --git a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c index 8f207ff..c2f5737 100755 --- a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c +++ b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c @@ -118,9 +118,6 @@ void DevConfProvCbInApp(ESDevConfData *eventData) return ; } - printf("Language : %s\n", eventData->language); - printf("Country : %s\n", eventData->country); - printf("DevConfProvCbInApp OUT\n"); } @@ -204,7 +201,7 @@ void SetDeviceInfo() printf("SetDeviceInfo IN\n"); ESDeviceProperty deviceProperty = { - {{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"} + {{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device"} }; // Set user properties if needed diff --git a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp index b23f07a..976ec97 100755 --- a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp +++ b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp @@ -74,7 +74,6 @@ void printConfiguration(const EnrolleeConf& conf) cout << "\tProvStatus : " << conf.getProvStatus() << endl; cout << "\tLastErrCode : " << conf.getLastErrCode() << endl; cout << "\tDevice Name : " << conf.getDeviceName() << endl; - cout << "\tModel Number : " << conf.getModelNumber() << endl; for(auto it : conf.getWiFiModes()) { @@ -244,7 +243,6 @@ void provisionDeviceProperty() DeviceProp devProp; devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES); - devProp.setDevConfProp("korean", "Korea", "Location"); try { diff --git a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp index e08ef1a..4b7e0bb 100755 --- a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp +++ b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp @@ -72,7 +72,6 @@ void printConfiguration(const EnrolleeConf& conf) { cout << "===========================================" << endl; cout << "\tDevice Name : " << conf.getDeviceName() << endl; - cout << "\tModel Number : " << conf.getModelNumber() << endl; for(auto it : conf.getWiFiModes()) { @@ -239,7 +238,6 @@ void provisionDeviceProperty() DeviceProp devProp; devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES); - devProp.setDevConfProp("korean", "Korea", "Location"); try { -- 2.7.4