X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-api%2Fbt-adapter-le.c;h=86be5869274025857240e7d1a570d60eced559f6;hb=9c4b9ae7f88a280c709c77e96d9415cd2fa708b3;hp=8cbb29df2d3d9eca8386741c05f017b424c3c79d;hpb=1ca798ea1f81a2fdb339a851471158f8617d8f5e;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-api/bt-adapter-le.c b/bt-api/bt-adapter-le.c index 8cbb29d..86be586 100644 --- a/bt-api/bt-adapter-le.c +++ b/bt-api/bt-adapter-le.c @@ -26,14 +26,13 @@ #include "bt-event-handler.h" static gboolean is_le_scanning = FALSE; -static int is_scan_filter_supported = -1; BT_EXPORT_API int bluetooth_check_adapter_le(void) { 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) return BLUETOOTH_ADAPTER_LE_DISABLED; @@ -82,7 +81,7 @@ BT_EXPORT_API int bluetooth_disable_adapter_le(void) 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; } @@ -94,13 +93,17 @@ BT_EXPORT_API gboolean bluetooth_is_le_scanning(void) BT_EXPORT_API int bluetooth_start_le_discovery(void) { int result; + uid_t uid = getuid(); 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, &uid, sizeof(uid_t)); + 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); @@ -115,13 +118,17 @@ BT_EXPORT_API int bluetooth_start_le_discovery(void) BT_EXPORT_API int bluetooth_stop_le_discovery(void) { int result; + uid_t uid = getuid(); 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, &uid, sizeof(uid_t)); + 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); @@ -158,48 +165,22 @@ BT_EXPORT_API int bluetooth_is_le_discovering(void) return is_discovering; } -BT_EXPORT_API gboolean bluetooth_is_scan_filter_supported(void) -{ - int result; - - if (is_scan_filter_supported == -1) { - 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_SCAN_FILTER_SUPPORTED, - in_param1, in_param2, in_param3, in_param4, &out_param); - - if (result == BLUETOOTH_ERROR_NONE) - is_scan_filter_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); - } - - if (is_scan_filter_supported == 1) - return TRUE; - - return FALSE; -} - -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 + if (result == BLUETOOTH_ERROR_NONE) { + *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); @@ -207,7 +188,7 @@ BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *fil 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; @@ -216,26 +197,9 @@ BT_EXPORT_API int bluetooth_unregister_scan_filter(int slot_id) 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); @@ -243,7 +207,6 @@ BT_EXPORT_API int bluetooth_unregister_all_scan_filters(void) return result; } -#ifdef TIZEN_PROFILE_WEARABLE gboolean __bluetooth_is_privileged_process(void) { FILE *fp = NULL; @@ -265,18 +228,18 @@ gboolean __bluetooth_is_privileged_process(void) 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_PROFILE_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); @@ -297,13 +260,14 @@ BT_EXPORT_API int bluetooth_set_custom_advertising(int handle, gboolean enable, bluetooth_advertising_params_t *params) { int result; - gboolean use_reserved_slot = FALSE; + gboolean use_reserved_slot = TRUE; BT_CHECK_ENABLED_ANY(return); -#ifdef TIZEN_PROFILE_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); @@ -352,7 +316,7 @@ BT_EXPORT_API int bluetooth_get_advertising_data(bluetooth_advertising_data_t *a 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); @@ -360,9 +324,8 @@ BT_EXPORT_API int bluetooth_set_advertising_data(int handle, const bluetooth_adv if (length > BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 3) return BLUETOOTH_ERROR_INVALID_PARAM; -#ifdef TIZEN_PROFILE_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); @@ -412,7 +375,7 @@ BT_EXPORT_API int bluetooth_set_scan_response_data(int handle, 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); @@ -420,9 +383,8 @@ BT_EXPORT_API int bluetooth_set_scan_response_data(int handle, if (length > BLUETOOTH_SCAN_RESP_DATA_LENGTH_MAX) return BLUETOOTH_ERROR_INVALID_PARAM; -#ifdef TIZEN_PROFILE_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); @@ -459,6 +421,25 @@ BT_EXPORT_API int bluetooth_set_scan_parameters(bluetooth_le_scan_params_t *para 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; @@ -715,3 +696,53 @@ BT_EXPORT_API int bluetooth_le_set_data_length(bluetooth_device_address_t *addre 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; +}