Add bt-driver-insmod.service trigger logic
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-adapter-le.c
index 2a022b8..d96c32a 100644 (file)
@@ -35,9 +35,8 @@ BT_EXPORT_API int bluetooth_check_adapter_le(void)
 
        ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), 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) {
@@ -101,6 +100,7 @@ BT_EXPORT_API int bluetooth_start_le_discovery(void)
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
+       BT_INFO_C("### Start LE scan");
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_START_LE_DISCOVERY,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
@@ -121,13 +121,13 @@ BT_EXPORT_API int bluetooth_stop_le_discovery(void)
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
+       BT_INFO_C("### Stop LE scan");
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_STOP_LE_DISCOVERY,
                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)
-               _bt_set_le_scan_status(FALSE);
+       _bt_set_le_scan_status(FALSE);
 
        return result;
 }
@@ -168,18 +168,16 @@ BT_EXPORT_API gboolean bluetooth_is_scan_filter_supported(void)
                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) {
+               if (result == BLUETOOTH_ERROR_NONE)
                        is_scan_filter_supported = 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);
        }
 
-       if (is_scan_filter_supported == 1) {
+       if (is_scan_filter_supported == 1)
                return TRUE;
-       }
 
        return FALSE;
 }
@@ -198,11 +196,10 @@ BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *fil
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_REGISTER_SCAN_FILTER,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
+       if (result == BLUETOOTH_ERROR_NONE)
                *slot_id = 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);
 
@@ -245,7 +242,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;
@@ -267,18 +263,16 @@ 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_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -299,13 +293,12 @@ 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_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -354,7 +347,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);
@@ -362,9 +355,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);
@@ -414,7 +406,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);
@@ -422,9 +414,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);
@@ -473,11 +464,10 @@ BT_EXPORT_API int bluetooth_is_advertising(gboolean *is_advertising)
        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);
 
@@ -658,9 +648,8 @@ BT_EXPORT_API int bluetooth_le_write_host_suggested_default_data_length(
                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);
 
@@ -712,9 +701,8 @@ BT_EXPORT_API int bluetooth_le_set_data_length(bluetooth_device_address_t *addre
                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);