ec12615be66a9133af615b4107f6b7ac1e084ff5
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / android / caedrutils.h
1 /* ****************************************************************
2  *
3  * Copyright 2014 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 /**
22  * @file
23  * This file contains the APIs for BT communications.
24  */
25 #ifndef CA_EDR_UTILS_H_
26 #define CA_EDR_UTILS_H_
27
28 #include "cacommon.h"
29 #include "cathreadpool.h"
30 #include "uarraylist.h"
31 #include "caedrinterface.h"
32 #include "jni.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * Get address from device socket.
41  * @param[in]   env                 JNI interface pointer.
42  * @param[in]   bluetoothSocketObj  bluetooth socket object.
43  * @return  Bluetooth device address.
44  */
45 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
46
47 /**
48  * Get local device address.
49  * @param[in]   env                 JNI interface pointer.
50  * @return  Bluetooth device address.
51  */
52 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
53
54 /**
55  * Get bonded devices list.
56  * @param[in]   env                 JNI interface pointer.
57  * @return  Bonded devices list.
58  */
59 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
60
61 /**
62  * Get Bluetooth device state.
63  * @param[in]   env                 JNI interface pointer.
64  * @return  Bluetooth device state.
65  */
66 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
67
68 /**
69  * Check the BT Adapter enable.
70  * @param[in]   env                 JNI interface pointer.
71  * @return  JNI_TRUE or JNI_FALSE.
72  */
73 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
74
75 /**
76  * Get address from BT device.
77  * @param[in]   env                 JNI interface pointer.
78  * @param[in]   bluetoothDevice     bluetooth socket object.
79  * @return  Bluetooth device address.
80  */
81 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
82
83 /**
84  * This function will create the device state list.
85  */
86 void CAEDRNativeCreateDeviceStateList();
87
88 /**
89  * Update connection state of device.
90  * @param[in]  state            connection state.
91  * @param[in]  address          remote address.
92  */
93 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
94
95 /**
96  * Add device object to the list.
97  * @param[in]  state            connection state object.
98  */
99 void CAEDRNativeAddDeviceStateToList(state_t *state);
100
101 /**
102  * Check whether the device exist in the list or not.
103  * @param[in]  remoteAddress    remote address.
104  * @return true or false.
105  */
106 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
107
108 /**
109  * Close all socket.
110  * @param[in]   env       JNI interface pointer.
111  */
112 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
113
114 /**
115  * Remove all device objects in the list.
116  */
117 void CAEDRNativeRemoveAllDeviceState();
118
119 /**
120  * Remove target device in the list.
121  * @param[in]   remoteAddress    remote address.
122  */
123 void CAEDRNativeRemoveDevice(const char *remoteAddress);
124
125 /**
126  * Get current device connection state.
127  * @param[in]   remoteAddress    remote address.
128  * @return  STATE_DISCONNECTED or STATE_CONNECTED.
129  */
130 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
131
132 /**
133  * This function will create the device socket list.
134  */
135 void CAEDRNativeCreateDeviceSocketList();
136
137 /**
138  * Add device object to the list.
139  * @param[in]  env              JNI interface pointer.
140  * @param[in]  deviceSocket     device socket object.
141  */
142 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
143
144 /**
145  * Add device object to the list.
146  * @param[in]  env              JNI interface pointer.
147  * @param[in]  remoteAddress    remote address.
148  * @return true or false.
149  */
150 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
151
152 /**
153  * Add device object to the list.
154  * @param[in]  env              JNI interface pointer.
155  */
156 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
157
158 /**
159  * Add device object to the list.
160  * @param[in]  env              JNI interface pointer.
161  * @param[in]  deviceSocket     device socket object.
162  */
163 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
164
165 /**
166  * Remove device socket.
167  * @param[in]   env             JNI interface pointer.
168  * @param[in]   address         remote address.
169  */
170 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
171
172 /**
173  * Get device socket object from the list.
174  * @param[in]  idx              index of device list.
175  * @return Device socket object or NULL.
176  */
177 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
178
179 /**
180  * Get device socket address.
181  * @param[in]   env             JNI interface pointer.
182  * @param[in]   remoteAddress   remote address.
183  * @return  Device socket object or NULL.
184  */
185 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
186
187 /**
188  * Get length of device socket list.
189  * @return length of list.
190  */
191 uint32_t CAEDRGetSocketListLength();
192
193 #ifdef __cplusplus
194 } /* extern "C" */
195 #endif
196
197 #endif /* CA_EDR_UTILS_H_ */
198