Commit 17b7f943 authored by Jihun Ha's avatar Jihun Ha Committed by Uze Choi

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: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18793Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent f6f29244
......@@ -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;
......
......@@ -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.");
......
......@@ -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();
}
......
......@@ -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,
......
......@@ -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"
......
......@@ -371,20 +371,6 @@ namespace OIC
m_rep.setValue(OC_RSRVD_ES_ENCTYPE, enctype);
}
/**
* 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
*
......@@ -445,50 +431,6 @@ namespace OIC
return NONE_ENC;
}
/**
* 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<std::string>(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<std::string>(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<std::string>(OC_RSRVD_ES_LOCATION);
}
return std::string("");
}
/**
* Get OCRepresentation object
*
......@@ -662,37 +604,6 @@ namespace OIC
return std::string("");
}
/**
* Get a model number of Enrollee.
*
* @return a model number of Enrollee
*/
std::string getModelNumber() const
{
std::vector<OCRepresentation> 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<OCRepresentation>(OC_RSRVD_REPRESENTATION);
}
else
{
return std::string("");
}
if(rep.hasAttribute(OC_RSRVD_ES_MODELNUMBER))
{
return rep.getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
}
}
}
return std::string("");
}
/**
* Get a set of WiFi supported modes of Enrollee
*
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
......@@ -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
{
......
......@@ -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
{
......
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