+++ /dev/null
-/**\r
- * ***************************************************************\r
- *\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * ****************************************************************\r
- */\r
-\r
-package org.iotivity.service.easysetup.mediator;\r
-\r
-/*\r
- * This class stores an Enrollee's configuration specific to device configuration\r
- * device name, language, and country information are stored\r
- */\r
-public class DeviceConfig\r
-{\r
- private final String mName;\r
- private final String mLanguage;\r
- private final String mCountry;\r
-\r
- /**\r
- * Constructor\r
- *\r
- * @param name Device's human-friendly name like device model name\r
- * @param language IETF language tag using ISO 639X\r
- * @param country ISO Country Code (ISO 3166-1 Alpha-2)\r
- */\r
- public DeviceConfig(String name, String language, String country)\r
- {\r
- mName = name;\r
- mLanguage = language;\r
- mCountry = country;\r
- }\r
-\r
- /**\r
- * Get a device name\r
- *\r
- * @return a device name\r
- */\r
- public String getName()\r
- {\r
- return mName;\r
- }\r
-\r
- /**\r
- * Get a language\r
- *\r
- * @return a language\r
- */\r
- public String getLanguage()\r
- {\r
- return mLanguage;\r
- }\r
-\r
- /**\r
- * Get a country\r
- *\r
- * @return a country\r
- */\r
- public String getCountry()\r
- {\r
- return mCountry;\r
- }\r
-}\r
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * 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;
+
+import android.util.Log;
+
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.service.easysetup.mediator.ESConstants;
+import org.iotivity.service.easysetup.mediator.enums.ESErrorCode;
+import org.iotivity.service.easysetup.mediator.enums.ProvStatus;
+
+/**
+ * This class stores Enrollee's status including provisioning status and last error code.
+ */
+public class EnrolleeStatus
+{
+ private static final String TAG = EnrolleeStatus.class.getName();
+ private OcRepresentation mRep = null;
+ /**
+ * Constructor
+ *
+ * @param rep received properties in a form of OcRepresentation
+ *
+ */
+ public EnrolleeStatus(OcRepresentation rep)
+ {
+ mRep = rep;
+ }
+
+ /**
+ * Get a provisioning status property of Enrollee.
+ *
+ * @return a provisioning status property of Enrollee
+ */
+ public ProvStatus getProvStatus()
+ {
+ try
+ {
+ if(mRep != null && mRep.hasAttribute(ESConstants.OC_RSRVD_ES_PROVSTATUS)) {
+ int provStatus = mRep.getValue(ESConstants.OC_RSRVD_ES_PROVSTATUS);
+ return ProvStatus.fromInt(provStatus);
+ }
+ } catch (OcException e) {
+ Log.e(TAG, "getProvStatus is failed.");
+ }
+ return ProvStatus.fromInt(0);
+ }
+
+ /**
+ * Get a last error code property of Enrollee.
+ *
+ * @return a last error code property of Enrollee.
+ */
+ public ESErrorCode getLastErrCode()
+ {
+ try
+ {
+ if(mRep != null && mRep.hasAttribute(ESConstants.OC_RSRVD_ES_LAST_ERRORCODE)) {
+ int errCode = mRep.getValue(ESConstants.OC_RSRVD_ES_LAST_ERRORCODE);
+ return ESErrorCode.fromInt(errCode);
+ }
+ } catch (OcException e) {
+ Log.e(TAG, "getLastErrCode is failed.");
+ }
+ return ESErrorCode.fromInt(0);
+ }
+}
+
+
package org.iotivity.service.easysetup.mediator;
-import org.iotivity.service.easysetup.mediator.GetConfigurationCallback;
-
/**
* This interface class is used as a callback function called after receiving
* Enrollee's configuration.
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * 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;
+
+import org.iotivity.service.easysetup.mediator.enums.ESResult;
+
+/**
+ * This class indicates a result if a getConfiguartion API succeed or fails and
+ * Enrollee's configuration delivered by a response.
+ */
+public class GetEnrolleeStatus
+{
+ private ESResult mResult;
+ private EnrolleeStatus mEnrolleeStatus;
+
+ /**
+ * Constructor
+ *
+ * @param result a result if a getStatus API succeed or fail
+ * @param status Enrollee's status
+ *
+ */
+ public GetEnrolleeStatus(int result, EnrolleeStatus status)
+ {
+ mResult = ESResult.fromInt(result);
+ mEnrolleeStatus = status;
+ }
+
+ /**
+ * Get a result of a getStatus API call
+ *
+ * @return ESResult
+ *
+ */
+ public ESResult getESResult()
+ {
+ return mResult;
+ }
+
+ /**
+ * Get Enrollee's status
+ *
+ * @return EnrolleeStatus includes a provisioning status and last error code.
+ *
+ * @see EnrolleeStatus
+ */
+ public EnrolleeStatus getEnrolleeStatus()
+ {
+ return mEnrolleeStatus;
+ }
+};
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * 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;
+
+/**
+ * This interface class is used as a callback function called after receiving
+ * Enrollee's status.
+ *
+ * @see GetEnrolleeStatus
+ */
+public abstract class GetStatusCallback {
+
+ /**
+ * Called after receiving Enrollee's status
+ *
+ * @param status
+ * result if the request succeeds or fails
+ * Enrollee's status like a provisioning status and last error code
+ */
+ public abstract void onProgress(GetEnrolleeStatus status);
+}
public static final String TAG = RemoteEnrollee.class.getName();
private long m_nativeHandle;
+ private native void nativeGetStatus(GetStatusCallback callback);
private native void nativeGetConfiguration(GetConfigurationCallback callback);
private native void nativeProvisionSecurity(SecurityProvisioningCallback callback);
private native void nativeProvisionDeviceProperties(OcRepresentation deviceProp,
}
/**
+ * Get an Enrollee's status which includes a provisioning status and last error code
+ *
+ * @param callback will give the requested status
+ *
+ * @throws ESException If some errors happen in this function
+ *
+ * @see GetStatusCallback
+ */
+ public void getStatus(GetStatusCallback callback) throws ESException
+ {
+ if(callback != null)
+ {
+ nativeGetStatus(callback);
+ return;
+ }
+ Log.d(TAG, "GetStatusCallback is null ");
+ }
+
+ /**
* Get an Enrollee's configuration which includes WiFi supported frequency and device name
*
* @param callback will give the requested configuration
+++ /dev/null
-/**\r
- * ***************************************************************\r
- *\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * ****************************************************************\r
- */\r
-\r
-package org.iotivity.service.easysetup.mediator;\r
-\r
-import android.util.Log;\r
-\r
-import org.iotivity.service.easysetup.mediator.enums.WIFI_FREQ;\r
-import org.iotivity.service.easysetup.mediator.enums.WIFI_MODE;\r
-\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * This class stores an Enrollee's configuration specific to WiFi configuration\r
- * supported WiFi modes and frequency are stored\r
- */\r
-public class WiFiConfig\r
-{\r
- public static final String TAG = WiFiConfig.class.getName();\r
- private final ArrayList<WIFI_MODE> mWifiModes;\r
- private final WIFI_FREQ mWifiFreq;\r
-\r
- /**\r
- * Constructor\r
- *\r
- * @param types\r
- * stores an array of Wifi modes like 11G and 11N.\r
- * 11A(0), 11B, 11G, 11N, 11AC(4) are supported\r
- * @param wifiFreq\r
- * stores WiFi frequency like 2.4G, 5G, or both\r
- */\r
- public WiFiConfig(ArrayList<Integer> types, int wifiFreq)\r
- {\r
- mWifiModes = convertWifiModes(types);\r
- mWifiFreq = WIFI_FREQ.fromInt(wifiFreq);\r
- }\r
-\r
- private ArrayList<WIFI_MODE> convertWifiModes(ArrayList<Integer> types)\r
- {\r
- ArrayList<WIFI_MODE> wifiModes = new ArrayList<>();\r
- for (Integer type: types) {\r
- wifiModes.add(WIFI_MODE.fromInt(type.intValue()));\r
- };\r
- return wifiModes;\r
- }\r
-\r
- /**\r
- * get WiFi mode\r
- *\r
- * @return ArrayList<WIFI_MODE>\r
- * 11A(0), 11B, 11G, 11N, 11AC(4) are supported\r
- * @see WIFI_MODE\r
- */\r
- public ArrayList<WIFI_MODE> getWifiModes()\r
- {\r
- return mWifiModes;\r
- }\r
-\r
- /**\r
- * get WiFi frequency\r
- *\r
- * @param WIFI_FREQ\r
- * 2.4G, 5G, or both\r
- *\r
- * @see WIFI_FREQ\r
- */\r
- public WIFI_FREQ getWifiFreq()\r
- {\r
- return mWifiFreq;\r
- }\r
-}\r
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * 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;
+
+/**
+ * @brief Indicate last error code to describe a reason of error during easy setup.
+ */
+public enum ESErrorCode {
+
+ /**
+ * Init Error Code
+ */
+ ES_ERRCODE_NO_ERROR(0),
+
+ /**
+ * Error Code that given WiFi's SSID is not found
+ */
+ ES_ERRCODE_SSID_NOT_FOUND(1),
+
+ /**
+ * Error Code that given WiFi's Password is wrong
+ */
+ ES_ERRCODE_PW_WRONG(2),
+
+ /**
+ * Error Code that IP address is not allocated
+ */
+ ES_ERRCODE_IP_NOT_ALLOCATED(3),
+
+ /**
+ * Error Code that there is no Internet connection
+ */
+ ES_ERRCODE_NO_INTERNETCONNECTION(4),
+
+ /**
+ * Error Code that Timeout occured
+ */
+ ES_ERRCODE_TIMEOUT(5),
+
+ /**
+ * Error Code that Unknown error occured
+ */
+ ES_ERRCODE_UNKNOWN(6);
+
+ private int value;
+
+ private ESErrorCode(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static ESErrorCode fromInt(int i) {
+ for (ESErrorCode b : ESErrorCode.values()) {
+ if (b.getValue() == i) { return b; }
+ }
+ return null;
+ }
+};
+
--- /dev/null
+/**
+ * ***************************************************************
+ *
+ * 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;
+
+/**
+ * It defines various states of the cloud provisioning during easy setup process
+ */
+public enum ProvStatus {
+
+ /**
+ * Default state of the device
+ */
+ ES_STATE_INIT(0),
+
+ /**
+ * Status indicating being connecting to target network
+ */
+ ES_STATE_CONNECTING_TO_ENROLLER(1),
+
+ /**
+ * Status indicating successful connection to target network
+ */
+ ES_STATE_CONNECTED_TO_ENROLLER(2),
+
+ /**
+ * Status indicating failure connection to target network
+ */
+ ES_STATE_CONNECTED_FAIL_TO_ENROLLER(3),
+
+ /**
+ * Status indicating successful registration to cloud
+ */
+ ES_STATE_REGISTERED_TO_CLOUD(4),
+
+ /**
+ * Status indicating failure registration to cloud
+ */
+ ES_STATE_REGISTRRED_FAIL_TO_CLOUD(5);
+
+ private int value;
+
+ private ProvStatus(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static ProvStatus fromInt(int i) {
+ for (ProvStatus b : ProvStatus.values()) {
+ if (b.getValue() == i) { return b; }
+ }
+ return null;
+ }
+};
+
--- /dev/null
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#include "JniGetEnrolleeStatusListener.h"
+#include "JniRemoteEnrollee.h"
+
+using namespace OC;
+using namespace OIC::Service;
+
+JniGetEnrolleeStatusListener::JniGetEnrolleeStatusListener(JNIEnv *env, jobject jListener,
+ JniRemoteEnrollee *owner)
+ : m_ownerResource(owner)
+{
+ m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniGetEnrolleeStatusListener::~JniGetEnrolleeStatusListener()
+{
+ ES_LOGI("~JniGetEnrolleeStatusListener()");
+ if (m_jwListener)
+ {
+ jint ret;
+ JNIEnv *env = GetESJNIEnv(ret);
+ if (NULL == env) return;
+ env->DeleteWeakGlobalRef(m_jwListener);
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ }
+}
+
+void JniGetEnrolleeStatusListener::getEnrolleeStatusCallback (
+ std::shared_ptr<GetEnrolleeStatus> getEnrolleeStatusCb)
+{
+ ES_LOGI("JniGetEnrolleeStatusListener::getEnrolleeStatusCallback enter");
+
+ jint ret;
+ JNIEnv *env = GetESJNIEnv(ret);
+ if (NULL == env) return;
+ jobject jListener = env->NewLocalRef(m_jwListener);
+ if (!jListener)
+ {
+ checkExAndRemoveListener(env);
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ return;
+ }
+
+ jclass clsL = env->GetObjectClass(jListener);
+ if (!clsL)
+ {
+ checkExAndRemoveListener(env);
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ return;
+ }
+
+ jmethodID midL = env->GetMethodID(clsL, "onProgress",
+ "(Lorg/iotivity/service/easysetup/mediator/"
+ "GetEnrolleeStatus;"
+ ")V");
+
+ if (!midL)
+ {
+ checkExAndRemoveListener(env);
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ return;
+ }
+
+ EnrolleeStatus enrolleeStatus = getEnrolleeStatusCb->getEnrolleeStatus();
+ OCRepresentation m_Rep = enrolleeStatus.getRepresentation();
+ OCRepresentation* rep = new OCRepresentation(m_Rep);
+ jlong handle = reinterpret_cast<jlong>(rep);
+ jobject jRepresentation = env->NewObject(g_cls_OcRepresentation,
+ g_mid_OcRepresentation_N_ctor_bool,
+ handle, true);
+ if (!jRepresentation)
+ {
+ delete rep;
+ checkExAndRemoveListener(env);
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
+ return;
+ }
+
+ jobject jEnrolleeStatus = NULL;
+ jEnrolleeStatus = env->NewObject(g_cls_EnrolleeStatus,
+ g_mid_EnrolleeStatus_ctor,
+ (jobject)jRepresentation);
+ if (!jEnrolleeStatus) {
+ ES_LOGE("JniGetEnrolleeStatusListener::getEnrolleeStatusCallback Unable to create the jEnrolleeStatus");
+ return ;
+ }
+
+ ESResult esResult = getEnrolleeStatusCb->getESResult();
+ jobject jgetEnrolleeStatus = NULL;
+ jgetEnrolleeStatus = env->NewObject(g_cls_getEnrolleeStatus,
+ g_mid_getEnrolleeStatus_ctor,
+ (jint)esResult,
+ (jobject)jEnrolleeStatus);
+
+ if (!jgetEnrolleeStatus)
+ {
+ ES_LOGE("JniGetEnrolleeStatusListener::getEnrolleeStatusCallback Unable to create the java object");
+ return ;
+ }
+
+ env->CallVoidMethod(jListener, midL, jgetEnrolleeStatus);
+
+ if (env->ExceptionCheck())
+ {
+ ES_LOGE("Java exception is thrown");
+ checkExAndRemoveListener(env);
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ return;
+ }
+
+ if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniGetEnrolleeStatusListener::checkExAndRemoveListener(JNIEnv *env)
+{
+ if (env->ExceptionCheck())
+ {
+ jthrowable ex = env->ExceptionOccurred();
+ env->ExceptionClear();
+ m_ownerResource->removeStatusListener<JniGetEnrolleeStatusListener>
+ (env, m_jwListener);
+
+ env->Throw((jthrowable)ex);
+ }
+ else
+ {
+ m_ownerResource->removeStatusListener<JniGetEnrolleeStatusListener>
+ (env, m_jwListener);
+ }
+}
+
--- /dev/null
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#ifndef __JNI_ES_GET_ENROLLEE_STATUS_LISTENER_H_
+#define __JNI_ES_GET_ENROLLEE_STATUS_LISTENER_H_
+
+#include <jni.h>
+
+#include "OCPlatform.h"
+#include "RemoteEnrollee.h"
+#include "ESRichCommon.h"
+
+#include "JniJvm.h"
+
+class JniRemoteEnrollee;
+
+using namespace OIC::Service;
+
+class JniGetEnrolleeStatusListener
+{
+ public:
+ /**
+ * @brief constructor
+ */
+ JniGetEnrolleeStatusListener(JNIEnv *env, jobject jListener, JniRemoteEnrollee *resource);
+
+ /**
+ * @brief destructor
+ */
+ ~JniGetEnrolleeStatusListener();
+
+ /**
+ * @brief callback function that will be passed to Native layer
+ */
+ void getEnrolleeStatusCallback (std::shared_ptr<GetEnrolleeStatus> getEnrolleeStatus);
+
+ private:
+ jweak m_jwListener;
+ JniRemoteEnrollee *m_ownerResource;
+ void checkExAndRemoveListener(JNIEnv *env);
+};
+
+#endif //__JNI_ES_GET_CONFIGURATION_STATUS_LISTENER_H_
+
jclass g_cls_RemoteEnrollee = NULL;
jclass g_cls_ESException = NULL;
+jclass g_cls_EnrolleeStatus = NULL;
jclass g_cls_EnrolleeConf = NULL;
-jclass g_cls_DeviceConfig = NULL;
-jclass g_cls_WiFiConfig = NULL;
+jclass g_cls_getEnrolleeStatus = NULL;
jclass g_cls_getConfigurationStatus = NULL;
jclass g_cls_SecurityProvisioningStatus = NULL;
jclass g_cls_DevicePropProvisioningStatus = NULL;
jmethodID g_mid_RemoteEnrollee_ctor = NULL;
jmethodID g_mid_ESException_ctor = NULL;
+jmethodID g_mid_EnrolleeStatus_ctor = NULL;
jmethodID g_mid_EnrolleeConf_ctor = NULL;
-jmethodID g_mid_DeviceConfig_ctor = NULL;
-jmethodID g_mid_WiFiConfig_ctor = NULL;
+jmethodID g_mid_getEnrolleeStatus_ctor = NULL;
jmethodID g_mid_getConfigurationStatus_ctor = NULL;
jmethodID g_mid_SecurityProvisioningStatus_ctor = NULL;
jmethodID g_mid_DevicePropProvisioningStatus_ctor = NULL;
g_mid_ESException_ctor = env->GetMethodID(g_cls_ESException, "<init>", "(Ljava/lang/String;)V");
if (!g_mid_ESException_ctor) return JNI_ERR;
- // DeviceConfig
- clazz = env->FindClass("org/iotivity/service/easysetup/mediator/DeviceConfig");
+ // EnrolleeStatus
+ clazz = env->FindClass("org/iotivity/service/easysetup/mediator/EnrolleeStatus");
if (!clazz) return JNI_ERR;
- g_cls_DeviceConfig = (jclass)env->NewGlobalRef(clazz);
+ g_cls_EnrolleeStatus = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
- g_mid_DeviceConfig_ctor = env->GetMethodID(g_cls_DeviceConfig, "<init>",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
- if (!g_mid_DeviceConfig_ctor) return JNI_ERR;
-
- // WiFiConfig
- clazz = env->FindClass("org/iotivity/service/easysetup/mediator/WiFiConfig");
- if (!clazz) return JNI_ERR;
-
- g_cls_WiFiConfig = (jclass)env->NewGlobalRef(clazz);
- env->DeleteLocalRef(clazz);
-
- g_mid_WiFiConfig_ctor = env->GetMethodID(g_cls_WiFiConfig, "<init>",
- "(Ljava/util/ArrayList;I)V");
- if (!g_mid_WiFiConfig_ctor) return JNI_ERR;
+ g_mid_EnrolleeStatus_ctor = env->GetMethodID(g_cls_EnrolleeStatus, "<init>",
+ "(Lorg/iotivity/base/OcRepresentation;)V");
+ if (!g_mid_EnrolleeStatus_ctor) return JNI_ERR;
// EnrolleeConf
clazz = env->FindClass("org/iotivity/service/easysetup/mediator/EnrolleeConf");
"(Lorg/iotivity/base/OcRepresentation;)V");
if (!g_mid_EnrolleeConf_ctor) return JNI_ERR;
+ // getEnrolleeStatus
+ clazz = env->FindClass("org/iotivity/service/easysetup/mediator/GetEnrolleeStatus");
+ if (!clazz) return JNI_ERR;
+
+ g_cls_getEnrolleeStatus = (jclass)env->NewGlobalRef(clazz);
+ env->DeleteLocalRef(clazz);
+
+ g_mid_getEnrolleeStatus_ctor = env->GetMethodID(g_cls_getEnrolleeStatus, "<init>",
+ "(ILorg/iotivity/service/easysetup/mediator/EnrolleeStatus;)V");
+ if (!g_mid_getEnrolleeStatus_ctor) return JNI_ERR;
+
// getConfigurationStatus
clazz = env->FindClass("org/iotivity/service/easysetup/mediator/GetConfigurationStatus");
if (!clazz) return JNI_ERR;
extern jclass g_cls_RemoteEnrollee;
extern jclass g_cls_ESException;
+extern jclass g_cls_EnrolleeStatus;
extern jclass g_cls_EnrolleeConf;
-extern jclass g_cls_DeviceConfig;
-extern jclass g_cls_WiFiConfig;
+extern jclass g_cls_getEnrolleeStatus;
extern jclass g_cls_getConfigurationStatus;
extern jclass g_cls_SecurityProvisioningStatus;
extern jclass g_cls_DevicePropProvisioningStatus;
extern jmethodID g_mid_RemoteEnrollee_ctor;
extern jmethodID g_mid_ESException_ctor;
+extern jmethodID g_mid_EnrolleeStatus_ctor;
extern jmethodID g_mid_EnrolleeConf_ctor;
-extern jmethodID g_mid_DeviceConfig_ctor;
-extern jmethodID g_mid_WiFiConfig_ctor;
+extern jmethodID g_mid_getEnrolleeStatus_ctor;
extern jmethodID g_mid_getConfigurationStatus_ctor;
extern jmethodID g_mid_SecurityProvisioningStatus_ctor;
extern jmethodID g_mid_DevicePropProvisioningStatus_ctor;
return remoteEnrollee;
}
+void JniRemoteEnrollee::getStatus(JNIEnv *env, jobject jListener)
+{
+ JniGetEnrolleeStatusListener *onGetEnrolleeStatusReceived =
+ addStatusListener<JniGetEnrolleeStatusListener>(env, jListener);
+
+ GetStatusCb getEnrolleeStatusCallback = [onGetEnrolleeStatusReceived]
+ (std::shared_ptr<OIC::Service::GetEnrolleeStatus > getEnrolleeStatus)
+ {
+ onGetEnrolleeStatusReceived->getEnrolleeStatusCallback(getEnrolleeStatus);
+ };
+
+ try
+ {
+ m_sharedResource->getStatus(getEnrolleeStatusCallback);
+ }
+ catch (ESBadRequestException exception)
+ {
+ ES_LOGE("JNI getStatus :: Exception occured");
+ //throw the exception to java
+ throwESException( env, exception.what());
+ }
+}
+
void JniRemoteEnrollee::getConfiguration(JNIEnv *env, jobject jListener)
{
JniGetConfigurationStatusListener *onGetConfigurationStatusReceived =
//JNI
JNIEXPORT void JNICALL
+Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeGetStatus
+(JNIEnv *env, jobject jClass, jobject jListener)
+{
+ ES_LOGD("nativeGetStatus Enter");
+
+ JniRemoteEnrollee *remoteEnrollee = JniRemoteEnrollee::getJniRemoteEnrollee(env, jClass);
+ remoteEnrollee->getStatus(env, jListener);
+
+ ES_LOGD("nativeGetStatus Exit");
+}
+
+//JNI
+JNIEXPORT void JNICALL
Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeGetConfiguration
(JNIEnv *env, jobject jClass, jobject jListener)
{
#include "JniJvm.h"
#include "JniEsUtils.h"
+#include "JniGetEnrolleeStatusListener.h"
#include "JniGetConfigurationStatusListener.h"
#include "JniSecurityStatusListener.h"
#include "JniDevicePropProvisioningStatusListener.h"
~JniRemoteEnrollee();
// ***** JNI APIs internally call the APIs of this class ***** //
+ void getStatus(JNIEnv *env, jobject jListener);
void getConfiguration(JNIEnv *env, jobject jListener);
void provisionSecurity(JNIEnv *env, jobject jListener);
void provisionDeviceProperties(JNIEnv *env, jobject jRepresentation, jobject jListener);
#endif
/**
+ * API for starting the Request Enrollee status process.
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeGetStatus
+(JNIEnv *env, jobject jClass, jobject jListener);
+
+/**
* API for starting the Request EnrolleeConf process.
*/
JNIEXPORT void JNICALL
m_rep.getValue<int>(OC_RSRVD_ES_LAST_ERRORCODE));
return ES_ERRCODE_NO_ERROR;
}
+
+ /**
+ * Get OCRepresentation object
+ *
+ * @return OCRepresentation object
+ */
+ const OCRepresentation& getRepresentation()
+ {
+ return m_rep;
+ }
protected:
OCRepresentation m_rep;
};