2 * Open Adaptation Layer (OAL)
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #ifndef _OAL_SOCKET_HOST_H_
22 #define _OAL_SOCKET_HOST_H_
35 * @fn oal_status_t socket_enable(void);
36 * @brief Enables the rfcomm profile
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.
43 * @param[in] data_cb A pointer to the callback function
44 * @return BLUETOOTH_ERROR_NONE - Success
48 oal_status_t socket_enable(void);
51 * @fn oal_status_t socket_disable(void);
52 * @brief Disables the rfcomm profile
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.
58 * @return BLUETOOTH_ERROR_NONE - Success
60 * @see socket_disconnect
62 oal_status_t socket_disable(void);
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
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
78 * This function is a asynchronous call.
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
87 int socket_connect(oal_sock_type_t sock_type, oal_uuid_t* p_uuid, int channel, bt_address_t* bd);
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.
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.
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
104 int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel);
108 #endif /* __cplusplus */
109 #endif /*_OAL_SOCKET_HOST_H_*/