/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
int ret;
int value;
- ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), NULL);
+ ret = _bt_get_adapter_path(_bt_get_system_private_conn(), NULL);
- if (ret != BLUETOOTH_ERROR_NONE) {
+ if (ret != BLUETOOTH_ERROR_NONE)
return BLUETOOTH_ADAPTER_LE_DISABLED;
- }
ret = vconf_get_int(VCONFKEY_BT_LE_STATUS, &value);
if (ret != 0) {
{
int result;
- retv_if(bluetooth_check_adapter_le() == BLUETOOTH_ADAPTER_LE_ENABLED,
- BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED);
-
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
void _bt_set_le_scan_status(gboolean mode)
{
- BT_DBG("set LE scan mode : %d", mode);
+ BT_DBG("set LE scan mode : %d -> %d", is_le_scanning, mode);
is_le_scanning = mode;
}
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ BT_INFO_C("### Start LE scan");
+ _bt_print_api_caller_name();
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_START_LE_DISCOVERY,
in_param1, in_param2, in_param3, in_param4, &out_param);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ BT_INFO_C("### Stop LE scan");
+ _bt_print_api_caller_name();
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_STOP_LE_DISCOVERY,
in_param1, in_param2, in_param3, in_param4, &out_param);
return is_discovering;
}
-BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id)
+BT_EXPORT_API int bluetooth_is_scan_filter_supported(gboolean *is_supported)
{
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_PARAMETER(is_supported, return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
- g_array_append_vals(in_param1, filter, sizeof(bluetooth_le_scan_filter_t));
-
- result = _bt_send_request(BT_BLUEZ_SERVICE, BT_REGISTER_SCAN_FILTER,
- in_param1, in_param2, in_param3, in_param4, &out_param);
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SCAN_FILTER_SUPPORTED,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
if (result == BLUETOOTH_ERROR_NONE) {
- *slot_id = g_array_index(out_param, int, 0);
- } else {
+ *is_supported = g_array_index(out_param, int, 0);
+ BT_INFO("Scan Filter Support[%s]", *is_supported ? "TRUE" : "FALSE");
+ } else
BT_ERR("Fail to send request");
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
-BT_EXPORT_API int bluetooth_unregister_scan_filter(int slot_id)
+BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter)
{
int result;
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
- g_array_append_vals(in_param1, &slot_id, sizeof(int));
-
- result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UNREGISTER_SCAN_FILTER,
- in_param1, in_param2, in_param3, in_param4, &out_param);
-
- BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
- return result;
-}
-
-BT_EXPORT_API int bluetooth_unregister_all_scan_filters(void)
-{
- int result;
-
- BT_CHECK_ENABLED_ANY(return);
-
- BT_INIT_PARAMS();
- BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ g_array_append_vals(in_param1, filter, sizeof(bluetooth_le_scan_filter_t));
- result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UNREGISTER_ALL_SCAN_FILTERS,
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_REGISTER_SCAN_FILTER,
in_param1, in_param2, in_param3, in_param4, &out_param);
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
-#ifdef TIZEN_WEARABLE
gboolean __bluetooth_is_privileged_process(void)
{
- FILE *fp= NULL;
+ FILE *fp = NULL;
char path[30] = {0, };
char buf[256] = {0, };
fclose(fp);
return FALSE;
}
-#endif
BT_EXPORT_API int bluetooth_set_advertising(int handle, gboolean enable)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_ENABLED_ANY(return);
-#ifdef TIZEN_WEARABLE
- use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+ if (TIZEN_PROFILE_WEARABLE)
+ use_reserved_slot = __bluetooth_is_privileged_process();
+
+ _bt_print_api_caller_name();
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
bluetooth_advertising_params_t *params)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_ENABLED_ANY(return);
-#ifdef TIZEN_WEARABLE
+ if (TIZEN_PROFILE_WEARABLE)
use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+
+ _bt_print_api_caller_name();
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_EXPORT_API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_PARAMETER(value, return);
BT_CHECK_ENABLED_ANY(return);
if (length > BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 3)
return BLUETOOTH_ERROR_INVALID_PARAM;
-#ifdef TIZEN_WEARABLE
- use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+ if (TIZEN_PROFILE_WEARABLE)
+ use_reserved_slot = __bluetooth_is_privileged_process();
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
const bluetooth_scan_resp_data_t *value, int length)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_PARAMETER(value, return);
BT_CHECK_ENABLED_ANY(return);
if (length > BLUETOOTH_SCAN_RESP_DATA_LENGTH_MAX)
return BLUETOOTH_ERROR_INVALID_PARAM;
-#ifdef TIZEN_WEARABLE
- use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+ if (TIZEN_PROFILE_WEARABLE)
+ use_reserved_slot = __bluetooth_is_privileged_process();
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+BT_EXPORT_API int bluetooth_set_scan_type(bluetooth_le_scan_type_t scan_type)
+{
+ int result;
+
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, &scan_type, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_SCAN_TYPE,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_is_advertising(gboolean *is_advertising)
{
int result;
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_ADVERTISING,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*is_advertising = g_array_index(out_param, int, 0);
- } else {
+ else
BT_ERR("Fail to send request");
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+BT_EXPORT_API int bluetooth_set_le_static_random_address(gboolean enable)
+{
+ int result;
+
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, &enable, sizeof(gboolean));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_LE_STATIC_RANDOM_ADDRESS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_check_privilege_advertising_parameter(void)
{
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_SET_ADVERTISING_PARAMETERS)
BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result != BLUETOOTH_ERROR_NONE) {
+ if (result != BLUETOOTH_ERROR_NONE)
BT_ERR("Failed to Write the host suggested default data length values : %d", result);
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_LE_SET_DATA_LENGTH,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result != BLUETOOTH_ERROR_NONE) {
+ if (result != BLUETOOTH_ERROR_NONE)
BT_ERR("Failed to Set data length values : %d", result);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_is_le_2m_phy_supported(gboolean *is_supported)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(is_supported, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_LE_2M_PHY_SUPPORTED,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *is_supported = g_array_index(out_param, int, 0);
+ } else {
+ BT_ERR("Fail to send request");
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ BT_INFO("LE 2M PHY Support[%s]", *is_supported ? "TRUE" : "FALSE");
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_is_le_coded_phy_supported(gboolean *is_supported)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(is_supported, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_LE_CODED_PHY_SUPPORTED,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *is_supported = g_array_index(out_param, int, 0);
+ } else {
+ BT_ERR("Fail to send request");
}
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ BT_INFO("LE CODED PHY Support[%s]", *is_supported ? "TRUE" : "FALSE");
return result;
}