/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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 org.iotivity.base.OcException;
import org.iotivity.base.OcConnectivityType;
+import java.util.EnumSet;
+
public class CaInterface {
static {
System.loadLibrary("connectivity_abstraction");
private static native void caBtPairingStartScan();
private static native void caBtPairingStopScan();
private static native void caBtPairingCreateBond(BluetoothDevice device);
-}
\ No newline at end of file
+
+ /**
+ * set BLE scan interval time and working count.
+ * scanning logic (start scan -> stop scan) will be worked repeatly for workingCount.
+ * and if you choose '0' value for workingCount parameter,
+ * scanning will be worked continually as interval time.
+ * @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);
+}