replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniCaInterface.c
index 8fdedd9..2a7861b 100644 (file)
@@ -356,6 +356,43 @@ Java_org_iotivity_ca_CaInterface_setLeScanIntervalTimeImpl(JNIEnv *env, jclass c
     CAUtilSetLEScanInterval(intervalTime, workignCount);
 }
 
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_stopLeScanImpl(JNIEnv *env, jclass clazz)
+{
+    LOGI("stopLeScan");
+    (void)env;
+    (void)clazz;
+    CAUtilStopLEScan();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_startLeAdvertisingImpl(JNIEnv *env, jclass clazz)
+{
+    LOGI("startLeAdvertising");
+    (void)env;
+    (void)clazz;
+    CAUtilStartLEAdvertising();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_stopLeAdvertisingImpl(JNIEnv *env, jclass clazz)
+{
+    LOGI("stopLeAdvertising");
+    (void)env;
+    (void)clazz;
+    CAUtilStopLEAdvertising();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_setBTConfigureImpl(JNIEnv *env, jclass clazz, jint flag)
+{
+    LOGI("setConfigureImpl");
+    (void)env;
+    (void)clazz;
+    CAUtilConfig_t configs = {(CATransportBTFlags_t)flag};
+    CAUtilSetBTConfigure(configs);
+}
+
 JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
   (JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter)
 {
@@ -370,3 +407,33 @@ JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
     return ret;
 }
 
+JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_disconnectTCPSessionImpl
+ (JNIEnv *env, jclass clazz, jstring address, jint port, jint transportFlags)
+{
+    LOGI("disconnectTCPSessionImpl");
+    (void)env;
+    (void)clazz;
+
+    if(!address)
+    {
+        LOGE("Java address is null");
+        return CA_STATUS_INVALID_PARAM;
+    }
+
+    //convert java string to native string
+    const char* nativeAddress = (*env)->GetStringUTFChars(env, address, NULL);
+    if (!nativeAddress)
+    {
+        LOGE("Native address is null");
+        return CA_STATUS_INVALID_PARAM;
+    }
+
+    CAResult_t result = CAUtilTCPDisconnectSession(nativeAddress, (int)port,
+                                            (CATransportFlags_t)transportFlags);
+    if (CA_STATUS_OK != result)
+    {
+        LOGE("disconnectTCPSessionImpl failed");
+    }
+    return result;
+}
+