From: Anupam Roy Date: Mon, 6 Aug 2018 21:04:10 +0000 (+0530) Subject: BT 5.0: Implement Is feature support API's X-Git-Tag: accepted/tizen/unified/20180816.134643~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=7092f14850355b0783267db14cf59007590d33bf BT 5.0: Implement Is feature support API's This patch implements FRWK API's which check whether adapter supports LE 2M PHY and LE CODED PHY features or not Change-Id: I31284348e3c18f2b2122883c7b83b5d7486dfb62 Signed-off-by: Anupam Roy --- diff --git a/bt-api/bt-adapter-le.c b/bt-api/bt-adapter-le.c index d96c32a..31c1c74 100644 --- a/bt-api/bt-adapter-le.c +++ b/bt-api/bt-adapter-le.c @@ -708,3 +708,53 @@ BT_EXPORT_API int bluetooth_le_set_data_length(bluetooth_device_address_t *addre return result; } + +BT_EXPORT_API int bluetooth_is_le_2m_phy_supported(gboolean *is_supported) +{ + int result; + + BT_CHECK_PARAMETER(is_supported, return); + BT_CHECK_ENABLED_ANY(return); + + 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_LE_2M_PHY_SUPPORTED, + in_param1, in_param2, in_param3, in_param4, &out_param); + + if (result == BLUETOOTH_ERROR_NONE) { + *is_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); + + BT_INFO("LE 2M PHY Support[%s]", *is_supported ? "TRUE" : "FALSE"); + return result; +} + +BT_EXPORT_API int bluetooth_is_le_coded_phy_supported(gboolean *is_supported) +{ + int result; + + BT_CHECK_PARAMETER(is_supported, return); + BT_CHECK_ENABLED_ANY(return); + + 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_LE_CODED_PHY_SUPPORTED, + in_param1, in_param2, in_param3, in_param4, &out_param); + + if (result == BLUETOOTH_ERROR_NONE) { + *is_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); + + BT_INFO("LE CODED PHY Support[%s]", *is_supported ? "TRUE" : "FALSE"); + return result; +} diff --git a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c index 353a8ec..145c68a 100644 --- a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c +++ b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c @@ -1610,4 +1610,21 @@ int _bt_is_advertising(void) return FALSE; } +gboolean _bt_is_le_2m_phy_supported(void) +{ + if (le_feature_info.le_2m_phy) + return TRUE; + else + return FALSE; +} + +gboolean _bt_is_le_coded_phy_supported(void) +{ + if (le_feature_info.le_coded_phy) + return TRUE; + else + return FALSE; +} + + /*************************************** LE Scan APIs *********************************************/ diff --git a/bt-service-adaptation/services/bt-request-handler.c b/bt-service-adaptation/services/bt-request-handler.c index fad5f48..c47990c 100644 --- a/bt-service-adaptation/services/bt-request-handler.c +++ b/bt-service-adaptation/services/bt-request-handler.c @@ -2756,6 +2756,20 @@ int __bt_bluez_request(int function_name, sizeof(gboolean)); break; } + case BT_IS_LE_2M_PHY_SUPPORTED: { + gboolean is_2m_phy_supported = FALSE; + + is_2m_phy_supported = _bt_is_le_2m_phy_supported(); + g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean)); + break; + } + case BT_IS_LE_CODED_PHY_SUPPORTED: { + gboolean is_coded_phy_supported = FALSE; + + is_coded_phy_supported = _bt_is_le_coded_phy_supported(); + g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean)); + break; + } default: BT_INFO("UnSupported function [%d]", function_name); result = BLUETOOTH_ERROR_NOT_SUPPORT; @@ -3706,6 +3720,8 @@ gboolean __bt_service_check_privilege(int function_name, case BT_GET_ADVERTISING_DATA: case BT_GET_SCAN_RESPONSE_DATA: case BT_IS_ADVERTISING: + case BT_IS_LE_2M_PHY_SUPPORTED: + case BT_IS_LE_CODED_PHY_SUPPORTED: case BT_REGISTER_SCAN_FILTER: case BT_UNREGISTER_SCAN_FILTER: case BT_UNREGISTER_ALL_SCAN_FILTERS: diff --git a/bt-service-adaptation/services/include/bt-service-core-adapter-le.h b/bt-service-adaptation/services/include/bt-service-core-adapter-le.h index 5e41fb1..965c9b5 100644 --- a/bt-service-adaptation/services/include/bt-service-core-adapter-le.h +++ b/bt-service-adaptation/services/include/bt-service-core-adapter-le.h @@ -82,6 +82,10 @@ int _bt_service_le_init(void); void _bt_service_le_deinit(void); +gboolean _bt_is_le_2m_phy_supported(void); + +gboolean _bt_is_le_coded_phy_supported(void); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/bluetooth-api.h b/include/bluetooth-api.h index f304c6d..2ee5edb 100644 --- a/include/bluetooth-api.h +++ b/include/bluetooth-api.h @@ -7737,6 +7737,44 @@ int bluetooth_otp_connect_otc(const bluetooth_device_address_t *device_address); int bluetooth_otp_disconnect_otc(const bluetooth_device_address_t *device_address); /** + * @fn int bluetooth_is_le_2m_phy_supported(gboolean *is_supported) + * @brief Check if Adapter supports LE 2M PHY feature or not. + * + * This API is used to check the whether LE Adapter supports LE 2M PHY feature, which is introduced + * in BT 5.0 specification. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Succeess \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * @param[out] is_supported. This boolean variable indicates whether LE 2M PHY is supported or not + * + * @remark None + */ +int bluetooth_is_le_2m_phy_supported(gboolean *is_supported); + +/** + * @fn int bluetooth_is_le_coded_phy_supported(gboolean *is_supported) + * @brief Check if Adapter supports LE 2M CODED feature or not. + * + * This API is used to check the whether LE Adapter supports LE CODED PHY feature, which is introduced + * in BT 5.0 specification. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Succeess \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * @param[out] is_supported. This boolean variable indicates whether LE CODED PHY is supported or not + * + * @remark None + */ +int bluetooth_is_le_coded_phy_supported(gboolean *is_supported); + +/** * @} */ diff --git a/include/bt-internal-types.h b/include/bt-internal-types.h index 728d9c4..8f267f4 100644 --- a/include/bt-internal-types.h +++ b/include/bt-internal-types.h @@ -185,6 +185,8 @@ typedef enum { BT_GET_SCAN_RESPONSE_DATA, BT_SET_SCAN_RESPONSE_DATA, BT_IS_ADVERTISING, + BT_IS_LE_2M_PHY_SUPPORTED, + BT_IS_LE_CODED_PHY_SUPPORTED, BT_SET_MANUFACTURER_DATA, BT_LE_CONN_UPDATE, BT_LE_READ_MAXIMUM_DATA_LENGTH,