Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / android / caedrserver.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  * This file contains the APIs for BT EDR communications.
24  */
25 #ifndef CA_EDR_SERVER_H_
26 #define CA_EDR_SERVER_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 typedef void (*CAPacketReceiveCallback)(const char *address, const char *data);
40
41 /**
42  * Initialize JNI object.
43  */
44 void CAEDRServerJniInit();
45
46 /**
47  * Initialize server for EDR.
48  * @param[in]   handle           thread pool handle object.
49  */
50 void CAEDRServerInitialize(ca_thread_pool_t handle);
51
52 /**
53  * Start Accept Thread.
54  */
55 void CAEDRServerStartAcceptThread();
56
57 /**
58  * Start unicast server.
59  * @param[in]   isSecured       unicast server type.
60  * @return ::CA_STATUS_OK or Appropriate error code.
61  */
62 CAResult_t CAEDRStartUnicastServer(bool isSecured);
63
64 /**
65  * Start multicast server.
66  * @return ::CA_STATUS_OK or Appropriate error code.
67  */
68 CAResult_t CAEDRStartMulticastServer();
69
70 /**
71  * Stop unicast server.
72  * @return ::CA_STATUS_OK or Appropriate error code.
73  */
74 CAResult_t CAEDRStopUnicastServer();
75
76 /**
77  * Stop multicast server.
78  * @return ::CA_STATUS_OK or Appropriate error code.
79  */
80 CAResult_t CAEDRStopMulticastServer();
81
82 /**
83  * This function will read the data from remote device.
84  * @param[in]  env              JNI interface pointer.
85  * @param[in]  id               index of remote address.
86  * @param[in]  type             EDR server type.
87  * @return ::CA_STATUS_OK or Appropriate error code.
88  */
89 CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id, CAAdapterServerType_t type);
90
91 /**
92  * Start Listen Task.
93  * @param[in]   env             JNI interface pointer.
94  */
95 void CANativeStartListenTask(JNIEnv *env);
96
97 /**
98  * This function will listen the connection from remote device.
99  * @param[in]  env              JNI interface pointer.
100  * @return server socket object or NULL.
101  */
102 jobject CAEDRNativeListen(JNIEnv *env);
103
104 /**
105  * This function will listen the connection from remote device.
106  * @param[in]  env              JNI interface pointer.
107  * @param[in]  socket           server socket object.
108  * @return JNI_TRUE or JNI_FALSE.
109  */
110 jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
111
112 /**
113  * This function will accept the connection from remote device.
114  * @param[in]  env                  JNI interface pointer.
115  * @param[in]  severSocketObject    server socket object.
116  */
117 void CAEDRNativeAccept(JNIEnv *env, jobject severSocketObject);
118
119 /**
120  * Remove all device objects in the list.
121  * @param[in]   env    JNI interface pointer.
122  */
123 void CAEDRNatvieCloseServerTask(JNIEnv* env);
124
125 #ifdef __cplusplus
126 } /* extern "C" */
127 #endif
128
129 #endif /* CA_EDR_SERVER_H_ */