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 * 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 * Get address from device socket.
41 * @param[in] env JNI interface pointer.
42 * @param[in] bluetoothSocketObj bluetooth socket object.
43 * @return Bluetooth device address.
45 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
48 * Get local device address.
49 * @param[in] env JNI interface pointer.
50 * @return Bluetooth device address.
52 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
55 * Get bonded devices list.
56 * @param[in] env JNI interface pointer.
57 * @return Bonded devices list.
59 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
62 * Get Bluetooth device state.
63 * @param[in] env JNI interface pointer.
64 * @return Bluetooth device state.
66 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
69 * Check the BT Adapter enable.
70 * @param[in] env JNI interface pointer.
71 * @return JNI_TRUE or JNI_FALSE.
73 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
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.
81 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
84 * This function will create the device state list.
86 void CAEDRNativeCreateDeviceStateList();
89 * Update connection state of device.
90 * @param[in] state connection state.
91 * @param[in] address remote address.
93 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
96 * Add device object to the list.
97 * @param[in] state connection state object.
99 void CAEDRNativeAddDeviceStateToList(state_t *state);
102 * Check whether the device exist in the list or not.
103 * @param[in] remoteAddress remote address.
104 * @return true or false.
106 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
110 * @param[in] env JNI interface pointer.
112 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
115 * Remove all device objects in the list.
117 void CAEDRNativeRemoveAllDeviceState();
120 * Remove target device in the list.
121 * @param[in] remoteAddress remote address.
123 void CAEDRNativeRemoveDevice(const char *remoteAddress);
126 * Get current device connection state.
127 * @param[in] remoteAddress remote address.
128 * @return STATE_DISCONNECTED or STATE_CONNECTED.
130 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
133 * Reordering for the list.
134 * @param[in] index index of device list that want to reordering.
136 void CAEDRReorderingDeviceList(uint32_t index);
139 * This function will create the device socket list.
141 void CAEDRNativeCreateDeviceSocketList();
144 * Add device object to the list.
145 * @param[in] env JNI interface pointer.
146 * @param[in] deviceSocket device socket object.
148 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
151 * Add device object to the list.
152 * @param[in] env JNI interface pointer.
153 * @param[in] remoteAddress remote address.
154 * @return true or false.
156 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
159 * Add device object to the list.
160 * @param[in] env JNI interface pointer.
162 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
165 * Add device object to the list.
166 * @param[in] env JNI interface pointer.
167 * @param[in] deviceSocket device socket object.
169 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
172 * Remove device socket.
173 * @param[in] env JNI interface pointer.
174 * @param[in] address remote address.
176 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
179 * Get device socket object from the list.
180 * @param[in] idx index of device list.
181 * @return Device socket object or NULL.
183 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
186 * Get device socket address.
187 * @param[in] env JNI interface pointer.
188 * @param[in] remoteAddress remote address.
189 * @return Device socket object or NULL.
191 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
194 * Get length of device socket list.
195 * @return length of list.
197 uint32_t CAEDRGetSocketListLength();
200 * Reordering for the list.
201 * @param[in] index index of device list that want to reordering.
203 void CAEDRReorderingDeviceSocketList(uint32_t index);
208 #endif /* CA_EDR_UTILS_H_ */