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.
18 #include "bluetooth-api.h"
19 #include "bt-internal-types.h"
21 #include "bt-common.h"
22 #include "bt-request-sender.h"
23 #include "bt-event-handler.h"
25 BT_EXPORT_API int bluetooth_proximity_monitor_set_property(const bluetooth_device_address_t *device_address,
26 bluetooth_pxp_poperty_t property, int value)
28 int result = BLUETOOTH_ERROR_INTERNAL;
30 BT_CHECK_PARAMETER(device_address, return);
31 BT_CHECK_ENABLED(return);
34 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
37 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
38 g_array_append_vals(in_param2, &property, sizeof(int));
39 g_array_append_vals(in_param3, &value, sizeof(int));
41 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_MONITOR_SET_PROPERTY,
42 in_param1, in_param2, in_param3, in_param4, &out_param);
44 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
49 BT_EXPORT_API int bluetooth_proximity_monitor_get_property(const bluetooth_device_address_t *device_address,
50 bluetooth_pxp_poperty_t property, int *value)
52 int result = BLUETOOTH_ERROR_INTERNAL;
54 BT_CHECK_PARAMETER(device_address, return);
55 BT_CHECK_ENABLED(return);
58 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
61 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
62 g_array_append_vals(in_param2, &property, sizeof(int));
64 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_MONITOR_GET_PROPERTY,
65 in_param1, in_param2, in_param3, in_param4, &out_param);
67 if (result == BLUETOOTH_ERROR_NONE) {
68 if (out_param->len > 0) {
69 *value = g_array_index(out_param,
72 BT_ERR("out_param length is 0!!");
76 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
81 BT_EXPORT_API int bluetooth_proximity_monitor_get_supported_services(const bluetooth_device_address_t *device_address,
82 int *services_supported)
84 int result = BLUETOOTH_ERROR_INTERNAL;
86 BT_CHECK_PARAMETER(device_address, return);
87 BT_CHECK_ENABLED(return);
90 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
93 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
95 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES,
96 in_param1, in_param2, in_param3, in_param4, &out_param);
98 if (result == BLUETOOTH_ERROR_NONE) {
99 if (out_param->len > 0) {
100 *services_supported = g_array_index(out_param,
103 BT_ERR("out_param length is 0!!");
107 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
112 BT_EXPORT_API int bluetooth_proximity_reporter_register()
114 int result = BLUETOOTH_ERROR_INTERNAL;
116 BT_CHECK_ENABLED(return);
119 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
122 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_REPORTER_REGISTER,
123 in_param1, in_param2, in_param3, in_param4, &out_param);
125 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
130 BT_EXPORT_API int bluetooth_proximity_reporter_unregister()
132 int result = BLUETOOTH_ERROR_INTERNAL;
134 BT_CHECK_ENABLED(return);
137 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
140 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_REPORTER_UNREGISTER,
141 in_param1, in_param2, in_param3, in_param4, &out_param);
143 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
148 BT_EXPORT_API int bluetooth_proximity_reporter_get_property(const bluetooth_device_address_t *device_address,
149 bluetooth_pxp_poperty_t property, int *value)
151 int result = BLUETOOTH_ERROR_INTERNAL;
153 BT_CHECK_PARAMETER(device_address, return);
154 BT_CHECK_ENABLED(return);
157 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
160 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
161 g_array_append_vals(in_param2, &property, sizeof(int));
163 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PXP_REPORTER_GET_PROPERTY,
164 in_param1, in_param2, in_param3, in_param4, &out_param);
166 if (result == BLUETOOTH_ERROR_NONE) {
167 if (out_param->len > 0) {
168 *value = g_array_index(out_param,
171 BT_ERR("out_param length is 0!!");
175 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);