5e852d4488113cc18834dddf4c24807c814e9538
[platform/upstream/iotivity.git] / resource / csdk / connectivity / api / cautilinterface.h
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 #ifndef CA_UTILS_INTERFACE_H_
22 #define CA_UTILS_INTERFACE_H_
23
24 #include "cacommon.h"
25 #ifdef __ANDROID__
26 #include "jni.h"
27 #endif
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 /**
34  * Callback function type for connection status changes delivery.
35  */
36 typedef void (*CAConnectionStateChangedCB)(CATransportAdapter_t adapter,
37         const char *remote_address, bool connected);
38
39 /**
40  * Callback function type for adapter status changes delivery.
41  * @param[out]   adapter    Transport type information.
42  * @param[out]   enabled    Current adapter status info.
43  */
44 typedef void (*CAAdapterStateChangedCB)(CATransportAdapter_t adapter, bool enabled);
45
46 /**
47  * Register network monitoring callback.
48  * Network status changes are delivered these callback.
49  * @param[in]   adapterStateCB  Adapter state monitoring callback.
50  * @param[in]   connStateCB     Connection state monitoring callback.
51  *
52  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
53  */
54 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
55                                            CAConnectionStateChangedCB connStateCB);
56
57 CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
58
59 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
60
61 #ifdef __ANDROID__
62 /**
63  * initialize util client for android
64  * @param[in]   env                   JNI interface pointer.
65  * @param[in]   jvm                   invocation inferface for JAVA virtual machine.
66  * @param[in]   context               application context.
67  *
68  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
69  */
70 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context);
71
72 /**
73  * terminate util client for android
74  * @param[in]   env                   JNI interface pointer.
75  *
76  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
77  */
78 CAResult_t CAUtilClientTerminate(JNIEnv *env);
79
80 // BT pairing
81 /**
82  * start discovery for BT device which has iotivity UUID.
83  * @param[in]  env              JNI interface pointer.
84  */
85 CAResult_t CAUtilStartScan(JNIEnv *env);
86
87 /**
88  * stop discovery
89  * @param[in]  env              JNI interface pointer.
90  */
91 CAResult_t CAUtilStopScan(JNIEnv *env);
92
93 /**
94  * bonding between devices.
95  * @param[in]  env              JNI interface pointer.
96  * @param[in]  device           bluetooth device object.
97  */
98 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device);
99
100
101 /**
102  * set callback listener of found device.
103  * @param[in]  listener         callback listener
104  */
105 void CAUtilSetFoundDeviceListener(jobject listener);
106 #endif
107
108 #ifdef __cplusplus
109 } /* extern "C" */
110 #endif
111
112 #endif /* CA_UTILS_INTERFACE_H_ */
113