4 * Copyright (c) 2012-2013 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.
20 #include "bluetooth-api.h"
21 #include "bt-internal-types.h"
23 #include "bt-common.h"
24 #include "bt-request-sender.h"
25 #include "bt-event-handler.h"
27 BT_EXPORT_API int bluetooth_network_activate_server()
31 BT_CHECK_ENABLED(return);
34 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
36 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_NETWORK_ACTIVATE,
37 in_param1, in_param2, in_param3, in_param4, &out_param);
39 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
44 BT_EXPORT_API int bluetooth_network_deactivate_server(void)
48 BT_CHECK_ENABLED(return);
51 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
53 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_NETWORK_DEACTIVATE,
54 in_param1, in_param2, in_param3, in_param4, &out_param);
56 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
61 BT_EXPORT_API int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
62 bluetooth_network_role_t role,
66 bt_user_info_t *user_info;
68 BT_CHECK_PARAMETER(device_address, return);
69 BT_CHECK_ENABLED(return);
72 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
74 user_info = _bt_get_user_data(BT_COMMON);
75 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
77 g_array_append_vals(in_param1, device_address,
78 sizeof(bluetooth_device_address_t));
79 g_array_append_vals(in_param2, &role, sizeof(int));
81 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_NETWORK_CONNECT,
82 in_param1, in_param2, in_param3, in_param4,
83 user_info->cb, user_info->user_data);
85 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
90 BT_EXPORT_API int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address)
93 bt_user_info_t *user_info;
95 BT_CHECK_PARAMETER(device_address, return);
96 BT_CHECK_ENABLED(return);
99 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
101 user_info = _bt_get_user_data(BT_COMMON);
102 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
104 g_array_append_vals(in_param1, device_address,
105 sizeof(bluetooth_device_address_t));
107 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_NETWORK_DISCONNECT,
108 in_param1, in_param2, in_param3, in_param4,
109 user_info->cb, user_info->user_data);
111 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);