if target_os in ['linux']:
easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl', 'coap'])
-#if target_os in ['android']:
-# easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-# if env.get('SECURED') == '1':
-# easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi'])
-# easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
-# easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-# easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
-# if env.get('SECURED') == '1':
-# easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
-# if not env.get('RELEASE'):
-# easy_setup_env.AppendUnique(LIBS = ['log'])
+if target_os in ['android']:
+ easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+ if env.get('SECURED') == '1':
+ easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi'])
+ easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
+ easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
+ if env.get('SECURED') == '1':
+ easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
+ if not env.get('RELEASE'):
+ easy_setup_env.AppendUnique(LIBS = ['log'])
if target_os in ['linux']:
easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
if env.get('SECURED') == '1':
easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
-#if target_os in ['android','linux']:
-if target_os in ['linux']:
+if target_os in ['android','linux']:
+#if target_os in ['linux']:
easy_setup_env.PrependUnique(CPPPATH = [
env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
env.get('SRC_DIR') + '/resource/include',
es_src = None
-#if target_os in ['android','linux']:
-if target_os in ['linux']:
+if target_os in ['android','linux']:
+#if target_os in ['linux']:
if env.get('SECURED') == '1':
env.AppendUnique(es_src = [os.path.join(easysetup_path, 'src/EnrolleeSecurity.cpp')])
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * Copyright 2017 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;
+
+import android.content.Context;
+import android.util.Log;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * This is facade class, a single point of contact for Application.
+ * It contains set of APIs to do easy setup of the enrolling device.
+ * ON-BOARDING - This is a step to establish connectivity between the device & Mediator device.
+ * PROVISION - This is a step where the netowork's detail & credentials are given to the
+ * enrolling device.
+ */
+public class EasySetup {
+
+ private static final String TAG = EasySetup.class.getName();
+
+ private static EasySetup sInstance;
+
+ //private final EasySetupStatus mCallback;
+
+ //private ArrayList<EnrolleeDevice> mEnrolleeDeviceList;
+
+ //private final ProvisioningCallback mProvisioningCallback;
+
+ private static Context mContext;
+
+ private ArrayList<RemoteEnrollee> mRemoteEnrolleeList;
+
+ protected RemoteEnrollee mRemoteEnrollee;
+
+ //function to call the native createEnrolleeDevice
+ private native RemoteEnrollee nativeCreateRemoteEnrollee();
+
+ static {
+ // Load Easy Setup JNI interface
+ System.loadLibrary("ESMediatorRich");
+ System.loadLibrary("easysetup-jni");
+ }
+
+ private EasySetup() {
+ //mCallback = callback;
+ //mProvisioningCallback = new ProvisioningCallbackImpl(mCallback);
+ //mEnrolleeDeviceList = new ArrayList<EnrolleeDevice>();
+ mContext = null;
+ }
+
+ /**
+ * Gives a singleton instance of Easy setup service and initialize the service
+ *
+ * @param callback Application needs to provide this callback to receive the status of easy
+ * setup process.
+ */
+
+ public synchronized static EasySetup getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new EasySetup();
+ mContext = context;
+ }
+ return sInstance;
+ }
+
+ public synchronized RemoteEnrollee createRemoteEnrollee()
+ {
+ // native call
+ mRemoteEnrollee = nativeCreateRemoteEnrollee();
+
+ mRemoteEnrolleeList.add(mRemoteEnrollee);
+
+ return mRemoteEnrollee;
+ }
+
+ /**
+ * Reset the Easy setup Service
+ */
+
+ public void finish() {
+ //Call the stop Provisioning
+ //for (EnrolleeDevice enrolleeDevice : mEnrolleeDeviceList) {
+ // enrolleeDevice.stopProvisioningProcess();
+ //}
+ }
+}
mProvisioningCallback.onProgress(this);
final EnrolleeDevice device = this;
if (mProvConfig.getConnType() == ProvisioningConfig.ConnType.WiFi) {
+ /*
try {
mRemoteEnrollee.registerProvisioningHandler(new IProvisionStatusNativeHandler() {
@Override
}
}
});
+
//native call
mRemoteEnrollee.startProvision();
}catch(ESException e) {
Log.i(TAG,"startProvisioningProcess Register Listener to native exception");
}
+ */
}
}
protected void stopProvisioningProcess(){
if(mState == EnrolleeState.DEVICE_PROVISIONING_STATE)
{ //native call
+ /*
try {
mRemoteEnrollee.stopProvision();
} catch (ESException e) {
Log.i(TAG,"stopProvisioningProcess exception");
}
+ */
}else{
Log.i(TAG,"stopProvisioningProcess : Provisioning is not in progress");
}
/**
* ***************************************************************
- * <p/>
+ *
* Copyright 2016 Samsung Electronics All Rights Reserved.
- * <p/>
- * <p/>
- * <p/>
+ *
+ *
+ *
* 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
- * <p/>
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ *
* 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.
- * <p/>
+ *
* ****************************************************************
*/
public static final String TAG = RemoteEnrollee.class.getName();
private long m_nativeHandle;
- private native void nativeStartProvision();
- private native void nativeStopProvision();
- private native void nativeRegisterProvisioningHandler(IProvisionStatusNativeHandler listener);
+ //private native void nativeStartProvision();
+ //private native void nativeStopProvision();
+ //private native void nativeRegisterProvisioningHandler(IProvisionStatusNativeHandler listener);
/* constructor will be invoked from the native layer */
private RemoteEnrollee(long nativeHandle){
}
/* Register native Listener for the Provisioning state */
- public void registerProvisioningHandler( IProvisionStatusNativeHandler provisioningListener) throws ESException{
- // this.provisioningListener = provisioningListener;
- nativeRegisterProvisioningHandler(provisioningListener);
- Log.i(TAG, "JNI Callback is registered for getting provisioning status");
- }
+ //public void registerProvisioningHandler( IProvisionStatusNativeHandler provisioningListener) throws ESException{
+ // // this.provisioningListener = provisioningListener;
+ // nativeRegisterProvisioningHandler(provisioningListener);
+ // Log.i(TAG, "JNI Callback is registered for getting provisioning status");
+ //}
- /* native StartProvision */
- public void startProvision() throws ESException{
- nativeStartProvision();
-}
+ ///* native StartProvision */
+ //public void startProvision() throws ESException{
+ //nativeStartProvision();
+ //}
/* native stopProvision */
- public void stopProvision() throws ESException{
- nativeStopProvision();
-}
+ //public void stopProvision() throws ESException{
+ //nativeStopProvision();
+ //}
}
DEFINE_FLAG = -DWITH_POSIX -D__ANDROID__
#Add Debug flags here
-DEBUG_FLAG = -DTB_LOG
+DEBUG_FLAG = -DTB_LOG
BUILD_FLAG = $(DEFINE_FLAG) $(DEBUG_FLAG)
$(LOCAL_PATH)/../../src \
$(LOCAL_PATH)/../../../../inc \
$(LOCAL_PATH)/../../../../../../resource/csdk/logger/include \
- $(LOCAL_PATH)/../../../../../../resource/csdk/connectivity/common/inc \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/connectivity/common/inc \
$(LOCAL_PATH)/../../../../../../resource/c_common/oic_string/include \
$(LOCAL_PATH)/../../../../../../resource/include \
$(LOCAL_PATH)/../../../../../../resource/c_common \
$(LOCAL_PATH)/../../../../../../resource/csdk/security/include \
$(LOCAL_PATH)/../../../../../../extlibs/cjson \
$(LOCAL_PATH)/../../../../../../extlibs/boost/boost_1_58_0 \
- $(LOCAL_PATH)/../../../../../../extlibs/timer \
+ $(LOCAL_PATH)/../../../../../../extlibs/timer \
$(LOCAL_PATH)/../../../../../../android/android_api/base/jni \
LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/*.cpp))
extern "C" {
#endif
JNIEXPORT jobject JNICALL
-Java_org_iotivity_service_easysetup_mediator_EasySetupService_nativeCreateEnrolleeDevice
-(JNIEnv *env, jobject interfaceClass, jstring ip, jstring ssid, jstring password,
- jint connectivityType, jboolean isSecured)
+Java_org_iotivity_service_easysetup_mediator_EasySetupService_nativeCreateRemoteEnrollee
+(JNIEnv *env, jobject interfaceClass)
{
- LOGI("JniEasySetup::nativeCreateEnrolleeDevice enter");
+ LOGI("JniEasySetup::nativeCreateRemoteEnrollee enter");
std::shared_ptr<RemoteEnrollee> nativeRemoteEnrollee;
jobject jRemoteEnrollee;
- ProvConfig netInfo;
- WiFiOnboadingConnection onboardConn;
-
- const char *cIp = (env)->GetStringUTFChars(ip, NULL);
- const char *cSssid = (env)->GetStringUTFChars(ssid, NULL);
- const char *cPassword = (env)->GetStringUTFChars(password, NULL);
-
- std::string sIp(cIp);
- std::string sSssid(cSssid);
- std::string sPassword(cPassword);
-
- netInfo.connType = getOCConnectivityTypeFromInt(connectivityType);
-
- onboardConn.isSecured = bool(isSecured);
-
- OICStrcpy(onboardConn.ipAddress, IPV4_ADDR_SIZE - 1, sIp.c_str());
- OICStrcpy(netInfo.provData.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, sSssid.c_str());
- OICStrcpy(netInfo.provData.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, sPassword.c_str());
try
{
- nativeRemoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo,onboardConn);
+ nativeRemoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee();
//create the java object
jRemoteEnrollee = env->NewObject(g_cls_RemoteEnrollee, g_mid_RemoteEnrollee_ctor);
if (!jRemoteEnrollee)
{
- LOGE("JniEasySetup::nativeCreateEnrolleeDevice Unable to create the java object");
+ LOGE("JniEasySetup::nativeCreateRemoteEnrollee Unable to create the java object");
return NULL;
}
}
catch (ESBadRequestException exception)
{
- LOGE("JniEasySetup::nativeCreateEnrolleeDevice Unable to create the Native EnrolleeDevice");
+ LOGE("JniEasySetup::nativeCreateRemoteEnrollee Unable to create the Native EnrolleeDevice");
//throw the exception to java layer
throwESException( env, exception.what());
}
- LOGI("JniEasySetup::nativeCreateEnrolleeDevice exit");
+ LOGI("JniEasySetup::nativeCreateRemoteEnrollee exit");
return jRemoteEnrollee;
}
/**
* API for creating and returning the RemoteEnrollee object to Java Layer
*
- * @param ip - ip address of Enrollee
- * @param ssid - ssid of the Enroller
- * @param password - password of the enroller
- * @param connectivityType - Connectivity Type
- * @param needSecuredEasysetup - need secured easy setup or not
- *
* @return jobject - RemoteEnrolleee
*/
JNIEXPORT jobject JNICALL
-Java_org_iotivity_service_easysetup_mediator_EasySetupService_nativeCreateEnrolleeDevice
-(JNIEnv *env, jobject interfaceClass, jstring ip, jstring ssid, jstring password,
- jint connectivityType, jboolean needSecuredEasysetup);
+Java_org_iotivity_service_easysetup_mediator_EasySetupService_nativeCreateRemoteEnrollee
+(JNIEnv *env, jobject interfaceClass);
#ifdef __cplusplus
}
}
return CT_DEFAULT;
}
-
+/*
int convertNativeProvisionStateToInt(EasySetupState nativeState)
{
switch (nativeState)
return 3;
}
return -1;
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file
/**
* @brief Convert EasySetupState Enum Value to int
*/
-int convertNativeProvisionStateToInt(EasySetupState nativeState);
+//int convertNativeProvisionStateToInt(EasySetupState nativeState);
#endif //__JNI_ES_UTILS_H_
if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
}
}
-
+/*
void JniProvisioningStatusListener::provisionStatusCallback (std::shared_ptr<EasySetupStatus>
easySetupStatus)
{
m_ownerResource->removeProvisioningStatusListener(env, m_jwListener);
}
}
+*/
/**
* @brief callback function that will be passed to Native layer
*/
- void provisionStatusCallback (std::shared_ptr<EasySetupStatus> easySetupStatus);
+ //void provisionStatusCallback (std::shared_ptr<EasySetupStatus> easySetupStatus);
private:
jweak m_jwListener;
}
return remoteEnrollee;
}
-
+/*
void JniRemoteEnrollee::startProvisioning(JNIEnv *env)
{
try
LOGD("nativeRegisterProvisioningHandler Exit");
}
-
+*/
// ***** JNI APIs internally call the APIs of this class ***** //
- void startProvisioning(JNIEnv *env);
- void stopProvisioning(JNIEnv *env);
- void registerProvisioningHandler(JNIEnv *env, jobject jListener);
+ //void startProvisioning(JNIEnv *env);
+ //void stopProvisioning(JNIEnv *env);
+ //void registerProvisioningHandler(JNIEnv *env, jobject jListener);
- JniProvisioningStatusListener *addProvisioningStatusListener(JNIEnv *env, jobject jListener);
- void removeProvisioningStatusListener(JNIEnv *env, jobject jListener);
+ //JniProvisioningStatusListener *addProvisioningStatusListener(JNIEnv *env, jobject jListener);
+ //void removeProvisioningStatusListener(JNIEnv *env, jobject jListener);
static JniRemoteEnrollee *getJniRemoteEnrollee(JNIEnv *env, jobject thiz);
private:
- JniEsListenerManager<JniProvisioningStatusListener> m_provisioingStatus;
+ //JniEsListenerManager<JniProvisioningStatusListener> m_provisioingStatus;
std::shared_ptr<RemoteEnrollee> m_sharedResource;
};
/**
* API for starting the provisioning process.
*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStartProvision
-(JNIEnv *env, jobject jClass);
+//JNIEXPORT void JNICALL
+//Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStartProvision
+//(JNIEnv *env, jobject jClass);
/**
* API for stopping the provisioning process.
*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStopProvision
-(JNIEnv *env, jobject jClass);
+//JNIEXPORT void JNICALL
+//Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStopProvision
+//(JNIEnv *env, jobject jClass);
/**
* API for setting the lisener for recieiving provisioning status.
*
* @param provisiongListener - Provisioning listener [callback from native layer will be passing to this listener]
*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeRegisterProvisioningHandler
-(JNIEnv *env, jobject jClass, jobject provisiongListener);
+//JNIEXPORT void JNICALL
+//Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeRegisterProvisioningHandler
+//(JNIEnv *env, jobject jClass, jobject provisiongListener);
#ifdef __cplusplus
}