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