replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / camanager / bt_le_manager / android / camanagerdevice.h
1 /* ****************************************************************
2  *
3  * Copyright 2016 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 #ifndef CA_MANAGER_DEVICE_H_
22 #define CA_MANAGER_DEVICE_H_
23
24 #include <jni.h>
25 #include "uarraylist.h"
26 #include "octhread.h"
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 /*
34  * Auto Connection Target Device Identity
35  */
36 typedef struct
37 {
38     jstring address;         /**< remote address */
39     bool isAutoConnecting;   /**< whether GATT connection has been in progress */
40 } CAManagerACData_t;
41
42 /**
43  * get address from auto connection list.
44  * @param[in]   env                   JNI interface pointer.
45  * @param[in]   idx                   index of auto connection data list.
46  * @return  address
47  */
48 jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx);
49
50 /**
51  * create auto connection list.
52  */
53 void CAManagerCreateACDataList();
54
55 /**
56  * Destroy auto connection list.
57  */
58 void CAManagerDestroyACDataList();
59
60 /**
61  * initialize mutex.
62  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
63  */
64 CAResult_t CAManagerInitMutexVaraibles();
65
66 /**
67  * terminate mutex.
68  */
69 void CAManagerTerminateMutexVariables();
70
71 /**
72  * check whether target address is already contained in ACData list or not.
73  * @param[in]   env                   JNI interface pointer.
74  * @param[in]   jaddress              ble address.
75  */
76 bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress);
77
78 /**
79  * add auto connection data into list.
80  * @param[in]   env                   JNI interface pointer.
81  * @param[in]   jaddress              ble address.
82  */
83 void CAManagerAddACData(JNIEnv *env, jstring jaddress);
84
85 /**
86  * remove auto connection data from ACData list for selected ble address.
87  * @param[in]   env                   JNI interface pointer.
88  * @param[in]   jaddress              ble address.
89  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
90  */
91 CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress);
92
93 /**
94  * remove auto connection data from ACData list for all devices.
95  * @param[in]   env                   JNI interface pointer.
96  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
97  */
98 CAResult_t CAManagerRemoveAllACData(JNIEnv *env);
99
100 /**
101  * get isAutoConnecting flag for the address.
102  * @param[in]   env                   JNI interface pointer.
103  * @param[in]   jaddress              ble address.
104  * @param[out]  flag                  isAutoConnecting flag
105  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
106  */
107 CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *flag);
108
109 /**
110  * set isAutoConnecting flag for the address.
111  * @param[in]   env                   JNI interface pointer.
112  * @param[in]   jaddress              ble address.
113  * @param[in]   flag                  isAutoConnecting flag.
114  * @return  true or false
115  */
116 bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag);
117
118 /**
119  * get length of auto connection list.
120  * @return  list size
121  */
122 size_t CAManagerGetACDataLength();
123
124 /**
125  * set BT adapter recovery flag.
126  * @param[in]   flag                  recovery flag.
127  */
128 void CAManagerSetBTRecovery(bool flag);
129
130 /**
131  * get BT adapter recovery flag.
132  * @return  recovery flag.
133  */
134 bool CAManagerIsRecoveryFlagSet();
135
136 #ifdef __cplusplus
137 } /* extern "C" */
138 #endif
139
140 #endif /* CA_MANAGER_DEVICE_H_ */
141