Implement BT 5.0 API's 28/186028/10
authorAnupam Roy <anupam.r@samsung.com>
Mon, 6 Aug 2018 21:08:52 +0000 (02:38 +0530)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 31 Aug 2018 04:53:44 +0000 (13:53 +0900)
This patch adds public API's which check whether
LE 2M PHY and LE CODED features are supported
by the adapter or not. These features are introduced
in BT 5.0 Core specification and thus would be
supported by devices enabled with BT 5.0 controller
or above.

This patch also defines new LE BT 5.0 feature defined as following
"tizen.org/feature/network.bluetooth.le.5_0"

Change-Id: I814bd512827bbb500a71e1052a6813f7c92b6bcf
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
include/bluetooth.h
include/bluetooth_private.h
src/bluetooth-adapter.c
test/bt_unit_test.c
test/bt_unit_test.h

index 4164c99..35e8f4b 100644 (file)
@@ -5991,6 +5991,48 @@ int bt_adapter_le_scan_filter_unregister(bt_scan_filter_h scan_filter);
 int bt_adapter_le_scan_filter_unregister_all(void);
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_5.0_MODULE
+ * @brief Checks if LE 2M PHY feature is supported or not.
+ * @since_tizen 5.0
+ *
+ * @remarks The LE 2M PHY feature was introduced in the BT 5.0 core specification.
+ *
+ * @param[out] is_supported The LE 2M PHY 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_2m_phy_supported(bool *is_supported);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_5.0_MODULE
+ * @brief Checks if LE CODED PHY feature is supported or not.
+ * @since_tizen 5.0
+ *
+ * @remarks The LE CODED PHY feature was introduced in the BT 5.0 core specification.
+ *
+ * @param[out] is_supported The LE CODED PHY 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_coded_phy_supported(bool *is_supported);
+
+/**
  * @}
  */
 
index 4e1181e..57c225d 100644 (file)
@@ -572,6 +572,7 @@ typedef void (*bt_adapter_passkey_notification_cb)(const char *remote_address, c
 
 #define BT_FEATURE_COMMON "tizen.org/feature/network.bluetooth"
 #define BT_FEATURE_LE "tizen.org/feature/network.bluetooth.le"
+#define BT_FEATURE_LE_5_0 "tizen.org/feature/network.bluetooth.le.5_0"
 #define BT_FEATURE_IPSP "tizen.org/feature/network.bluetooth.le.ipsp"
 #define BT_FEATURE_AUDIO_CALL "tizen.org/feature/network.bluetooth.audio.call"
 #define BT_FEATURE_AUDIO_MEDIA "tizen.org/feature/network.bluetooth.audio.media"
index a219ce9..93ee00e 100644 (file)
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
 }
 
+#define BT_CHECK_LE_5_0_SUPPORT() \
+{ \
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_5_0); \
+}
+
 static bt_scan_filter_h pxp_linkloss_alert_filter;
 static bt_scan_filter_h pxp_immediate_alert_filter;
 static bt_scan_filter_h pxp_signal_loss_filter;
@@ -3915,3 +3921,43 @@ int bt_adapter_passkey_confirmation_reply(bool confirmation_reply)
 
        return error_code;
 }
+
+int bt_adapter_le_is_2m_phy_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_2m_phy_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;
+}
+
+int bt_adapter_le_is_coded_phy_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_coded_phy_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;
+}
index 88043bd..86af66f 100644 (file)
@@ -337,6 +337,10 @@ tc_table_t tc_adapter_le[] = {
                , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH},
        {"bt_adater_le_read_host_suggested_def_data_length"
                , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH},
+       {"bt_adapter_le_is_2m_phy_supported"
+               , BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT},
+       {"bt_adapter_le_is_coded_phy_supported"
+               , BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT},
        {"Select this menu to set parameters and then select the function again."
                , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
        {NULL                                   , 0x0000},
@@ -5022,7 +5026,26 @@ int test_input_callback(void *data)
                                        def_tx_octets, def_tx_time);
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT: {
 
+                       TC_PRT("Check LE 2M PHY Feature support");
+                       bool is_2m_phy_supported = FALSE;
+
+                       ret = bt_adapter_le_is_2m_phy_supported(&is_2m_phy_supported);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       TC_PRT("LE 2M PHY Support [%s]", is_2m_phy_supported ? "YES" : "NO");
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT: {
+
+                       TC_PRT("Check LE CODED PHY Feature support");
+                       bool is_coded_phy_supported = FALSE;
+
+                       ret = bt_adapter_le_is_coded_phy_supported(&is_coded_phy_supported);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       TC_PRT("LE CODED PHY Support [%s]", is_coded_phy_supported ? "YES" : "NO");
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: {
 
                        TC_PRT("Set LE Data length paramters cmd");
index d37b39c..bfa5c68 100644 (file)
@@ -134,6 +134,8 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH,
        BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH,
        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_DEVICE_SET_DATA_LENGTH,
        BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1,