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_SERVER_H_
26 #define CA_EDR_SERVER_H_
31 #include "cathreadpool.h"
39 typedef void (*CAPacketReceiveCallback)(const char *address, const char *data);
42 * @brief Initialize JNI object
45 void CAEDRServerJniInit();
48 * @brief Initialize server for EDR
49 * @param handle [IN] thread pool handle object
52 void CAEDRServerInitialize(ca_thread_pool_t handle);
55 * @brief Start Accept Thread
58 void CAEDRServerStartAcceptThread();
60 * @brief Start unicast server
61 * @param isSecured [IN] unicast server type
62 * @return #CA_STATUS_OK or Appropriate error code
64 CAResult_t CAEDRStartUnicastServer(bool isSecured);
67 * @brief Start multicast server
68 * @param isSecured [IN] multicst server type
69 * @return #CA_STATUS_OK or Appropriate error code
71 CAResult_t CAEDRStartMulticastServer(bool isSecured);
74 * @brief Stop unicast server
75 * @param serverID [IN] unicast server id
76 * @return #CA_STATUS_OK or Appropriate error code
78 CAResult_t CAEDRStopUnicastServer(int32_t serverID);
81 * @brief Stop multicast server
82 * @param serverID [IN] multicast server id
83 * @return #CA_STATUS_OK or Appropriate error code
85 CAResult_t CAEDRStopMulticastServer(int32_t serverID);
92 * @brief This function will read the data from remote device.
93 * @param env [IN] JNI interface pointer
94 * @param id [IN] index of remote address
95 * @param type [IN] EDR server type
96 * @return #CA_STATUS_OK or Appropriate error code
98 CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id, CAAdapterServerType_t type);
101 * @brief Start Listen Task
102 * @param env [IN] JNI interface pointer
105 void CANativeStartListenTask(JNIEnv *env);
108 * @brief This function will listen the connection from remote device.
109 * @param env [IN] JNI interface pointer
110 * @return server socket object or NULL
112 jobject CAEDRNativeListen(JNIEnv *env);
115 * @brief This function will listen the connection from remote device.
116 * @param env [IN] JNI interface pointer
117 * @param socket [IN] server socket object
118 * @return JNI_TRUE or JNI_FALSE
120 jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
123 * @brief This function will accept the connection from remote device.
124 * @param env [IN] JNI interface pointer
125 * @param severSocketObject [IN] server socket object
128 void CAEDRNativeAccept(JNIEnv *env, jobject severSocketObject);
131 * @brief Remove all device objects in the list
132 * @param env [IN] JNI interface pointer
135 void CAEDRNatvieCloseServerTask(JNIEnv* env);
141 #endif /* CA_EDR_SERVER_H_ */