1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
21 * @file caedradapter_singlethread.h
22 * @brief This file contains the APIs for EDR adapters to be implemented
24 #ifndef __CA_EDRADAPTER_SINGLETHREAD_H_
25 #define __CA_EDRADAPTER_SINGLETHREAD_H_
31 #include "caadapterinterface.h"
40 * @brief Initialize EDR connectivity interface.
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.
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
53 * @retval #CA_STATUS_FAILED Operation failed
55 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
56 CANetworkPacketReceivedCallback reqRespCallback,
57 CANetworkChangeCallback netCallback);
61 * @brief Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
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
70 CAResult_t CAStartEDR();
73 * @fn CAStartEDRListeningServer
74 * @brief Starting listening server for receiving multicast search requests.
75 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
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
81 * @retval #CA_STATUS_FAILED Operation failed
84 CAResult_t CAStartEDRListeningServer();
87 * @fn CAStartEDRDiscoveryServer
88 * @brief Starting discovery server for receiving multicast advertisements.
89 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
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
95 * @retval #CA_STATUS_FAILED Operation failed
98 CAResult_t CAStartEDRDiscoveryServer();
101 * @fn CASendEDRUnicastData
102 * @brief Sends data to the peer bluetooth OIC device using the adapter connectivity.
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.
108 * @return Number of bytes sent on the network. 0 indicates failed to send data.
111 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, void *data,
112 uint32_t dataLength);
115 * @fn CASendEDRMulticastData
116 * @brief Sends multicast data to all discovered bluetooth OIC devices using the adapter
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.
122 * @return Number of bytes sent on the network. 0 indicates failed to send data.
125 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLength);
128 * @fn CAGetEDRInterfaceInformation
129 * @brief Get EDR Connectivity network information.
131 * @param[out] info Array of local connectivity information structures.
132 * @param[out] size Size of the array @info.
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
141 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
145 * @brief Read Synchronous API callback.
147 * @return #CA_STATUS_OK on success otherwise proper error code.
148 * @retval #CA_STATUS_OK Successful
149 * @retval #CA_STATUS_FAILED Operation failed
152 CAResult_t CAReadEDRData();
156 * @brief Stopping the adapters and close socket connections
157 * EDR Stops all RFCOMM servers and close sockets.
159 * @return #CA_STATUS_OK on success
162 CAResult_t CAStopEDR();
166 * @brief Terminate the EDR connectivity adapter.
167 * Configuration information will be deleted from further use.
170 void CATerminateEDR();
176 #endif //__CA_EDRADAPTER_SINGLETHREAD_H_