wrap CAcloseSslConnectionFreeEndpoint method with __TIZEN__ flag
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caedradapter.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 EDR adapters.
24  */
25
26 #ifndef CA_EDRADAPTER_H_
27 #define CA_EDRADAPTER_H_
28
29 /**
30  * EDR Interface AP.
31  **/
32 #include "cacommon.h"
33 #include "caadapterinterface.h"
34 #include "cathreadpool.h" /* for thread pool */
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40
41 /**
42  * Initialize EDR Interface.
43  * @param[in]   registerCallback   Callback to register EDR interface to Connectivity
44  *                                 Abstraction Layer.
45  * @param[in]   reqRespCallback    Callback to notify request and response messages from
46  *                                 server(s) started at Connectivity Abstraction Layer.
47  * @param[in]   netCallback        Callback to notify the adapter changes to Connectivity
48  *                                 Abstraction Layer.
49  * @param[in]   connCallback       Callback to notify the connection changes to Connectivity
50  *                                 Abstraction Layer.
51  * @param[in]   errorCallback      errorCallback to notify error to connectivity common logic
52  *                                 layer from adapter.
53  * @param[in]   handle             Threadpool Handle.
54  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
55  */
56 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
57                            CANetworkPacketReceivedCallback packetReceivedCallback,
58                            CAAdapterChangeCallback netCallback,
59                            CAConnectionChangeCallback connCallback,
60                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
61
62 /**
63  * Starts EDR connectivity adapters.
64  * As its peer to peer it does not require to start any servers.
65  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
66  */
67 CAResult_t CAStartEDR();
68
69 /**
70  * Starts listening server for receiving multicast search requests.
71  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
72  *
73  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
74  */
75 CAResult_t CAStartEDRListeningServer();
76
77 /**
78  * Stop listening server for receiving multicast search requests.
79  * Stop  RFCOMM Server with prefixed UUID as per OIC specification.
80  *
81  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
82  */
83 CAResult_t CAStopEDRListeningServer();
84
85 /**
86  * Starting discovery server for receiving multicast advertisements.
87  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
88  *
89  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
90  */
91 CAResult_t CAStartEDRDiscoveryServer();
92
93 /**
94  * Sends data to the peer bluetooth OIC device using the adapter connectivity.
95  * @param[in]  endpoint         Remote Endpoint information (like ipaddress, port, and
96  *                              connectivity type) to which the unicast data has to be sent.
97  * @param[in]  data             Data to be sent.
98  * @param[in]  dataLength       Size of data to be sent.
99  * @param[in]  dataType         Data type which is REQUEST or RESPONSE.
100  * @return The number of bytes sent on the network. Returns -1 on error.
101  *
102  */
103 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
104                              uint32_t dataLength, CADataType_t dataType);
105
106 /**
107  * Sends multicast data to all discovered bluetooth OIC devices using the adapter.
108  * @param[in]  endpoint      Remote Endpoint information (like ipaddress, port, and connectivity.
109  * @param[in]  data          Data which needs to be sent to all discovered bluetooth OIC device.
110  * @param[in]  dataLength    Length of data in bytes.
111  * @param[in]  dataType      Data type which is REQUEST or RESPONSE.
112  * @return Number of bytes sent on the network. Returns -1 on error.
113  */
114 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
115                                uint32_t dataLength, CADataType_t dataType);
116
117 /**
118  * Get EDR Connectivity network information.
119  *
120  * @param[out]  info    Array of local connectivity information structures.
121  * @param[out]  size    Size of the array @info.
122  *
123  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
124  */
125 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
126
127 /**
128  * Read Synchronous API callback.
129  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
130  */
131 CAResult_t CAReadEDRData();
132
133 /**
134  * EDR Stops all RFCOMM servers and close sockets.
135  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
136  */
137 CAResult_t CAStopEDR();
138
139 /**
140  * Terminate the EDR connectivity adapter.
141  * Configuration information will be deleted from further use.
142  */
143 void CATerminateEDR();
144
145 /**
146  * Initializes the adapter queues.
147  * This will initiates both server and receiver adapter queues.
148  * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
149  */
150 CAResult_t CAAdapterStartQueue();
151
152 #ifdef __cplusplus
153 } /* extern "C" */
154 #endif
155
156 #endif  /* CA_EDRADAPTER_H_ */
157