47d840a57334f9ef5fd4ba2958d4ed93b36a21a9
[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  * @param[out]   info           Remote endpoint information.
36  * @param[out]   isConnected    Current connection status info.
37  */
38 typedef void (*CAConnectionStateChangedCB)(const CAEndpoint_t *info, bool isConnected);
39
40 /**
41  * Callback function type for adapter status changes delivery.
42  * @param[out]   adapter    Transport type information.
43  * @param[out]   enabled    Current adapter status info.
44  */
45 typedef void (*CAAdapterStateChangedCB)(CATransportAdapter_t adapter, bool enabled);
46
47 /**
48  * Register network monitoring callback.
49  * Network status changes are delivered these callback.
50  * @param[in]   adapterStateCB  Adapter state monitoring callback.
51  * @param[in]   connStateCB     Connection state monitoring callback.
52  *
53  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
54  */
55 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
56                                            CAConnectionStateChangedCB connStateCB);
57
58 /**
59  * Unregister network monitoring callback.
60  * @param[in]   adapterStateCB  Adapter state monitoring callback.
61  * @param[in]   connStateCB     Connection state monitoring callback.
62  *
63  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
64  */
65 CAResult_t CAUnregisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
66                                              CAConnectionStateChangedCB connStateCB);
67
68 /**
69  * Set device to handle for auto connection.
70  * @param[in]   address         LE address to set.
71  *
72  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
73  */
74 CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
75
76 /**
77  * Unset device to handle for auto connection.
78  * @param[in]   address         LE address to unset.
79  *
80  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
81  */
82 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
83
84 /**
85  * Set the port number to assign .
86  * @param[in]   adapter     Transport adapter information.
87  * @param[in]   flag        Transport flag information.
88  * @param[in]   port        The port number to use.
89  *
90  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
91  */
92 CAResult_t CASetPortNumberToAssign(CATransportAdapter_t adapter,
93                                    CATransportFlags_t flag, uint16_t port);
94
95 /**
96  * Get the assigned port number currently.
97  * @param[in]   adapter     Transport adapter information.
98  * @param[in]   flag        Transport flag information.
99  *
100  * @return  assigned port number information.
101  */
102 uint16_t CAGetAssignedPortNumber(CATransportAdapter_t adapter, CATransportFlags_t flag);
103
104 #ifdef __ANDROID__
105 /**
106  * initialize util client for android
107  * @param[in]   env                   JNI interface pointer.
108  * @param[in]   jvm                   invocation inferface for JAVA virtual machine.
109  * @param[in]   context               application context.
110  *
111  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
112  */
113 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context);
114
115 /**
116  * terminate util client for android
117  * @param[in]   env                   JNI interface pointer.
118  *
119  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
120  */
121 CAResult_t CAUtilClientTerminate(JNIEnv *env);
122
123 // BT pairing
124 /**
125  * start discovery for BT device which has iotivity UUID.
126  * @param[in]  env              JNI interface pointer.
127  */
128 CAResult_t CAUtilStartScan(JNIEnv *env);
129
130 /**
131  * stop discovery
132  * @param[in]  env              JNI interface pointer.
133  */
134 CAResult_t CAUtilStopScan(JNIEnv *env);
135
136 /**
137  * bonding between devices.
138  * @param[in]  env              JNI interface pointer.
139  * @param[in]  device           bluetooth device object.
140  */
141 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device);
142
143
144 /**
145  * set callback listener of found device.
146  * @param[in]  listener         callback listener
147  */
148 void CAUtilSetFoundDeviceListener(jobject listener);
149
150 /**
151  * set interval time and working count for LE scan.
152  * @param[in]  intervalTime         interval time(Seconds).
153  * @param[in]  workingCount         working cycle for selected interval time.
154  *
155  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
156  */
157 CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
158
159 #endif
160
161 #ifdef __cplusplus
162 } /* extern "C" */
163 #endif
164
165 #endif /* CA_UTILS_INTERFACE_H_ */
166