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 server(s)
47 * started at Connectivity Abstraction Layer.
48 * @param netCallback [IN] Callback to notify the network additions to Connectivity
50 * @param handle [IN] Threadpool Handle
51 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
53 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
54 CANetworkPacketReceivedCallback reqRespCallback,
55 CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
58 * @brief Starts EDR connectivity adapters. As its peer to peer it doesnot require to start
60 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
62 CAResult_t CAStartEDR();
65 * @brief Starts listening server for receiving multicast search requests.
66 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
68 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
70 CAResult_t CAStartEDRListeningServer();
73 * @brief Starting discovery server for receiving multicast advertisements.
74 * Starts RFCOMM Server with prefixed UUID as per OIC specification.
76 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
78 CAResult_t CAStartEDRDiscoveryServer();
81 * @brief Sends data to the peer bluetooth OIC device using the adapter connectivity.
82 * @param remoteEndpoint [IN] Remote Endpoint information (like ipaddress, port, reference uri and
83 * connectivity type) to which the unicast data has to be sent.
84 * @param data [IN] Data to be sent.
85 * @param dataLength [IN] Size of data to be sent.
86 * @return The number of bytes sent on the network. Returns -1 on error.
89 int32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, const void *data,
93 * @brief Sends multicast data to all discovered bluetooth OIC devices using the adapter
95 * @param data [IN] Data which needs to be sent to all discovered bluetooth OIC device.
96 * @param dataLength [IN] Length of data in bytes.
97 * @return Number of bytes sent on the network. Returns -1 on error.
99 int32_t CASendEDRMulticastData(const void *data, uint32_t dataLength);
102 * @brief Get EDR Connectivity network information.
104 * @param info [OUT] Array of local connectivity information structures.
105 * @param size [OUT] Size of the array @info.
107 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
109 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
112 * @brief Read Synchronous API callback.
113 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
115 CAResult_t CAReadEDRData();
118 * @brief EDR Stops all RFCOMM servers and close sockets.
119 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
121 CAResult_t CAStopEDR();
124 * @brief Terminate the EDR connectivity adapter.
125 * Configuration information will be deleted from further use.
128 void CATerminateEDR();
131 * @brief Initializes the adapter queues.
132 * This will initiates both server and receiver adapter queues.
133 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
135 CAResult_t CAAdapterStartQueue();
141 #endif /* CA_EDRADAPTER_H_ */