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