From: himanshu Date: Thu, 31 Oct 2019 12:47:14 +0000 (+0530) Subject: Implemented the is scan filter supported API X-Git-Tag: accepted/tizen/unified/20191112.125153~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F216754%2F2;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Implemented the is scan filter supported API This API is used to get the information whether the scan filter feature is supported or not. Change-Id: Ife02b2e1c79548fa92de6f185d68007e66e6dcbd Signed-off-by: himanshu --- diff --git a/bt-api/bt-adapter-le.c b/bt-api/bt-adapter-le.c index 20b2d31..4479d8e 100644 --- a/bt-api/bt-adapter-le.c +++ b/bt-api/bt-adapter-le.c @@ -26,7 +26,6 @@ #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) { @@ -160,29 +159,27 @@ BT_EXPORT_API int bluetooth_is_le_discovering(void) return is_discovering; } -BT_EXPORT_API gboolean bluetooth_is_scan_filter_supported(void) +BT_EXPORT_API int bluetooth_is_scan_filter_supported(gboolean *is_supported) { int result; - if (is_scan_filter_supported == -1) { - BT_INIT_PARAMS(); - BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + BT_CHECK_PARAMETER(is_supported, return); - result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SCAN_FILTER_SUPPORTED, - 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); - if (result == BLUETOOTH_ERROR_NONE) - is_scan_filter_supported = g_array_index(out_param, int, 0); - else - BT_ERR("Fail to send request"); + result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SCAN_FILTER_SUPPORTED, + in_param1, in_param2, in_param3, in_param4, &out_param); - BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); - } + 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"); - if (is_scan_filter_supported == 1) - return TRUE; + BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); - return FALSE; + return result; } BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id) diff --git a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c index 6c3ab7a..77e94b1 100644 --- a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c +++ b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c @@ -1890,6 +1890,14 @@ gboolean _bt_is_le_coded_phy_supported(void) return FALSE; } +gboolean _bt_is_scan_filter_supported(void) +{ + if (le_feature_info.max_filter > 0) + return TRUE; + + return FALSE; +} + int _bt_set_le_privacy(gboolean set_privacy) { int result = BLUETOOTH_ERROR_NONE; diff --git a/bt-service-adaptation/services/bt-request-handler.c b/bt-service-adaptation/services/bt-request-handler.c index 9676206..45cf633 100644 --- a/bt-service-adaptation/services/bt-request-handler.c +++ b/bt-service-adaptation/services/bt-request-handler.c @@ -951,6 +951,17 @@ int __bt_bluez_request(int function_name, } break; } + case BT_IS_SCAN_FILTER_SUPPORTED:{ + int is_supported = 0; + + if (_bt_is_scan_filter_supported() == TRUE) + is_supported = 1; + + g_array_append_vals(*out_param1, + &is_supported, sizeof(int)); + + break; + } case BT_ENABLE_RSSI: { bluetooth_device_address_t bd_addr; int link_type; diff --git a/bt-service-adaptation/services/include/bt-service-core-adapter-le.h b/bt-service-adaptation/services/include/bt-service-core-adapter-le.h index 1353180..bba7eaf 100644 --- a/bt-service-adaptation/services/include/bt-service-core-adapter-le.h +++ b/bt-service-adaptation/services/include/bt-service-core-adapter-le.h @@ -93,6 +93,8 @@ gboolean _bt_is_le_2m_phy_supported(void); gboolean _bt_is_le_coded_phy_supported(void); +gboolean _bt_is_scan_filter_supported(void); + int _bt_set_le_static_random_address(gboolean is_enable); int _bt_set_le_privacy(gboolean set_privacy); diff --git a/include/bluetooth-api.h b/include/bluetooth-api.h index 30dbdb9..5570984 100644 --- a/include/bluetooth-api.h +++ b/include/bluetooth-api.h @@ -3263,7 +3263,7 @@ is_le_scanning = bluetooth_is_le_scanning (); */ gboolean bluetooth_is_le_scanning(void); -gboolean bluetooth_is_scan_filter_supported(void); +int bluetooth_is_scan_filter_supported(gboolean *is_supported); /** * @fn int bluetooth_force_hcidump(int timeout)