Imported Upstream version 1.2.0
[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  * Set device to handle for auto connection.
60  * @param[in]   address         LE address to set.
61  *
62  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
63  */
64 CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
65
66 /**
67  * Unset device to handle for auto connection.
68  * @param[in]   address         LE address to unset.
69  *
70  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
71  */
72 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
73
74 /**
75  * Set the port number to assign .
76  * @param[in]   adapter     Transport adapter information.
77  * @param[in]   flag        Transport flag information.
78  * @param[in]   port        The port number to use.
79  *
80  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED.
81  */
82 CAResult_t CASetPortNumberToAssign(CATransportAdapter_t adapter,
83                                    CATransportFlags_t flag, uint16_t port);
84
85 /**
86  * Get the assigned port number currently.
87  * @param[in]   adapter     Transport adapter information.
88  * @param[in]   flag        Transport flag information.
89  *
90  * @return  assigned port number information.
91  */
92 uint16_t CAGetAssignedPortNumber(CATransportAdapter_t adapter, CATransportFlags_t flag);
93
94 #ifdef __ANDROID__
95 /**
96  * initialize util client for android
97  * @param[in]   env                   JNI interface pointer.
98  * @param[in]   jvm                   invocation inferface for JAVA virtual machine.
99  * @param[in]   context               application context.
100  *
101  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
102  */
103 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context);
104
105 /**
106  * terminate util client for android
107  * @param[in]   env                   JNI interface pointer.
108  *
109  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
110  */
111 CAResult_t CAUtilClientTerminate(JNIEnv *env);
112
113 // BT pairing
114 /**
115  * start discovery for BT device which has iotivity UUID.
116  * @param[in]  env              JNI interface pointer.
117  */
118 CAResult_t CAUtilStartScan(JNIEnv *env);
119
120 /**
121  * stop discovery
122  * @param[in]  env              JNI interface pointer.
123  */
124 CAResult_t CAUtilStopScan(JNIEnv *env);
125
126 /**
127  * bonding between devices.
128  * @param[in]  env              JNI interface pointer.
129  * @param[in]  device           bluetooth device object.
130  */
131 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device);
132
133
134 /**
135  * set callback listener of found device.
136  * @param[in]  listener         callback listener
137  */
138 void CAUtilSetFoundDeviceListener(jobject listener);
139
140 /**
141  * set interval time and working count for LE scan.
142  * @param[in]  intervalTime         interval time(Seconds).
143  * @param[in]  workingCount         working cycle for selected interval time.
144  *
145  * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
146  */
147 CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
148
149 #endif
150
151 #ifdef __cplusplus
152 } /* extern "C" */
153 #endif
154
155 #endif /* CA_UTILS_INTERFACE_H_ */
156