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 "caedrinterface.h"
39 * EDR Socket Information for EDR transport
43 jobject deviceSocket; /**< Bluetooth device socket info */
44 jobject inputStream; /**< InputStream for read data */
48 * Get address from device socket.
49 * @param[in] env JNI interface pointer.
50 * @param[in] bluetoothSocketObj bluetooth socket object.
51 * @return Bluetooth device address.
53 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
56 * Get local device address.
57 * @param[in] env JNI interface pointer.
58 * @return Bluetooth device address.
60 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
63 * Get bonded devices list.
64 * @param[in] env JNI interface pointer.
65 * @return Bonded devices list.
67 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
70 * Get Bluetooth device state.
71 * @param[in] env JNI interface pointer.
72 * @return Bluetooth device state.
74 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
77 * Check the BT Adapter enable.
78 * @param[in] env JNI interface pointer.
79 * @return JNI_TRUE or JNI_FALSE.
81 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
84 * Get address from BT device.
85 * @param[in] env JNI interface pointer.
86 * @param[in] bluetoothDevice bluetooth socket object.
87 * @return Bluetooth device address.
89 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
92 * This function will create the device state list.
94 void CAEDRNativeCreateDeviceStateList();
97 * Update connection state of device.
98 * @param[in] state connection state.
99 * @param[in] address remote address.
101 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
104 * Add device object to the list.
105 * @param[in] state connection state object.
107 void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *state);
110 * Check whether the device exist in the list or not.
111 * @param[in] remoteAddress remote address.
112 * @return true or false.
114 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
118 * @param[in] env JNI interface pointer.
120 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
123 * Remove all device objects in the list.
125 void CAEDRNativeRemoveAllDeviceState();
128 * Remove target device in the list.
129 * @param[in] remoteAddress remote address.
131 void CAEDRNativeRemoveDevice(const char *remoteAddress);
134 * Get current device connection state.
135 * @param[in] remoteAddress remote address.
136 * @return STATE_DISCONNECTED or STATE_CONNECTED.
138 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
141 * This function will create the device socket list.
143 void CAEDRNativeCreateDeviceSocketList();
146 * Add device object to the list.
147 * @param[in] env JNI interface pointer.
148 * @param[in] deviceSocket device socket object.
150 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
153 * Add device object to the list.
154 * @param[in] env JNI interface pointer.
155 * @param[in] remoteAddress remote address.
156 * @return true or false.
158 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
161 * Add device object to the list.
162 * @param[in] env JNI interface pointer.
164 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
167 * Add device object to the list.
168 * @param[in] env JNI interface pointer.
169 * @param[in] deviceSocket device socket object.
171 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
174 * Remove device socket.
175 * @param[in] env JNI interface pointer.
176 * @param[in] address remote address.
178 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
181 * Get device socket object from the list.
182 * @param[in] index index of device list.
183 * @return Device socket object or NULL.
185 jobject CAEDRNativeGetDeviceSocket(uint32_t index);
188 * Get device socket address.
189 * @param[in] env JNI interface pointer.
190 * @param[in] remoteAddress remote address.
191 * @return Device socket object or NULL.
193 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
196 * Get input stream object from the list.
197 * @param[in] index index of device list.
198 * @return Input stream object or NULL.
200 jobject CAEDRNativeGetInputStream(uint32_t index);
203 * Get length of device socket list.
204 * @return length of list.
206 uint32_t CAEDRGetSocketListLength();
209 * Get device information from list.
210 * @param[in] remoteAddress remote address.
211 * @return Device information object or NULL.
213 CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress);
219 #endif /* CA_EDR_UTILS_H_ */