4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Atul Rai <a.rai@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include "bt-hal-log.h"
30 #include "bt-hal-msg.h"
31 #include "bt-hal-utils.h"
32 #include "bt-hal-rfcomm-dbus-handler.h"
34 static bt_status_t listen(btsock_type_t type, const char *service_name,
35 const uint8_t *uuid, int channel, int *sock_fd, int flags)
41 if (service_name == NULL || sock_fd == NULL) {
42 ERR("invalid parameters, service_name:%p, uuid:%p, channel:%d, sock_fd:%p",
43 service_name, uuid, channel, sock_fd);
44 return BT_STATUS_PARM_INVALID;
48 ERR("Currently we only support to listen using UUID");
49 return BT_STATUS_UNSUPPORTED;
52 INFO("channel: %d, sock_fd: %d, type: %d", channel, *sock_fd, type);
56 /* Call rfcomm dbus handler to connect rfcomm client */
57 status = _bt_hal_dbus_handler_rfcomm_listen(
58 service_name, (unsigned char *)uuid, sock_fd);
61 ERR("bt l2cap socket type not supported");
62 status = BT_STATUS_UNSUPPORTED;
65 ERR("bt sco socket not supported");
66 status = BT_STATUS_UNSUPPORTED;
69 ERR("unknown bt socket type:%d", type);
70 status = BT_STATUS_UNSUPPORTED;
82 static bt_status_t connect(const bt_bdaddr_t *bd_addr, btsock_type_t type,
83 const uint8_t *uuid, int channel, int *sock_fd, int flags)
89 if (bd_addr == NULL || sock_fd == NULL) {
90 ERR("invalid parameters, bd_addr:%p, uuid:%p, channel:%d, sock_fd:%p",
91 bd_addr, uuid, channel, sock_fd);
92 return BT_STATUS_PARM_INVALID;
96 ERR("Currently we only support to connect using UUID");
97 return BT_STATUS_UNSUPPORTED;
100 INFO("channel: %d, sock_fd: %d, type: %d", channel, *sock_fd, type);
104 /* Call rfcomm dbus handler to connect rfcomm client */
105 status = _bt_hal_dbus_handler_rfcomm_connect(
106 (unsigned char *)bd_addr->address,
107 (unsigned char *)uuid, sock_fd);
110 ERR("bt l2cap socket type not supported");
111 status = BT_STATUS_UNSUPPORTED;
114 ERR("bt sco socket not supported");
115 status = BT_STATUS_UNSUPPORTED;
118 ERR("unknown bt socket type:%d", type);
119 status = BT_STATUS_UNSUPPORTED;
131 static btsock_interface_t socket_if = {
132 .size = sizeof(socket_if),
137 btsock_interface_t *bt_get_socket_interface(void)