BT 5.0: Implement CAPIs for getting supported features 76/297376/2
authorAyush Garg <ayush.garg@samsung.com>
Wed, 16 Aug 2023 08:53:46 +0000 (14:23 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Thu, 17 Aug 2023 11:19:23 +0000 (16:49 +0530)
This patch adds following APIs:
1. bt_adapter_le_is_extended_advertising_supported()
2. bt_adapter_le_is_extended_scan_supported()
3. bt_adapter_le_get_maximum_advertising_data_length()

Change-Id: Id5c7b9c9873db52264853cc93e9a1d0a9e21453e
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
include/bluetooth_internal.h
src/bluetooth-adapter.c
tests/test/bt_unit_test.c
tests/test/bt_unit_test.h
tests/unittest/mock/bluetooth-mock.c

index 13a2c39..a28fb10 100644 (file)
@@ -1199,6 +1199,69 @@ int bt_adapter_le_set_advertising_transport_discovery_data(bt_advertiser_h adver
                unsigned char *transport_data, unsigned int transport_data_len);
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_50_MODULE
+ * @brief Checks if LE Extended Advertising feature is supported or not.
+ * @since_tizen 8.0
+ *
+ * @remarks The LE Extended Advertising feature was introduced in the BT 5.0 core specification.
+ *
+ * @param[out] is_supported The LE Extended Advertising feature support: (@c true = supported , @c  false = not supported)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED  Adapter is not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_adapter_le_is_extended_advertising_supported(bool *is_supported);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_50_MODULE
+ * @brief Checks if LE Extended Scan feature is supported or not.
+ * @since_tizen 8.0
+ *
+ * @remarks The LE Extended Scan feature was introduced in the BT 5.0 core specification.
+ *
+ * @param[out] is_supported The LE Extended Scan feature support: (@c true = supported , @c  false = not supported)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED  Adapter is not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_adapter_le_is_extended_scan_supported(bool *is_supported);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_50_MODULE
+ * @brief Maximum advertisement data length supported by controller
+ * @since_tizen 8.0
+ *
+ * @remarks The LE Maximum Advertising Data Length feature was introduced in the BT 5.0 core specification.
+ *
+ * @param[out] data_length The maximum length supported by controller for use as advertisement data or scan response data
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED  Adapter is not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_adapter_le_get_maximum_advertising_data_length(int *data_length);
+
+/**
  * @internal
  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
  * @brief Retrieves the address of the devices connected with the specific profile.
index c179e35..05f9395 100644 (file)
@@ -4609,3 +4609,72 @@ int bt_adapter_le_is_scan_filter_supported(bool *is_supported)
        return BT_ERROR_NONE;
 }
 /* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+int bt_adapter_le_is_extended_advertising_supported(bool *is_supported)
+{
+       int ret = BT_ERROR_NONE;
+       gboolean support = FALSE;
+
+       BT_CHECK_LE_5_0_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(is_supported);
+
+       ret = _bt_get_error_code(bluetooth_is_le_extended_advertising_supported(&support));
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+               return ret;
+       }
+
+       *is_supported = support ? true : false;
+
+       return BT_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+int bt_adapter_le_is_extended_scan_supported(bool *is_supported)
+{
+       int ret = BT_ERROR_NONE;
+       gboolean support = FALSE;
+
+       BT_CHECK_LE_5_0_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(is_supported);
+
+       ret = _bt_get_error_code(bluetooth_is_le_extended_scan_supported(&support));
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+               return ret;
+       }
+
+       *is_supported = support ? true : false;
+
+       return BT_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+int bt_adapter_le_get_maximum_advertising_data_length(int *data_length)
+{
+       int ret = BT_ERROR_NONE;
+       gint max_data_len = 0;
+
+       BT_CHECK_LE_5_0_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(data_length);
+
+       ret = _bt_get_error_code(bluetooth_le_get_maximum_advertising_data_length(&max_data_len));
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+               return ret;
+       }
+
+       *data_length = max_data_len;
+
+       return BT_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
index bb81c5b..badbc22 100644 (file)
@@ -373,6 +373,12 @@ tc_table_t tc_adapter_le[] = {
                , BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT},
        {"bt_adapter_le_is_coded_phy_supported"
                , BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT},
+       {"bt_adapter_le_is_extended_advertising_supported"
+               , BT_UNIT_TEST_FUNCTION_LE_EXTENDED_ADVERTISING_SUPPORT},
+       {"bt_adapter_le_is_extended_scan_supported"
+               , BT_UNIT_TEST_FUNCTION_LE_EXTENDED_SCAN_SUPPORT},
+       {"bt_adapter_le_get_maximum_advertising_data_length"
+               , BT_UNIT_TEST_FUNCTION_LE_GET_MAXIMUM_ADVERTISING_DATA_LENGTH},
        {"Select this menu to set parameters and then select the function again."
                , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
        {NULL                                   , 0x0000},
@@ -5893,6 +5899,37 @@ int test_input_callback(void *data)
                        TC_PRT("LE CODED PHY Support [%s]", is_coded_phy_supported ? "YES" : "NO");
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_LE_EXTENDED_ADVERTISING_SUPPORT: {
+
+                       TC_PRT("Check LE Extended Advertising Feature support");
+                       bool is_extended_advertising_supported = FALSE;
+
+                       ret = bt_adapter_le_is_extended_advertising_supported(&is_extended_advertising_supported);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       TC_PRT("LE Extended Advertising Support [%s]",
+                               is_extended_advertising_supported ? "YES" : "NO");
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_LE_EXTENDED_SCAN_SUPPORT: {
+
+                       TC_PRT("Check LE Extended Scan Feature support");
+                       bool is_extended_scan_supported = FALSE;
+
+                       ret = bt_adapter_le_is_extended_scan_supported(&is_extended_scan_supported);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       TC_PRT("LE Extended Scan Support [%s]", is_extended_scan_supported ? "YES" : "NO");
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_LE_GET_MAXIMUM_ADVERTISING_DATA_LENGTH: {
+
+                       TC_PRT("Check Maximum Advertising Data Length");
+                       int max_advt_len = 0;
+
+                       ret = bt_adapter_le_get_maximum_advertising_data_length(&max_advt_len);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       TC_PRT("LE Maximum Advertising Data Length [%d]", max_advt_len);
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
                        need_to_set_params = true;
                        TC_PRT("Select the function again");
index 7c4b254..0b3f219 100644 (file)
@@ -149,6 +149,9 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH,
        BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT,
        BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT,
+       BT_UNIT_TEST_FUNCTION_LE_EXTENDED_ADVERTISING_SUPPORT,
+       BT_UNIT_TEST_FUNCTION_LE_EXTENDED_SCAN_SUPPORT,
+       BT_UNIT_TEST_FUNCTION_LE_GET_MAXIMUM_ADVERTISING_DATA_LENGTH,
        BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1,
        BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE,
        BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB,
index 546d050..de6c825 100644 (file)
@@ -268,6 +268,24 @@ API int bluetooth_is_le_coded_phy_supported(gboolean *is_supported)
        return BLUETOOTH_ERROR_NONE;
 }
 
+API int bluetooth_is_le_extended_advertising_supported(gboolean *is_supported)
+{
+       *is_supported = TRUE;
+       return BLUETOOTH_ERROR_NONE;
+}
+
+API int bluetooth_is_le_extended_scan_supported(gboolean *is_supported)
+{
+       *is_supported = TRUE;
+       return BLUETOOTH_ERROR_NONE;
+}
+
+API int bluetooth_le_get_maximum_advertising_data_length(gint *max_data_len)
+{
+       *max_data_len = 31;
+       return BLUETOOTH_ERROR_NONE;
+}
+
 API int bluetooth_av_connect(bluetooth_device_address_t *remote_address)
 {
        return BLUETOOTH_ERROR_NONE;