Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / android / caedrclient.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
23  * @brief This file contains the APIs for BT EDR communications.
24  */
25 #ifndef CA_EDR_CLIENT_H_
26 #define CA_EDR_CLIENT_H_
27
28 #include <stdbool.h>
29
30 #include "cacommon.h"
31 #include "cathreadpool.h"
32 #include "jni.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * @brief   Initialize context of application
41  * @return  None
42  */
43 void CAEDRJniInitContext();
44
45 /**
46  * @brief   Create JNI Object
47  * @param   context          [IN] context of application
48  * @return  #CA_STATUS_OK or Appropriate error code
49  */
50 CAResult_t CAEDRCreateJNIInterfaceObject(jobject context);
51
52 /**
53  * @brief   Initialize client for EDR
54  * @param   handle           [IN] thread pool handle object
55  * @return  None
56  */
57 void CAEDRInitialize(ca_thread_pool_t handle);
58
59 /**
60  * @brief   Terminate server for EDR
61  * @return  None
62  */
63 void CAEDRTerminate();
64
65 /**
66  * @brief   Initialize JNI object
67  * @return  None
68  */
69 void CAEDRCoreJniInit();
70
71 /**
72  * @brief   Send data for unicast
73  * @param   address         [IN] remote address
74  * @param   data            [IN] data for transmission
75  * @param   dataLen         [IN] data length
76  * @return  #CA_STATUS_OK or Appropriate error code
77  * @retval  #CA_STATUS_OK  Successful
78  * @retval  #CA_STATUS_FAILED Operation failed
79  */
80 CAResult_t CAEDRSendUnicastMessage(const char *address, const char *data, uint32_t dataLen);
81
82 /**
83  * @brief   Send data for multicast
84  * @param   data            [IN] data for transmission
85  * @param   dataLen         [IN] data length
86  * @return  #CA_STATUS_OK or Appropriate error code
87  * @retval  #CA_STATUS_OK  Successful
88  * @retval  #CA_STATUS_FAILED Operation failed
89  */
90 CAResult_t CAEDRSendMulticastMessage(const char *data, uint32_t dataLen);
91
92 /**
93  * @brief   Get Local EDR Address
94  * @param   address         [OUT] local address
95  * @return  #CA_STATUS_OK or Appropriate error code
96  * @retval  #CA_STATUS_OK  Successful
97  * @retval  #CA_STATUS_FAILED Operation failed
98  */
99 CAResult_t CAEDRGetInterfaceInfo(char **address);
100
101 /**
102  * @brief   Get address from a local device
103  * @param   address         [OUT] local address
104  * @return  None
105  */
106 void CAEDRGetLocalAddress(char **address);
107
108 /**
109  * @brief   Send data for unicast (implement)
110  * @param   address         [IN] remote address
111  * @param   data            [IN] data for transmission
112  * @param   dataLen         [IN] data length
113  * @return  #CA_STATUS_OK or Appropriate error code
114  * @retval  #CA_STATUS_OK  Successful
115  * @retval  #CA_STATUS_FAILED Operation failed
116  */
117 CAResult_t CAEDRSendUnicastMessageImpl(const char *address, const char *data, uint32_t dataLen);
118
119 /**
120  * @brief   Send data for multicast (implement)
121  * @param   env             [IN] JNI interface pointer
122  * @param   data            [IN] data for transmission
123  * @param   dataLen         [IN] data length
124  * @return  #CA_STATUS_OK or Appropriate error code
125  * @retval  #CA_STATUS_OK  Successful
126  * @retval  #CA_STATUS_FAILED Operation failed
127  */
128 CAResult_t CAEDRSendMulticastMessageImpl(JNIEnv *env, const char *data, uint32_t dataLen);
129
130 /**
131  * EDR Method
132  */
133
134 /**
135  * @brief  This function will send the data to remote device.
136  * @param  env              [IN] JNI interface pointer
137  * @param  address          [IN] Remote Address
138  * @param  data             [IN] Data to be transmitted from EDR
139  * @param  dataLength       [IN] Length of data
140  * @param  id               [IN] index of remote address
141  * @return #CA_STATUS_OK or Appropriate error code
142  */
143 CAResult_t CAEDRNativeSendData(JNIEnv *env, const char* address, const char* data,
144                                uint32_t dataLength, uint32_t id);
145
146 /**
147  * @brief  This function will connect to remote device.
148  * @param  env              [IN] JNI interface pointer
149  * @param  address          [IN] Remote Address
150  * @param  id               [IN] index of remote address
151  * @return #CA_STATUS_OK or Appropriate error code
152  */
153 CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address, uint32_t id);
154
155 /**
156  * @brief  This function will close socket.
157  * @param  env              [IN] JNI interface pointer
158  * @param  address          [IN] Remote Address
159  * @param  id               [IN] index of remote address
160  * @return None
161  */
162 void CAEDRNativeSocketClose(JNIEnv *env, const char *address, uint32_t id);
163
164 #ifdef __cplusplus
165 } /* extern "C" */
166 #endif
167
168 #endif /* CA_EDR_CLIENT_H_ */
169