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 * Get address from device socket.
40 * @param[in] env JNI interface pointer.
41 * @param[in] bluetoothSocketObj bluetooth socket object.
42 * @return Bluetooth device address.
44 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
47 * Get local device address.
48 * @param[in] env JNI interface pointer.
49 * @return Bluetooth device address.
51 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
54 * Get bonded devices list.
55 * @param[in] env JNI interface pointer.
56 * @return Bonded devices list.
58 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
61 * Get Bluetooth device state.
62 * @param[in] env JNI interface pointer.
63 * @return Bluetooth device state.
65 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
68 * Check the BT Adapter enable.
69 * @param[in] env JNI interface pointer.
70 * @return JNI_TRUE or JNI_FALSE.
72 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
75 * Get address from BT device.
76 * @param[in] env JNI interface pointer.
77 * @param[in] bluetoothDevice bluetooth socket object.
78 * @return Bluetooth device address.
80 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
83 * This function will create the device state list.
85 void CAEDRNativeCreateDeviceStateList();
88 * Update connection state of device.
89 * @param[in] state connection state.
90 * @param[in] address remote address.
92 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
95 * Add device object to the list.
96 * @param[in] state connection state object.
98 void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *state);
101 * Check whether the device exist in the list or not.
102 * @param[in] remoteAddress remote address.
103 * @return true or false.
105 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
109 * @param[in] env JNI interface pointer.
111 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
114 * Remove all device objects in the list.
116 void CAEDRNativeRemoveAllDeviceState();
119 * Remove target device in the list.
120 * @param[in] remoteAddress remote address.
122 void CAEDRNativeRemoveDevice(const char *remoteAddress);
125 * Get current device connection state.
126 * @param[in] remoteAddress remote address.
127 * @return STATE_DISCONNECTED or STATE_CONNECTED.
129 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
132 * This function will create the device socket list.
134 void CAEDRNativeCreateDeviceSocketList();
137 * Add device object to the list.
138 * @param[in] env JNI interface pointer.
139 * @param[in] deviceSocket device socket object.
141 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
144 * Add device object to the list.
145 * @param[in] env JNI interface pointer.
146 * @param[in] remoteAddress remote address.
147 * @return true or false.
149 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
152 * Add device object to the list.
153 * @param[in] env JNI interface pointer.
155 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
158 * Add device object to the list.
159 * @param[in] env JNI interface pointer.
160 * @param[in] deviceSocket device socket object.
162 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
165 * Remove device socket.
166 * @param[in] env JNI interface pointer.
167 * @param[in] address remote address.
169 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
172 * Get device socket object from the list.
173 * @param[in] idx index of device list.
174 * @return Device socket object or NULL.
176 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
179 * Get device socket address.
180 * @param[in] env JNI interface pointer.
181 * @param[in] remoteAddress remote address.
182 * @return Device socket object or NULL.
184 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
187 * Get length of device socket list.
188 * @return length of list.
190 uint32_t CAEDRGetSocketListLength();
193 * Get device information from list.
194 * @param[in] remoteAddress remote address.
195 * @return Device information object or NULL.
197 CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress);
203 #endif /* CA_EDR_UTILS_H_ */