1 /* ****************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "camanagerleinterface.h"
22 #include "cabtpairinginterface.h"
23 #include "cautilinterface.h"
28 #define TAG "OIC_CA_COMMON_UTILS"
30 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
31 CAConnectionStateChangedCB connStateCB)
33 OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
36 CASetLENetworkMonitorCallbacks(adapterStateCB, connStateCB);
41 return CA_NOT_SUPPORTED;
46 CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
48 OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
51 return CASetLEClientAutoConnectionDeviceInfo(address);
54 return CA_NOT_SUPPORTED;
58 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char *address)
60 OIC_LOG(DEBUG, TAG, "CAUnsetAutoConnectionDeviceInfo");
63 return CAUnsetLEClientAutoConnectionDeviceInfo(address);
66 return CA_NOT_SUPPORTED;
72 * initialize client connection manager
73 * @param[in] env JNI interface pointer.
74 * @param[in] jvm invocation inferface for JAVA virtual machine.
75 * @param[in] context application context.
77 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context)
79 OIC_LOG(DEBUG, TAG, "CAUtilClientInitialize");
81 CAResult_t res = CA_STATUS_OK;
83 if (CA_STATUS_OK != CAManagerLEClientInitialize(env, jvm, context))
85 OIC_LOG(ERROR, TAG, "CAManagerLEClientInitialize has failed");
86 res = CA_STATUS_FAILED;
91 if (CA_STATUS_OK != CABTPairingInitialize(env, jvm, context))
93 OIC_LOG(ERROR, TAG, "CABTPairingInitialize has failed");
94 res = CA_STATUS_FAILED;
101 * terminate client connection manager
102 * @param[in] env JNI interface pointer.
104 CAResult_t CAUtilClientTerminate(JNIEnv *env)
106 OIC_LOG(DEBUG, TAG, "CAUtilClientTerminate");
108 return CAManagerLEClientTerminate(env);
110 OIC_LOG(DEBUG, TAG, "it is not supported");
112 return CA_NOT_SUPPORTED;
117 CAResult_t CAUtilStartScan(JNIEnv *env)
120 return CABTPairingStartScan(env);
122 OIC_LOG(DEBUG, TAG, "it is not supported");
124 return CA_NOT_SUPPORTED;
128 CAResult_t CAUtilStopScan(JNIEnv *env)
131 return CABTPairingStopScan(env);
133 OIC_LOG(DEBUG, TAG, "it is not supported");
135 return CA_NOT_SUPPORTED;
139 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device)
142 return CABTPairingCreateBond(env, device);
144 OIC_LOG(DEBUG, TAG, "it is not supported");
147 return CA_NOT_SUPPORTED;
151 void CAUtilSetFoundDeviceListener(jobject listener)
154 CABTPairingSetFoundDeviceListener(listener);