replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / ca / CaInterface.java
index 6924eb4..73fec6c 100644 (file)
@@ -28,6 +28,8 @@ import android.bluetooth.BluetoothDevice;
 import org.iotivity.base.OcException;
 import org.iotivity.base.OcConnectivityType;
 
+import java.util.EnumSet;
+
 public class CaInterface {
     static {
         System.loadLibrary("connectivity_abstraction");
@@ -186,17 +188,72 @@ public class CaInterface {
      *  @param intervalTime                  interval time(Seconds).
      *  @param workingCount                  working count with interval time.
      */
-
     public synchronized static void setLeScanIntervalTime(int intervalTime, int workingCount){
         CaInterface.setLeScanIntervalTimeImpl(intervalTime, workingCount);
     }
-
     private static native void setLeScanIntervalTimeImpl(int intervalTime, int workingCount);
 
+    /**
+     *  stop BLE scan.
+     *  if you want to start scan, it can be triggered by setLeScanIntervalTime or
+     *  other request API like findResource.
+     */
+    public synchronized static void stopLeScan(){
+        CaInterface.stopLeScanImpl();
+    }
+    private static native void stopLeScanImpl();
+
+    /**
+     *  start BLE Advertising.
+     */
+    public synchronized static void startLeAdvertising(){
+        CaInterface.startLeAdvertisingImpl();
+    }
+    private static native void startLeAdvertisingImpl();
+
+    /**
+     *  stop BLE Advertising.
+     */
+    public synchronized static void stopLeAdvertising(){
+        CaInterface.stopLeAdvertisingImpl();
+    }
+    private static native void stopLeAdvertisingImpl();
+
+    /**
+     *  set BT configure
+     */
+    public synchronized static void setBTConfigure(int flag){
+        CaInterface.setBTConfigureImpl(flag);
+    }
+    private static native void setBTConfigureImpl(int flag);
 
     public synchronized static int setCipherSuite(OicCipher cipher, OcConnectivityType connType){
         return CaInterface.setCipherSuiteImpl(cipher.getValue(), connType.getValue());
     }
     private static native int setCipherSuiteImpl(int cipher, int adapter);
 
+    /**
+    *  Disconnect TCP session.
+    *  It will disconnect the current TCP session.
+    *
+    *  @param address host address [IP address].
+    *  @param port Port number.
+    *  @param transportFlags Set of Transport flags.
+    *
+    *  @return Result of the API call.
+    *
+    *  @see CaTransportFlags
+    */
+    public synchronized static int disconnectTCPSession(String address, int port,
+                                     EnumSet<CaTransportFlags> transportFlags) {
+        int transPortFlagsInt = 0;
+        for (CaTransportFlags flag : CaTransportFlags.values()) {
+            if (transportFlags.contains(flag)) {
+                transPortFlagsInt |= flag.getValue();
+            }
+        }
+
+        return CaInterface.disconnectTCPSessionImpl(address, port, transPortFlagsInt);
+    }
+    private static native int disconnectTCPSessionImpl(String address, int port, int flags);
 }