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.h
22 * @brief This file contains the APIs for EDR adapters to be implemented
24 #ifndef __CA_EDRADAPTER_H_
25 #define __CA_EDRADAPTER_H_
31 #include "caadapterinterface.h"
32 #include "uthreadpool.h" /* for thread pool */
41 * @brief Initialize EDR connectivity interface.
43 * @param[in] registerCallback To register EDR interfaces to Connectivity Abstraction Layer
44 * @param[in] reqRespCallback Callback to be notified on receival of request/responses from
45 * peer bluetooth devices.
46 * @param[in] netCallback Callback to be notified when network adapter state changes.
47 * @param[in] threadPool Thread pool for handling asynchronous tasks.
49 * @return #CA_STATUS_OK or #CA_ADAPTER_NOT_ENABLED on success otherwise proper error code.
50 * @retval #CA_STATUS_OK Successful
51 * @retval #CA_STATUS_INVALID_PARAM Invalid input parameters
52 * @retval #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
54 * @retval #CA_STATUS_FAILED Operation failed
56 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
57 CANetworkPacketReceivedCallback reqRespCallback,
58 CANetworkChangeCallback netCallback,
59 u_thread_pool_t handle);
63 * @brief Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
66 * @return #CA_STATUS_OK on success otherwise proper error code.
67 * @retval #CA_STATUS_OK Successful
68 * @retval #CA_ADAPTER_NOT_ENABLED Bluetooth adapter is not enabled
69 * @retval #CA_STATUS_FAILED Operation failed
72 CAResult_t CAStartEDR();
75 * @fn CAStartEDRListeningServer
76 * @brief Starting listening server for receiving multicast search requests.
77 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
79 * @return #CA_STATUS_OK on success otherwise proper error code.
80 * @retval #CA_STATUS_OK Successful
81 * @retval #CA_SERVER_STARTED_ALREADY Server is already started and running for the predefined
83 * @retval #CA_STATUS_FAILED Operation failed
86 CAResult_t CAStartEDRListeningServer();
89 * @fn CAStartEDRDiscoveryServer
90 * @brief Starting discovery server for receiving multicast advertisements.
91 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
93 * @return #CA_STATUS_OK on success otherwise proper error code.
94 * @retval #CA_STATUS_OK Successful
95 * @retval #CA_SERVER_STARTED_ALREADY Server is already started and running for the predefined
97 * @retval #CA_STATUS_FAILED Operation failed
100 CAResult_t CAStartEDRDiscoveryServer();
103 * @fn CASendEDRUnicastData
104 * @brief Sends data to the peer bluetooth OIC device using the adapter connectivity.
106 * @param[in] remoteEndpoint Information about peer device to which data needs to be send.
107 * @param[in] data Data which needs to be send to peer OIC device.
108 * @param[in] dataLength Length of data in bytes.
110 * @return Number of bytes sent on the network. 0 indicates failed to send data.
113 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, void *data,
114 uint32_t dataLength);
117 * @fn CASendEDRMulticastData
118 * @brief Sends multicast data to all discovered bluetooth OIC devices using the adapter
121 * @param[in] data Data which needs to be send to all discovered bluetooth OIC device.
122 * @param[in] dataLength Length of data in bytes.
124 * @return Number of bytes sent on the network. 0 indicates failed to send data.
127 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLength);
130 * @fn CAGetEDRInterfaceInformation
131 * @brief Get EDR Connectivity network information.
133 * @param[out] info Array of local connectivity information structures.
134 * @param[out] size Size of the array @info.
136 * @return #CA_STATUS_OK on success otherwise proper error code.
137 * @retval #CA_STATUS_OK Successful
138 * @retval #CA_STATUS_INVALID_PARAM Invalid input parameters
139 * @retval #CA_MEMORY_ALLOC_FAILED Failed to allocate memory
140 * @retval #CA_STATUS_FAILED Operation failed
143 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
147 * @brief Read Synchronous API callback.
149 * @return #CA_STATUS_OK on success otherwise proper error code.
150 * @retval #CA_STATUS_OK Successful
151 * @retval #CA_STATUS_FAILED Operation failed
154 CAResult_t CAReadEDRData();
158 * @brief Stopping the adapters and close socket connections
159 * EDR Stops all RFCOMM servers and close sockets.
161 * @return #CA_STATUS_OK on success
164 CAResult_t CAStopEDR();
168 * @brief Terminate the EDR connectivity adapter.
169 * Configuration information will be deleted from further use.
172 void CATerminateEDR();
178 #endif //__CA_EDRADAPTER_H_