Implement MTU changed callback for GATT server
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / include / oal-socket.h
1 /*
2 * Open Adaptation Layer (OAL)
3 *
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *              http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20
21 #ifndef _OAL_SOCKET_HOST_H_
22 #define _OAL_SOCKET_HOST_H_
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 typedef enum {
29         OAL_SOCK_RFCOMM,
30         OAL_SOCK_SCO,
31         OAL_SOCK_L2CAP
32 } oal_sock_type_t;
33
34 /**
35  * @fn oal_status_t socket_enable(void);
36  * @brief Enables the rfcomm profile
37  *
38  * This API will register the callback function, when any response/data are received from
39  * bluetooth RFCOMM remote device. @n
40  * this registered callback function will be get called with fd of remote device, data buffer and its length.
41  * This function is a synchronous call.
42  *
43  * @param[in]   data_cb      A pointer to the callback function
44  * @return      BLUETOOTH_ERROR_NONE - Success
45  * @remark      None
46  * @see         None
47  * */
48 oal_status_t socket_enable(void);
49
50 /**
51  * @fn oal_status_t socket_disable(void);
52  * @brief Disables the rfcomm profile
53  *
54  * This API will disable RFCOMM profile. Before disabling it's better to ensure
55  * all the connections are closed
56  * This function is a synchronous call.
57  *
58  * @return      BLUETOOTH_ERROR_NONE - Success
59  * @remark      None
60  * @see         socket_disconnect
61  * */
62 oal_status_t socket_disable(void);
63
64 /**
65  * @fn int  socket_connect(oal_sock_type_t sock_type, bt_address_t* bd, oal_uuid_t* p_uuid, int channel);
66  * @brief Creates outgoing client
67  *
68  * This API connects to the remote RFCOMM server. It takes either server UUID or Channel
69  * along with the bluetooth MAC address of Server.
70  * It returns the Outgoing Client FD. Two events are associated with this API:
71  *      1. OAL_EVENT_OUTGOING_CONNECTED: When Outgoing Client connects
72  *      succefully to remote Server.
73  *      2. OAL_EVENT_SOCKET_DISCONNECTED: When Outgoing Client fails to
74  *      connect/Outgoing client hung up.
75  * The FD received can be used to send data using interface socket_write. Data
76  * coming from remote interface comes through the callback registered at time of
77  * socket_init
78  * This function is a asynchronous call.
79  *
80  * @param[in]   sock_type  Bluetooth socket type to be connected
81  * @param[in]   p_uuid     UUID of the remote RFCOMM SERVER
82  * @param[in]   channel    channel
83  * @param[in]   bd         Bluetooth Mac address of RFCOMM server
84  * @return      Outgoing client FD --- Success
85  * @see         socket_disconnect
86  */
87 int socket_connect(oal_sock_type_t sock_type, oal_uuid_t* p_uuid, int channel, bt_address_t* bd);
88
89 /**
90  * @fn int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel);
91  * @brief Creates server socket and start listen for incomming connection.
92  *
93  * This API creates Server socket. It takes UUID and service name.
94  * It returns the server FD on success. There can be multiple SERVERs, with each server having its
95  * unique FD. This function is a synchronous call.
96  *
97  * @param[in]   sock_type  Bluetooth socket type to be connected
98  * @param[in]   p_uuid     UUID of the RFCOMM SERVER to be created
99  * @param[in]   channel    channel
100  * @param[in]   svc_name   Name for the server
101  * @return      Server Socket FD - Success
102  * @remark      None
103  */
104 int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel);
105
106 #ifdef __cplusplus
107 }
108 #endif /* __cplusplus */
109 #endif /*_OAL_SOCKET_HOST_H_*/