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 #ifdef TIZEN_DPM_ENABLE
29 BT_EXPORT_API int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
32 bt_user_info_t *user_info;
34 BT_CHECK_PARAMETER(device_address, return);
35 BT_CHECK_ENABLED(return);
37 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_BOND_DEVICE)
38 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
39 BT_ERR("Don't have a privilege to use this API");
40 return BLUETOOTH_ERROR_PERMISSION_DEINED;
43 #ifdef TIZEN_DPM_ENABLE
44 if (_bt_check_dpm(BT_DPM_PAIRING, NULL) == BT_DPM_RESTRICTED) {
45 BT_ERR("Not allow to pair the device");
46 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
49 if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)device_address) == BT_DPM_RESTRICTED) {
50 BT_ERR("Blacklist device");
51 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
55 user_info = _bt_get_user_data(BT_COMMON);
56 retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
59 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));
63 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_BOND_DEVICE,
64 in_param1, in_param2, in_param3, in_param4,
65 user_info->cb, user_info->user_data);
67 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
72 BT_EXPORT_API int bluetooth_bond_device_by_type(
73 const bluetooth_device_address_t *device_address,
74 bluetooth_conn_type_t conn_type)
77 bt_user_info_t *user_info;
79 BT_CHECK_PARAMETER(device_address, return);
80 BT_CHECK_ENABLED(return);
82 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_BOND_DEVICE_BY_TYPE)
83 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
84 BT_ERR("Don't have a privilege to use this API");
85 return BLUETOOTH_ERROR_PERMISSION_DEINED;
89 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
91 user_info = _bt_get_user_data(BT_COMMON);
92 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
94 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
95 g_array_append_vals(in_param2, &conn_type, sizeof(unsigned short));
97 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_BOND_DEVICE_BY_TYPE,
98 in_param1, in_param2, in_param3, in_param4,
99 user_info->cb, user_info->user_data);
101 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
106 BT_EXPORT_API int bluetooth_cancel_bonding(void)
110 BT_CHECK_ENABLED(return);
113 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
115 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_CANCEL_BONDING,
116 in_param1, in_param2, in_param3, in_param4, &out_param);
118 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
123 BT_EXPORT_API int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
126 bt_user_info_t *user_info;
128 BT_CHECK_PARAMETER(device_address, return);
129 BT_CHECK_ENABLED(return);
131 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_UNBOND_DEVICE)
132 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
133 BT_ERR("Don't have a privilege to use this API");
134 return BLUETOOTH_ERROR_PERMISSION_DEINED;
137 user_info = _bt_get_user_data(BT_COMMON);
138 retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
141 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
143 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
145 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_UNBOND_DEVICE,
146 in_param1, in_param2, in_param3, in_param4,
147 user_info->cb, user_info->user_data);
149 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
154 BT_EXPORT_API int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
155 bluetooth_device_info_t *dev_info)
159 BT_CHECK_PARAMETER(device_address, return);
160 BT_CHECK_PARAMETER(dev_info, return);
161 BT_CHECK_ENABLED(return);
164 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
166 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
168 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_BONDED_DEVICE,
169 in_param1, in_param2, in_param3, in_param4, &out_param);
171 if (result == BLUETOOTH_ERROR_NONE) {
172 if (out_param->len > 0) {
173 *dev_info = g_array_index(out_param,
174 bluetooth_device_info_t, 0);
176 BT_ERR("out_param length is 0!!");
180 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
185 BT_EXPORT_API int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
187 return BLUETOOTH_ERROR_NONE;
190 BT_EXPORT_API int bluetooth_search_service(const bluetooth_device_address_t *device_address)
193 bt_user_info_t *user_info;
195 BT_CHECK_PARAMETER(device_address, return);
196 BT_CHECK_ENABLED(return);
198 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_SEARCH_SERVICE)
199 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
200 BT_ERR("Don't have a privilege to use this API");
201 return BLUETOOTH_ERROR_PERMISSION_DEINED;
204 user_info = _bt_get_user_data(BT_COMMON);
205 retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
208 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
210 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
212 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_SEARCH_SERVICE,
213 in_param1, in_param2, in_param3, in_param4,
214 user_info->cb, user_info->user_data);
216 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
221 BT_EXPORT_API int bluetooth_cancel_service_search(void)
225 BT_CHECK_ENABLED(return);
228 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
230 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_CANCEL_SEARCH_SERVICE,
231 in_param1, in_param2, in_param3, in_param4, &out_param);
233 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
238 BT_EXPORT_API int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
242 char alias_name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
244 BT_CHECK_PARAMETER(device_address, return);
245 BT_CHECK_PARAMETER(alias, return);
246 BT_CHECK_ENABLED(return);
249 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
251 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
252 g_strlcpy(alias_name, alias, sizeof(alias_name));
253 g_array_append_vals(in_param2, alias_name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
255 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_ALIAS,
256 in_param1, in_param2, in_param3, in_param4, &out_param);
258 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
263 BT_EXPORT_API int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
268 BT_CHECK_PARAMETER(device_address, return);
269 BT_CHECK_ENABLED(return);
272 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
274 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
275 g_array_append_vals(in_param2, &authorized, sizeof(gboolean));
277 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_AUTHORIZATION,
278 in_param1, in_param2, in_param3, in_param4, &out_param);
280 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
285 BT_EXPORT_API int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address,
286 bluetooth_service_type_t type,
287 gboolean *is_connected)
291 BT_CHECK_PARAMETER(device_address, return);
292 BT_CHECK_PARAMETER(is_connected, return);
293 BT_CHECK_ENABLED(return);
296 if (type & BLUETOOTH_RFCOMM_SERVICE) {
297 result = bluetooth_rfcomm_client_is_connected(device_address, is_connected);
298 if (*is_connected == FALSE)
299 result = bluetooth_rfcomm_server_is_connected(device_address, is_connected);
306 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
308 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
309 g_array_append_vals(in_param2, &type, sizeof(int));
311 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_DEVICE_CONNECTED,
312 in_param1, in_param2, in_param3, in_param4, &out_param);
314 if (result == BLUETOOTH_ERROR_NONE) {
315 *is_connected = g_array_index(out_param, gboolean, 0);
318 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
323 BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_address, gboolean auto_connect)
326 bt_user_info_t *user_info;
328 BT_CHECK_PARAMETER(device_address, return);
329 BT_CHECK_ENABLED_ANY(return);
331 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_CONNECT_LE)
332 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
333 BT_ERR("Don't have a privilege to use this API");
334 return BLUETOOTH_ERROR_PERMISSION_DEINED;
338 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
340 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
341 g_array_append_vals(in_param2, &auto_connect, sizeof(gboolean));
343 user_info = _bt_get_user_data(BT_COMMON);
344 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
346 BT_INFO_C("### Connect LE");
347 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_CONNECT_LE,
348 in_param1, in_param2, in_param3, in_param4,
349 user_info->cb, user_info->user_data);
351 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
356 BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address)
359 bt_user_info_t *user_info;
361 BT_CHECK_PARAMETER(device_address, return);
362 BT_CHECK_ENABLED_ANY(return);
364 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_DISCONNECT_LE)
365 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
366 BT_ERR("Don't have a privilege to use this API");
367 return BLUETOOTH_ERROR_PERMISSION_DEINED;
371 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
373 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
374 user_info = _bt_get_user_data(BT_COMMON);
375 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
377 BT_INFO_C("### Disconnect LE");
378 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_DISCONNECT_LE,
379 in_param1, in_param2, in_param3, in_param4,
380 user_info->cb, user_info->user_data);
382 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
387 BT_EXPORT_API int bluetooth_enable_rssi(const bluetooth_device_address_t *remote_address,
388 int link_type, bt_rssi_threshold_t *rssi_threshold)
390 #ifdef __BROADCOM_PATCH__
393 BT_CHECK_ENABLED(return);
396 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
397 g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
398 g_array_append_vals(in_param2, &link_type, sizeof(int));
399 g_array_append_vals(in_param3, rssi_threshold, sizeof(bt_rssi_threshold_t));
401 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_RSSI,
402 in_param1, in_param2, in_param3, in_param4, &out_param);
404 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
408 BT_ERR("Current chipset does not support this function.");
409 return BLUETOOTH_ERROR_NOT_SUPPORT;
413 BT_EXPORT_API int bluetooth_get_rssi_strength(const bluetooth_device_address_t *remote_address, int link_type)
415 #ifdef __BROADCOM_PATCH__
418 BT_CHECK_ENABLED(return);
421 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
422 g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
423 g_array_append_vals(in_param2, &link_type, sizeof(int));
425 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_RSSI,
426 in_param1, in_param2, in_param3, in_param4, &out_param);
428 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
432 BT_ERR("Current chipset does not support this function.");
433 return BLUETOOTH_ERROR_NOT_SUPPORT;
437 BT_EXPORT_API int bluetooth_le_conn_update(const bluetooth_device_address_t *address,
438 const bluetooth_le_connection_param_t *parameters)
442 BT_CHECK_ENABLED(return);
443 BT_CHECK_PARAMETER(address, return);
444 BT_CHECK_PARAMETER(parameters, return);
447 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
449 g_array_append_vals(in_param1, address,
450 sizeof(bluetooth_device_address_t));
451 g_array_append_vals(in_param2, parameters,
452 sizeof(bluetooth_le_connection_param_t));
454 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_LE_CONN_UPDATE,
455 in_param1, in_param2, in_param3, in_param4, &out_param);
457 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
462 BT_EXPORT_API int bluetooth_get_connected_link_type(
463 const bluetooth_device_address_t *device_address,
464 bluetooth_connected_link_t *connected)
468 BT_CHECK_PARAMETER(device_address, return);
469 BT_CHECK_ENABLED(return);
472 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
474 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
476 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_CONNECTED_LINK_TYPE,
477 in_param1, in_param2, in_param3, in_param4, &out_param);
479 if (result == BLUETOOTH_ERROR_NONE) {
480 *connected = g_array_index(out_param, guint, 0);
483 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
488 BT_EXPORT_API int bluetooth_set_pin_code(
489 const bluetooth_device_address_t *device_address,
490 const bluetooth_device_pin_code_t *pin_code)
494 BT_CHECK_PARAMETER(device_address, return);
495 BT_CHECK_PARAMETER(pin_code, return);
496 BT_CHECK_ENABLED(return);
499 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
501 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
502 g_array_append_vals(in_param2, pin_code, sizeof(bluetooth_device_pin_code_t));
504 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PIN_CODE,
505 in_param1, in_param2, in_param3, in_param4, &out_param);
507 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
512 BT_EXPORT_API int bluetooth_unset_pin_code(
513 const bluetooth_device_address_t *device_address)
517 BT_CHECK_PARAMETER(device_address, return);
518 BT_CHECK_ENABLED(return);
521 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
523 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
525 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UNSET_PIN_CODE,
526 in_param1, in_param2, in_param3, in_param4, &out_param);
528 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
533 BT_EXPORT_API int bluetooth_update_le_connection_mode(const bluetooth_device_address_t *address,
534 const bluetooth_le_connection_mode_t mode)
538 BT_CHECK_ENABLED(return);
539 BT_CHECK_PARAMETER(address, return);
542 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
544 g_array_append_vals(in_param1, address,
545 sizeof(bluetooth_device_address_t));
546 g_array_append_vals(in_param2, &mode,
547 sizeof(bluetooth_le_connection_mode_t));
549 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UPDATE_LE_CONNECTION_MODE,
550 in_param1, in_param2, in_param3, in_param4, &out_param);
552 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
557 BT_EXPORT_API int bluetooth_request_att_mtu(const bluetooth_device_address_t *device_address, unsigned int mtu)
560 bt_user_info_t *user_info;
562 BT_CHECK_PARAMETER(device_address, return);
563 BT_CHECK_ENABLED_ANY(return);
565 if (mtu > BLUETOOTH_MAX_ATT_MTU)
566 return BLUETOOTH_ERROR_INVALID_PARAM;
568 if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_REQ_ATT_MTU)
569 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
570 BT_ERR("Don't have a privilege to use this API");
571 return BLUETOOTH_ERROR_PERMISSION_DEINED;
575 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
577 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
578 g_array_append_vals(in_param2, &mtu, sizeof(unsigned int));
580 user_info = _bt_get_user_data(BT_COMMON);
581 retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
583 result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_REQ_ATT_MTU,
584 in_param1, in_param2, in_param3, in_param4,
585 user_info->cb, user_info->user_data);
587 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
592 BT_EXPORT_API int bluetooth_get_att_mtu(const bluetooth_device_address_t *device_address,
597 BT_CHECK_PARAMETER(device_address, return);
598 BT_CHECK_PARAMETER(mtu, return);
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, device_address, sizeof(bluetooth_device_address_t));
606 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_ATT_MTU,
607 in_param1, in_param2, in_param3, in_param4, &out_param);
609 if (result == BLUETOOTH_ERROR_NONE) {
610 *mtu = g_array_index(out_param, unsigned int, 0);
613 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
618 BT_EXPORT_API int bluetooth_get_device_ida(const bluetooth_device_address_t *device_rpa,
619 bluetooth_device_address_t *id_address)
623 BT_CHECK_PARAMETER(device_rpa, return);
624 BT_CHECK_PARAMETER(id_address, return);
625 BT_CHECK_ENABLED_ANY(return);
628 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
630 g_array_append_vals(in_param1, device_rpa, sizeof(bluetooth_device_address_t));
632 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_DEVICE_IDA,
633 in_param1, in_param2, in_param3, in_param4, &out_param);
635 if (result == BLUETOOTH_ERROR_NONE) {
636 *id_address = g_array_index(out_param,
637 bluetooth_device_address_t, 0);
640 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
645 BT_EXPORT_API int bluetooth_force_hcidump(int timeout)
649 BT_CHECK_ENABLED_ANY(return);
652 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
654 g_array_append_vals(in_param1, &timeout, sizeof(int));
656 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_FORCE_HCI_DUMP,
657 in_param1, in_param2, in_param3, in_param4, &out_param);
659 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
664 BT_EXPORT_API int bluetooth_set_profile_trusted(
665 const bluetooth_device_address_t *device_address,
666 int profile, int trust)
670 BT_CHECK_PARAMETER(device_address, return);
671 BT_CHECK_ENABLED(return);
674 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
676 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
677 g_array_append_vals(in_param2, &profile, sizeof(int));
678 g_array_append_vals(in_param3, &trust, sizeof(int));
680 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_TRUSTED,
681 in_param1, in_param2, in_param3, in_param4, &out_param);
683 if (result == BLUETOOTH_ERROR_NONE) {
684 BT_DBG("SUCCESSFUL");
687 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
692 BT_EXPORT_API int bluetooth_get_profile_trusted(
693 const bluetooth_device_address_t *device_address,
694 int profile, int *trust)
697 int trust_profile = 0;
698 BT_CHECK_PARAMETER(device_address, return);
699 BT_CHECK_ENABLED(return);
702 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
704 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
705 g_array_append_vals(in_param2, &profile, sizeof(int));
707 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_TRUSTED,
708 in_param1, in_param2, in_param3, in_param4, &out_param);
710 if (result == BLUETOOTH_ERROR_NONE) {
711 trust_profile = g_array_index(out_param, guint, 0);
712 BT_DBG("SUCCESSFUL");
714 BT_DBG("TRUST %d", trust_profile);
715 *trust = trust_profile;
716 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
721 BT_EXPORT_API int bluetooth_set_profile_restricted(
722 const bluetooth_device_address_t *device_address,
723 int profile, int restricted)
727 BT_CHECK_PARAMETER(device_address, return);
728 BT_CHECK_ENABLED(return);
731 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
733 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
734 g_array_append_vals(in_param2, &profile, sizeof(int));
735 g_array_append_vals(in_param3, &restricted, sizeof(int));
737 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_RESTRICTED,
738 in_param1, in_param2, in_param3, in_param4, &out_param);
740 if (result == BLUETOOTH_ERROR_NONE) {
741 BT_DBG("SUCCESSFUL");
744 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
749 BT_EXPORT_API int bluetooth_get_profile_restricted(
750 const bluetooth_device_address_t *device_address,
751 int profile, int *restricted)
754 int restrict_profile = 0;
755 BT_CHECK_PARAMETER(device_address, return);
756 BT_CHECK_ENABLED(return);
759 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
761 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
762 g_array_append_vals(in_param2, &profile, sizeof(int));
764 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_RESTRICTED,
765 in_param1, in_param2, in_param3, in_param4, &out_param);
767 if (result == BLUETOOTH_ERROR_NONE) {
768 restrict_profile = g_array_index(out_param, guint, 0);
769 BT_DBG("SUCCESSFUL");
771 BT_DBG("Restricted %d", restrict_profile);
772 *restricted = restrict_profile;
773 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
778 BT_EXPORT_API int bluetooth_passkey_reply(char *passkey, gboolean reply)
782 char str_passkey[BLUETOOTH_DEVICE_PASSKEY_LENGTH_MAX];
784 BT_CHECK_PARAMETER(passkey, return);
785 BT_CHECK_ENABLED(return);
788 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
790 g_strlcpy(str_passkey, passkey, sizeof(str_passkey));
791 g_array_append_vals(in_param1, str_passkey, BLUETOOTH_DEVICE_PASSKEY_LENGTH_MAX);
792 g_array_append_vals(in_param2, &reply, sizeof(gboolean));
794 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PASSKEY_REPLY,
795 in_param1, in_param2, in_param3, in_param4, &out_param);
797 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
802 BT_EXPORT_API int bluetooth_passkey_confirmation_reply(gboolean reply)
806 BT_CHECK_ENABLED(return);
809 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
810 g_array_append_vals(in_param1, &reply, sizeof(gboolean));
811 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_PASSKEY_CONFIRMATION_REPLY,
812 in_param1, in_param2, in_param3, in_param4, &out_param);
813 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);