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 ******************************************************************/
23 * This file contains the APIs for EDR adapters.
26 #ifndef CA_EDRADAPTER_H_
27 #define CA_EDRADAPTER_H_
33 #include "caadapterinterface.h"
34 #include "cathreadpool.h" /* for thread pool */
42 * Initialize EDR Interface.
43 * @param[in] registerCallback Callback to register EDR interface to Connectivity
45 * @param[in] reqRespCallback Callback to notify request and response messages from
46 * server(s) started at Connectivity Abstraction Layer.
47 * @param[in] netCallback Callback to notify the network additions to Connectivity
49 * @param[in] errorCallback errorCallback to notify error to connectivity common logic
51 * @param[in] handle Threadpool Handle.
52 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
54 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
55 CANetworkPacketReceivedCallback reqRespCallback,
56 CANetworkChangeCallback netCallback,
57 CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
60 * Starts EDR connectivity adapters.
61 * As its peer to peer it does not require to start any servers.
62 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
64 CAResult_t CAStartEDR();
67 * Starts listening server for receiving multicast search requests.
68 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
70 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
72 CAResult_t CAStartEDRListeningServer();
75 * Starting discovery server for receiving multicast advertisements.
76 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
78 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
80 CAResult_t CAStartEDRDiscoveryServer();
83 * Sends data to the peer bluetooth OIC device using the adapter connectivity.
84 * @param[in] endpoint Remote Endpoint information (like ipaddress, port, and
85 * connectivity type) to which the unicast data has to be sent.
86 * @param[in] data Data to be sent.
87 * @param[in] dataLength Size of data to be sent.
88 * @return The number of bytes sent on the network. Returns -1 on error.
91 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
95 * Sends multicast data to all discovered bluetooth OIC devices using the adapter.
96 * @param[in] endpoint Remote Endpoint information (like ipaddress, port, and connectivity.
97 * @param[in] data Data which needs to be sent to all discovered bluetooth OIC device.
98 * @param[in] dataLength Length of data in bytes.
99 * @return Number of bytes sent on the network. Returns -1 on error.
101 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
102 uint32_t dataLength);
105 * Get EDR Connectivity network information.
107 * @param[out] info Array of local connectivity information structures.
108 * @param[out] size Size of the array @info.
110 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
112 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
115 * Read Synchronous API callback.
116 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
118 CAResult_t CAReadEDRData();
121 * EDR Stops all RFCOMM servers and close sockets.
122 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
124 CAResult_t CAStopEDR();
127 * Terminate the EDR connectivity adapter.
128 * Configuration information will be deleted from further use.
130 void CATerminateEDR();
133 * Initializes the adapter queues.
134 * This will initiates both server and receiver adapter queues.
135 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
137 CAResult_t CAAdapterStartQueue();
143 #endif /* CA_EDRADAPTER_H_ */