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 ******************************************************************/
24 * This file contains the APIs for EDR adapters.
27 #ifndef CA_EDRADAPTER_H_
28 #define CA_EDRADAPTER_H_
34 #include "caadapterinterface.h"
35 #include "cathreadpool.h" /* for thread pool */
43 * @brief Initialize EDR Interface.
44 * @param registerCallback [IN] Callback to register EDR interface to Connectivity
46 * @param reqRespCallback [IN] Callback to notify request and response messages from
47 * server(s) started at Connectivity Abstraction Layer.
48 * @param netCallback [IN] Callback to notify the network additions to Connectivity
50 * @param errorCallback [IN] errorCallback to notify error to connectivity common logic
52 * @param handle [IN] Threadpool Handle
53 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
55 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
56 CANetworkPacketReceivedCallback reqRespCallback,
57 CANetworkChangeCallback netCallback,
58 CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
61 * @brief Starts EDR connectivity adapters. As its peer to peer it doesnot require to start
63 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
65 CAResult_t CAStartEDR();
68 * @brief Starts listening server for receiving multicast search requests.
69 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
71 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
73 CAResult_t CAStartEDRListeningServer();
76 * @brief Starting discovery server for receiving multicast advertisements.
77 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
79 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
81 CAResult_t CAStartEDRDiscoveryServer();
84 * @brief Sends data to the peer bluetooth OIC device using the adapter connectivity.
85 * @param endpoint [IN] Remote Endpoint information (like ipaddress, port, and
86 * connectivity type) to which the unicast data has to be sent.
87 * @param data [IN] Data to be sent.
88 * @param dataLength [IN] Size of data to be sent.
89 * @return The number of bytes sent on the network. Returns -1 on error.
92 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
96 * @brief Sends multicast data to all discovered bluetooth OIC devices using the adapter
97 * @param endpoint [IN] Remote Endpoint information (like ipaddress, port, and connectivity.
98 * @param data [IN] Data which needs to be sent to all discovered bluetooth OIC device.
99 * @param dataLength [IN] Length of data in bytes.
100 * @return Number of bytes sent on the network. Returns -1 on error.
102 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
103 uint32_t dataLength);
106 * @brief Get EDR Connectivity network information.
108 * @param info [OUT] Array of local connectivity information structures.
109 * @param size [OUT] Size of the array @info.
111 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
113 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
116 * @brief Read Synchronous API callback.
117 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
119 CAResult_t CAReadEDRData();
122 * @brief EDR Stops all RFCOMM servers and close sockets.
123 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
125 CAResult_t CAStopEDR();
128 * @brief Terminate the EDR connectivity adapter.
129 * Configuration information will be deleted from further use.
132 void CATerminateEDR();
135 * @brief Initializes the adapter queues.
136 * This will initiates both server and receiver adapter queues.
137 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
139 CAResult_t CAAdapterStartQueue();
145 #endif /* CA_EDRADAPTER_H_ */