1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
23 * @brief This file contains the APIs for BT communications.
25 #ifndef CA_EDR_UTILS_H_
26 #define CA_EDR_UTILS_H_
29 #include "cathreadpool.h"
30 #include "uarraylist.h"
31 #include "caedrinterface.h"
40 * @brief Get address from device socket
41 * @param env [IN] JNI interface pointer
42 * @param bluetoothSocketObj [IN] bluetooth socket object
43 * @return Bluetooth device address
45 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
48 * @brief Get local device address
49 * @param env [IN] JNI interface pointer
50 * @return Bluetooth device address
52 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
55 * @brief Get bonded devices list
56 * @param env [IN] JNI interface pointer
57 * @return Bonded devices list
59 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
62 * @brief Get Bluetooth device state
63 * @param env [IN] JNI interface pointer
64 * @return Bluetooth device state
66 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
69 * @brief Check the BT Adapter enable
70 * @param env [IN] JNI interface pointer
71 * @return JNI_TRUE or JNI_FALSE
73 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
76 * @brief Get address from BT device
77 * @param env [IN] JNI interface pointer
78 * @param bluetoothSocketObj [IN] bluetooth socket object
79 * @return Bluetooth device address
81 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
88 * @brief This function will create the device state list.
91 void CAEDRNativeCreateDeviceStateList();
94 * @brief Update connection state of device
95 * @param state [IN] connection state
96 * @param address [IN] remote address
99 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
102 * @brief Add device object to the list
103 * @param state [IN] connection state object
106 void CAEDRNativeAddDeviceStateToList(state_t *state);
109 * @brief Check whether the device exist in the list or not
110 * @param remoteAddress [IN] remote address
111 * @return true or false
113 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
116 * @brief Close all socket
117 * @param env [IN] JNI interface pointer
120 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
123 * @brief Remove all device objects in the list
126 void CAEDRNativeRemoveAllDeviceState();
129 * @brief Remove target device in the list
130 * @param remoteAddress [IN] remote address
133 void CAEDRNativeRemoveDevice(const char *remoteAddress);
136 * @brief Get current device connection state
137 * @param remoteAddress [IN] remote address
138 * @return STATE_DISCONNECTED or STATE_CONNECTED
140 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
143 * @brief Reordering for the list
144 * @param index [IN] index of device list that want to reordering
147 void CAEDRReorderingDeviceList(uint32_t index);
150 * Bluetooth Socket Object List
154 * @brief This function will create the device socket list.
157 void CAEDRNativeCreateDeviceSocketList();
160 * @brief Add device object to the list
161 * @param env [IN] JNI interface pointer
162 * @param deviceSocket [IN] device socket object
165 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
168 * @brief Add device object to the list
169 * @param env [IN] JNI interface pointer
170 * @param remoteAddress [IN] remote address
171 * @return true or false
173 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
176 * @brief Add device object to the list
177 * @param env [IN] JNI interface pointer
180 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
183 * @brief Add device object to the list
184 * @param env [IN] JNI interface pointer
185 * @param deviceSocket [IN] device socket object
188 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
191 * @brief Remove device socket
192 * @param env [IN] JNI interface pointer
193 * @param address [IN] remote address
196 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
199 * @brief Get device socket object from the list
200 * @param idx [IN] index of device list
201 * @return Device socket object or NULL
203 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
206 * @brief Get device socket address
207 * @param env [IN] JNI interface pointer
208 * @param remoteAddress [IN] remote address
209 * @return Device socket object or NULL
211 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
214 * @brief Get length of device socket list
215 * @return length of list
217 uint32_t CAEDRGetSocketListLength();
220 * @brief Reordering for the list
221 * @param index [IN] index of device list that want to reordering
224 void CAEDRReorderingDeviceSocketList(uint32_t index);
229 #endif /* CA_EDR_UTILS_H_ */