Merge the code from tizen_2.4
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-ipsp.c
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Paras Kumar <paras.kumar@samsung.com>
7  *
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
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #include "bluetooth-api.h"
23 #include "bluetooth-ipsp-api.h"
24 #include "bt-internal-types.h"
25
26 #include "bt-common.h"
27 #include "bt-request-sender.h"
28 #include "bt-event-handler.h"
29
30 BT_EXPORT_API int bluetooth_le_ipsp_init(void)
31 {
32         int ret = IPSP_ERROR_NONE;
33
34         BT_CHECK_ENABLED_LE(return);
35
36         BT_INIT_PARAMS();
37
38         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
39
40         ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_LE_IPSP_INIT,
41                 in_param1, in_param2, in_param3, in_param4, &out_param);
42
43         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
44
45         return ret;
46 }
47
48 BT_EXPORT_API int bluetooth_le_ipsp_deinit(void)
49 {
50         int ret = IPSP_ERROR_NONE;
51
52         BT_CHECK_ENABLED_LE(return);
53
54         BT_INIT_PARAMS();
55
56         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
57
58         ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_LE_IPSP_DEINIT,
59                 in_param1, in_param2, in_param3, in_param4, &out_param);
60
61         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
62
63         return ret;
64 }
65
66 BT_EXPORT_API int bluetooth_le_ipsp_connect(const ipsp_device_address_t *device_address)
67 {
68         int ret = IPSP_ERROR_NONE;
69
70         BT_CHECK_PARAMETER(device_address, return);
71         BT_CHECK_ENABLED_LE(return);
72
73         BT_INIT_PARAMS();
74         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
75
76         g_array_append_vals(in_param1, device_address, sizeof(ipsp_device_address_t));
77
78         ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_LE_IPSP_CONNECT,
79                 in_param1, in_param2, in_param3, in_param4, &out_param);
80
81         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
82
83         return ret;
84 }
85
86 BT_EXPORT_API int bluetooth_le_ipsp_disconnect(const ipsp_device_address_t *device_address)
87 {
88         int ret = IPSP_ERROR_NONE;
89
90         BT_CHECK_PARAMETER(device_address, return);
91         BT_CHECK_ENABLED_LE(return);
92
93         BT_INIT_PARAMS();
94         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
95
96         g_array_append_vals(in_param1, device_address, sizeof(ipsp_device_address_t));
97
98         ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_LE_IPSP_DISCONNECT,
99                 in_param1, in_param2, in_param3, in_param4, &out_param);
100
101         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
102
103         return ret;
104 }