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 jint GATT_SUCCESS = 0;
47 static const jint BOND_BONDED = 12;
48 static const jint BOND_BONDING = 11;
49 static const jint BOND_NONE = 10;
52 * get uuid(jni object) from uuid(character).
53 * @param[in] env JNI interface pointer.
54 * @param[in] uuid uuid(character).
55 * @return uuid(jni object).
57 jobject CALEGetUuidFromString(JNIEnv *env, const char* uuid);
60 * get parcel uuid object.
61 * @param[in] env JNI interface pointer.
62 * @param[in] uuid uuid (jni object).
63 * @return parcel uuid object.
65 jobject CALEGetParcelUuid(JNIEnv *env, jobject uuid);
68 * get address from a local device.
69 * @param[in] env JNI interface pointer.
70 * @return local address.
72 jstring CALEGetLocalDeviceAddress(JNIEnv *env);
76 * @param[in] env JNI interface pointer.
77 * @return bonded list.
79 jobjectArray CALEGetBondedDevices(JNIEnv *env);
82 * get constants information of bluetooth state-on.
83 * @param[in] env JNI interface pointer.
84 * @return constants information of bluetooth state-on.
86 jint CALEGetBTStateOnInfo(JNIEnv *env);
89 * check this device can be supported as BLE client or server.
90 * @param[in] env JNI interface pointer.
91 * @param[in] level Android API Level to support.
92 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
94 CAResult_t CALECheckPlatformVersion(JNIEnv *env, uint16_t level);
97 * get constants information of android.os.Build.VERSION.SDK_INT.
98 * @param[in] env JNI interface pointer.
99 * @return constants information of android.os.Build.VERSION.SDK_INT.
101 jint CALEGetBuildVersion(JNIEnv *env);
104 * get constants information of android.os.Build.VERSION_CODES.[VersionName].
105 * @param[in] env JNI interface pointer.
106 * @param[in] versionName version name (.., KITKAT, LOLLIPOP, ..).
107 * @return constants information of android.os.Build.VERSION_CODES.[VersionName].
109 jint CALEGetBuildVersionCodeForName(JNIEnv *env, const char* versionName);
112 * get bluetooth adapter state information.
113 * @param[in] env JNI interface pointer.
114 * @return JNI_TRUE if the local adapter is turned on.
116 jboolean CALEIsEnableBTAdapter(JNIEnv *env);
119 * get address from remote device.
120 * @param[in] env JNI interface pointer.
121 * @param[in] bluetoothDevice bluetooth device object.
122 * @return remote address.
124 jstring CALEGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
130 #endif /* CA_LE_UTILS_H_ */