To add connection manager for client for android BLE.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / cautilinterface.c
1 /* ****************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 #include "camanagerleinterface.h"
22 #include "cautilinterface.h"
23
24 #include "cacommon.h"
25 #include "logger.h"
26
27 #define TAG "OIC_CA_UTIL_INF"
28
29 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
30                                            CAConnectionStateChangedCB connStateCB)
31 {
32     OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
33
34 #ifdef LE_ADAPTER
35     CASetLENetworkMonitorCallbacks(adapterStateCB, connStateCB);
36     return CA_STATUS_OK;
37 #else
38     (void)adapterStateCB;
39     (void)connStateCB;
40     return CA_NOT_SUPPORTED;
41 #endif
42
43 }
44
45 CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
46 {
47     OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
48
49 #ifdef LE_ADAPTER
50     return CASetLEClientAutoConnectionDeviceInfo(address);
51 #else
52     (void)address;
53     return CA_NOT_SUPPORTED;
54 #endif
55 }
56
57 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char *address)
58 {
59     OIC_LOG(DEBUG, TAG, "CAUnsetAutoConnectionDeviceInfo");
60
61 #ifdef LE_ADAPTER
62     return CAUnsetLEClientAutoConnectionDeviceInfo(address);
63 #else
64     (void)address;
65     return CA_NOT_SUPPORTED;
66 #endif
67 }
68
69 #ifdef __ANDROID__
70 /**
71  * initialize client connection manager
72  * @param[in]   env                   JNI interface pointer.
73  * @param[in]   jvm                   invocation inferface for JAVA virtual machine.
74  * @param[in]   context               application context.
75  */
76 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context)
77 {
78     OIC_LOG(DEBUG, TAG, "CAUtilClientInitialize");
79 #ifdef LE_ADAPTER
80     return CAManagerLEClientInitialize(env, jvm, context);
81 #else
82     OIC_LOG(DEBUG, TAG, "it is not supported");
83     (void)env;
84     (void)jvm;
85     (void)context;
86     return CA_NOT_SUPPORTED;
87 #endif
88 }
89
90 /**
91  * terminate client connection manager
92  * @param[in]   env                   JNI interface pointer.
93  */
94 CAResult_t CAUtilClientTerminate(JNIEnv *env)
95 {
96     OIC_LOG(DEBUG, TAG, "CAUtilClientTerminate");
97 #ifdef LE_ADAPTER
98     return CAManagerLEClientTerminate(env);
99 #else
100     OIC_LOG(DEBUG, TAG, "it is not supported");
101     (void)env;
102     return CA_NOT_SUPPORTED;
103 #endif
104 }
105 #endif