98e2cc885c31a9f5c50caa4106bdfd25ecbca418
[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  * Initialize context of application.
41  */
42 void CAEDRJniInitContext();
43
44 /**
45  * Create JNI Object.
46  * @param[in]  context          context of application.
47  * @return  ::CA_STATUS_OK or Appropriate error code.
48  */
49 CAResult_t CAEDRCreateJNIInterfaceObject(jobject context);
50
51 /**
52  * Initialize client for EDR.
53  * @param[in]  handle           thread pool handle object.
54  */
55 void CAEDRInitialize(ca_thread_pool_t handle);
56
57 /**
58  * Terminate server for EDR.
59  */
60 void CAEDRTerminate();
61
62 /**
63  * Initialize JNI object.
64  */
65 void CAEDRCoreJniInit();
66
67 /**
68  * Send data for unicast.
69  * @param[in]  address         remote address.
70  * @param[in]  data            data for transmission.
71  * @param[in]  dataLen         data length.
72  * @return  ::CA_STATUS_OK or Appropriate error code.
73  * @retval  ::CA_STATUS_OK  Successful.
74  * @retval  ::CA_STATUS_FAILED Operation failed.
75  */
76 CAResult_t CAEDRSendUnicastMessage(const char *address, const uint8_t *data, uint32_t dataLen);
77
78 /**
79  * Send data for multicast.
80  * @param[in]  data            data for transmission.
81  * @param[in]  dataLen         data length.
82  * @return  ::CA_STATUS_OK or Appropriate error code.
83  * @retval  ::CA_STATUS_OK  Successful.
84  * @retval  ::CA_STATUS_FAILED Operation failed.
85  */
86 CAResult_t CAEDRSendMulticastMessage(const uint8_t *data, uint32_t dataLen);
87
88 /**
89  * Get Local EDR Address.
90  * @param[out]   address         local address.
91  * @return  ::CA_STATUS_OK or Appropriate error code.
92  * @retval  ::CA_STATUS_OK  Successful.
93  * @retval  ::CA_STATUS_FAILED Operation failed.
94  */
95 CAResult_t CAEDRGetInterfaceInfo(char **address);
96
97 /**
98  * Get address from a local device.
99  * @param[out]   address         local address.
100  */
101 void CAEDRGetLocalAddress(char **address);
102
103 /**
104  * Send data for unicast (implement).
105  * @param[in]  address         remote address.
106  * @param[in]  data            data for transmission.
107  * @param[in]  dataLen         data length.
108  * @return  ::CA_STATUS_OK or Appropriate error code.
109  * @retval  ::CA_STATUS_OK  Successful.
110  * @retval  ::CA_STATUS_FAILED Operation failed.
111  */
112 CAResult_t CAEDRSendUnicastMessageImpl(const char *address, const uint8_t *data, uint32_t dataLen);
113
114 /**
115  * Send data for multicast (implement).
116  * @param[in]  env             JNI interface pointer.
117  * @param[in]  data            data for transmission.
118  * @param[in]  dataLen         data length.
119  * @return  ::CA_STATUS_OK or Appropriate error code.
120  * @retval  ::CA_STATUS_OK  Successful.
121  * @retval  ::CA_STATUS_FAILED Operation failed.
122  */
123 CAResult_t CAEDRSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data, uint32_t dataLen);
124
125 /**
126  * EDR Method
127  */
128
129 /**
130  * This function will send the data to remote device.
131  * @param[in] env              JNI interface pointer.
132  * @param[in] address          Remote Address.
133  * @param[in] data             Data to be transmitted from EDR.
134  * @param[in] dataLength       Length of data.
135  * @return ::CA_STATUS_OK or Appropriate error code.
136  */
137 CAResult_t CAEDRNativeSendData(JNIEnv *env, const char* address, const uint8_t* data,
138                                uint32_t dataLength);
139
140 /**
141  * This function will connect to remote device.
142  * @param[in] env              JNI interface pointer.
143  * @param[in] address          Remote Address.
144  * @return ::CA_STATUS_OK or Appropriate error code.
145  */
146 CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address);
147
148 /**
149  * This function will close socket.
150  * @param[in] env              JNI interface pointer.
151  * @param[in] address          Remote Address.
152  */
153 void CAEDRNativeSocketClose(JNIEnv *env, const char *address);
154
155 #ifdef __cplusplus
156 } /* extern "C" */
157 #endif
158
159 #endif /* CA_EDR_CLIENT_H_ */
160