2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <gio/gunixfdlist.h>
22 #include <sys/socket.h>
25 #include "bluetooth-api.h"
26 #include "bt-internal-types.h"
28 #include "bt-common.h"
29 #include "bt-request-sender.h"
30 #include "bt-event-handler.h"
32 #ifdef TIZEN_DPM_ENABLE
38 static GSList *rfcomm_nodes;
48 bluetooth_device_address_t addr;
49 guint disconnect_idle_id;
52 static rfcomm_info_t *__find_rfcomm_info_with_id(int id)
56 for (l = rfcomm_nodes; l != NULL; l = l->next) {
57 rfcomm_info_t *info = l->data;
66 static rfcomm_info_t *__find_rfcomm_info_with_fd(int fd)
70 for (l = rfcomm_nodes; l != NULL; l = l->next) {
71 rfcomm_info_t *info = l->data;
80 static rfcomm_info_t *__find_rfcomm_info_with_path(const gchar *path)
84 for (l = rfcomm_nodes; l != NULL; l = l->next) {
85 rfcomm_info_t *info = l->data;
87 if (g_strcmp0(info->path, path) == 0)
94 static rfcomm_info_t *__find_rfcomm_info_with_uuid(const char *uuid)
98 for (l = rfcomm_nodes; l != NULL; l = l->next) {
99 rfcomm_info_t *info = l->data;
101 if (g_strcmp0(info->uuid, uuid) == 0)
108 gboolean _check_uuid_path(char *path, char *uuid)
110 rfcomm_info_t *info = NULL;
111 info = __find_rfcomm_info_with_path(path);
115 if (strcmp(info->uuid, uuid) == 0)
121 static void __connected_cb(rfcomm_info_t *info, bt_event_info_t *event_info)
123 bluetooth_rfcomm_connection_t conn_info;
125 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
126 conn_info.device_role = RFCOMM_ROLE_SERVER;
127 g_strlcpy(conn_info.uuid, info->uuid, BLUETOOTH_UUID_STRING_MAX);
128 conn_info.socket_fd = info->fd;
129 conn_info.device_addr = info->addr;
130 conn_info.server_id = info->id;
132 BT_INFO_C("### Connected [RFCOMM Server]");
133 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED,
134 BLUETOOTH_ERROR_NONE, &conn_info,
135 event_info->cb, event_info->user_data);
138 static gboolean __rfcomm_server_disconnect(rfcomm_info_t *info)
140 bluetooth_rfcomm_disconnection_t disconn_info;
142 bt_event_info_t *event_info;
144 BT_INFO_C("### Disconnected [RFCOMM Server]");
146 if (info->data_id > 0) {
147 g_source_remove(info->data_id);
157 g_io_channel_shutdown(info->data_io, TRUE, NULL);
158 g_io_channel_unref(info->data_io);
159 info->data_io = NULL;
161 info->disconnect_idle_id = 0;
162 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
163 if (event_info == NULL)
166 memset(&disconn_info, 0x00, sizeof(bluetooth_rfcomm_disconnection_t));
167 disconn_info.device_role = RFCOMM_ROLE_SERVER;
168 g_strlcpy(disconn_info.uuid, info->uuid, BLUETOOTH_UUID_STRING_MAX);
169 disconn_info.socket_fd = fd;
170 disconn_info.device_addr = info->addr;
172 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
173 BLUETOOTH_ERROR_NONE, &disconn_info,
174 event_info->cb, event_info->user_data);
180 static gboolean __is_error_by_disconnect(GError *err)
182 return !g_strcmp0(err->message, "Connection reset by peer") ||
183 !g_strcmp0(err->message, "Connection timed out") ||
184 !g_strcmp0(err->message, "Software caused connection abort");
187 static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
192 int result = BLUETOOTH_ERROR_NONE;
193 rfcomm_info_t *info = data;
194 bt_event_info_t *event_info;
195 bluetooth_rfcomm_received_data_t data_r;
196 GIOStatus status = G_IO_STATUS_NORMAL;
199 retv_if(info == NULL, FALSE);
201 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
203 if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
204 BT_ERR_C("RFComm Server disconnected: %d", info->fd);
206 if (info->disconnect_idle_id > 0) {
207 BT_INFO("Disconnect idle still not process remove source");
208 g_source_remove(info->disconnect_idle_id);
209 info->disconnect_idle_id = 0;
212 __rfcomm_server_disconnect(info);
216 buffer = g_malloc0(BT_RFCOMM_BUFFER_LEN + 1);
218 status = g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_LEN,
220 if (status != G_IO_STATUS_NORMAL) {
221 BT_ERR("IO Channel read is failed with %d", status);
225 BT_ERR("IO Channel read error [%s]", err->message);
226 if (status == G_IO_STATUS_ERROR &&
227 __is_error_by_disconnect(err)) {
228 BT_ERR("cond : %d", cond);
230 if (info->disconnect_idle_id > 0) {
231 BT_INFO("Disconnect idle still not process remove source");
232 g_source_remove(info->disconnect_idle_id);
233 info->disconnect_idle_id = 0;
235 __rfcomm_server_disconnect(info);
244 BT_ERR("Length is zero");
246 if (event_info == NULL) {
251 data_r.socket_fd = info->fd;
252 data_r.buffer_size = len;
253 data_r.buffer = buffer;
255 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED,
257 event_info->cb, event_info->user_data);
264 int new_server_connection(const char *path, int fd, bluetooth_device_address_t *addr)
267 bt_event_info_t *event_info;
269 BT_DBG("%s %d", path, fd);
271 info = __find_rfcomm_info_with_path(path);
276 memcpy(&info->addr, addr, sizeof(bluetooth_device_address_t));
278 info->data_io = g_io_channel_unix_new(info->fd);
280 g_io_channel_set_encoding(info->data_io, NULL, NULL);
281 g_io_channel_set_flags(info->data_io, G_IO_FLAG_NONBLOCK, NULL);
283 info->data_id = g_io_add_watch(info->data_io,
284 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
285 __data_received_cb, info);
287 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
289 __connected_cb(info, event_info);
295 static rfcomm_info_t *__register_method()
302 id = __rfcomm_assign_id();
306 path = g_strdup_printf("/org/socket/server/%d/%d", getpid(), id);
308 object_id = _bt_register_new_conn(path, new_server_connection);
310 __rfcomm_delete_id(id);
313 info = g_new(rfcomm_info_t, 1);
314 info->object_id = (guint)object_id;
319 rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
324 static rfcomm_info_t *__register_method_2(const char *path,const char *bus_name)
329 object_id = _bt_register_new_conn_ex(path, bus_name, new_server_connection);
333 info = g_new(rfcomm_info_t, 1);
334 info->object_id = (guint)object_id;
335 info->path = g_strdup(path);
339 rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
344 void free_rfcomm_info(rfcomm_info_t *info)
346 bt_event_info_t *event_info;
349 if (info->disconnect_idle_id > 0) {
350 BT_INFO("Disconnect idle still not process remove source");
351 g_source_remove(info->disconnect_idle_id);
352 info->disconnect_idle_id = 0;
355 __rfcomm_delete_id(info->id);
356 _bt_unregister_gdbus(info->object_id);
359 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
361 BT_DBG("event type %d", event_info->event_type);
362 __rfcomm_server_disconnect(info);
370 void _bt_rfcomm_server_free_all()
372 BT_DBG("Free all the servers");
374 g_slist_free_full(rfcomm_nodes, (GDestroyNotify)free_rfcomm_info);
379 BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
386 char uuid_str[BLUETOOTH_UUID_STRING_MAX];
389 BT_CHECK_ENABLED(return);
390 BT_CHECK_PARAMETER(uuid, return);
391 BT_INFO("UUID Provided %s", uuid);
393 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET)
394 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
395 BT_ERR("Don't have a privilege to use this API");
396 return BLUETOOTH_ERROR_PERMISSION_DEINED;
399 #ifdef TIZEN_DPM_ENABLE
400 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
401 BT_ERR("Not allow to use SPP profile");
402 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
407 BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
408 info = __register_method();
412 info->uuid = g_strdup(uuid);
413 info->disconnect_idle_id = 0;
418 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
420 g_strlcpy(uuid_str, uuid, sizeof(uuid_str));
421 g_array_append_vals(in_param1, uuid_str, BLUETOOTH_UUID_STRING_MAX);
423 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET,
424 in_param1, in_param2, in_param3, in_param4, &out_param);
426 BT_DBG("result: %x", result);
428 if (result == BLUETOOTH_ERROR_NONE) {
429 socket_fd = g_array_index(out_param, int, 0);
431 BT_ERR("Fail to send request");
434 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
440 BT_EXPORT_API int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path)
445 BT_CHECK_ENABLED(return);
446 BT_CHECK_PARAMETER(path, return);
447 BT_INFO("PATH Provided %s", path);
449 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET_EX)
450 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
451 BT_ERR("Don't have a privilege to use this API");
452 return BLUETOOTH_ERROR_PERMISSION_DEINED;
455 #ifdef TIZEN_DPM_ENABLE
456 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
457 BT_ERR("Not allow to use SPP profile");
458 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
462 BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
463 info = __register_method_2(path, bus_name);
465 return BLUETOOTH_ERROR_IN_PROGRESS;
466 info->uuid = g_strdup(uuid);
467 info->disconnect_idle_id = 0;
469 return BLUETOOTH_ERROR_NONE;
471 return BLUETOOTH_ERROR_NOT_SUPPORT;
476 BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
484 BT_CHECK_ENABLED(return);
486 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
487 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
488 BT_ERR("Don't have a privilege to use this API");
489 return BLUETOOTH_ERROR_PERMISSION_DEINED;
493 BT_ERR("Invalid FD");
494 return BLUETOOTH_ERROR_INVALID_PARAM;
498 BT_INFO("RFCOMM Remove socket request from app, fd=[%d]", socket_fd);
500 info = __find_rfcomm_info_with_id(socket_fd);
502 return BLUETOOTH_ERROR_INVALID_PARAM;
504 _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid);
505 _bt_unregister_profile(info->path);
507 rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
508 free_rfcomm_info(info);
510 return BLUETOOTH_ERROR_NONE;
513 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
515 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
517 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET,
518 in_param1, in_param2, in_param3, in_param4, &out_param);
520 BT_DBG("result: %x", result);
522 if (result == BLUETOOTH_ERROR_NONE) {
523 _bt_remove_server(socket_fd);
526 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
532 BT_EXPORT_API int bluetooth_rfcomm_remove_socket_ex(const char *uuid)
537 BT_CHECK_ENABLED(return);
539 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
540 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
541 BT_ERR("Don't have a privilege to use this API");
542 return BLUETOOTH_ERROR_PERMISSION_DEINED;
545 BT_INFO("RFCOMM Remove socket request from app, uuid=[%s]", uuid);
547 info = __find_rfcomm_info_with_uuid(uuid);
549 return BLUETOOTH_ERROR_INVALID_PARAM;
551 _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid);
552 _bt_unregister_profile(info->path);
554 rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
555 free_rfcomm_info(info);
557 return BLUETOOTH_ERROR_NONE;
559 return BLUETOOTH_ERROR_NOT_SUPPORT;
563 BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
570 BT_INFO("### Disconnect RFCOMM server");
572 BT_ERR("Invalid FD");
573 return BLUETOOTH_ERROR_INVALID_PARAM;
576 info = __find_rfcomm_info_with_fd(socket_fd);
578 return BLUETOOTH_ERROR_INVALID_PARAM;
580 if (info->data_io == NULL)
581 return BLUETOOTH_ERROR_NOT_CONNECTED;
583 g_io_channel_shutdown(info->data_io, TRUE, NULL);
584 g_io_channel_unref(info->data_io);
585 info->data_io = NULL;
587 _bt_convert_addr_type_to_string(address, info->addr.addr);
588 BT_DBG("Address %s", address);
589 _bt_disconnect_profile(address, info->uuid, NULL, NULL);
591 info->disconnect_idle_id = g_idle_add((GSourceFunc)
592 __rfcomm_server_disconnect, info);
595 return BLUETOOTH_ERROR_NONE;
599 BT_CHECK_ENABLED(return);
602 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
604 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
606 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_SOCKET_DISCONNECT,
607 in_param1, in_param2, in_param3, in_param4, &out_param);
609 BT_DBG("result: %x", result);
611 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
617 BT_EXPORT_API gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid)
620 gboolean available = TRUE;
621 char uuid_str[BLUETOOTH_UUID_STRING_MAX];
623 retv_if(uuid == NULL, FALSE);
624 retv_if(bluetooth_check_adapter() ==
625 BLUETOOTH_ADAPTER_DISABLED, FALSE);
628 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
630 g_strlcpy(uuid_str, uuid, sizeof(uuid_str));
631 g_array_append_vals(in_param1, uuid_str, BLUETOOTH_UUID_STRING_MAX);
633 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_IS_UUID_AVAILABLE,
634 in_param1, in_param2, in_param3, in_param4, &out_param);
636 BT_DBG("result: %x", result);
638 if (result == BLUETOOTH_ERROR_NONE) {
639 available = g_array_index(out_param, gboolean, 0);
642 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
644 BT_DBG("available: %d", available);
649 BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected)
653 char connected_addr[BT_ADDRESS_STRING_SIZE] = { 0 };
654 char input_addr[BT_ADDRESS_STRING_SIZE] = { 0 };
656 BT_CHECK_PARAMETER(device_address, return);
657 BT_CHECK_PARAMETER(connected, return);
659 _bt_convert_addr_type_to_string(input_addr, (unsigned char *)device_address->addr);
663 for (l = rfcomm_nodes; l != NULL; l = l->next) {
668 _bt_convert_addr_type_to_string(connected_addr, info->addr.addr);
670 if (g_strcmp0(connected_addr, input_addr) == 0) {
672 return BLUETOOTH_ERROR_NONE;
676 return BLUETOOTH_ERROR_NONE;
679 BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection)
685 gboolean native_service = TRUE;
688 BT_CHECK_ENABLED(return);
690 BT_ERR("Invalid FD");
691 return BLUETOOTH_ERROR_INVALID_PARAM;
694 #ifdef TIZEN_DPM_ENABLE
695 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
696 BT_ERR("Not allow to use SPP profile");
697 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
702 BT_INFO("RFCOMM Listen & accept from app");
704 info = __find_rfcomm_info_with_id(socket_fd);
706 return BLUETOOTH_ERROR_INVALID_PARAM;
708 bt_register_profile_info_t profile_info;
711 profile_info.authentication = TRUE;
712 profile_info.authorization = TRUE;
713 profile_info.obj_path = info->path;
714 profile_info.role = NULL;
715 profile_info.service = info->uuid;
716 profile_info.uuid = info->uuid;
718 BT_INFO("uuid %s", profile_info.uuid);
719 result = _bt_register_profile(&profile_info, TRUE);
724 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
726 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
727 g_array_append_vals(in_param2, &max_pending_connection, sizeof(int));
728 g_array_append_vals(in_param3, &native_service, sizeof(gboolean));
730 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
731 in_param1, in_param2, in_param3, in_param4, &out_param);
733 BT_DBG("result: %x", result);
735 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
741 BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path)
746 BT_CHECK_ENABLED(return);
748 #ifdef TIZEN_DPM_ENABLE
749 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
750 BT_ERR("Not allow to use SPP profile");
751 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
755 BT_INFO("RFCOMM Listen & accept from app");
757 info = __find_rfcomm_info_with_uuid(uuid);
759 return BLUETOOTH_ERROR_INVALID_PARAM;
761 bt_register_profile_info_t profile_info;
764 profile_info.authentication = TRUE;
765 profile_info.authorization = TRUE;
766 profile_info.obj_path = info->path;
767 profile_info.role = NULL;
768 profile_info.service = info->uuid;
769 profile_info.uuid = info->uuid;
771 BT_INFO("uuid %s", profile_info.uuid);
772 result = _bt_register_profile_ex(&profile_info, TRUE, bus_name, path);
776 return BLUETOOTH_ERROR_NOT_SUPPORT;
780 BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection)
786 gboolean native_service = FALSE;
789 BT_CHECK_ENABLED(return);
791 #ifdef TIZEN_DPM_ENABLE
792 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
793 BT_ERR("Not allow to use SPP profile");
794 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
799 BT_ERR("Invalid FD");
800 return BLUETOOTH_ERROR_INVALID_PARAM;
804 BT_INFO("RFCOMM Listen");
806 info = __find_rfcomm_info_with_id(socket_fd);
808 return BLUETOOTH_ERROR_INVALID_PARAM;
810 bt_register_profile_info_t profile_info;
813 profile_info.authentication = TRUE;
814 profile_info.authorization = TRUE;
815 profile_info.obj_path = info->path;
816 profile_info.role = NULL;
817 profile_info.service = info->uuid;
818 profile_info.uuid = info->uuid;
819 BT_INFO("UUID %s", info->uuid);
820 BT_INFO("PATH %s", info->path);
821 result = _bt_register_profile_platform(&profile_info, TRUE);
822 if (result != BLUETOOTH_ERROR_NONE)
825 return _bt_register_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid,
826 info->path, socket_fd);
830 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
832 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
833 g_array_append_vals(in_param2, &max_pending_connection, sizeof(int));
834 g_array_append_vals(in_param3, &native_service, sizeof(gboolean));
836 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
837 in_param1, in_param2, in_param3, in_param4, &out_param);
839 BT_DBG("result: %x", result);
841 if (result == BLUETOOTH_ERROR_NONE) {
842 _bt_add_server(socket_fd);
845 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
851 BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd)
855 BT_CHECK_ENABLED(return);
857 #ifdef TIZEN_DPM_ENABLE
858 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
859 BT_ERR("Not allow to use SPP profile");
860 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
865 BT_ERR("Invalid FD");
866 return BLUETOOTH_ERROR_INVALID_PARAM;
870 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
872 g_array_append_vals(in_param1, &server_fd, sizeof(int));
874 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_ACCEPT_CONNECTION,
875 in_param1, in_param2, in_param3, in_param4, &out_param);
877 BT_DBG("result: %x", result);
879 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
884 BT_EXPORT_API int bluetooth_rfcomm_reject_connection(int server_fd)
888 BT_CHECK_ENABLED(return);
891 BT_ERR("Invalid FD");
892 return BLUETOOTH_ERROR_INVALID_PARAM;
898 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
900 g_array_append_vals(in_param1, &server_fd, sizeof(int));
902 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_REJECT_CONNECTION,
903 in_param1, in_param2, in_param3, in_param4, &out_param);
905 BT_DBG("result: %x", result);
907 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);