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 * This function will create the device socket list.
135 void CAEDRNativeCreateDeviceSocketList();
138 * Add device object to the list.
139 * @param[in] env JNI interface pointer.
140 * @param[in] deviceSocket device socket object.
142 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
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.
150 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
153 * Add device object to the list.
154 * @param[in] env JNI interface pointer.
156 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
159 * Add device object to the list.
160 * @param[in] env JNI interface pointer.
161 * @param[in] deviceSocket device socket object.
163 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
166 * Remove device socket.
167 * @param[in] env JNI interface pointer.
168 * @param[in] address remote address.
170 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
173 * Get device socket object from the list.
174 * @param[in] idx index of device list.
175 * @return Device socket object or NULL.
177 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
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.
185 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
188 * Get length of device socket list.
189 * @return length of list.
191 uint32_t CAEDRGetSocketListLength();
197 #endif /* CA_EDR_UTILS_H_ */