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"
33 #include "uthreadpool.h" /* for thread pool */
43 * @brief Initialize EDR connectivity interface.
45 * @param[in] registerCallback To register EDR interfaces to Connectivity Abstraction Layer
46 * @param[in] reqRespCallback Callback to be notified on receival of request/responses from
47 * peer bluetooth devices.
48 * @param[in] netCallback Callback to be notified when network adapter state changes.
49 * @param[in] threadPool Thread pool for handling asynchronous tasks.
51 * @return #CA_STATUS_OK or #CA_ADAPTER_NOT_ENABLED on success otherwise proper error code.
52 * @retval #CA_STATUS_OK Successful
53 * @retval #CA_STATUS_INVALID_PARAM Invalid input parameters
54 * @retval #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
56 * @retval #CA_STATUS_FAILED Operation failed
59 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
60 CANetworkPacketReceivedCallback reqRespCallback,
61 CANetworkChangeCallback netCallback);
63 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
64 CANetworkPacketReceivedCallback reqRespCallback,
65 CANetworkChangeCallback netCallback,
66 u_thread_pool_t handle);
67 #endif //#ifdef ARDUINO
72 * @brief Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
75 * @return #CA_STATUS_OK on success otherwise proper error code.
76 * @retval #CA_STATUS_OK Successful
77 * @retval #CA_ADAPTER_NOT_ENABLED Bluetooth adapter is not enabled
78 * @retval #CA_STATUS_FAILED Operation failed
81 CAResult_t CAStartEDR();
84 * @fn CAStartEDRListeningServer
85 * @brief Starting listening server for receiving multicast search requests.
86 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
88 * @return #CA_STATUS_OK on success otherwise proper error code.
89 * @retval #CA_STATUS_OK Successful
90 * @retval #CA_SERVER_STARTED_ALREADY Server is already started and running for the predefined
92 * @retval #CA_STATUS_FAILED Operation failed
95 CAResult_t CAStartEDRListeningServer();
98 * @fn CAStartEDRDiscoveryServer
99 * @brief Starting discovery server for receiving multicast advertisements.
100 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
102 * @return #CA_STATUS_OK on success otherwise proper error code.
103 * @retval #CA_STATUS_OK Successful
104 * @retval #CA_SERVER_STARTED_ALREADY Server is already started and running for the predefined
106 * @retval #CA_STATUS_FAILED Operation failed
109 CAResult_t CAStartEDRDiscoveryServer();
112 * @fn CASendEDRUnicastData
113 * @brief Sends data to the peer bluetooth OIC device using the adapter connectivity.
115 * @param[in] remoteEndpoint Information about peer device to which data needs to be send.
116 * @param[in] data Data which needs to be send to peer OIC device.
117 * @param[in] dataLength Length of data in bytes.
119 * @return Number of bytes sent on the network. 0 indicates failed to send data.
122 uint32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, void *data,
123 uint32_t dataLength);
126 * @fn CASendEDRMulticastData
127 * @brief Sends multicast data to all discovered bluetooth OIC devices using the adapter
130 * @param[in] data Data which needs to be send to all discovered bluetooth OIC device.
131 * @param[in] dataLength Length of data in bytes.
133 * @return Number of bytes sent on the network. 0 indicates failed to send data.
136 uint32_t CASendEDRMulticastData(void *data, uint32_t dataLength);
139 * @fn CAGetEDRInterfaceInformation
140 * @brief Get EDR Connectivity network information.
142 * @param[out] info Array of local connectivity information structures.
143 * @param[out] size Size of the array @info.
145 * @return #CA_STATUS_OK on success otherwise proper error code.
146 * @retval #CA_STATUS_OK Successful
147 * @retval #CA_STATUS_INVALID_PARAM Invalid input parameters
148 * @retval #CA_MEMORY_ALLOC_FAILED Failed to allocate memory
149 * @retval #CA_STATUS_FAILED Operation failed
152 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
156 * @brief Read Synchronous API callback.
158 * @return #CA_STATUS_OK on success otherwise proper error code.
159 * @retval #CA_STATUS_OK Successful
160 * @retval #CA_STATUS_FAILED Operation failed
163 CAResult_t CAReadEDRData();
167 * @brief Stopping the adapters and close socket connections
168 * EDR Stops all RFCOMM servers and close sockets.
170 * @return #CA_STATUS_OK on success
173 CAResult_t CAStopEDR();
177 * @brief Terminate the EDR connectivity adapter.
178 * Configuration information will be deleted from further use.
181 void CATerminateEDR();
187 #endif //__CA_EDRADAPTER_H_