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 LE communications.
25 #ifndef CA_LE_UTILS_H_
26 #define CA_LE_UTILS_H_
29 #include "cathreadpool.h"
30 #include "cagattservice.h"
31 #include "uarraylist.h"
40 static const char OIC_GATT_SERVICE_UUID[] = CA_GATT_SERVICE_UUID;
41 static const char OIC_GATT_CHARACTERISTIC_REQUEST_UUID[] = CA_GATT_REQUEST_CHRC_UUID;
42 static const char OIC_GATT_CHARACTERISTIC_RESPONSE_UUID[] = CA_GATT_RESPONSE_CHRC_UUID;
43 static const char OIC_GATT_CHARACTERISTIC_CONFIG_UUID[] = "00002902-0000-1000-8000-00805f9b34fb";
45 static const char CLASSPATH_BT_PROFILE[] = "android/bluetooth/BluetoothProfile";
46 static const char CLASSPATH_BT_GATT[] = "android/bluetooth/BluetoothGatt";
47 static const char CLASSPATH_BT_ADAPTER[] = "android/bluetooth/BluetoothAdapter";
48 static const char CLASSPATH_BT_DEVICE[] = "android/bluetooth/BluetoothDevice";
49 static const char CLASSPATH_BT_UUID[] = "java/util/UUID";
52 static const char METHODID_OBJECTNONPARAM[] = "()Landroid/bluetooth/BluetoothAdapter;";
53 static const char METHODID_BT_DEVICE[] = "()Landroid/bluetooth/BluetoothDevice;";
54 static const char METHODID_BT_REMOTE_DEVICE[] = "(Ljava/lang/String;)Landroid/bluetooth/BluetoothDevice;";
56 static const jint GATT_SUCCESS = 0;
58 static const jint BOND_BONDED = 12;
59 static const jint BOND_BONDING = 11;
60 static const jint BOND_NONE = 10;
63 * get uuid(jni object) from uuid(character).
64 * @param[in] env JNI interface pointer.
65 * @param[in] uuid uuid(character).
66 * @return uuid(jni object).
68 jobject CALEGetUuidFromString(JNIEnv *env, const char* uuid);
71 * get parcel uuid object.
72 * @param[in] env JNI interface pointer.
73 * @param[in] uuid uuid (jni object).
74 * @return parcel uuid object.
76 jobject CALEGetParcelUuid(JNIEnv *env, jobject uuid);
79 * get address from a local device.
80 * @param[in] env JNI interface pointer.
81 * @return local address.
83 jstring CALEGetLocalDeviceAddress(JNIEnv *env);
87 * @param[in] env JNI interface pointer.
88 * @return bonded list.
90 jobjectArray CALEGetBondedDevices(JNIEnv *env);
93 * get constants information of bluetooth state-on.
94 * @param[in] env JNI interface pointer.
95 * @return constants information of bluetooth state-on.
97 jint CALEGetBTStateOnInfo(JNIEnv *env);
100 * check this device can be supported as BLE client or server.
101 * @param[in] env JNI interface pointer.
102 * @param[in] level Android API Level to support.
103 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
105 CAResult_t CALECheckPlatformVersion(JNIEnv *env, uint16_t level);
108 * get constants information of android.os.Build.VERSION.SDK_INT.
109 * @param[in] env JNI interface pointer.
110 * @return constants information of android.os.Build.VERSION.SDK_INT.
112 jint CALEGetBuildVersion(JNIEnv *env);
115 * get constants information of android.os.Build.VERSION_CODES.[VersionName].
116 * @param[in] env JNI interface pointer.
117 * @param[in] versionName version name (.., KITKAT, LOLLIPOP, ..).
118 * @return constants information of android.os.Build.VERSION_CODES.[VersionName].
120 jint CALEGetBuildVersionCodeForName(JNIEnv *env, const char* versionName);
123 * get bluetooth adapter state information.
124 * @param[in] env JNI interface pointer.
125 * @return JNI_TRUE if the local adapter is turned on.
127 jboolean CALEIsEnableBTAdapter(JNIEnv *env);
130 * get address from remote device.
131 * @param[in] env JNI interface pointer.
132 * @param[in] bluetoothDevice bluetooth device object.
133 * @return remote address.
135 jstring CALEGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
138 * get value from selected constants.
139 * @param[in] env JNI interface pointer.
140 * @param[in] classType class type
141 * @param[in] name constants name to get.
142 * @return remote address.
144 jint CALEGetConstantsValue(JNIEnv *env, const char* classType, const char* name);
149 #endif /* CA_LE_UTILS_H_ */