Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / android / caleutils.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file caleutils.h
23  * @brief This file contains the APIs for BT LE communications.
24  */
25 #ifndef CA_LE_UTILS_H_
26 #define CA_LE_UTILS_H_
27
28 #include "cacommon.h"
29 #include "cathreadpool.h"
30 #include "uarraylist.h"
31 #include "jni.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /* Service UUID */
39 static const char OIC_GATT_SERVICE_UUID[] = "ADE3D529-C784-4F63-A987-EB69F70EE816";
40 static const char OIC_GATT_CHARACTERISTIC_REQUEST_UUID[] = "AD7B334F-4637-4B86-90B6-9D787F03D218";
41 static const char OIC_GATT_CHARACTERISTIC_RESPONSE_UUID[] = "E9241982-4580-42C4-8831-95048216B256";
42 static const char OIC_GATT_CHARACTERISTIC_CONFIG_UUID[] = "00002902-0000-1000-8000-00805f9b34fb";
43
44 static const uint32_t GATT_SUCCESS = 0;
45
46 static const uint32_t BOND_BONDED = 12;
47 static const uint32_t BOND_BONDING = 11;
48 static const uint32_t BOND_NONE = 10;
49
50 /**
51  * @brief   get uuid(jni object) from uuid(character)
52  * @param   env              [IN] JNI interface pointer
53  * @param   uuid             [IN] uuid(character)
54  * @return  uuid(jni object)
55  */
56 jobject CALEGetUuidFromString(JNIEnv *env, const char* uuid);
57
58 /**
59  * @brief   get parcel uuid object
60  * @param   env              [IN] JNI interface pointer
61  * @param   uuid             [IN] uuid (jni object)
62  * @return  parcel uuid object
63  */
64 jobject CALEGetParcelUuid(JNIEnv *env, jobject uuid);
65
66 /**
67  * @brief   get address from a local device
68  * @param   env              [IN] JNI interface pointer
69  * @return  local address
70  */
71 jstring CALEGetLocalDeviceAddress(JNIEnv *env);
72
73 /**
74  * @brief   get bonded list
75  * @param   env              [IN] JNI interface pointer
76  * @return  bonded list
77  */
78 jobjectArray CALEGetBondedDevices(JNIEnv *env);
79
80 /**
81  * @brief   get constants information of bluetooth state-on
82  * @param   env              [IN] JNI interface pointer
83  * @return  constants information of bluetooth state-on
84  */
85 jint CALEGetBTStateOnInfo(JNIEnv *env);
86
87 /**
88  * @brief   check this device can be supported as BLE client or server
89  * @param   env              [IN] JNI interface pointer
90  * @param   level            [IN] Android API Level to support
91  * @return  CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
92  */
93 CAResult_t CALECheckPlatformVersion(JNIEnv *env, uint16_t level);
94
95 /**
96  * @brief   get constants information of android.os.Build.VERSION.SDK_INT
97  * @param   env              [IN] JNI interface pointer
98  * @return  constants information of android.os.Build.VERSION.SDK_INT
99  */
100 jint CALEGetBuildVersion(JNIEnv *env);
101
102 /**
103  * @brief   get constants information of android.os.Build.VERSION_CODES.[VersionName]
104  * @param   env              [IN] JNI interface pointer
105  * @param   versionName      [IN] version name (.., KITKAT, LOLLIPOP, ..)
106  * @return  constants information of android.os.Build.VERSION_CODES.[VersionName]
107  */
108 jint CALEGetBuildVersionCodeForName(JNIEnv *env, const char* versionName);
109
110 /**
111  * @brief   get bluetooth adapter state information
112  * @param   env              [IN] JNI interface pointer
113  * @return  JNI_TRUE if the local adapter is turned on
114  */
115 jboolean CALEIsEnableBTAdapter(JNIEnv *env);
116
117 /**
118  * @brief   get address from remote device
119  * @param   env              [IN] JNI interface pointer
120  * @param   bluetoothDevice  [IN] bluetooth device object
121  * @return  remote address
122  */
123 jstring CALEGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
124
125 #ifdef __cplusplus
126 } /* extern "C" */
127 #endif
128
129 #endif /* CA_LE_UTILS_H_ */