Enhance debug message
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-rfcomm-server.c
index 05c311d..ee29302 100644 (file)
@@ -488,7 +488,7 @@ void _bt_rfcomm_server_disconnect_all(void)
        GSList *conn;
        char addr[20];
 
-       BT_INFO("### Disconnect all RFCOMM server connections");
+       BT_INFO(" ### Disconnect all RFCOMM server connections");
 
        for (server = rfcomm_nodes; server; ) {
                rfcomm_info_t *info = server->data;
@@ -1050,7 +1050,7 @@ err:
        return FALSE;
 }
 
-static int __rfcomm_listen(rfcomm_server_info_t *server_info)
+static int __rfcomm_listen(rfcomm_server_info_t *server_info, bool accept)
 {
        int result;
        GUnixFDList *out_fd_list = NULL;
@@ -1061,9 +1061,15 @@ static int __rfcomm_listen(rfcomm_server_info_t *server_info)
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
-       result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
-                       in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       if (accept == false) {
+               g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+               result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
+                               in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       } else {
+               g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+               result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN_AND_ACCEPT,
+                               in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       }
 
        BT_DBG("result: %x", result);
        if (result != BLUETOOTH_ERROR_NONE) {
@@ -1278,7 +1284,7 @@ BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
 
        char address[20];
 
-       BT_INFO("### Disconnect RFCOMM server");
+       BT_INFO(" ### Disconnect RFCOMM server");
        if (socket_fd < 0) {
                BT_ERR("Invalid FD");
                return BLUETOOTH_ERROR_INVALID_PARAM;
@@ -1473,7 +1479,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int id, int max_pending_con
        server_info->max_pending_conn = max_pending_connection;
        server_info->auto_accept = TRUE;
 
-       return __rfcomm_listen(server_info);
+       return __rfcomm_listen(server_info, true);
 #endif
 }
 
@@ -1580,7 +1586,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen(int id, int max_pending_connection)
 
        server_info->max_pending_conn = max_pending_connection;
        server_info->auto_accept = FALSE;
-       return __rfcomm_listen(server_info);
+       return __rfcomm_listen(server_info, false);
 #endif
 }