Merge "Implementation of following functionality" into connectivity-abstraction
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caedradapter_singlethread.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  * @file caedradapter_singlethread.h
22  * @brief This file contains the APIs for EDR adapters to be implemented
23  */
24 #ifndef __CA_EDRADAPTER_SINGLETHREAD_H_
25 #define __CA_EDRADAPTER_SINGLETHREAD_H_
26
27 /**
28  * BT Interface AP
29  **/
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /**
39  * @fn  CAInitializeEDR
40  * @brief  Initialize EDR connectivity interface.
41  *
42  * @param[in]  registerCallback  To register EDR interfaces to Connectivity Abstraction Layer
43  * @param[in]  reqRespCallback  Callback to be notified on receival of request/responses from
44  * peer bluetooth devices.
45  * @param[in]  netCallback  Callback to be notified when network adapter state changes.
46  * @param[in]  threadPool  Thread pool for handling asynchronous tasks.
47  *
48  * @return  #CA_STATUS_OK or #CA_ADAPTER_NOT_ENABLED on success otherwise proper error code.
49  * @retval  #CA_STATUS_OK  Successful
50  * @retval  #CA_STATUS_INVALID_PARAM  Invalid input parameters
51  * @retval  #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
52  * not enabled
53  * @retval  #CA_STATUS_FAILED Operation failed
54  */
55 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
56                            CANetworkPacketReceivedCallback reqRespCallback,
57                            CANetworkChangeCallback netCallback);
58
59 /**
60  * @fn  CAStartEDR
61  * @brief  Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
62  * any servers.
63  *
64  * @return  #CA_STATUS_OK on success otherwise proper error code.
65  * @retval  #CA_STATUS_OK  Successful
66  * @retval  #CA_ADAPTER_NOT_ENABLED Bluetooth adapter is not enabled
67  * @retval  #CA_STATUS_FAILED Operation failed
68  *
69  */
70 CAResult_t CAStartEDR();
71
72 /**
73  * @fn  CAStartEDRListeningServer
74  * @brief  Starting listening server for receiving multicast search requests.
75  * Starts RFCOMM Server with prefixed UUID as per OIC specification.
76  *
77  * @return  #CA_STATUS_OK on success otherwise proper error code.
78  * @retval  #CA_STATUS_OK  Successful
79  * @retval  #CA_SERVER_STARTED_ALREADY  Server is already started and running for the predefined
80  *                                                            service UUID
81  * @retval  #CA_STATUS_FAILED Operation failed
82  *
83  */
84 CAResult_t CAStartEDRListeningServer();
85
86 /**
87  * @fn  CAStartEDRDiscoveryServer
88  * @brief  Starting discovery server for receiving multicast advertisements.
89  * Starts RFCOMM Server with prefixed UUID as per OIC specification.
90  *
91  * @return  #CA_STATUS_OK on success otherwise proper error code.
92  * @retval  #CA_STATUS_OK  Successful
93  * @retval  #CA_SERVER_STARTED_ALREADY  Server is already started and running for the predefined
94  * service UUID
95  * @retval  #CA_STATUS_FAILED Operation failed
96  *
97  */
98 CAResult_t CAStartEDRDiscoveryServer();
99
100 /**
101  * @fn  CASendEDRUnicastData
102  * @brief  Sends data to the peer bluetooth OIC device using the adapter connectivity.
103  *
104  * @param[in]  remoteEndpoint  Information about peer device to which data needs to be send.
105  * @param[in]  data  Data which needs to be send to peer OIC device.
106  * @param[in]  dataLength  Length of data in bytes.
107  *
108  * @return  Number of bytes sent on the network. 0 indicates failed to send data.
109  *
110  */
111 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, void *data,
112                               uint32_t dataLength);
113
114 /**
115  * @fn  CASendEDRMulticastData
116  * @brief  Sends multicast data to all discovered bluetooth OIC devices using the adapter
117  * connectivity.
118  *
119  * @param[in]  data  Data which needs to be send to all discovered bluetooth OIC device.
120  * @param[in]  dataLength  Length of data in bytes.
121  *
122  * @return  Number of bytes sent on the network. 0 indicates failed to send data.
123  *
124  */
125 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLength);
126
127 /**
128  * @fn  CAGetEDRInterfaceInformation
129  * @brief  Get EDR Connectivity network information.
130  *
131  * @param[out]  info  Array of local connectivity information structures.
132  * @param[out]  size  Size of the array @info.
133  *
134  * @return  #CA_STATUS_OK on success otherwise proper error code.
135  * @retval  #CA_STATUS_OK  Successful
136  * @retval  #CA_STATUS_INVALID_PARAM  Invalid input parameters
137  * @retval  #CA_MEMORY_ALLOC_FAILED  Failed to allocate memory
138  * @retval  #CA_STATUS_FAILED Operation failed
139  *
140  */
141 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
142
143 /**
144  * @fn  CAReadEDRData
145  * @brief  Read Synchronous API callback.
146  *
147  * @return  #CA_STATUS_OK on success otherwise proper error code.
148  * @retval  #CA_STATUS_OK  Successful
149  * @retval  #CA_STATUS_FAILED Operation failed
150  *
151  */
152 CAResult_t CAReadEDRData();
153
154 /**
155  * @fn  CAStopEDR
156  * @brief  Stopping the adapters and close socket connections
157  * EDR Stops all RFCOMM servers and close sockets.
158  *
159  * @return  #CA_STATUS_OK on success
160  *
161  */
162 CAResult_t CAStopEDR();
163
164 /**
165  * @fn  CATerminateEDR
166  * @brief  Terminate the EDR connectivity adapter.
167  * Configuration information will be deleted from further use.
168  *
169  */
170 void CATerminateEDR();
171
172 #ifdef __cplusplus
173 } /* extern "C" */
174 #endif
175
176 #endif  //__CA_EDRADAPTER_SINGLETHREAD_H_