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