From: Hyuk Lee Date: Fri, 20 May 2016 06:31:04 +0000 (+0900) Subject: API addition for getting Gatt permission of characteristic or descriptor X-Git-Tag: submit/tizen/20160523.041954~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04a7cc72870c548f618cc7966fc29df6254ebd55;p=platform%2Fcore%2Fapi%2Fbluetooth.git API addition for getting Gatt permission of characteristic or descriptor Change-Id: Ifeae8ebeb213693394a1cc3a22251e03c8663516 Signed-off-by: Hyuk Lee --- diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index 01d4881..9d926a9 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -1815,21 +1815,37 @@ int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic or descriptor's GATT handle has + * @brief Gets the permissions which a characteristic's GATT handle has * @since_tizen 2.4 * - * @param[in] gatt_handle The handle of a characteristic or descriptor - * @param[out] permissions The permissions which a characteristic or descriptor's GATT handle has. + * @param[in] gatt_handle The handle of a characteristic + * @param[out] permissions The permissions which a characteristic's GATT handle has. * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_SUPPORTED Not supported * * @see bt_gatt_characteristic_create() + * @see bt_gatt_permission_e + */ +int bt_gatt_characteristic_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has + * @since_tizen 2.4 + * + * @param[in] gatt_handle The handle of a descriptor + * @param[out] permissions The permissions which a descriptor's GATT handle has. + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * * @see bt_gatt_descriptor_create() * @see bt_gatt_permission_e */ -int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions); +int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h index 3666d28..b7c37a9 100644 --- a/include/tv/bluetooth_internal.h +++ b/include/tv/bluetooth_internal.h @@ -1815,21 +1815,37 @@ int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic or descriptor's GATT handle has + * @brief Gets the permissions which a characteristic's GATT handle has * @since_tizen 2.4 * - * @param[in] gatt_handle The handle of a characteristic or descriptor - * @param[out] permissions The permissions which a characteristic or descriptor's GATT handle has. + * @param[in] gatt_handle The handle of a characteristic + * @param[out] permissions The permissions which a characteristic's GATT handle has. * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_SUPPORTED Not supported * * @see bt_gatt_characteristic_create() + * @see bt_gatt_permission_e + */ +int bt_gatt_characteristic_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has + * @since_tizen 2.4 + * + * @param[in] gatt_handle The handle of a descriptor + * @param[out] permissions The permissions which a descriptor's GATT handle has. + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * * @see bt_gatt_descriptor_create() * @see bt_gatt_permission_e */ -int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions); +int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index 32018d9..4aef17a 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -2460,21 +2460,37 @@ int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic or descriptor's GATT handle has + * @brief Gets the permissions which a characteristic's GATT handle has * @since_tizen 2.4 * - * @param[in] gatt_handle The handle of a characteristic or descriptor - * @param[out] permissions The permissions which a characteristic or descriptor's GATT handle has. + * @param[in] gatt_handle The handle of a characteristic + * @param[out] permissions The permissions which a characteristic's GATT handle has. * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_SUPPORTED Not supported * * @see bt_gatt_characteristic_create() + * @see bt_gatt_permission_e + */ +int bt_gatt_characteristic_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has + * @since_tizen 2.4 + * + * @param[in] gatt_handle The handle of a descriptor + * @param[out] permissions The permissions which a descriptor's GATT handle has. + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * * @see bt_gatt_descriptor_create() * @see bt_gatt_permission_e */ -int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions); +int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c index db2fe70..fb6003a 100644 --- a/src/bluetooth-gatt.c +++ b/src/bluetooth-gatt.c @@ -1367,11 +1367,10 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, return BT_ERROR_NONE; /* LCOV_EXCL_STOP */ } /* LCOV_EXCL_START */ -int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions) +int bt_gatt_characteristic_get_permissions(bt_gatt_h gatt_handle, int *permissions) { bt_gatt_common_s *handle = (bt_gatt_common_s *)gatt_handle; bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle; - bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle; BT_CHECK_GATT_SUPPORT(); BT_CHECK_INIT_STATUS(); @@ -1381,7 +1380,26 @@ int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions) if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) *permissions = chr->permissions; - else if (handle->type == BT_GATT_TYPE_DESCRIPTOR) + else { + BT_ERR("Type is invalid(type:%d)", handle->type); + return BT_ERROR_INVALID_PARAMETER; + } + + return BT_ERROR_NONE; +} + +int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions) +{ + bt_gatt_common_s *handle = (bt_gatt_common_s *)gatt_handle; + bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + BT_CHECK_INPUT_PARAMETER(gatt_handle); + BT_CHECK_INPUT_PARAMETER(permissions); + + if (handle->type == BT_GATT_TYPE_DESCRIPTOR) *permissions = desc->permissions; else { BT_ERR("Type is invalid(type:%d)", handle->type);