1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
23 * @brief This file contains the APIs for BT EDR communications.
25 #ifndef CA_EDR_CLIENT_H_
26 #define CA_EDR_CLIENT_H_
31 #include "cathreadpool.h"
40 * @brief Initialize context of application
43 void CAEDRJniInitContext();
46 * @brief Create JNI Object
47 * @param context [IN] context of application
48 * @return #CA_STATUS_OK or Appropriate error code
50 CAResult_t CAEDRCreateJNIInterfaceObject(jobject context);
53 * @brief Initialize client for EDR
54 * @param handle [IN] thread pool handle object
57 void CAEDRInitialize(ca_thread_pool_t handle);
60 * @brief Terminate server for EDR
63 void CAEDRTerminate();
66 * @brief Initialize JNI object
69 void CAEDRCoreJniInit();
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
80 CAResult_t CAEDRSendUnicastMessage(const char *address, const char *data, uint32_t dataLen);
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
90 CAResult_t CAEDRSendMulticastMessage(const char *data, uint32_t dataLen);
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
99 CAResult_t CAEDRGetInterfaceInfo(char **address);
102 * @brief Get address from a local device
103 * @param address [OUT] local address
106 void CAEDRGetLocalAddress(char **address);
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
117 CAResult_t CAEDRSendUnicastMessageImpl(const char *address, const char *data, uint32_t dataLen);
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
128 CAResult_t CAEDRSendMulticastMessageImpl(JNIEnv *env, const char *data, uint32_t dataLen);
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
143 CAResult_t CAEDRNativeSendData(JNIEnv *env, const char* address, const char* data,
144 uint32_t dataLength, uint32_t id);
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
153 CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address, uint32_t id);
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
162 void CAEDRNativeSocketClose(JNIEnv *env, const char *address, uint32_t id);
168 #endif /* CA_EDR_CLIENT_H_ */