IoT-243 Connectivity Abstraction single-threaded module missing definition for CASend...
[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  * EDR Interface AP
29  **/
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /**
39  * @brief  Initialize EDR Interface.
40  * @param  registerCallback  [IN] Callback to register EDR interface to Connectivity
41  *                                Abstraction Layer
42  * @param  reqRespCallback   [IN] Callback to notify request and response messages from server(s)
43  *                                started at Connectivity Abstraction Layer.
44  * @param  netCallback       [IN] Callback to intimate the network additions to Connectivity
45  *                                Abstraction Layer.
46  * @return #CA_STATUS_OK or Appropriate error code
47  * @retval #CA_STATUS_OK Successful
48  * @retval #CA_STATUS_INVALID_PARAM Invalid input parameters
49  * @retval #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is not
50  *                                 enabled
51  * @retval #CA_STATUS_FAILED Operation failed
52  */
53 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
54                            CANetworkPacketReceivedCallback reqRespCallback,
55                            CANetworkChangeCallback netCallback);
56
57 /**
58  * @brief  Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
59  *         any servers.
60  * @return #CA_STATUS_OK or Appropriate error code
61  * @retval #CA_STATUS_OK  Successful
62  * @retval #CA_ADAPTER_NOT_ENABLED Bluetooth adapter is not enabled
63  * @retval #CA_STATUS_FAILED Operation failed
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  * @return #CA_STATUS_OK or Appropriate error code
71  * @retval #CA_STATUS_OK  Successful
72  * @retval #CA_SERVER_STARTED_ALREADY  Server is already started and running for the predefined
73  *                                     service UUID
74  * @retval #CA_STATUS_FAILED Operation failed
75  */
76 CAResult_t CAStartEDRListeningServer();
77
78 /**
79  * @brief  Starts discovery server for receiving multicast advertisements.
80  *         Starts RFCOMM Server with prefixed UUID as per OIC specification.
81  * @return #CA_STATUS_OK or Appropriate error code
82  * @retval #CA_STATUS_OK  Successful
83  * @retval #CA_SERVER_STARTED_ALREADY Server is already started and running for the predefined
84  *                                    service UUID
85  * @retval #CA_STATUS_FAILED Operation failed
86  */
87 CAResult_t CAStartEDRDiscoveryServer();
88
89 /**
90  * @brief  Sends data to the peer bluetooth OIC device using the adapter connectivity.
91  * @param  remoteEndpoint  [IN] Remote Endpoint information (like ipaddress, port, reference uri and
92  *                              connectivity type) to which the unicast data has to be sent.
93  * @param  data            [IN] Data to be sent.
94  * @param  dataLength      [IN] Size of data to be sent.
95  * @return Number of bytes sent on the network. Returns 0 on error.
96  */
97 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, void *data,
98                               uint32_t dataLength);
99
100 /**
101  * @brief  Sends multicast data to all discovered bluetooth OIC devices using the adapter
102  *         connectivity.
103  * @param  data         [IN]  Data which needs to be sent to all discovered bluetooth OIC device.
104  * @param  dataLength   [IN]  Length of data in bytes.
105  * @return Number of bytes sent on the network. Returns 0 on error.
106  */
107 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLength);
108
109 /**
110  * @brief  Get EDR Connectivity network information.
111  *
112  * @param  info [OUT] Array of local connectivity information structures.
113  * @param  size [OUT] Size of the array @info.
114  *
115  * @return #CA_STATUS_OK or Appropriate error code
116  * @retval #CA_STATUS_OK  Successful
117  * @retval #CA_STATUS_INVALID_PARAM  Invalid input parameters
118  * @retval #CA_MEMORY_ALLOC_FAILED  Failed to allocate memory
119  * @retval #CA_STATUS_FAILED Operation failed
120  * @remarks info is allocated in this API and should be freed by the caller.
121  */
122 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
123
124 /**
125  * @brief  Read Synchronous API callback.
126  * @return #CA_STATUS_OK on success otherwise proper error code.
127  * @retval #CA_STATUS_OK  Successful
128  * @retval #CA_STATUS_FAILED Operation failed
129  */
130 CAResult_t CAReadEDRData();
131
132 /**
133  * @brief  EDR Stops all RFCOMM servers and close sockets.
134  * @return #CA_STATUS_OK or Appropriate error code
135  */
136 CAResult_t CAStopEDR();
137
138 /**
139  * @brief  Terminate the EDR connectivity adapter.
140  * Configuration information will be deleted from further use.
141  * @return NONE
142  */
143 void CATerminateEDR();
144
145 #ifdef __cplusplus
146 } /* extern "C" */
147 #endif
148
149 #endif  //__CA_EDRADAPTER_SINGLETHREAD_H_