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