Imported Upstream version 1.1.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  * Start Accept Thread.
48  * @return ::CA_STATUS_OK or Appropriate error code.
49  */
50 CAResult_t CAEDRServerStartAcceptThread();
51
52 /**
53  * Start unicast server.
54  * @param[in]   isSecured       unicast server type.
55  * @return ::CA_STATUS_OK or Appropriate error code.
56  */
57 CAResult_t CAEDRStartUnicastServer(bool isSecured);
58
59 /**
60  * Start multicast server.
61  * @return ::CA_STATUS_OK or Appropriate error code.
62  */
63 CAResult_t CAEDRStartMulticastServer();
64
65 /**
66  * Stop unicast server.
67  * @return ::CA_STATUS_OK or Appropriate error code.
68  */
69 CAResult_t CAEDRStopUnicastServer();
70
71 /**
72  * Stop multicast server.
73  * @return ::CA_STATUS_OK or Appropriate error code.
74  */
75 CAResult_t CAEDRStopMulticastServer();
76
77 /**
78  * This function will read the data from remote device.
79  * @param[in]  env              JNI interface pointer.
80  * @param[in]  id               index of remote address.
81  * @return ::CA_STATUS_OK or Appropriate error code.
82  */
83 CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id);
84
85 /**
86  * Start Listen Task.
87  * @param[in]   env             JNI interface pointer.
88  */
89 void CANativeStartListenTask(JNIEnv *env);
90
91 /**
92  * This function will listen the connection from remote device.
93  * @param[in]  env              JNI interface pointer.
94  * @return server socket object or NULL.
95  */
96 jobject CAEDRNativeListen(JNIEnv *env);
97
98 /**
99  * This function will listen the connection from remote device.
100  * @param[in]  env              JNI interface pointer.
101  * @param[in]  socket           server socket object.
102  * @return JNI_TRUE or JNI_FALSE.
103  */
104 jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
105
106 /**
107  * This function will accept the connection from remote device.
108  * @param[in]  env                  JNI interface pointer.
109  * @param[in]  severSocketObject    server socket object.
110  */
111 void CAEDRNativeAccept(JNIEnv *env, jobject severSocketObject);
112
113 /**
114  * Remove all device objects in the list.
115  * @param[in]   env    JNI interface pointer.
116  */
117 void CAEDRNatvieCloseServerTask(JNIEnv* env);
118
119 #ifdef __cplusplus
120 } /* extern "C" */
121 #endif
122
123 #endif /* CA_EDR_SERVER_H_ */