New API to set LE scan type 45/213845/1
authorinjun.yang <injun.yang@samsung.com>
Thu, 22 Aug 2019 10:10:18 +0000 (19:10 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 16 Sep 2019 00:17:14 +0000 (09:17 +0900)
[Model] All
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] Internal
[Occurrence Version] N/A

[Problem] n/a
[Cause & Measure] New API to set LE scan type
[Checking Method] n/a

[Team] Convergence BT
[Developer] Injun Yang
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I2523d6783a210ed44bfd80b204a976e4aeb787a5
Signed-off-by: injun.yang <injun.yang@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/bluetooth_internal.h
src/bluetooth-adapter.c
test/bt_unit_test.c
test/bt_unit_test.h

index 697addb..318fc70 100644 (file)
@@ -680,6 +680,26 @@ int bt_adapter_le_set_state_changed_cb(bt_adapter_le_state_changed_cb callback,
 int bt_adapter_le_unset_state_changed_cb(void);
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief Sets Bluetooth LE scan type
+ * @since_tizen 5.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/bluetooth.admin
+ * @param[in]  scan_type  The scan type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER Parameter is invalid
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ */
+int bt_adapter_le_set_scan_type(bt_adapter_le_scan_type_e scan_type);
+
+/**
  * @internal
  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
  * @brief add address to whitelist for accepting scanning request.
index 8d12f69..a9f7b4d 100644 (file)
@@ -1498,6 +1498,23 @@ int bt_adapter_le_set_scan_mode(bt_adapter_le_scan_mode_e scan_mode)
 }
 
 /* LCOV_EXCL_START */
+int bt_adapter_le_set_scan_type(bt_adapter_le_scan_type_e scan_type)
+{
+       int ret = BT_ERROR_NONE;
+
+       BT_CHECK_LE_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+
+       ret = _bt_get_error_code(bluetooth_set_scan_type(scan_type));
+       if (ret != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret),
+                                               ret); /* LCOV_EXCL_LINE */
+       } /* LCOV_EXCL_LINE */
+       return ret;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 int bt_adapter_le_set_customized_scan_mode(float scan_interval, float scan_window)
 {
        int ret = BT_ERROR_NONE;
index fe85217..3f9794d 100644 (file)
@@ -296,6 +296,8 @@ tc_table_t tc_adapter_le[] = {
                , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE},
        {"bt_adapter_le_set_scan_mode"
                , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE},
+       {"bt_adapter_le_set_scan_type"
+               , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE},
        {"bt_adapter_le_start_scan"
                , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN},
        {"bt_adapter_le_stop_scan"
@@ -3418,6 +3420,10 @@ int test_set_params(int test_id, char *param)
                        param_count = 1;
                        TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)");
                        break;
+               case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE:
+                       param_count = 1;
+                       TC_PRT("Scan type\n (0 : Passive, 1: Active)");
+                       break;
                case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA:
                        param_count = 1;
                        TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS");
@@ -4494,6 +4500,18 @@ int test_input_callback(void *data)
                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE: {
+                       int type = BT_ADAPTER_LE_PASSIVE_SCAN;
+
+                       if (g_test_param.param_count > 0) {
+                               type = atoi(g_test_param.params[0]);
+                               __bt_free_test_param(&g_test_param);
+                       }
+
+                       ret = bt_adapter_le_set_scan_type(type);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
 
                case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN:
                        ret = bt_adapter_le_start_scan(
index 1d1dbef..c92f27d 100644 (file)
@@ -109,6 +109,7 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE,
+BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY,