Commit 920553bf authored by Jihun Ha's avatar Jihun Ha Committed by Madan Lanka

Add 'model number' and 'location' properties from mediator side

 - 'setDevConfProp' function is added parameter which is information of location
 - add 'getModelNumber' function.

Change-Id: I48a028dd77310d690035f348cb721fa52adfc462
Signed-off-by: default avatarHeewon Park <h_w.park@samsung.com>
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10497Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent a31b400c
......@@ -194,7 +194,7 @@ private:
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
devProp.setDevConfProp("korean", "Korea");
devProp.setDevConfProp("korean", "Korea", "Location");
m_remoteEnrollee->provisionDeviceProperties(devProp,
std::bind(&ESMediatorSimulator::deviceProvisioningStatusCallback,
......
......@@ -55,11 +55,12 @@ public class DeviceProp {
}
}
public void setDevConfProp(String language, String country)
public void setDevConfProp(String language, String country, String location)
{
try {
mRep.setValue(ESConstants.OC_RSRVD_ES_LANGUAGE, language);
mRep.setValue(ESConstants.OC_RSRVD_ES_COUNTRY, country);
mRep.setValue(ESConstants.OC_RSRVD_ES_LOCATION, location);
} catch (OcException e) {
Log.e(TAG, "setDevConfProp is failed.");
}
......@@ -163,6 +164,22 @@ public class DeviceProp {
return new String("");
}
/**
* Get location info
*
* @return String location info of GPS
*/
public String getLocation()
{
try {
if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_LOCATION))
return mRep.getValue(ESConstants.OC_RSRVD_ES_LOCATION);
} catch (OcException e) {
Log.e(TAG, "getLocation is failed.");
}
return new String("");
}
public OcRepresentation toOCRepresentation()
{
return mRep;
......
......@@ -21,6 +21,8 @@ public class ESConstants {
public static final String OC_RSRVD_ES_DEVNAME = "dn";
public static final String OC_RSRVD_ES_LANGUAGE = "lang";
public static final String OC_RSRVD_ES_COUNTRY = "ctry";
public static final String OC_RSRVD_ES_MODELNUMBER = "mnmo";
public static final String OC_RSRVD_ES_LOCATION = "loc";
/**
* Easysetup defined resoruce types and uris
......@@ -33,5 +35,5 @@ public class ESConstants {
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_URI_DEVCONF = "/DevConfProvisioningResURI";
}
......@@ -88,6 +88,24 @@ public class EnrolleeConf
return new String("");
}
/**
* Get Model Number property in DevConf resource
*
* @return modelNumber
*/
public String getModelNumber()
{
try
{
if(mDevConfRep != null && mDevConfRep.hasAttribute(ESConstants.OC_RSRVD_ES_MODELNUMBER)) {
return (String) mDevConfRep.getValue(ESConstants.OC_RSRVD_ES_MODELNUMBER);
}
} catch (OcException e) {
Log.e(TAG, "getModelNumber is failed.");
}
return new String("");
}
/**
* Get Supported WiFi Modes property in WiFi resource
*
......
......@@ -292,10 +292,11 @@ namespace OIC
* @param language IETF language tag using ISO 639X
* @param country ISO Country Code (ISO 3166-1 Alpha-2)
*/
void setDevConfProp(string language, string country)
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);
}
/**
......@@ -388,6 +389,20 @@ namespace OIC
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_MODELNUMBER))
{
return m_rep.getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
}
return std::string("");
}
/**
* Get OCRepresentation object
*
......@@ -490,6 +505,27 @@ 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_ProvRep.getChildren();
for(auto child = children.begin(); child != children.end(); ++child)
{
if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
{
if(child->hasAttribute(OC_RSRVD_ES_MODELNUMBER))
{
return child->getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
}
}
}
return std::string("");
}
/**
* Get a set of WiFi supported modes of Enrollee
*
......
......@@ -378,7 +378,6 @@ namespace OIC
const CloudPropProvStatusCb callback)
{
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Enter provisionCloudProperties");
ESResult res = ES_OK;
if(!callback)
{
......@@ -414,6 +413,7 @@ namespace OIC
#ifdef __WITH_DTLS__
try
{
ESResult res = ES_OK;
m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
if(cloudProp.getCloudID().empty())
......
......@@ -64,7 +64,7 @@ public:
ESResult setDeviceProperty()
{
ESDeviceProperty deviceProperty = {
{{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"}
{{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
};
return ESSetDeviceProperty(&deviceProperty);
......
......@@ -201,10 +201,13 @@ TEST_F(GetConfigurationTest, GetConfigurationSucceed)
{
if(conf.getWiFiModes().at(0) == WIFI_11G &&
conf.getWiFiFreq() == WIFI_5G &&
!strcmp(conf.getDeviceName().c_str(), "Test Device"))
!strcmp(conf.getDeviceName().c_str(), "Test Device") &&
!strcmp(conf.getModelNumber().c_str(), "Test Model Number"))
{
isWellConstructed = true;
}
cout << "getDeviceName : " << conf.getDeviceName().c_str() << endl;
cout << "getModelNumber : " << conf.getModelNumber().c_str() << endl;
}
}
});
......@@ -303,7 +306,7 @@ TEST_F(ProvisionDevicePropertiesTest,
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
devProp.setDevConfProp("korean", "Korea");
devProp.setDevConfProp("korean", "Korea", "Location");
EXPECT_ANY_THROW(g_remoteEnrollee->provisionDeviceProperties(devProp, nullptr));
}
......@@ -313,7 +316,7 @@ TEST_F(ProvisionDevicePropertiesTest,
{
DeviceProp devProp;
devProp.setWiFiProp("", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
devProp.setDevConfProp("korean", "Korea");
devProp.setDevConfProp("korean", "Korea", "Location");
EXPECT_ANY_THROW(g_remoteEnrollee->provisionDeviceProperties(devProp,
deviceProvisioningStatusCb));
}
......@@ -323,7 +326,7 @@ TEST_F(ProvisionDevicePropertiesTest,
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
devProp.setDevConfProp("korean", "Korea");
devProp.setDevConfProp("korean", "Korea", "Location");
int cntForReceivedCallbackWithSuccess = 0;
......
......@@ -126,6 +126,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
TextView mGetconfigurationStateText;
TextView mDevNameText;
TextView mModelNumberText;
TextView mLanguageText;
TextView mCountryText;
TextView mWifiModeText;
......@@ -140,6 +141,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
EditText mEnrollerPWText;
EditText mInputLanguageText;
EditText mInputCountryText;
EditText mInputLocationText;
EditText mAuthCodeText;
EditText mAuthProviderText;
EditText mCIServerText;
......@@ -186,6 +188,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
mGetconfigurationStateText =
(TextView) findViewById(R.id.txt_getConfigurationState);
mDevNameText = (TextView) findViewById(R.id.txt_devName);
mModelNumberText = (TextView) findViewById(R.id.txt_modelNumber);
mLanguageText = (TextView) findViewById(R.id.txt_language);
mCountryText = (TextView) findViewById(R.id.txt_country);
mWifiModeText = (TextView) findViewById(R.id.txt_wifiMode);
......@@ -201,6 +204,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
mEnrollerPWText = (EditText) findViewById(R.id.editText_EnrollerPW);
mInputLanguageText = (EditText) findViewById(R.id.editText_Language);
mInputCountryText = (EditText) findViewById(R.id.editText_Country);
mInputLocationText = (EditText) findViewById(R.id.editText_Location);
mAuthCodeText = (EditText) findViewById(R.id.editText_authcode);
mAuthProviderText = (EditText) findViewById(R.id.editText_authprovider);
mCIServerText = (EditText) findViewById(R.id.editText_ciserver);
......@@ -543,6 +547,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
public void run() {
mGetconfigurationStateText.setText("Success");
mDevNameText.setText(enrolleeConf.getDeviceName());
mModelNumberText.setText(enrolleeConf.getModelNumber());
setWifiModes(enrolleeConf.getWiFiModes());
setWifiFreq(enrolleeConf.getWiFiFreq());
......@@ -609,10 +614,11 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
WIFI_ENCTYPE.fromInt(mEncType.getSelectedItemPosition());
String inputLanguage = mInputLanguageText.getText().toString();
String inputCountry = mInputCountryText.getText().toString();
String inputLocation = mInputLocationText.getText().toString();
DeviceProp deviceProp = new DeviceProp();
deviceProp.setWiFiProp(enrollerSSID, enrollerPW, authType, encType);
deviceProp.setDevConfProp(inputLanguage, inputCountry);
deviceProp.setDevConfProp(inputLanguage, inputCountry, inputLocation);
mRemoteEnrollee.provisionDeviceProperties(deviceProp, new DevicePropProvisioningCallback() {
@Override
......
......@@ -304,6 +304,30 @@
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_modelNumber"
android:weightSum="1"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" >
<TextView
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="modelNumber"
android:id="@+id/textView7"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="empty"
android:id="@+id/txt_modelNumber" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
......@@ -570,6 +594,31 @@
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_InputLocation"
android:weightSum="1"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" >
<TextView
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="location"
android:id="@+id/textView23"
android:layout_gravity="center_vertical" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText_Location"
android:text="Test_Location"
android:layout_marginLeft="20dp"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
......
......@@ -70,6 +70,7 @@ void printConfiguration(EnrolleeConf conf)
{
cout << "===========================================" << endl;
cout << "\tDevice Name : " << conf.getDeviceName() << endl;
cout << "\tModel Number : " << conf.getModelNumber() << endl;
for(auto it : conf.getWiFiModes())
{
......@@ -195,7 +196,7 @@ void provisionDeviceProperty()
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
devProp.setDevConfProp("korean", "Korea");
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