562503a3d2568947cd153cd3cf4897dd343f67cb
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / tizen / cabtmanager.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file    cabtmanager.h
23  * @brief   This    file provides the APIs to control Bluetooth transport
24  */
25
26 #ifndef __CA_BT_MANAGER_H_
27 #define __CA_BT_MANAGER_H_
28
29 #include <pthread.h>
30 #include <string.h>
31 #include <bluetooth.h>
32
33 #include "caedradapter.h"
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39
40 /**
41  * @fn  CABTManagerInitialize
42  * @brief  Initializes Bluetooth adapter
43  *
44  * @param  threadPool  Thread pool for handling asynchronous tasks
45  *
46  * @return  CA_STATUS_OK or CA_ADAPTER_NOT_ENABLED on success otherwise proper error code.
47  * @retval  CA_STATUS_OK  Successful
48  * @retval  CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
49  *                                                    not enabled.
50  * @retval  CA_STATUS_FAILED Operation failed
51  *
52  */
53 CAResult_t CABTManagerInitialize(u_thread_pool_t threadPool);
54
55 /**
56  * @fn  CABTManagerTerminate
57  * @brief  Deinitialize with bluetooth adapter
58  *
59  * @see CABTManagerIntialize
60  *
61  */
62 void CABTManagerTerminate(void);
63
64 /**
65  * @fn  CABTManagerStart
66  * @brief  Start bluetooth adapter which includes start searching for nearby OIC devices
67  *
68  * @return  CA_STATUS_OK on success otherwise proper error code.
69  * @retval  CA_STATUS_OK  Successful
70  * @retval  CA_STATUS_FAILED Operation failed
71  *
72  * @pre CABTManagerIntialize should be invoked before using this API
73  *
74  * @see CABTManagerIntialize
75  *
76  */
77 CAResult_t CABTManagerStart(void);
78
79 /**
80  * @fn  CABTManagerStop
81  * @brief  Stop bluetooth adapter which includes stoping searching for nearby OIC devices
82  *
83  * @pre CABTManagerIntialize should be invoked before using this API
84  *
85  * @see CABTManagerIntialize
86  * @see CABTManagerStart
87  *
88  */
89 void CABTManagerStop(void);
90
91 /**
92  * @fn  CABTManagerSetPacketReceivedCallback
93  * @brief  Register callback for receiving packets from remote Bluetooth device.
94  *
95  * @param  packetReceivedCallback  Callback function to register for receiving network packets
96  *
97  * @return  none.
98  *
99  * @see CBNetworkPacketReceived
100  *
101  */
102 void CABTManagerSetPacketReceivedCallback(CANetworkPacketReceivedCallback packetReceivedCallback);
103
104 /**
105  * @fn  CABTManagerSetNetworkChangeCallback
106  * @brief  Register callback for receiving network chang state of local Bluetooth adapter.
107  *
108  * @param  networkChangeCallback  Callback function to register for receiving network adapter status
109  *
110  * @return  none
111  *
112  * @see CBNetworkChange
113  *
114  */
115 void CABTManagerSetNetworkChangeCallback(CANetworkChangeCallback networkChangeCallback);
116
117 /**
118  * @fn  CABTManagerSendData
119  * @brief  Send unicast/multicast data to remote bluetooth device
120  *
121  * @param  remoteAddress  The address of remote bluetooth device to which data needs to be sent.
122  *                                   This will be NULL in case of sending multicast data.
123  * @param  serviceUUID  The UUID of service to which RFCOMM connection needs to established
124  * @param  data  The data needs to be send to remote bluetooth device
125  * @param  dataLength  Length of data
126  * @param  sentLength  Length of data actually sent or added to pending list for sending
127  *
128  * @return  CA_STATUS_OK on success otherwise proper error code.
129  * @retval  CA_STATUS_OK  Successful
130  * @retval  CA_STATUS_INVALID_PARAM  Invalid input argumets
131  * @retval  CA_STATUS_FAILED Operation failed
132  *
133  */
134 CAResult_t CABTManagerSendData(const char *remoteAddress, const char *serviceUUID,
135                                void *data, uint32_t dataLength, uint32_t *sentLength);
136
137 /**
138  * @fn  CABTManagerStartServer
139  * @brief  Start RFCOMM server for given service UUID
140  *
141  * @param  serviceUUID  The UUID of service with which RFCOMM server needs to be started
142  * @param  serverID  The ID for the server which started
143  *
144  * @return  CA_STATUS_OK on success otherwise proper error code.
145  * @retval  CA_STATUS_OK  Successful
146  * @retval  CA_SERVER_STARTED_ALREADY Service on the specified UUID is already running.
147  * @retval  CA_STATUS_INVALID_PARAM  Invalid input argumets
148  * @retval  CA_STATUS_FAILED Operation failed
149  *
150  */
151 CAResult_t CABTManagerStartServer(const char *serviceUUID, int32_t *serverID);
152
153 /**
154  * @fn  CABTManagerStopServer
155  * @brief  Stop RFCOMM server
156  *
157  * @param  serverID  The ID of server which needs to be stopped
158  *
159  * @return  CA_STATUS_OK on success otherwise proper error code.
160  * @retval  CA_STATUS_OK  Successful
161  * @retval  CA_STATUS_FAILED Operation failed
162  *
163  */
164 CAResult_t CABTManagerStopServer(const int32_t serverID);
165
166 /**
167  * @fn  CABTManagerGetInterface
168  * @brief  Get the local bluetooth adapter information.
169  *
170  * @param  info  Local bluetooth adapter information
171  *
172  * @return  CA_STATUS_OK on success otherwise proper error code.
173  * @retval  CA_STATUS_OK  Successful
174  * @retval  CA_STATUS_INVALID_PARAM  Invalid input argumets
175  * @retval  CA_STATUS_FAILED Operation failed
176  *
177  * @see CALocalConnectivity_t
178  *
179  */
180 CAResult_t CABTManagerGetInterface(CALocalConnectivity_t **info);
181
182 /**
183  * @fn  CABTManagerReadData
184  * @brief  All received data will be notified to upper layer.
185  *
186  * @return  CA_STATUS_OK on success otherwise proper error code.
187  * @retval  CA_STATUS_OK  Successful
188  * @retval  CA_STATUS_FAILED Operation failed
189  *
190  */
191 CAResult_t CABTManagerReadData(void);
192
193 #ifdef __cplusplus
194 } /* extern "C" */
195 #endif
196
197 #endif //__CA_BT_MANAGER_H_
198