Added Android EDR code
[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  * @brief 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  * @brief   Initialize JNI object
43  * @return  None
44  */
45 void CAEDRServerJniInit();
46
47 /**
48  * @brief   Initialize server for EDR
49  * @param   handle           [IN] thread pool handle object
50  * @return  None
51  */
52 void CAEDRServerInitialize(ca_thread_pool_t handle);
53
54 /*
55  * @brief   Start Accept Thread
56  * @return  None
57  */
58 void CAEDRServerStartAcceptThread();
59 /**
60  * @brief   Start unicast server
61  * @param   isSecured       [IN] unicast server type
62  * @return #CA_STATUS_OK or Appropriate error code
63  */
64 CAResult_t CAEDRStartUnicastServer(bool isSecured);
65
66 /**
67  * @brief   Start multicast server
68  * @param   isSecured       [IN] multicst server type
69  * @return #CA_STATUS_OK or Appropriate error code
70  */
71 CAResult_t CAEDRStartMulticastServer(bool isSecured);
72
73 /**
74  * @brief   Stop unicast server
75  * @param   serverID        [IN] unicast server id
76  * @return #CA_STATUS_OK or Appropriate error code
77  */
78 CAResult_t CAEDRStopUnicastServer(int32_t serverID);
79
80 /**
81  * @brief   Stop multicast server
82  * @param   serverID        [IN] multicast server id
83  * @return #CA_STATUS_OK or Appropriate error code
84  */
85 CAResult_t CAEDRStopMulticastServer(int32_t serverID);
86
87 /**
88  * EDR Method
89  */
90
91 /**
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
97  */
98 CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id, CAAdapterServerType_t type);
99
100 /*
101  * @brief   Start Listen Task
102  * @param   env             [IN] JNI interface pointer
103  * @return  None
104  */
105 void CANativeStartListenTask(JNIEnv *env);
106
107 /**
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
111  */
112 jobject CAEDRNativeListen(JNIEnv *env);
113
114 /**
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
119  */
120 jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
121
122 /**
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
126  * @return None
127  */
128 void CAEDRNativeAccept(JNIEnv *env, jobject severSocketObject);
129
130 /**
131  * @brief   Remove all device objects in the list
132  * @param   env    [IN] JNI interface pointer
133  * @return  None
134  */
135 void CAEDRNatvieCloseServerTask(JNIEnv* env);
136
137 #ifdef __cplusplus
138 } /* extern "C" */
139 #endif
140
141 #endif
142