diff options
author | jg.ham <jg.ham@samsung.com> | 2017-02-13 09:48:03 +0900 |
---|---|---|
committer | Dan Mihai <Daniel.Mihai@microsoft.com> | 2017-02-13 15:10:22 +0000 |
commit | 44afcaa714a2cef07506b0976eabe6987f9488fe (patch) | |
tree | 646c18564dcaa2ac925fd4474938d7e04ac726d1 /java | |
parent | ce5af55ebf421d7d550563da266b76dfd89e3051 (diff) | |
download | iotivity-44afcaa714a2cef07506b0976eabe6987f9488fe.tar.gz iotivity-44afcaa714a2cef07506b0976eabe6987f9488fe.tar.bz2 iotivity-44afcaa714a2cef07506b0976eabe6987f9488fe.zip |
[IOT-1540] Connection manager logic add.
Add the function to switch cloud IP to local IP
in connection manager.
Change-Id: I032d2ae38e63ad79694ebc92b900f6621d0130c3
Signed-off-by: Jonggyu Ham <jg.ham@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15909
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Diffstat (limited to 'java')
4 files changed, 83 insertions, 0 deletions
diff --git a/java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java index 5a8847687..5cad30900 100644 --- a/java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java +++ b/java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java @@ -268,4 +268,13 @@ public class CaInterface { } private static native int setCipherSuiteImpl(int cipher, int adapter); + /** + * Set Connection Manager configuration. + * It can be set a connection manager configuration.(default: CA_CLOUD) + */ + public synchronized static void setConnectionUserConfig(CaIpConnectionPreference connPriority) { + CaInterface.caManagerSetConnectionUserConfig(connPriority.getValue()); + } + + private static native void caManagerSetConnectionUserConfig(int connPriority); } diff --git a/java/iotivity-android/src/main/java/org/iotivity/ca/CaIpConnectionPreference.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaIpConnectionPreference.java new file mode 100644 index 000000000..04edcef0e --- /dev/null +++ b/java/iotivity-android/src/main/java/org/iotivity/ca/CaIpConnectionPreference.java @@ -0,0 +1,47 @@ +/* + ******************************************************************** + * + * 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.ca; + +import java.security.InvalidParameterException; +import java.util.EnumSet; + +public enum CaIpConnectionPreference { + + /** Cloud TCP (default) */ + CA_CLOUD (0), + /** local UDP */ + CA_LOCAL_UDP (1), + /** local TCP */ + CA_LOCAL_TCP (2), + ; + + private int value; + + private CaIpConnectionPreference(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/java/jni/JniCaInterface.c b/java/jni/JniCaInterface.c index a2ce4a0cb..9e380f059 100644 --- a/java/jni/JniCaInterface.c +++ b/java/jni/JniCaInterface.c @@ -453,3 +453,22 @@ JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl return ret; } +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_caManagerSetConnectionUserConfig(JNIEnv *env, jclass clazz, + jint connPriority) +{ + (void)env; + (void)clazz; +#if defined(TCP_ADAPTER) && defined(WITH_CLOUD) + LOGI("CaManager_SetConnecitonUserConfig connPriority: %d", connPriority); + CAResult_t ret = CAUtilCMSetConnectionUserConfig(connPriority); + if (CA_STATUS_OK != ret) + { + LOGE("CASetIpConnSwitchConfig has failed"); + } +#else + LOGI("[CaManager_SetConnecitonUserConfig] stack doesn't support TCP and CLOUD"); + (void)connPriority; +#endif +} + diff --git a/java/jni/JniCaInterface.h b/java/jni/JniCaInterface.h index 6edd7f231..904f442be 100644 --- a/java/jni/JniCaInterface.h +++ b/java/jni/JniCaInterface.h @@ -166,6 +166,14 @@ extern "C" { JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl (JNIEnv *, jclass, jint, jint); + /* + * Class: org_iotivity_ca_CaInterface + * Method: caManagerSetConnectionUserConfig + * Signature: (I)V + */ + JNIEXPORT void JNICALL + Java_org_iotivity_ca_CaInterface_caManagerSetConnectionUserConfig + (JNIEnv *, jclass, jint); #ifdef __cplusplus } #endif |