Commit 0cb946db authored by Jihun Ha's avatar Jihun Ha Committed by Uze Choi

[Update] change Api desgin and modify function & data structure naming issue.

- Add comments for doxygen
- Initailize step logic change
	chage the logic for user can select target device.
		createRemoteEnrollee() -> createRemoteEnrollee(OC::OCResource* )
		initRemoteEnrollee() -> deleted

- callback function signature change
	setXXX(), startXXX(Callback) -> startXXX( setdata, Callback)

- modify function's name
	requsetPropertyData -> getConfiguration
	startSecurityProvisioning -> configureSecurity
	startDataProvisioning -> provisionDeviceProperties
	startCloudProvisioning -> provisionCloudProperties

- modify datastructure's name
	propertyData -> EnrolleeConf
	NetworkInfo -> WiFiConfig
	DeviceProvInfo -> DeviceProp
	CloudInfo -> CloudProp

Change-Id: I084cbb821ba26b303aaebbcab96da2fc52fe8429
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/9407Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent a5c63ff4
......@@ -135,8 +135,8 @@ print "Files path is %s" % env.get('es_src')
######################################################################
# Build RichSDK Mediator Sample App
################################################ ######################
if target_os in ['linux']:
SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
#if target_os in ['linux']:
# SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
######################################################################
#Build UnitTestcases for Mediator[RichSDK]
......
......@@ -24,13 +24,13 @@ package org.iotivity.service.easysetup.mediator;
* This class contains on cloud provisioning information.
* It implements ProvisioningInfo interface and provide configuration object specific to cloud registration
*/
public class CloudProvInfo {
public class CloudProp {
private final String mAuthCode;
private final String mAuthProvider;
private final String mCiServer;
public CloudProvInfo(String authCode, String authProvider, String ciServer) {
public CloudProp(String authCode, String authProvider, String ciServer) {
mAuthCode = authCode;
mAuthProvider = authProvider;
mCiServer = ciServer;
......
......@@ -20,9 +20,9 @@
package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.CloudProvisioningStatus;
import org.iotivity.service.easysetup.mediator.CloudPropProvisioningStatus;
public abstract class CloudProvisioningCallback {
public abstract void onProgress(CloudProvisioningStatus status);
public abstract class CloudPropProvisioningCallback {
public abstract void onProgress(CloudPropProvisioningStatus status);
}
......@@ -27,12 +27,12 @@ import org.iotivity.service.easysetup.mediator.enums.ESResult;
* This interface facilitates Application to get progress & result of Cloud provisioning
* process in easy setup
*/
public class CloudProvisioningStatus
public class CloudPropProvisioningStatus
{
private ESResult m_result;
private ESCloudProvState m_esCloudState;
public CloudProvisioningStatus(int result, int state)
public CloudPropProvisioningStatus(int result, int state)
{
m_result = ESResult.fromInt(result);
m_esCloudState = ESCloudProvState.fromInt(state);
......
......@@ -22,24 +22,17 @@ package org.iotivity.service.easysetup.mediator;
public class DeviceConfig
{
private final String mId;
private final String mName;
private final String mLanguage;
private final String mCountry;
public DeviceConfig(String id, String name, String language, String country)
public DeviceConfig(String name, String language, String country)
{
mId = id;
mName = name;
mLanguage = language;
mCountry = country;
}
public String getId()
{
return mId;
}
public String getName()
{
return mName;
......
......@@ -27,7 +27,7 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_ENCTYPE;
* This class contains on data provisioning information.
* It implements ProvisioningInfo interface and provide configuration object specific to data registration
*/
public class DataProvInfo {
public class DeviceProp {
private final String mSsid;
private final String mPwd;
......@@ -36,7 +36,7 @@ public class DataProvInfo {
private final String mLanguage;
private final String mCountry;
public DataProvInfo(String ssid, String pwd, WIFI_AUTHTYPE authType, WIFI_ENCTYPE encType,
public DeviceProp(String ssid, String pwd, WIFI_AUTHTYPE authType, WIFI_ENCTYPE encType,
String language, String country)
{
mSsid = ssid;
......
......@@ -20,8 +20,8 @@
package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.RequestPropertyDataCallback;
import org.iotivity.service.easysetup.mediator.DevicePropProvisioningStatus;
public abstract class RequestPropertyDataCallback {
public abstract void onProgress(RequestPropertyDataStatus status);
public abstract class DevicePropProvisioningCallback {
public abstract void onProgress(DevicePropProvisioningStatus status);
}
......@@ -22,24 +22,17 @@ package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.enums.ESResult;
public class RequestPropertyDataStatus
public class DevicePropProvisioningStatus
{
private ESResult m_result;
private PropertyData m_propertyData;
public RequestPropertyDataStatus(int result, PropertyData data)
public DevicePropProvisioningStatus(int result)
{
m_result = ESResult.fromInt(result);
m_propertyData = data;
}
public ESResult getESResult()
{
return m_result;
}
public PropertyData getPropertyData()
{
return m_propertyData;
}
};
......@@ -2,7 +2,7 @@
* ***************************************************************
*
* Copyright 2017 Samsung Electronics All Rights Reserved.
*
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -25,8 +25,13 @@ package org.iotivity.service.easysetup.mediator;
import android.content.Context;
import android.util.Log;
import java.io.IOException;
import org.iotivity.base.OcConnectivityType;
import org.iotivity.base.OcResource;
import org.iotivity.base.OcPlatform;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
/**
* <To be modified>
......@@ -39,7 +44,7 @@ import java.util.ArrayList;
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;
......@@ -49,8 +54,8 @@ public class EasySetup {
protected RemoteEnrollee mRemoteEnrollee;
//function to call the native nativeCreateRemoteEnrollee
private native RemoteEnrollee nativeCreateRemoteEnrollee();
private native RemoteEnrollee nativeCreateRemoteEnrollee(String Host, String Uri, String devID,
Boolean isObservable, int conType);
static {
// Load Easy Setup JNI interface
System.loadLibrary("ESMediatorRich");
......@@ -76,10 +81,38 @@ public class EasySetup {
/**
* API to create a new RemoteEnrollee instance
*/
public synchronized RemoteEnrollee createRemoteEnrollee()
public synchronized RemoteEnrollee createRemoteEnrollee(OcResource enrolleeResource)
{
// native call
mRemoteEnrollee = nativeCreateRemoteEnrollee();
String Host = enrolleeResource.getHost();
String HostInIPv6;
int pos1 = Host.indexOf("%"); // it indicates the address is IPv6.
if(pos1 >= 0) {
int pos2 = Host.indexOf("]");
HostInIPv6 = Host.substring(0, pos1) + Host.substring(pos2, Host.length());
Host = HostInIPv6;
Log.d(TAG,"Host address of the resource(truncated): " + HostInIPv6);
}
String Uri = enrolleeResource.getUri();
String devID = enrolleeResource.getServerId();
Boolean isObservable = enrolleeResource.isObservable();
EnumSet<OcConnectivityType> ConType = enrolleeResource.getConnectivityTypeSet();
int conType = 0;
for (OcConnectivityType type : ConType)
{
conType |= type.getValue();
}
List<String> resourceTypes = enrolleeResource.getResourceTypes();
List<String> resourceInterfaces = enrolleeResource.getResourceInterfaces();
if(!resourceTypes.contains(PROV_RESOURCE_TYPE)
|| !resourceInterfaces.contains(OcPlatform.BATCH_INTERFACE))
{
Log.e(TAG, "Validation check for OcResource is failed.");
return null;
}
mRemoteEnrollee = nativeCreateRemoteEnrollee(Host, Uri, devID, isObservable, conType);
mRemoteEnrolleeList.add(mRemoteEnrollee);
return mRemoteEnrollee;
}
......
......@@ -25,16 +25,16 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_MODE;
import java.util.ArrayList;
public class PropertyData
public class EnrolleeConf
{
private final DeviceConfig mDevConf;
private final NetworkInfo mNetInfo;
private final WiFiConfig mWiFiConf;
private final boolean mCloudable;
public PropertyData(DeviceConfig devConf, NetworkInfo netInfo, boolean cloudable)
public EnrolleeConf(DeviceConfig devConf, WiFiConfig wifiConf, boolean cloudable)
{
mDevConf = devConf;
mNetInfo = netInfo;
mWiFiConf = wifiConf;
mCloudable = cloudable;
}
......@@ -43,9 +43,9 @@ public class PropertyData
return mDevConf;
}
public NetworkInfo getNetworkInfo()
public WiFiConfig getWiFiConfig()
{
return mNetInfo;
return mWiFiConf;
}
public boolean isCloudable()
......
......@@ -20,8 +20,8 @@
package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.DataProvisioningCallback;
import org.iotivity.service.easysetup.mediator.GetConfigurationCallback;
public abstract class DataProvisioningCallback {
public abstract void onProgress(DataProvisioningStatus status);
public abstract class GetConfigurationCallback {
public abstract void onProgress(GetConfigurationStatus status);
}
......@@ -20,27 +20,26 @@
package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.enums.ESDataProvState;
import org.iotivity.service.easysetup.mediator.enums.ESResult;
public class DataProvisioningStatus
public class GetConfigurationStatus
{
private ESResult m_result;
private ESDataProvState m_state;
private ESResult mResult;
private EnrolleeConf mEnrolleeConf;
public DataProvisioningStatus(int result, int state)
public GetConfigurationStatus(int result, EnrolleeConf conf)
{
m_result = ESResult.fromInt(result);
m_state = ESDataProvState.fromInt(state);
mResult = ESResult.fromInt(result);
mEnrolleeConf = conf;
}
public ESResult getESResult()
{
return m_result;
return mResult;
}
public ESDataProvState getESDataProvState()
public EnrolleeConf getEnrolleeConf()
{
return m_state;
return mEnrolleeConf;
}
};
......@@ -30,76 +30,58 @@ public class RemoteEnrollee{
public static final String TAG = RemoteEnrollee.class.getName();
private long m_nativeHandle;
private native void nativeInitRemoteEnrollee();
private native void nativeRequestPropertyData(RequestPropertyDataCallback callback);
private native void nativeStartSecurityProvision(SecurityProvisioningCallback callback);
private native void nativeSetDataProvInfo(String ssid, String pwd, int authType, int encType,
String language, String country);
private native void nativeStartDataProvision(DataProvisioningCallback callback);
private native void nativeSetCloudProvInfo(String authCode, String autoProvider,
String ciServer);
private native void nativeStartCloudProvisioning(CloudProvisioningCallback callback);
private native void nativeGetConfiguration(GetConfigurationCallback callback);
private native void nativeConfigureSecurity(SecurityProvisioningCallback callback);
private native void nativeProvisionDeviceProperties(String ssid, String pwd, int authType, int encType,
String language, String country, DevicePropProvisioningCallback callback);
private native void nativeProvisionCloudProperties(String authCode, String autoProvider,
String ciServer, CloudPropProvisioningCallback callback);
/* constructor will be invoked from the native layer */
private RemoteEnrollee(long nativeHandle){
this.m_nativeHandle = nativeHandle;
}
/* native setCloudProvInfo */
public void initRemoteEnrollee() throws ESException
{
nativeInitRemoteEnrollee();
}
public void requestPropertyData(RequestPropertyDataCallback callback) throws ESException
public void getConfiguration(GetConfigurationCallback callback) throws ESException
{
if(callback != null)
{
nativeRequestPropertyData(callback);
nativeGetConfiguration(callback);
return;
}
Log.d(TAG, "RequestPropertyDataCallback is null ");
Log.d(TAG, "GetConfigurationCallback is null ");
}
public void startSecurityProvisioning(SecurityProvisioningCallback callback) throws ESException
public void configureSecurity(SecurityProvisioningCallback callback) throws ESException
{
if(callback != null)
{
nativeStartSecurityProvision(callback);
nativeConfigureSecurity(callback);
return;
}
Log.d(TAG, "SecurityProvisioningCallback is null ");
}
public void setDataProvInfo(DataProvInfo dataInfo) throws ESException
{
nativeSetDataProvInfo(dataInfo.getSsid(), dataInfo.getPwd(),
dataInfo.getAuthType().getValue(), dataInfo.getEncType().getValue(),
dataInfo.getLanguage(), dataInfo.getCountry());
}
public void startDataProvisioning(DataProvisioningCallback callback) throws ESException
public void provisionDeviceProperties(DeviceProp deviceProp, DevicePropProvisioningCallback callback) throws ESException
{
if(callback != null)
{
nativeStartDataProvision(callback);
nativeProvisionDeviceProperties(deviceProp.getSsid(), deviceProp.getPwd(),
deviceProp.getAuthType().getValue(), deviceProp.getEncType().getValue(),
deviceProp.getLanguage(), deviceProp.getCountry(), callback);
return;
}
Log.d(TAG, "DataProvisioningCallback is null ");
}
public void setCloudProvInfo(CloudProvInfo cloudInfo) throws ESException{
nativeSetCloudProvInfo(cloudInfo.getAuthCode(), cloudInfo.getAuthProvider(),
cloudInfo.getCiServer());
Log.d(TAG, "DevicePropProvisioningCallback is null ");
}
/* native startCloudProvisioning */
public void startCloudProvisioning(CloudProvisioningCallback callback) throws ESException{
/* native provisionCloudProperties */
public void provisionCloudProperties(CloudProp cloudProp , CloudPropProvisioningCallback callback) throws ESException{
if(callback != null)
{
nativeStartCloudProvisioning(callback);
nativeProvisionCloudProperties(cloudProp.getAuthCode(), cloudProp.getAuthProvider(),
cloudProp.getCiServer(), callback);
return;
}
Log.d(TAG, "CloudProvisioningCallback is null ");
Log.d(TAG, "CloudPropProvisioningCallback is null ");
}
}
......@@ -20,7 +20,7 @@
package org.iotivity.service.easysetup.mediator;
import org.iotivity.service.easysetup.mediator.SecurityProvisioningCallback;
import org.iotivity.service.easysetup.mediator.SecurityProvisioningStatus;
public abstract class SecurityProvisioningCallback {
public abstract void onProgress(SecurityProvisioningStatus status);
......
......@@ -27,13 +27,13 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_MODE;
import java.util.ArrayList;
public class NetworkInfo
public class WiFiConfig
{
public static final String TAG = NetworkInfo.class.getName();
public static final String TAG = WiFiConfig.class.getName();
private final ArrayList<WIFI_MODE> mWifiModeTypes;
private final WIFI_FREQ mWifiFreq;
public NetworkInfo(ArrayList<Integer> types, int wifiFreq)
public WiFiConfig(ArrayList<Integer> types, int wifiFreq)
{
mWifiModeTypes = convertWifiModeTypes(types);
mWifiFreq = WIFI_FREQ.fromInt(wifiFreq);
......
/**
* ***************************************************************
*
* Copyright 2016 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ****************************************************************
*/
package org.iotivity.service.easysetup.mediator.enums;
public enum ESDataProvState
{
ES_PROVISIONING_ERROR(-1),
ES_NEED_PROVISIONING(0),
ES_PROVISIONED_ALREADY(1),
ES_PROVISIONING_SUCCESS(2);
private int value;
private ESDataProvState(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
public static ESDataProvState fromInt(int i)
{
for (ESDataProvState b : ESDataProvState.values())
{
if (b.getValue() == i)
return b;
}
return null;
}
}
......@@ -17,21 +17,21 @@
*
******************************************************************/
#include "JniCloudProvisioningStatusListener.h"
#include "JniCloudPropProvisioningStatusListener.h"
#include "JniRemoteEnrollee.h"
using namespace OIC::Service;
JniCloudProvisioningStatusListener::JniCloudProvisioningStatusListener(JNIEnv *env, jobject jListener,
JniCloudPropProvisioningStatusListener::JniCloudPropProvisioningStatusListener(JNIEnv *env, jobject jListener,
JniRemoteEnrollee *owner)
: m_ownerResource(owner)
{
m_jwListener = env->NewWeakGlobalRef(jListener);
}
JniCloudProvisioningStatusListener::~JniCloudProvisioningStatusListener()
JniCloudPropProvisioningStatusListener::~JniCloudPropProvisioningStatusListener()
{
LOGI("~JniCloudProvisioningStatusListener()");
LOGI("~JniCloudPropProvisioningStatusListener()");
if (m_jwListener)
{
jint ret;
......@@ -42,11 +42,11 @@ JniCloudProvisioningStatusListener::~JniCloudProvisioningStatusListener()
}
}
void JniCloudProvisioningStatusListener::onCloudProvisioningStatus(std::shared_ptr<CloudProvisioningStatus>
cloudProvisioningStatus)
void JniCloudPropProvisioningStatusListener::onCloudPropProvisioningStatus(std::shared_ptr<CloudPropProvisioningStatus>
cloudPropProvisioningStatus)
{
LOGI("JniCloudProvisioningStatusListener::onCloudProvisioningStatus enter");
LOGI("JniCloudPropProvisioningStatusListener::onCloudPropProvisioningStatus enter");
jint ret;
JNIEnv *env = GetESJNIEnv(ret);
......@@ -69,7 +69,7 @@ void JniCloudProvisioningStatusListener::onCloudProvisioningStatus(std::shared_p
jmethodID midL = env->GetMethodID(clsL, "onProgress",
"(Lorg/iotivity/service/easysetup/mediator/"
"CloudProvisioningStatus;"
"CloudPropProvisioningStatus;"
")V");
if (!midL)
{
......@@ -78,24 +78,24 @@ void JniCloudProvisioningStatusListener::onCloudProvisioningStatus(std::shared_p
return;
}
ESResult esResult = cloudProvisioningStatus->getESResult();
ESCloudProvState cloudProvisionState = cloudProvisioningStatus->getESCloudState();
ESResult esResult = cloudPropProvisioningStatus->getESResult();
ESCloudProvState cloudProvisionState = cloudPropProvisioningStatus->getESCloudState();
//create the java object