Merge the code from private
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-adapter-le.c
old mode 100755 (executable)
new mode 100644 (file)
index 0995f35..c43ecc3
@@ -26,6 +26,7 @@
 #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)
 {
@@ -53,9 +54,6 @@ BT_EXPORT_API int bluetooth_enable_adapter_le(void)
 {
        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);
 
@@ -159,6 +157,33 @@ 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)
 {
        int result;
@@ -537,6 +562,25 @@ BT_EXPORT_API int bluetooth_enable_le_privacy(gboolean enable_privacy)
        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)