From: Hyuk Lee Date: Tue, 31 May 2016 07:07:04 +0000 (+0900) Subject: Move GATT Server APIs header to bluetooth.h X-Git-Tag: submit/submit/tizen/20160620.042720/20160620.042801~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f07bc7aedcfc23c9fc34a98583eb61e449688a30;p=platform%2Fcore%2Fapi%2Fbluetooth.git Move GATT Server APIs header to bluetooth.h - modify the api version - modify the func description - modify the callback function name - modify the typos - add the return type for privilege APIs Change-Id: I25489e0815ea2bdbded9473c8bd3b9727a099747 Signed-off-by: Hyuk Lee --- diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 2ac8b06..1407f6c 100644 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -68,7 +68,7 @@ typedef enum { BT_EVENT_OPP_PUSH_REQUESTED, /**< OPP push is requested */ BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS, /**< OPP transfer progress */ BT_EVENT_OPP_SERVER_TRANSFER_FINISHED, /**< OPP transfer is completed */ - BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, /**< OPP client connection is reponsed */ + BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, /**< OPP client connection is responsed */ BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, /**< OPP client push progress */ BT_EVENT_OPP_CLIENT_PUSH_FINISHED, /**< OPP client push is finished */ BT_EVENT_PAN_CONNECTION_STATE_CHANGED, /**< PAN connection change */ @@ -300,7 +300,7 @@ typedef struct { bt_gatt_server_notification_sent_cb notified_cb; void *notified_user_data; - bt_gatt_server_notification_state_change_cb notification_changed_cb; + bt_gatt_server_characteristic_notification_state_changed_cb notification_changed_cb; void *notification_changed_user_data; int value_length; diff --git a/include/mobile/bluetooth.h b/include/mobile/bluetooth.h index 0143324..19145af 100644 --- a/include/mobile/bluetooth.h +++ b/include/mobile/bluetooth.h @@ -23,7 +23,7 @@ #include #include -#include "bluetooth_type.h" +#include #ifdef __cplusplus extern "C" @@ -3744,7 +3744,7 @@ int bt_gatt_unset_characteristic_changed_cb(void); /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_set_characteristic_value_changed_cb instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Watches all the characteristic value changes of the service + * @brief Watches all the characteristic value changes of the service. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3764,7 +3764,7 @@ int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service); /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_unset_characteristic_value_changed_cb instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Remove watching of all the characteristic value changes of the service + * @brief Remove watching of all the characteristic value changes of the service. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3891,7 +3891,7 @@ int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle); /** * @deprecated Deprecated since 2.3.1. Use gatt_client_read_value instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Reads the value of characteristic from remote device + * @brief Reads the value of characteristic from remote device. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3939,7 +3939,7 @@ int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristi /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle + * @brief Gets the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a value must be released using free(). \n @@ -3958,7 +3958,7 @@ int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type + * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -3979,7 +3979,7 @@ int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type + * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -4000,7 +4000,7 @@ int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle + * @brief Updates the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4020,7 +4020,7 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4042,7 +4042,7 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4065,7 +4065,7 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle + * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a uuid must be released using free(). \n @@ -4082,7 +4082,7 @@ int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the type of GATT handle + * @brief Gets the type of GATT handle. * @since_tizen 2.3.1 * * @param[in] gatt_handle The GATT handle @@ -4096,7 +4096,7 @@ int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT client handle which the specified service belongs to + * @brief Gets the GATT client handle which the specified service belongs to. * @since_tizen 2.3.1 * * @remark This function doesn't allocate new memory for GATT client handle. @@ -4116,7 +4116,7 @@ int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a characteristic's GATT handle which has specific UUID + * @brief Gets a characteristic's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4137,7 +4137,7 @@ int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each characteristic that belongs to the specified service + * @brief Invokes @a callback function on each characteristic that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -4155,7 +4155,7 @@ int bt_gatt_service_foreach_characteristics(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets an included service's GATT handle which has specific UUID + * @brief Gets an included service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4176,7 +4176,7 @@ int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each included service that belongs to the specified service + * @brief Invokes @a callback function on each included service that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -4194,7 +4194,7 @@ int bt_gatt_service_foreach_included_services(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the service's GATT handle which the specified characteristic belongs to + * @brief Gets the service's GATT handle which the specified characteristic belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4211,7 +4211,7 @@ int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *serv /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the properties which a characteristic's GATT handle has + * @brief Gets the properties which a characteristic's GATT handle has. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4227,7 +4227,7 @@ int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *propert /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the write type of the specified characteristic + * @brief Gets the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4244,7 +4244,7 @@ int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the write type of the specified characteristic + * @brief Updates the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4262,7 +4262,7 @@ int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a descriptor's GATT handle which has specific UUID + * @brief Gets a descriptor's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4283,7 +4283,7 @@ int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char * /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic + * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4301,7 +4301,7 @@ int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to + * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4318,7 +4318,7 @@ int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *chara /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT client handle + * @brief Creates the GATT client handle. * @since_tizen 2.3.1 * * @remark The GATT client handle must be freed by bt_gatt_client_destroy() after use @@ -4338,7 +4338,7 @@ int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT client's handle + * @brief Destroys the GATT client's handle. * @since_tizen 2.3.1 * * @remark All related service, characteristic and descriptor's GATT handles are freed also @@ -4355,7 +4355,7 @@ int bt_gatt_client_destroy(bt_gatt_client_h client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the address of remote device + * @brief Gets the address of remote device. * @since_tizen 2.3.1 * * @param[in] client The created GATT client's handle @@ -4372,7 +4372,7 @@ int bt_gatt_client_get_remote_address(bt_gatt_client_h client, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously + * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -4398,7 +4398,7 @@ int bt_gatt_client_read_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously + * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -4428,7 +4428,7 @@ int bt_gatt_client_write_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4449,7 +4449,7 @@ int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle, whose value change will not be informed @@ -4465,7 +4465,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID + * @brief Gets a service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4473,7 +4473,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi * If there are multiple services which have same UUID, only the first matched one will be returned. * * @param[in] client The GATT client's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists * @param[out] service The service's GATT handle which has @a uuid if it exists * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful @@ -4486,7 +4486,7 @@ int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT client + * @brief Invokes @a callback function on each service that belongs to the specified GATT client. * @since_tizen 2.3.1 * * @param[in] client The GATT client's handle @@ -4598,6 +4598,531 @@ int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb */ int bt_gatt_unset_connection_state_changed_cb(void); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of service. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of service + * @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_service_create() + */ +int bt_gatt_service_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of characteristic. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of characteristic + * @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() + */ +int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of descriptor. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of descriptor + * @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() + */ +int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the permissions which a characteristic's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_SERVER_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT service. + * @since_tizen 3.0 + * + * @remarks The @a service should be destroyed by using bt_gatt_service_destroy() + * + * @param[in] uuid The UUID of the service + * @param[in] type The type of the service + * @param[out] service The GATT handle of the created service + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_service_destroy() + */ +int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a characteristic to a specified service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] characteristic The characteristic's GATT handle to be added + * @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_service_create() + * @see bt_gatt_characteristic_create() + */ +int bt_gatt_service_add_characteristic(bt_gatt_h service, + bt_gatt_h characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a service to a specified service as included service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] included_service The service's GATT handle to be added as included service + * @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_service_create() + */ +int bt_gatt_service_add_included_service(bt_gatt_h service, + bt_gatt_h included_service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the GATT server handle to which the specified service belongs. + * @since_tizen 3.0 + * + * @remarks The returned Server handle must not be freed by application. + * + * @param[in] service The service's GATT handle + * @param[out] server The GATT server handle to which @a service belongs + * @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_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_register_service() + */ +int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a properties can be one or more values of #bt_gatt_property_e, combined with bitwise 'or'. + * @remarks The @a characteristic should be destroyed by using bt_gatt_characteristic_destroy(). + * + * @param[in] uuid The UUID of the characteristic + * @param[in] permissions the permissions of the characteristic + * @param[in] properties The properties of the characteristic + * @param[in] Value The value(byte stream) of the characteristic + * @param[in] value_length The length of @a value + * @param[out] characteristic The GATT handle of the created characteristic + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_characteristic_destroy() + */ +int bt_gatt_characteristic_create(const char *uuid, int permissions, + int properties, const char *value, int value_length, + bt_gatt_h *characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a descriptor to a specified characteristic. + * @since_tizen 3.0 + * + * @param[in] characteristic The GATT handle of the characteristic + * @param[in] descriptor The descriptor's GATT handle to be added + * @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_descriptor_create() + */ +int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, + bt_gatt_h descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic descriptor. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a descriptor should be destroyed by using bt_gatt_descriptor_destroy(). + * + * @param[in] uuid The UUID of the descriptor + * @param[in] permissions The permissions of the descriptor + * @param[in] value The value(byte stream) associated with the descriptor + * @param[in] value_length The length of @a value + * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_descriptor_destroy() + */ +int bt_gatt_descriptor_create(const char *uuid, int permissions, + const char *value, int value_length, + bt_gatt_h *descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Initializes the GATT Server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_deinitialize() + */ +int bt_gatt_server_initialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief DeInitializes the GATT server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_initialize() + */ +int bt_gatt_server_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT server's handle. + * @since_tizen 3.0 + * + * @remarks The @a server handle should be destroyed by using bt_gatt_server_destroy() + * + * @param[out] server The GATT server's handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_destroy() + */ +int bt_gatt_server_create(bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT server's handle. + * @since_tizen 3.0 + * + * @remarks All registered services to GATT server are unregistered + * + * @param[in] server The GATT server's handle + * @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_server_create() + */ +int bt_gatt_server_destroy(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client). + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_read_value_requested_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_characteristic_notification_state_changed_cb() + */ +int bt_gatt_server_set_characteristic_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_characteristic_notification_state_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_write_value_requested_cb() + */ +int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_write_value_requested_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a specified service to the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be registered in @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_start() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters a specified service from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be unregistered from @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters all services from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers the application along with the GATT services of the application it is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_initialize() + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_start(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Sends a response to the remote device as a result of a read/write request. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks Until this function is called, a read/write request is not finished. + * + * @param[in] request_id The identification of a read/write request + * @param[in] request_type The request type for read/write + * @param[in] offset The offset from where a value is read + * @param[in] resp_status The application error if any occurred or BT_ERROR_NONE for successful. + * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. + * @param[in] value_length Value Length + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_read_value_requested_cb() + */ +int bt_gatt_server_send_response(int request_id, bluetooth_gatt_att_request_type_e request_type, + int offset, int resp_status, char *value, int value_length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor. + * @since_tizen 3.0 + * + * @param[in] characteristic The characteristic which has a changed value + * @param[in] callback The function to be invoked on each remote device when a sending operation is done + * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_notification_sent_cb() + */ +int bt_gatt_server_notify_characteristic_changed_value(bt_gatt_h characteristic, + bt_gatt_server_notification_sent_cb callback, + const char *device_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets a service's GATT handle which has specific UUID. + * @since_tizen 3.0 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). + * If there are multiple services which have same UUID, only the first matched one will be returned. + * + * @param[in] server The GATT server's handle + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists + * @param[out] service The service's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Invokes @a callback function on each service that belongs to the specified GATT server. + * @since_tizen 3.0 + * + * @param[in] server The GATT server's handle + * @param[in] callback The function to be invoked on each service + * @param[in] user_data The user data to be passed to @a callback function + * @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_foreach_cb() + */ +int bt_gatt_server_foreach_services(bt_gatt_server_h server, + bt_gatt_foreach_cb callback, void *user_data); + /** * @} */ diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index ed6ce93..dc406df 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -1752,105 +1752,9 @@ int bt_a2dp_set_content_protection(bool status); int bt_gatt_get_uuid_specification_name(const char *uuid, char **name); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service, characteristic or descriptor - * @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_service_create() - * @see bt_gatt_characteristic_create() - * @see bt_gatt_descriptor_create() - */ -int bt_gatt_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service - * @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_service_create() - */ -int bt_gatt_service_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of characteristic - * @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() - */ -int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of descriptor - * @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() - */ -int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic's GATT handle has - * @since_tizen 2.4 - * - * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the permissions which a characteristic or descriptor's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the permissions which a characteristic or descriptor's GATT handle has. + * @since_tizen 3.0 * * @param[in] gatt_handle The handle of a characteristic or descriptor * @param[in] permissions The permissions to be updated @@ -1866,122 +1770,9 @@ int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); int bt_gatt_set_permissions(bt_gatt_h gatt_handle, int permissions); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT service - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the service - * @param[in] type The type of the service - * @param[out] service The GATT handle of the created service - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a characteristic to a specified service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] characteristic The characteristic's GATT handle to be added - * @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_service_create() - * @see bt_gatt_characteristic_create() - */ -int bt_gatt_service_add_characteristic(bt_gatt_h service, - bt_gatt_h characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a service to a specified service as included service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] included_service The service's GATT handle to be added as included service - * @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_service_create() - */ -int bt_gatt_service_add_included_service(bt_gatt_h service, - bt_gatt_h included_service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT server handle to which the specified service belongs - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[out] server The GATT server handle to which @a service belongs - * @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_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_register_service() - */ -int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the characteristic - * @param[in] permissions the permissions of the characteristic - * @param[in] properties The properties of the characteristic - * @param[in] Value The value(byte stream) of the characteristic - * @param[in] value_length The length of @a value - * @param[out] characteristic The GATT handle of the created characteristic - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_characteristic_create(const char *uuid, int permissions, - int properties, const char *value, int value_length, - bt_gatt_h *characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a descriptor to a specified characteristic - * @since_tizen 2.4 - * - * @param[in] characteristic The GATT handle of the characteristic - * @param[in] descriptor The descriptor's GATT handle to be added - * @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_descriptor_create() - */ -int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, - bt_gatt_h descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the properties which a characteristic's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the properties which a characteristic's GATT handle has. + * @since_tizen 3.0 * * @param[in] characteristic The characteristic's GATT handle * @param[in] properties The properties to be updated @@ -1996,307 +1787,20 @@ int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properti /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic descriptor + * @brief Destroys the GATT handle * @since_tizen 2.4 * - * @param[in] uuid The UUID of the descriptor - * @param[in] permissions The permissions of the descriptor - * @param[in] value The value(byte stream) associated with the descriptor - * @param[in] value_length The length of @a value - * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @param[in] gatt_handle The handle of service, characteristic or descriptor * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_descriptor_create(const char *uuid, int permissions, - const char *value, int value_length, - bt_gatt_h *descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Initializes the GATT Server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_deinitialize() - */ -int bt_gatt_server_initialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief DeInitializes the GATT server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_initialize() - */ -int bt_gatt_server_deinitialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT server's handle - * @since_tizen 2.4 - * - * @param[out] server The GATT server's handle - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_destroy() - */ -int bt_gatt_server_create(bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT server's handle - * @since_tizen 2.4 - * - * @remarks All registered services to GATT server are unregistered - * - * @param[in] server The GATT server's handle - * @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_server_create() - */ -int bt_gatt_server_destroy(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client) - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_read_value_requested_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_state_change_cb() - */ -int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, - bt_gatt_server_notification_state_change_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_write_value_requested_cb() - */ -int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_write_value_requested_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a specified service to the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be registered in @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done * @retval #BT_ERROR_NOT_SUPPORTED Not supported * - * @see bt_gatt_server_create() * @see bt_gatt_service_create() - * @see bt_gatt_server_start() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a specified service from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be unregistered from @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_register_service() - */ -int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters all services from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @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_server_register_service() - */ -int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers the applciation along with the GATT services of the aplciation it is hosting - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * - * @see bt_gatt_server_initialize() - * @see bt_gatt_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_start(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Sends a response to the remote device as a result of a read request - * @since_tizen 2.4 - * - * @remarks Until this function is called, a read request is not finished. - * - * @param[in] request_id The identification of a read/write request - * @param[in] request_type The request type for read/write. - * @param[in] offset The offset from where a value is read - * @param[in] resp_status The applciation error if any occured or BT_ERROR_NONE for successful. - * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. - * @param[in] value_length Value Length - * @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_server_read_value_requested_cb() - */ -int bt_gatt_server_send_response(int request_id, int request_type, - int offset, int resp_status, char *value, int value_length); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor - * @since_tizen 2.4 - * - * @param[in] characteristic The characteristic which has a changed value - * @param[in] need_confirm If it is true, an indication is sent. If it is false, a notification is sent. - * @param[in] callback The function to be invoked on each remote device when a sending operation is done - * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_sent_cb() - */ -int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm, - bt_gatt_server_notification_sent_cb callback, - const char *device_address, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID - * @since_tizen 2.4 - * - * @remark The returned GATT handle must not be freed by application. - * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). - * If there are multiple services which have same UUID, only the first matched one will be returned. - * - * @param[in] server The GATT server's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists - * @param[out] service The service's GATT handle which has @a uuid if it exists - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NO_DATA No data available - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - */ -int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT server - * @since_tizen 2.4 - * - * @param[in] server The GATT server's handle - * @param[in] callback The function to be invoked on each service - * @param[in] user_data The user data to be passed to @a callback function - * @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_foreach_cb() + * @see bt_gatt_characteristic_create() + * @see bt_gatt_descriptor_create() */ -int bt_gatt_server_foreach_services(bt_gatt_server_h server, - bt_gatt_foreach_cb callback, void *user_data); +int bt_gatt_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE diff --git a/include/mobile/bluetooth_type.h b/include/mobile/bluetooth_type.h index ccddfb7..43ca353 100644 --- a/include/mobile/bluetooth_type.h +++ b/include/mobile/bluetooth_type.h @@ -627,7 +627,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the integer type for GATT handle's value + * @brief Enumerations of the integer type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -641,7 +641,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the float type for GATT handle's value + * @brief Enumerations of the float type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -651,7 +651,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the write type + * @brief Enumerations of the write type. * @since_tizen 2.3.1 */ typedef enum { @@ -661,7 +661,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the GATT handle's type + * @brief Enumerations of the GATT handle's type. * @since_tizen 2.3.1 */ typedef enum { @@ -672,7 +672,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the service type + * @brief Enumerations of the service type. * @since_tizen 2.3.1 */ typedef enum { @@ -682,7 +682,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the characteristic's property + * @brief Enumerations of the characteristic's property. * @since_tizen 2.3.1 */ typedef enum { @@ -696,9 +696,33 @@ typedef enum { BT_GATT_PROPERTY_EXTENDED_PROPERTIES = 0x80, /**< Extended properties */ } bt_gatt_property_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the attribute's permission. + * @since_tizen 3.0 + */ +typedef enum { + BT_GATT_PERMISSION_READ = 0x01, /**< Read permission */ + BT_GATT_PERMISSION_WRITE = 0x02, /**< Write permission */ + BT_GATT_PERMISSION_ENCRYPTION = 0x04, /**< Encryption permission */ + BT_GATT_PERMISSION_AUTHENTICATION = 0x08, /**< Authentication permission */ + BT_GATT_PERMISSION_AUTHORIZATION = 0x10, /**< Authorization permission */ + BT_GATT_PERMISSION_NONE = 0x20, /**< None */ +} bt_gatt_permission_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the remote device request types for attributes + * @since_tizen 3.0 + */ +typedef enum { + BLUETOOTH_GATT_REQUEST_TYPE_READ = 0x00, /* Read Requested */ + BLUETOOTH_GATT_REQUEST_TYPE_WRITE = 0x01, /* Write Requested */ +} bluetooth_gatt_att_request_type_e; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Enumerations for the types of PAN(Personal Area Networking) service + * @brief Enumerations for the types of PAN(Personal Area Networking) service. * @since_tizen 2.3 */ typedef enum { @@ -707,7 +731,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle to control Bluetooth LE advertising + * @brief The handle to control Bluetooth LE advertising. * @since_tizen 2.3 */ typedef void *bt_advertiser_h; @@ -715,28 +739,35 @@ typedef void *bt_advertiser_h; /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_h instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief The attribute handle of GATT(Generic Attribute Profile) + * @brief The attribute handle of GATT(Generic Attribute Profile). * @since_tizen 2.3 */ typedef void *bt_gatt_attribute_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a service, characteristic or descriptor + * @brief The handle of a service, characteristic or descriptor. * @since_tizen 2.3.1 */ typedef void *bt_gatt_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT client which is associated with a remote device + * @brief The handle of a GATT client which is associated with a remote device. * @since_tizen 2.3.1 */ typedef void *bt_gatt_client_h; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief The handle of a GATT server. + * @since_tizen 3.0 + */ +typedef void *bt_gatt_server_h; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief The handle of calls state + * @brief The handle of calls state. * @since_tizen 2.3 */ typedef void *bt_call_list_h; @@ -818,7 +849,7 @@ typedef struct { /** * @deprecated Deprecated since 2.3.1 * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Structure of advertising parameters + * @brief Structure of advertising parameters. * @since_tizen 2.3 * * @see bt_adapter_le_advertising_state_changed_cb() @@ -835,7 +866,7 @@ typedef struct { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief LE service data structure + * @brief LE service data structure. * @since_tizen 2.3.1 * * @see bt_adapter_le_get_scan_result_service_data() @@ -1672,7 +1703,7 @@ typedef void (*bt_gatt_client_request_completed_cb) (int result, * @brief Called when a value of a watched characteristic's GATT handle has been changed * @since_tizen 2.3.1 * - * @remarks After this function is returned, a changed vlaue is automatically + * @remarks After this function is returned, a changed value is automatically * applied to @a characteristic. Before that, @a characteristic has an old value. * * @param[in] characteristic The characteristic's GATT handle of which value change is informed. It has an old value. @@ -1705,6 +1736,108 @@ typedef void (*bt_gatt_client_characteristic_value_changed_cb) (bt_gatt_h charac */ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected, const char *remote_address, void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks After this function is returned, a changed value is automatically + * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * @remarks The @a value must not be freed by application. + * + * @param[in] remote_address The address of the remote device which requests a change + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value + * @param[in] offset The requested offset from where the @a gatt_handle value will be updated + * @param[in] value The new value + * @param[in] len The length of @a value + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_write_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, + const char *value, int len, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device requests to read a value on a GATT server. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] remote_address The address of the requesting remote device + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read + * @param[in] offset The requested offset from where the GATT handle's value is read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_read_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @details By using this callback function, server can know notification state. + * + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] notify Indicates whether the Notification/Indication is enabled or not + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic's GATT handle to be read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + */ +typedef void (*bt_gatt_server_characteristic_notification_state_changed_cb) (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the sending notification / indication is done. + * @since_tizen 3.0 + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a characteristic must not be freed by application. + * + * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n + * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n + * For the last remote device, @a completed will be set as true. + * + * @param[in] result The result of a sending operation + * @param[in] remote_address The address of the remote device + * @param[in] server The GATT server handle + * @param[in] characteristic The characteristic's GATT handle + * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. + * @param[in] user_data The user data passed from the requesting function + * + * @see bt_gatt_server_notify_characteristic_changed_value() + */ +typedef void (*bt_gatt_server_notification_sent_cb) (int result, + const char *remote_address, bt_gatt_server_h server, + bt_gatt_h characteristic, bool completed, void *user_data); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE * @brief Called when the connection state is changed. diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h index 3c59412..877572a 100644 --- a/include/mobile/bluetooth_type_internal.h +++ b/include/mobile/bluetooth_type_internal.h @@ -154,20 +154,6 @@ typedef enum { typedef void (*bt_adapter_manufacturer_data_changed_cb) (char *data, int len, void *user_data); -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the attribute's permission - * @since_tizen 2.4 - */ -typedef enum { - BT_GATT_PERMISSION_READ = 0x01, - BT_GATT_PERMISSION_WRITE = 0x02, - BT_GATT_PERMISSION_ENCRYPTION = 0x04, - BT_GATT_PERMISSION_AUTHENTICATION = 0x08, - BT_GATT_PERMISSION_AUTHORIZATION = 0x10, - BT_GATT_PERMISSION_NONE = 0x20, -} bt_gatt_permission_e; - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DPM_MODULE * @brief DPM BT allowance state @@ -224,92 +210,6 @@ typedef enum { */ typedef void *bt_scan_filter_h; -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT server - * @since_tizen 2.4 - */ -typedef void *bt_gatt_server_h; - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed - * @since_tizen 2.4 - * - * @remarks After this function is returned, a changed vlaue is automatically - * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. - * - * @param[in] remote_address The address of the remote device which requests a change - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the @a gatt_handle value will be updated - * @param[in] value The new value - * @param[in] len The length of @a value - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_write_value_requested_cb() - */ -typedef void (*bt_gatt_server_write_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, int offset, - char *value, int len, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device requests to read a value on a GATT server - * @since_tizen 2.4 - * - * @param[in] remote_address The address of the requesting remote device - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the GATT handle's value is read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic's GATT handle to be read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - */ -typedef void (*bt_gatt_server_notification_state_change_cb) (bool notify, - bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the sending notification / indication is done - * @since_tizen 2.4 - * - * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n - * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n - * For the last remote device, @a completed will be set as true. - * - * @param[in] result The result of a sending operation - * @param[in] remote_address The address of the remote device - * @param[in] server The GATT server handle - * @param[in] characteristic The characteristic's GATT handle - * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. - * @param[in] user_data The user data passed from the requesting function - * - * @see bt_gatt_server_notify() - */ -typedef void (*bt_gatt_server_notification_sent_cb) (int result, - char *remote_address, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void *user_data); - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Device LE connection update structure. @@ -322,7 +222,6 @@ typedef struct { unsigned int time_out; /**< Supervision timeout (msec) */ } bt_le_conn_update_s; - /** * Structure to DPM device list */ diff --git a/include/tv/bluetooth.h b/include/tv/bluetooth.h index f38f5e2..b73ac44 100644 --- a/include/tv/bluetooth.h +++ b/include/tv/bluetooth.h @@ -23,7 +23,7 @@ #include #include -#include "bluetooth_type.h" +#include #ifdef __cplusplus extern "C" @@ -3746,7 +3746,7 @@ int bt_gatt_unset_characteristic_changed_cb(void); /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_set_characteristic_value_changed_cb instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Watches all the characteristic value changes of the service + * @brief Watches all the characteristic value changes of the service. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3766,7 +3766,7 @@ int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service); /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_unset_characteristic_value_changed_cb instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Remove watching of all the characteristic value changes of the service + * @brief Remove watching of all the characteristic value changes of the service. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3894,7 +3894,7 @@ int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle); /** * @deprecated Deprecated since 2.3.1. Use gatt_client_read_value instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Reads the value of characteristic from remote device + * @brief Reads the value of characteristic from remote device. * @since_tizen 2.3 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3942,7 +3942,7 @@ int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristi /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle + * @brief Gets the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a value must be released using free(). \n @@ -3961,7 +3961,7 @@ int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type + * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -3982,7 +3982,7 @@ int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type + * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -4003,7 +4003,7 @@ int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle + * @brief Updates the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4023,7 +4023,7 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4045,7 +4045,7 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -4068,7 +4068,7 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle + * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a uuid must be released using free(). \n @@ -4085,7 +4085,7 @@ int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the type of GATT handle + * @brief Gets the type of GATT handle. * @since_tizen 2.3.1 * * @param[in] gatt_handle The GATT handle @@ -4099,7 +4099,7 @@ int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT client handle which the specified service belongs to + * @brief Gets the GATT client handle which the specified service belongs to. * @since_tizen 2.3.1 * * @remark This function doesn't allocate new memory for GATT client handle. @@ -4119,7 +4119,7 @@ int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a characteristic's GATT handle which has specific UUID + * @brief Gets a characteristic's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4140,7 +4140,7 @@ int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each characteristic that belongs to the specified service + * @brief Invokes @a callback function on each characteristic that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -4158,7 +4158,7 @@ int bt_gatt_service_foreach_characteristics(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets an included service's GATT handle which has specific UUID + * @brief Gets an included service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4179,7 +4179,7 @@ int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each included service that belongs to the specified service + * @brief Invokes @a callback function on each included service that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -4197,7 +4197,7 @@ int bt_gatt_service_foreach_included_services(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the service's GATT handle which the specified characteristic belongs to + * @brief Gets the service's GATT handle which the specified characteristic belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4214,7 +4214,7 @@ int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *serv /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the properties which a characteristic's GATT handle has + * @brief Gets the properties which a characteristic's GATT handle has. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4230,7 +4230,7 @@ int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *propert /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the write type of the specified characteristic + * @brief Gets the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4247,7 +4247,7 @@ int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the write type of the specified characteristic + * @brief Updates the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4265,7 +4265,7 @@ int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a descriptor's GATT handle which has specific UUID + * @brief Gets a descriptor's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4286,7 +4286,7 @@ int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char * /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic + * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4304,7 +4304,7 @@ int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to + * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4321,7 +4321,7 @@ int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *chara /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT client handle + * @brief Creates the GATT client handle. * @since_tizen 2.3.1 * * @remark The GATT client handle must be freed by bt_gatt_client_destroy() after use @@ -4341,7 +4341,7 @@ int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT client's handle + * @brief Destroys the GATT client's handle. * @since_tizen 2.3.1 * * @remark All related service, characteristic and descriptor's GATT handles are freed also @@ -4358,7 +4358,7 @@ int bt_gatt_client_destroy(bt_gatt_client_h client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the address of remote device + * @brief Gets the address of remote device. * @since_tizen 2.3.1 * * @param[in] client The created GATT client's handle @@ -4375,7 +4375,7 @@ int bt_gatt_client_get_remote_address(bt_gatt_client_h client, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously + * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -4401,7 +4401,7 @@ int bt_gatt_client_read_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously + * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -4431,7 +4431,7 @@ int bt_gatt_client_write_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -4452,7 +4452,7 @@ int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle, whose value change will not be informed @@ -4468,7 +4468,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID + * @brief Gets a service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -4476,7 +4476,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi * If there are multiple services which have same UUID, only the first matched one will be returned. * * @param[in] client The GATT client's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists * @param[out] service The service's GATT handle which has @a uuid if it exists * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful @@ -4489,7 +4489,7 @@ int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT client + * @brief Invokes @a callback function on each service that belongs to the specified GATT client. * @since_tizen 2.3.1 * * @param[in] client The GATT client's handle @@ -4601,6 +4601,529 @@ int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb */ int bt_gatt_unset_connection_state_changed_cb(void); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of service. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of service + * @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_service_create() + */ +int bt_gatt_service_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of characteristic. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of characteristic + * @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() + */ +int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of descriptor. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of descriptor + * @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() + */ +int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the permissions which a characteristic's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_SERVER_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT service. + * @since_tizen 3.0 + * + * @remarks The @a service should be destroyed by using bt_gatt_service_destroy() + * + * @param[in] uuid The UUID of the service + * @param[in] type The type of the service + * @param[out] service The GATT handle of the created service + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_service_destroy() + */ +int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a characteristic to a specified service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] characteristic The characteristic's GATT handle to be added + * @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_service_create() + * @see bt_gatt_characteristic_create() + */ +int bt_gatt_service_add_characteristic(bt_gatt_h service, + bt_gatt_h characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a service to a specified service as included service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] included_service The service's GATT handle to be added as included service + * @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_service_create() + */ +int bt_gatt_service_add_included_service(bt_gatt_h service, + bt_gatt_h included_service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the GATT server handle to which the specified service belongs. + * @since_tizen 3.0 + * + * @remarks The returned Server handle must not be freed by application. + * + * @param[in] service The service's GATT handle + * @param[out] server The GATT server handle to which @a service belongs + * @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_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_register_service() + */ +int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a properties can be one or more values of #bt_gatt_property_e, combined with bitwise 'or'. + * @remarks The @a characteristic should be destroyed by using bt_gatt_characteristic_destroy(). + * + * @param[in] uuid The UUID of the characteristic + * @param[in] permissions the permissions of the characteristic + * @param[in] properties The properties of the characteristic + * @param[in] Value The value(byte stream) of the characteristic + * @param[in] value_length The length of @a value + * @param[out] characteristic The GATT handle of the created characteristic + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_characteristic_destroy() + */ +int bt_gatt_characteristic_create(const char *uuid, int permissions, + int properties, const char *value, int value_length, + bt_gatt_h *characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a descriptor to a specified characteristic. + * @since_tizen 3.0 + * + * @param[in] characteristic The GATT handle of the characteristic + * @param[in] descriptor The descriptor's GATT handle to be added + * @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_descriptor_create() + */ +int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, + bt_gatt_h descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic descriptor. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a descriptor should be destroyed by using bt_gatt_descriptor_destroy() + * + * @param[in] uuid The UUID of the descriptor + * @param[in] permissions The permissions of the descriptor + * @param[in] value The value(byte stream) associated with the descriptor + * @param[in] value_length The length of @a value + * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_descriptor_destroy() + */ +int bt_gatt_descriptor_create(const char *uuid, int permissions, + const char *value, int value_length, + bt_gatt_h *descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Initializes the GATT Server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_deinitialize() + */ +int bt_gatt_server_initialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief DeInitializes the GATT server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_initialize() + */ +int bt_gatt_server_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT server's handle. + * @since_tizen 3.0 + * + * @param[out] server The GATT server's handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_destroy() + */ +int bt_gatt_server_create(bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT server's handle. + * @since_tizen 3.0 + * + * @remarks All registered services to GATT server are unregistered + * + * @param[in] server The GATT server's handle + * @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_server_create() + */ +int bt_gatt_server_destroy(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client). + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_read_value_requested_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_characteristic_notification_state_changed_cb() + */ +int bt_gatt_server_set_characteristic_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_characteristic_notification_state_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_write_value_requested_cb() + */ +int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_write_value_requested_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a specified service to the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be registered in @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_start() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters a specified service from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be unregistered from @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters all services from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers the application along with the GATT services of the application it is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_initialize() + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_start(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Sends a response to the remote device as a result of a read/write request. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks Until this function is called, a read/write request is not finished. + * + * @param[in] request_id The identification of a read/write request + * @param[in] request_type The request type for read/write + * @param[in] offset The offset from where a value is read + * @param[in] resp_status The application error if any occurred or BT_ERROR_NONE for successful. + * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. + * @param[in] value_length Value Length + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_read_value_requested_cb() + */ +int bt_gatt_server_send_response(int request_id, bluetooth_gatt_att_request_type_e request_type, + int offset, int resp_status, char *value, int value_length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor. + * @since_tizen 3.0 + * + * @param[in] characteristic The characteristic which has a changed value + * @param[in] callback The function to be invoked on each remote device when a sending operation is done + * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_notification_sent_cb() + */ +int bt_gatt_server_notify_characteristic_changed_value(bt_gatt_h characteristic, + bt_gatt_server_notification_sent_cb callback, + const char *device_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets a service's GATT handle which has specific UUID. + * @since_tizen 3.0 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). + * If there are multiple services which have same UUID, only the first matched one will be returned. + * + * @param[in] server The GATT server's handle + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists + * @param[out] service The service's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Invokes @a callback function on each service that belongs to the specified GATT server. + * @since_tizen 3.0 + * + * @param[in] server The GATT server's handle + * @param[in] callback The function to be invoked on each service + * @param[in] user_data The user data to be passed to @a callback function + * @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_foreach_cb() + */ +int bt_gatt_server_foreach_services(bt_gatt_server_h server, + bt_gatt_foreach_cb callback, void *user_data); + /** * @} */ diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h index cedf9dc..f393187 100644 --- a/include/tv/bluetooth_internal.h +++ b/include/tv/bluetooth_internal.h @@ -1752,105 +1752,9 @@ int bt_a2dp_set_content_protection(bool status); int bt_gatt_get_uuid_specification_name(const char *uuid, char **name); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service, characteristic or descriptor - * @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_service_create() - * @see bt_gatt_characteristic_create() - * @see bt_gatt_descriptor_create() - */ -int bt_gatt_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service - * @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_service_create() - */ -int bt_gatt_service_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of characteristic - * @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() - */ -int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of descriptor - * @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() - */ -int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic's GATT handle has - * @since_tizen 2.4 - * - * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the permissions which a characteristic or descriptor's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the permissions which a characteristic or descriptor's GATT handle has. + * @since_tizen 3.0 * * @param[in] gatt_handle The handle of a characteristic or descriptor * @param[in] permissions The permissions to be updated @@ -1866,122 +1770,9 @@ int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); int bt_gatt_set_permissions(bt_gatt_h gatt_handle, int permissions); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT service - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the service - * @param[in] type The type of the service - * @param[out] service The GATT handle of the created service - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a characteristic to a specified service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] characteristic The characteristic's GATT handle to be added - * @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_service_create() - * @see bt_gatt_characteristic_create() - */ -int bt_gatt_service_add_characteristic(bt_gatt_h service, - bt_gatt_h characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a service to a specified service as included service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] included_service The service's GATT handle to be added as included service - * @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_service_create() - */ -int bt_gatt_service_add_included_service(bt_gatt_h service, - bt_gatt_h included_service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT server handle to which the specified service belongs - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[out] server The GATT server handle to which @a service belongs - * @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_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_register_service() - */ -int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the characteristic - * @param[in] permissions the permissions of the characteristic - * @param[in] properties The properties of the characteristic - * @param[in] Value The value(byte stream) of the characteristic - * @param[in] value_length The length of @a value - * @param[out] characteristic The GATT handle of the created characteristic - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_characteristic_create(const char *uuid, int permissions, - int properties, const char *value, int value_length, - bt_gatt_h *characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a descriptor to a specified characteristic - * @since_tizen 2.4 - * - * @param[in] characteristic The GATT handle of the characteristic - * @param[in] descriptor The descriptor's GATT handle to be added - * @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_descriptor_create() - */ -int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, - bt_gatt_h descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the properties which a characteristic's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the properties which a characteristic's GATT handle has. + * @since_tizen 3.0 * * @param[in] characteristic The characteristic's GATT handle * @param[in] properties The properties to be updated @@ -1996,307 +1787,20 @@ int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properti /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic descriptor + * @brief Destroys the GATT handle * @since_tizen 2.4 * - * @param[in] uuid The UUID of the descriptor - * @param[in] permissions The permissions of the descriptor - * @param[in] value The value(byte stream) associated with the descriptor - * @param[in] value_length The length of @a value - * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @param[in] gatt_handle The handle of service, characteristic or descriptor * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_descriptor_create(const char *uuid, int permissions, - const char *value, int value_length, - bt_gatt_h *descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Initializes the GATT Server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_deinitialize() - */ -int bt_gatt_server_initialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief DeInitializes the GATT server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_initialize() - */ -int bt_gatt_server_deinitialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT server's handle - * @since_tizen 2.4 - * - * @param[out] server The GATT server's handle - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_destroy() - */ -int bt_gatt_server_create(bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT server's handle - * @since_tizen 2.4 - * - * @remarks All registered services to GATT server are unregistered - * - * @param[in] server The GATT server's handle - * @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_server_create() - */ -int bt_gatt_server_destroy(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client) - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_read_value_requested_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_state_change_cb() - */ -int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, - bt_gatt_server_notification_state_change_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_write_value_requested_cb() - */ -int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_write_value_requested_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a specified service to the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be registered in @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done * @retval #BT_ERROR_NOT_SUPPORTED Not supported * - * @see bt_gatt_server_create() * @see bt_gatt_service_create() - * @see bt_gatt_server_start() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a specified service from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be unregistered from @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_register_service() - */ -int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters all services from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @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_server_register_service() - */ -int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers the applciation along with the GATT services of the aplciation it is hosting - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * - * @see bt_gatt_server_initialize() - * @see bt_gatt_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_start(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Sends a response to the remote device as a result of a read request - * @since_tizen 2.4 - * - * @remarks Until this function is called, a read request is not finished. - * - * @param[in] request_id The identification of a read/write request - * @param[in] request_type The request type for read/write. - * @param[in] offset The offset from where a value is read - * @param[in] resp_status The applciation error if any occured or BT_ERROR_NONE for successful. - * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. - * @param[in] value_length Value Length - * @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_server_read_value_requested_cb() - */ -int bt_gatt_server_send_response(int request_id, int request_type, - int offset, int resp_status, char *value, int value_length); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor - * @since_tizen 2.4 - * - * @param[in] characteristic The characteristic which has a changed value - * @param[in] need_confirm If it is true, an indication is sent. If it is false, a notification is sent. - * @param[in] callback The function to be invoked on each remote device when a sending operation is done - * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_sent_cb() - */ -int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm, - bt_gatt_server_notification_sent_cb callback, - const char *device_address, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID - * @since_tizen 2.4 - * - * @remark The returned GATT handle must not be freed by application. - * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). - * If there are multiple services which have same UUID, only the first matched one will be returned. - * - * @param[in] server The GATT server's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists - * @param[out] service The service's GATT handle which has @a uuid if it exists - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NO_DATA No data available - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - */ -int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT server - * @since_tizen 2.4 - * - * @param[in] server The GATT server's handle - * @param[in] callback The function to be invoked on each service - * @param[in] user_data The user data to be passed to @a callback function - * @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_foreach_cb() + * @see bt_gatt_characteristic_create() + * @see bt_gatt_descriptor_create() */ -int bt_gatt_server_foreach_services(bt_gatt_server_h server, - bt_gatt_foreach_cb callback, void *user_data); +int bt_gatt_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE diff --git a/include/tv/bluetooth_type.h b/include/tv/bluetooth_type.h index 9da5a01..f005951 100644 --- a/include/tv/bluetooth_type.h +++ b/include/tv/bluetooth_type.h @@ -627,7 +627,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the integer type for GATT handle's value + * @brief Enumerations of the integer type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -641,7 +641,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the float type for GATT handle's value + * @brief Enumerations of the float type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -651,7 +651,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the write type + * @brief Enumerations of the write type. * @since_tizen 2.3.1 */ typedef enum { @@ -661,7 +661,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the GATT handle's type + * @brief Enumerations of the GATT handle's type. * @since_tizen 2.3.1 */ typedef enum { @@ -672,7 +672,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the service type + * @brief Enumerations of the service type. * @since_tizen 2.3.1 */ typedef enum { @@ -682,7 +682,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the characteristic's property + * @brief Enumerations of the characteristic's property. * @since_tizen 2.3.1 */ typedef enum { @@ -696,9 +696,33 @@ typedef enum { BT_GATT_PROPERTY_EXTENDED_PROPERTIES = 0x80, /**< Extended properties */ } bt_gatt_property_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the attribute's permission. + * @since_tizen 3.0 + */ +typedef enum { + BT_GATT_PERMISSION_READ = 0x01, /**< Read permission */ + BT_GATT_PERMISSION_WRITE = 0x02, /**< Write permission */ + BT_GATT_PERMISSION_ENCRYPTION = 0x04, /**< Encryption permission */ + BT_GATT_PERMISSION_AUTHENTICATION = 0x08, /**< Authentication permission */ + BT_GATT_PERMISSION_AUTHORIZATION = 0x10, /**< Authorization permission */ + BT_GATT_PERMISSION_NONE = 0x20, /**< None */ +} bt_gatt_permission_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the remote device request types for attributes + * @since_tizen 3.0 + */ +typedef enum { + BLUETOOTH_GATT_REQUEST_TYPE_READ = 0x00, /* Read Requested */ + BLUETOOTH_GATT_REQUEST_TYPE_WRITE = 0x01, /* Write Requested */ +} bluetooth_gatt_att_request_type_e; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Enumerations for the types of PAN(Personal Area Networking) service + * @brief Enumerations for the types of PAN(Personal Area Networking) service. * @since_tizen 2.3 */ typedef enum { @@ -707,7 +731,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle to control Bluetooth LE advertising + * @brief The handle to control Bluetooth LE advertising. * @since_tizen 2.3 */ typedef void *bt_advertiser_h; @@ -715,28 +739,35 @@ typedef void *bt_advertiser_h; /** * @deprecated Deprecated since 2.3.1. Use bt_gatt_h instead. * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief The attribute handle of GATT(Generic Attribute Profile) + * @brief The attribute handle of GATT(Generic Attribute Profile). * @since_tizen 2.3 */ typedef void *bt_gatt_attribute_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a service, characteristic or descriptor + * @brief The handle of a service, characteristic or descriptor. * @since_tizen 2.3.1 */ typedef void *bt_gatt_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT client which is associated with a remote device + * @brief The handle of a GATT client which is associated with a remote device. * @since_tizen 2.3.1 */ typedef void *bt_gatt_client_h; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief The handle of a GATT server. + * @since_tizen 3.0 + */ +typedef void *bt_gatt_server_h; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief The handle of calls state + * @brief The handle of calls state. * @since_tizen 2.3 */ typedef void *bt_call_list_h; @@ -818,7 +849,7 @@ typedef struct { /** * @deprecated Deprecated since 2.3.1 * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Structure of advertising parameters + * @brief Structure of advertising parameters. * @since_tizen 2.3 * * @see bt_adapter_le_advertising_state_changed_cb() @@ -835,7 +866,7 @@ typedef struct { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief LE service data structure + * @brief LE service data structure. * @since_tizen 2.3.1 * * @see bt_adapter_le_get_scan_result_service_data() @@ -1674,7 +1705,7 @@ typedef void (*bt_gatt_client_request_completed_cb) (int result, * @brief Called when a value of a watched characteristic's GATT handle has been changed * @since_tizen 2.3.1 * - * @remarks After this function is returned, a changed vlaue is automatically + * @remarks After this function is returned, a changed value is automatically * applied to @a characteristic. Before that, @a characteristic has an old value. * * @param[in] characteristic The characteristic's GATT handle of which value change is informed. It has an old value. @@ -1707,6 +1738,108 @@ typedef void (*bt_gatt_client_characteristic_value_changed_cb) (bt_gatt_h charac */ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected, const char *remote_address, void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks After this function is returned, a changed value is automatically + * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * @remarks The @a value must not be freed by application. + * + * @param[in] remote_address The address of the remote device which requests a change + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value + * @param[in] offset The requested offset from where the @a gatt_handle value will be updated + * @param[in] value The new value + * @param[in] len The length of @a value + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_write_value_requested_cb()a + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, + const char *value, int len, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device requests to read a value on a GATT server. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] remote_address The address of the requesting remote device + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read + * @param[in] offset The requested offset from where the GATT handle's value is read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_read_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @details By using this callback function, server can know notification state. + * + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] notify Indicates whether the Notification/Indication is enabled or not + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic's GATT handle to be read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + */ +typedef void (*bt_gatt_server_characteristic_notification_state_changed_cb) (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the sending notification / indication is done. + * @since_tizen 3.0 + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a characteristic must not be freed by application. + * + * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n + * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n + * For the last remote device, @a completed will be set as true. + * + * @param[in] result The result of a sending operation + * @param[in] remote_address The address of the remote device + * @param[in] server The GATT server handle + * @param[in] characteristic The characteristic's GATT handle + * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. + * @param[in] user_data The user data passed from the requesting function + * + * @see bt_gatt_server_notify_characteristic_changed_value() + */ +typedef void (*bt_gatt_server_notification_sent_cb) (int result, + const char *remote_address, bt_gatt_server_h server, + bt_gatt_h characteristic, bool completed, void *user_data); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE * @brief Called when the connection state is changed. diff --git a/include/tv/bluetooth_type_internal.h b/include/tv/bluetooth_type_internal.h index 85159c4..e3872b7 100644 --- a/include/tv/bluetooth_type_internal.h +++ b/include/tv/bluetooth_type_internal.h @@ -154,20 +154,6 @@ typedef enum { typedef void (*bt_adapter_manufacturer_data_changed_cb) (char *data, int len, void *user_data); -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the attribute's permission - * @since_tizen 2.4 - */ -typedef enum { - BT_GATT_PERMISSION_READ = 0x01, - BT_GATT_PERMISSION_WRITE = 0x02, - BT_GATT_PERMISSION_ENCRYPTION = 0x04, - BT_GATT_PERMISSION_AUTHENTICATION = 0x08, - BT_GATT_PERMISSION_AUTHORIZATION = 0x10, - BT_GATT_PERMISSION_NONE = 0x20, -} bt_gatt_permission_e; - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DPM_MODULE * @brief DPM BT allowance state @@ -224,92 +210,6 @@ typedef enum { */ typedef void *bt_scan_filter_h; -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT server - * @since_tizen 2.4 - */ -typedef void *bt_gatt_server_h; - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed - * @since_tizen 2.4 - * - * @remarks After this function is returned, a changed vlaue is automatically - * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. - * - * @param[in] remote_address The address of the remote device which requests a change - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the @a gatt_handle value will be updated - * @param[in] value The new value - * @param[in] len The length of @a value - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_write_value_requested_cb() - */ -typedef void (*bt_gatt_server_write_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, int offset, - char *value, int len, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device requests to read a value on a GATT server - * @since_tizen 2.4 - * - * @param[in] remote_address The address of the requesting remote device - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the GATT handle's value is read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic's GATT handle to be read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - */ -typedef void (*bt_gatt_server_notification_state_change_cb) (bool notify, - bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the sending notification / indication is done - * @since_tizen 2.4 - * - * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n - * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n - * For the last remote device, @a completed will be set as true. - * - * @param[in] result The result of a sending operation - * @param[in] remote_address The address of the remote device - * @param[in] server The GATT server handle - * @param[in] characteristic The characteristic's GATT handle - * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. - * @param[in] user_data The user data passed from the requesting function - * - * @see bt_gatt_server_notify() - */ -typedef void (*bt_gatt_server_notification_sent_cb) (int result, - char *remote_address, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void *user_data); - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Device LE connection update structure. @@ -322,7 +222,6 @@ typedef struct { unsigned int time_out; /**< Supervision timeout (msec) */ } bt_le_conn_update_s; - /** * Structure to DPM device list */ diff --git a/include/wearable/bluetooth.h b/include/wearable/bluetooth.h index 1bb867b..03a8dcb 100644 --- a/include/wearable/bluetooth.h +++ b/include/wearable/bluetooth.h @@ -23,7 +23,7 @@ #include #include -#include "bluetooth_type.h" +#include #ifdef __cplusplus extern "C" @@ -3385,7 +3385,7 @@ int bt_hdp_unset_data_received_cb(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle + * @brief Gets the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a value must be released using free(). \n @@ -3404,7 +3404,7 @@ int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type + * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -3425,7 +3425,7 @@ int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type + * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type. * @since_tizen 2.3.1 * * @remarks This function returns a locally saved value in @a gatt_handle. \n @@ -3446,7 +3446,7 @@ int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle + * @brief Updates the value of a characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -3466,7 +3466,7 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -3488,7 +3488,7 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value + * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value. * @since_tizen 2.3.1 * * @remarks This function updates a value of @a gatt_handle locally. \n @@ -3511,7 +3511,7 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle + * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle. * @since_tizen 2.3.1 * * @remarks @a uuid must be released using free(). \n @@ -3528,7 +3528,7 @@ int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the type of GATT handle + * @brief Gets the type of GATT handle. * @since_tizen 2.3.1 * * @param[in] gatt_handle The GATT handle @@ -3542,7 +3542,7 @@ int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT client handle which the specified service belongs to + * @brief Gets the GATT client handle which the specified service belongs to. * @since_tizen 2.3.1 * * @remark This function doesn't allocate new memory for GATT client handle. @@ -3562,7 +3562,7 @@ int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a characteristic's GATT handle which has specific UUID + * @brief Gets a characteristic's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3583,7 +3583,7 @@ int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each characteristic that belongs to the specified service + * @brief Invokes @a callback function on each characteristic that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -3601,7 +3601,7 @@ int bt_gatt_service_foreach_characteristics(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets an included service's GATT handle which has specific UUID + * @brief Gets an included service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3622,7 +3622,7 @@ int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each included service that belongs to the specified service + * @brief Invokes @a callback function on each included service that belongs to the specified service. * @since_tizen 2.3.1 * * @param[in] service The service's GATT handle @@ -3640,7 +3640,7 @@ int bt_gatt_service_foreach_included_services(bt_gatt_h service, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the service's GATT handle which the specified characteristic belongs to + * @brief Gets the service's GATT handle which the specified characteristic belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3657,7 +3657,7 @@ int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *serv /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the properties which a characteristic's GATT handle has + * @brief Gets the properties which a characteristic's GATT handle has. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -3673,7 +3673,7 @@ int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *propert /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the write type of the specified characteristic + * @brief Gets the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -3690,7 +3690,7 @@ int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the write type of the specified characteristic + * @brief Updates the write type of the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -3708,7 +3708,7 @@ int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a descriptor's GATT handle which has specific UUID + * @brief Gets a descriptor's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3729,7 +3729,7 @@ int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char * /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic + * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -3747,7 +3747,7 @@ int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to + * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3764,7 +3764,7 @@ int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *chara /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT client handle + * @brief Creates the GATT client handle. * @since_tizen 2.3.1 * * @remark The GATT client handle must be freed by bt_gatt_client_destroy() after use @@ -3784,7 +3784,7 @@ int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT client's handle + * @brief Destroys the GATT client's handle. * @since_tizen 2.3.1 * * @remark All related service, characteristic and descriptor's GATT handles are freed also @@ -3801,7 +3801,7 @@ int bt_gatt_client_destroy(bt_gatt_client_h client); /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the address of remote device + * @brief Gets the address of remote device. * @since_tizen 2.3.1 * * @param[in] client The created GATT client's handle @@ -3818,7 +3818,7 @@ int bt_gatt_client_get_remote_address(bt_gatt_client_h client, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously + * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3844,7 +3844,7 @@ int bt_gatt_client_read_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously + * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously. * @since_tizen 2.3.1 * @privlevel public * @privilege %http://tizen.org/privilege/bluetooth @@ -3874,7 +3874,7 @@ int bt_gatt_client_write_value(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle @@ -3895,7 +3895,7 @@ int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device + * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device. * @since_tizen 2.3.1 * * @param[in] characteristic The characteristic's GATT handle, whose value change will not be informed @@ -3911,7 +3911,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID + * @brief Gets a service's GATT handle which has specific UUID. * @since_tizen 2.3.1 * * @remark The returned GATT handle must not be freed by application. @@ -3919,7 +3919,7 @@ int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristi * If there are multiple services which have same UUID, only the first matched one will be returned. * * @param[in] client The GATT client's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists * @param[out] service The service's GATT handle which has @a uuid if it exists * @return 0 on success, otherwise a negative error value * @retval #BT_ERROR_NONE Successful @@ -3932,7 +3932,7 @@ int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT client + * @brief Invokes @a callback function on each service that belongs to the specified GATT client. * @since_tizen 2.3.1 * * @param[in] client The GATT client's handle @@ -4044,6 +4044,531 @@ int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb */ int bt_gatt_unset_connection_state_changed_cb(void); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of service. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of service + * @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_service_create() + */ +int bt_gatt_service_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of characteristic. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of characteristic + * @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() + */ +int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT handle of descriptor. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The handle of descriptor + * @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() + */ +int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the permissions which a characteristic's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_SERVER_MODULE + * @brief Gets the permissions which a descriptor's GATT handle has. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * + * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT service. + * @since_tizen 3.0 + * + * @remarks The @a service should be destroyed by using bt_gatt_service_destroy() + * + * @param[in] uuid The UUID of the service + * @param[in] type The type of the service + * @param[out] service The GATT handle of the created service + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_service_destroy() + */ +int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a characteristic to a specified service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] characteristic The characteristic's GATT handle to be added + * @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_service_create() + * @see bt_gatt_characteristic_create() + */ +int bt_gatt_service_add_characteristic(bt_gatt_h service, + bt_gatt_h characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a service to a specified service as included service. + * @since_tizen 3.0 + * + * @param[in] service The service's GATT handle + * @param[in] included_service The service's GATT handle to be added as included service + * @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_service_create() + */ +int bt_gatt_service_add_included_service(bt_gatt_h service, + bt_gatt_h included_service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets the GATT server handle to which the specified service belongs. + * @since_tizen 3.0 + * + * @remarks The returned Server handle must not be freed by application. + * + * @param[in] service The service's GATT handle + * @param[out] server The GATT server handle to which @a service belongs + * @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_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_register_service() + */ +int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a properties can be one or more values of #bt_gatt_property_e, combined with bitwise 'or'. + * @remarks The @a characteristic should be destroyed by using bt_gatt_characteristic_destroy(). + * + * @param[in] uuid The UUID of the characteristic + * @param[in] permissions the permissions of the characteristic + * @param[in] properties The properties of the characteristic + * @param[in] Value The value(byte stream) of the characteristic + * @param[in] value_length The length of @a value + * @param[out] characteristic The GATT handle of the created characteristic + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_characteristic_destroy() + */ +int bt_gatt_characteristic_create(const char *uuid, int permissions, + int properties, const char *value, int value_length, + bt_gatt_h *characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Adds a descriptor to a specified characteristic. + * @since_tizen 3.0 + * + * @param[in] characteristic The GATT handle of the characteristic + * @param[in] descriptor The descriptor's GATT handle to be added + * @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_descriptor_create() + */ +int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, + bt_gatt_h descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT characteristic descriptor. + * @since_tizen 3.0 + * + * @remarks The @a permissions can be one or more values of #bt_gatt_permissions_e, combined with bitwise 'or'. + * @remarks The @a descriptor should be destroyed by using bt_gatt_descriptor_destroy(). + * + * @param[in] uuid The UUID of the descriptor + * @param[in] permissions The permissions of the descriptor + * @param[in] value The value(byte stream) associated with the descriptor + * @param[in] value_length The length of @a value + * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_descriptor_destroy() + */ +int bt_gatt_descriptor_create(const char *uuid, int permissions, + const char *value, int value_length, + bt_gatt_h *descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Initializes the GATT Server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_deinitialize() + */ +int bt_gatt_server_initialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief DeInitializes the GATT server. + * @since_tizen 3.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @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. + * @see bt_gatt_server_initialize() + */ +int bt_gatt_server_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Creates the GATT server's handle. + * @since_tizen 3.0 + * + * @param[out] server The GATT server's handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_destroy() + */ +int bt_gatt_server_create(bt_gatt_server_h *server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Destroys the GATT server's handle. + * @since_tizen 3.0 + * + * @remarks All registered services to GATT server are unregistered + * + * @param[in] server The GATT server's handle + * @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_server_create() + */ +int bt_gatt_server_destroy(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client). + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_read_value_requested_cb callback, + void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_characteristic_notification_state_changed_cb() + */ +int bt_gatt_server_set_characteristic_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_characteristic_notification_state_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request. + * @since_tizen 3.0 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_write_value_requested_cb() + */ +int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, + bt_gatt_server_write_value_requested_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers a specified service to the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be registered in @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_start() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters a specified service from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @param[in] service The service, which needs to be unregistered from @a server + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Unregisters all services from the specified GATT server that the local device is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] server The GATT server that local device is hosting + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_register_service() + */ +int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Registers the application along with the GATT services of the application it is hosting. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_initialize() + * @see bt_gatt_server_create() + * @see bt_gatt_service_create() + * @see bt_gatt_server_unregister_service() + */ +int bt_gatt_server_start(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Sends a response to the remote device as a result of a read/write request. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks Until this function is called, a read/write request is not finished. + * + * @param[in] request_id The identification of a read/write request + * @param[in] request_type The request type for read/write + * @param[in] offset The offset from where a value is read + * @param[in] resp_status The application error if any occurred or BT_ERROR_NONE for successful. + * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. + * @param[in] value_length Value Length + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_read_value_requested_cb() + */ +int bt_gatt_server_send_response(int request_id, bluetooth_gatt_att_request_type_e request_type, + int offset, int resp_status, char *value, int value_length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor. + * @since_tizen 3.0 + * + * @param[in] characteristic The characteristic which has a changed value + * @param[in] callback The function to be invoked on each remote device when a sending operation is done + * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. + * @param[in] user_data The user data to be passed to @a callback function + * @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_server_notification_sent_cb() + */ +int bt_gatt_server_notify_characteristic_changed_value(bt_gatt_h characteristic, + bt_gatt_server_notification_sent_cb callback, + const char *device_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Gets a service's GATT handle which has specific UUID. + * @since_tizen 3.0 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). + * If there are multiple services which have same UUID, only the first matched one will be returned. + * + * @param[in] server The GATT server's handle + * @param[in] uuid The service's GATT handle which has this UUID will be returned if it exists + * @param[out] service The service's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Invokes @a callback function on each service that belongs to the specified GATT server. + * @since_tizen 3.0 + * + * @param[in] server The GATT server's handle + * @param[in] callback The function to be invoked on each service + * @param[in] user_data The user data to be passed to @a callback function + * @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_foreach_cb() + */ +int bt_gatt_server_foreach_services(bt_gatt_server_h server, + bt_gatt_foreach_cb callback, void *user_data); + + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE * @brief Initializes the Bluetooth PBAP Client. diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index 8815bf3..7f6946a 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -2098,105 +2098,9 @@ int bt_hf_free_call_status_info_list(GSList *call_list); int bt_gatt_get_uuid_specification_name(const char *uuid, char **name); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service, characteristic or descriptor - * @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_service_create() - * @see bt_gatt_characteristic_create() - * @see bt_gatt_descriptor_create() - */ -int bt_gatt_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of service - * @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_service_create() - */ -int bt_gatt_service_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of characteristic - * @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() - */ -int bt_gatt_characteristic_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT handle - * @since_tizen 2.4 - * - * @param[in] gatt_handle The handle of descriptor - * @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() - */ -int bt_gatt_descriptor_destroy(bt_gatt_h gatt_handle); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the permissions which a characteristic's GATT handle has - * @since_tizen 2.4 - * - * @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_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the permissions which a characteristic or descriptor's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the permissions which a characteristic or descriptor's GATT handle has. + * @since_tizen 3.0 * * @param[in] gatt_handle The handle of a characteristic or descriptor * @param[in] permissions The permissions to be updated @@ -2212,122 +2116,9 @@ int bt_gatt_descriptor_get_permissions(bt_gatt_h gatt_handle, int *permissions); int bt_gatt_set_permissions(bt_gatt_h gatt_handle, int permissions); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT service - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the service - * @param[in] type The type of the service - * @param[out] service The GATT handle of the created service - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a characteristic to a specified service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] characteristic The characteristic's GATT handle to be added - * @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_service_create() - * @see bt_gatt_characteristic_create() - */ -int bt_gatt_service_add_characteristic(bt_gatt_h service, - bt_gatt_h characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a service to a specified service as included service - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[in] included_service The service's GATT handle to be added as included service - * @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_service_create() - */ -int bt_gatt_service_add_included_service(bt_gatt_h service, - bt_gatt_h included_service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets the GATT server handle to which the specified service belongs - * @since_tizen 2.4 - * - * @param[in] service The service's GATT handle - * @param[out] server The GATT server handle to which @a service belongs - * @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_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_register_service() - */ -int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic - * @since_tizen 2.4 - * - * @param[in] uuid The UUID of the characteristic - * @param[in] permissions the permissions of the characteristic - * @param[in] properties The properties of the characteristic - * @param[in] Value The value(byte stream) of the characteristic - * @param[in] value_length The length of @a value - * @param[out] characteristic The GATT handle of the created characteristic - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_characteristic_create(const char *uuid, int permissions, - int properties, const char *value, int value_length, - bt_gatt_h *characteristic); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Adds a descriptor to a specified characteristic - * @since_tizen 2.4 - * - * @param[in] characteristic The GATT handle of the characteristic - * @param[in] descriptor The descriptor's GATT handle to be added - * @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_descriptor_create() - */ -int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, - bt_gatt_h descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Updates the properties which a characteristic's GATT handle has - * @since_tizen 2.4 + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Updates the properties which a characteristic's GATT handle has. + * @since_tizen 3.0 * * @param[in] characteristic The characteristic's GATT handle * @param[in] properties The properties to be updated @@ -2342,308 +2133,20 @@ int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properti /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT characteristic descriptor + * @brief Destroys the GATT handle * @since_tizen 2.4 * - * @param[in] uuid The UUID of the descriptor - * @param[in] permissions The permissions of the descriptor - * @param[in] value The value(byte stream) associated with the descriptor - * @param[in] value_length The length of @a value - * @param[out] descriptor The GATT handle of the created characteristic descriptor + * @param[in] gatt_handle The handle of service, characteristic or descriptor * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_destroy() - */ -int bt_gatt_descriptor_create(const char *uuid, int permissions, - const char *value, int value_length, - bt_gatt_h *descriptor); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Initializes the GATT Server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_deinitialize() - */ -int bt_gatt_server_initialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief DeInitializes the GATT server - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @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. - * @see bt_gatt_server_initialize() - */ -int bt_gatt_server_deinitialize(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Creates the GATT server's handle - * @since_tizen 2.4 - * - * @param[out] server The GATT server's handle - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_destroy() - */ -int bt_gatt_server_create(bt_gatt_server_h *server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Destroys the GATT server's handle - * @since_tizen 2.4 - * - * @remarks All registered services to GATT server are unregistered - * - * @param[in] server The GATT server's handle - * @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_server_create() - */ -int bt_gatt_server_destroy(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a read request for a specified characteristic or descriptor is issued from a remote device(GATT client) - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_read_value_requested_cb callback, - void *user_data); - - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_state_change_cb() - */ -int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, - bt_gatt_server_notification_state_change_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request - * @since_tizen 2.4 - * - * @param[in] gatt_handle The GATT handle of a characteristic or descriptor - * @param[in] callback The callback to be invoked - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_write_value_requested_cb() - */ -int bt_gatt_server_set_write_value_requested_cb(bt_gatt_h gatt_handle, - bt_gatt_server_write_value_requested_cb callback, - void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers a specified service to the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be registered in @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done * @retval #BT_ERROR_NOT_SUPPORTED Not supported * - * @see bt_gatt_server_create() * @see bt_gatt_service_create() - * @see bt_gatt_server_start() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters a specified service from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @param[in] service The service, which needs to be unregistered from @a server - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_gatt_server_register_service() - */ -int bt_gatt_server_unregister_service(bt_gatt_server_h server, bt_gatt_h service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Unregisters all services from the specified GATT server that the local device is hosting - * @since_tizen 2.4 - * - * @param[in] server The GATT server that local device is hosting - * @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_server_register_service() - */ -int bt_gatt_server_unregister_all_services(bt_gatt_server_h server); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Registers the applciation along with the GATT services of the aplciation it is hosting - * @since_tizen 2.4 - * - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * - * @see bt_gatt_server_initialize() - * @see bt_gatt_server_create() - * @see bt_gatt_service_create() - * @see bt_gatt_server_unregister_service() - */ -int bt_gatt_server_start(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Sends a response to the remote device as a result of a read request - * @since_tizen 2.4 - * - * @remarks Until this function is called, a read request is not finished. - * - * @param[in] request_id The identification of a read/write request - * @param[in] request_type The request type for read/write. - * @param[in] offset The offset from where a value is read - * @param[in] resp_status The applciation error if any occured or BT_ERROR_NONE for successful. - * @param[in] value The value to be sent. It will be sent from @a offset. If it is NULL, a requested GATT handle's value will be sent from @a offset. - * @param[in] value_length Value Length - * @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_server_read_value_requested_cb() - */ -int bt_gatt_server_send_response(int request_id, int request_type, - int offset, int resp_status, char *value, int value_length); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Notifies value change of the characteristic to the remote devices which enable a Client Characteristic Configuration Descriptor - * @since_tizen 2.4 - * - * @param[in] characteristic The characteristic which has a changed value - * @param[in] need_confirm If it is true, an indication is sent. If it is false, a notification is sent. - * @param[in] callback The function to be invoked on each remote device when a sending operation is done - * @param[in] device_address Remote device address to send notify or indicate and if set to NULL then notify/indicate all is enabled. - * @param[in] user_data The user data to be passed to @a callback function - * @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_server_notification_sent_cb() - */ -int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm, - bt_gatt_server_notification_sent_cb callback, - const char *device_address, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Gets a service's GATT handle which has specific UUID - * @since_tizen 2.4 - * - * @remark The returned GATT handle must not be freed by application. - * It will be freed when an associated server is destroyed by bt_gatt_server_destroy(). - * If there are multiple services which have same UUID, only the first matched one will be returned. - * - * @param[in] server The GATT server's handle - * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists - * @param[out] service The service's GATT handle which has @a uuid if it exists - * @return 0 on success, otherwise a negative error value - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NO_DATA No data available - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - */ -int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, - bt_gatt_h *service); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Invokes @a callback function on each service that belongs to the specified GATT server - * @since_tizen 2.4 - * - * @param[in] server The GATT server's handle - * @param[in] callback The function to be invoked on each service - * @param[in] user_data The user data to be passed to @a callback function - * @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_foreach_cb() + * @see bt_gatt_characteristic_create() + * @see bt_gatt_descriptor_create() */ -int bt_gatt_server_foreach_services(bt_gatt_server_h server, - bt_gatt_foreach_cb callback, void *user_data); +int bt_gatt_destroy(bt_gatt_h gatt_handle); /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE diff --git a/include/wearable/bluetooth_type.h b/include/wearable/bluetooth_type.h index c7538f9..658981d 100644 --- a/include/wearable/bluetooth_type.h +++ b/include/wearable/bluetooth_type.h @@ -626,7 +626,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the integer type for GATT handle's value + * @brief Enumerations of the integer type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -640,7 +640,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the float type for GATT handle's value + * @brief Enumerations of the float type for GATT handle's value. * @since_tizen 2.3.1 */ typedef enum { @@ -650,7 +650,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the write type + * @brief Enumerations of the write type. * @since_tizen 2.3.1 */ typedef enum { @@ -660,7 +660,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the GATT handle's type + * @brief Enumerations of the GATT handle's type. * @since_tizen 2.3.1 */ typedef enum { @@ -671,7 +671,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the service type + * @brief Enumerations of the service type. * @since_tizen 2.3.1 */ typedef enum { @@ -681,7 +681,7 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the characteristic's property + * @brief Enumerations of the characteristic's property. * @since_tizen 2.3.1 */ typedef enum { @@ -695,9 +695,33 @@ typedef enum { BT_GATT_PROPERTY_EXTENDED_PROPERTIES = 0x80, /**< Extended properties */ } bt_gatt_property_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the attribute's permission. + * @since_tizen 3.0 + */ +typedef enum { + BT_GATT_PERMISSION_READ = 0x01, /**< Read permission*/ + BT_GATT_PERMISSION_WRITE = 0x02, /**< Write permission */ + BT_GATT_PERMISSION_ENCRYPTION = 0x04, /**< Encryption permission */ + BT_GATT_PERMISSION_AUTHENTICATION = 0x08, /**< Authentication permission */ + BT_GATT_PERMISSION_AUTHORIZATION = 0x10, /**< Authorization permission */ + BT_GATT_PERMISSION_NONE = 0x20, /**< None */ +} bt_gatt_permission_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Enumerations of the remote device request types for attributes + * @since_tizen 3.0 + */ +typedef enum { + BLUETOOTH_GATT_REQUEST_TYPE_READ = 0x00, /* Read Requested */ + BLUETOOTH_GATT_REQUEST_TYPE_WRITE = 0x01, /* Write Requested */ +} bluetooth_gatt_att_request_type_e; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Enumerations for the types of PAN(Personal Area Networking) service + * @brief Enumerations for the types of PAN(Personal Area Networking) service. * @since_tizen 2.3.1 */ typedef enum { @@ -761,28 +785,35 @@ typedef enum { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle to control Bluetooth LE advertising + * @brief The handle to control Bluetooth LE advertising. * @since_tizen 2.3.1 */ typedef void *bt_advertiser_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a service, characteristic or descriptor + * @brief The handle of a service, characteristic or descriptor. * @since_tizen 2.3.1 */ typedef void *bt_gatt_h; /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT client which is associated with a remote device + * @brief The handle of a GATT client which is associated with a remote device. * @since_tizen 2.3.1 */ typedef void *bt_gatt_client_h; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief The handle of a GATT server. + * @since_tizen 3.0 + */ +typedef void *bt_gatt_server_h; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief The handle of calls state + * @brief The handle of calls state. * @since_tizen 2.3.1 */ typedef void *bt_call_list_h; @@ -844,7 +875,7 @@ typedef struct { /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief LE service data structure + * @brief LE service data structure. * @since_tizen 2.3.1 * * @see bt_adapter_le_get_scan_result_service_data() @@ -1547,7 +1578,7 @@ typedef void (*bt_gatt_client_request_completed_cb) (int result, * @brief Called when a value of a watched characteristic's GATT handle has been changed * @since_tizen 2.3.1 * - * @remarks After this function is returned, a changed vlaue is automatically + * @remarks After this function is returned, a changed value is automatically * applied to @a characteristic. Before that, @a characteristic has an old value. * * @param[in] characteristic The characteristic's GATT handle of which value change is informed. It has an old value. @@ -1580,6 +1611,108 @@ typedef void (*bt_gatt_client_characteristic_value_changed_cb) (bt_gatt_h charac */ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected, const char *remote_address, void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks After this function is returned, a changed value is automatically + * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * @remarks The @a value must not be freed by application. + * + * @param[in] remote_address The address of the remote device which requests a change + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value + * @param[in] offset The requested offset from where the @a gatt_handle value will be updated + * @param[in] value The new value + * @param[in] len The length of @a value + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_write_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, + const char *value, int len, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device requests to read a value on a GATT server. + * @since_tizen 3.0 + * + * @details For finishing the request, call the function #bt_gatt_server_send_response in callback. + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] remote_address The address of the requesting remote device + * @param[in] request_id The identification of this request. It will be used to send a response. + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read + * @param[in] offset The requested offset from where the GATT handle's value is read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + * @see bt_gatt_server_send_response() + */ +typedef void (*bt_gatt_server_read_value_requested_cb) (const char *remote_address, + int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 3.0 + * + * @details By using this callback function, server can know notification state. + * + * @remarks The @a server must not be freed by application. + * @remarks The @a gatt_handle must not be freed by application. + * + * @param[in] notify Indicates whether the Notification/Indication is enabled or not + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic's GATT handle to be read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + */ +typedef void (*bt_gatt_server_characteristic_notification_state_changed_cb) (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE + * @brief Called when the sending notification / indication is done. + * @since_tizen 3.0 + * + * @remarks The @a remote_address must not be freed by application. + * @remarks The @a server must not be freed by application. + * @remarks The @a characteristic must not be freed by application. + * + * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n + * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n + * For the last remote device, @a completed will be set as true. + * + * @param[in] result The result of a sending operation + * @param[in] remote_address The address of the remote device + * @param[in] server The GATT server handle + * @param[in] characteristic The characteristic's GATT handle + * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. + * @param[in] user_data The user data passed from the requesting function + * + * @see bt_gatt_server_notify_characteristic_changed_value() + */ +typedef void (*bt_gatt_server_notification_sent_cb) (int result, + const char *remote_address, bt_gatt_server_h server, + bt_gatt_h characteristic, bool completed, void *user_data); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE * @brief Called when the connection state is changed. diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h index eef15ed..a596b0b 100644 --- a/include/wearable/bluetooth_type_internal.h +++ b/include/wearable/bluetooth_type_internal.h @@ -295,20 +295,6 @@ typedef void (*bt_hf_speaker_gain_changed_cb) (int gain, void *user_data); */ typedef void (*bt_hf_call_status_updated_event_cb) (GSList *call_info_list, void *user_data); -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Enumerations of the attribute's permission - * @since_tizen 2.4 - */ -typedef enum { - BT_GATT_PERMISSION_READ = 0x01, - BT_GATT_PERMISSION_WRITE = 0x02, - BT_GATT_PERMISSION_ENCRYPTION = 0x04, - BT_GATT_PERMISSION_AUTHENTICATION = 0x08, - BT_GATT_PERMISSION_AUTHORIZATION = 0x10, - BT_GATT_PERMISSION_NONE = 0x20, -} bt_gatt_permission_e; - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DPM_MODULE * @brief DPM BT allowance state @@ -365,92 +351,6 @@ typedef enum { */ typedef void *bt_scan_filter_h; -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief The handle of a GATT server - * @since_tizen 2.4 - */ -typedef void *bt_gatt_server_h; - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when a value of a characteristic or descriptor's GATT handle has been changed - * @since_tizen 2.4 - * - * @remarks After this function is returned, a changed vlaue is automatically - * applied to @a gatt_handle. Before that, @a gatt_handle has an old value. - * - * @param[in] remote_address The address of the remote device which requests a change - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the @a gatt_handle value will be updated - * @param[in] value The new value - * @param[in] len The length of @a value - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_write_value_requested_cb() - */ -typedef void (*bt_gatt_server_write_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, int offset, - char *value, int len, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device requests to read a value on a GATT server - * @since_tizen 2.4 - * - * @param[in] remote_address The address of the requesting remote device - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic or descriptor's GATT handle to be read - * @param[in] request_id The identification of this request. It will be used to send a reponse. - * @param[in] offset The requested offset from where the GATT handle's value is read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - * @see bt_gatt_server_send_response() - */ -typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, - int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. - * @since_tizen 2.4 - * - * @param[in] server The GATT server handle - * @param[in] gatt_handle The characteristic's GATT handle to be read - * @param[in] user_data The user data passed from the registration function - * - * @see bt_gatt_server_set_read_value_requested_cb() - */ -typedef void (*bt_gatt_server_notification_state_change_cb) (bool notify, - bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE - * @brief Called when the sending notification / indication is done - * @since_tizen 2.4 - * - * @remarks In case of an indication, once a confirmation is received from the remote device this callback will be called. \n - * This callback will be called several times if there are two or more remote devices which enable a Client Characteristic Configuration Descriptor(CCCD). \n - * For the last remote device, @a completed will be set as true. - * - * @param[in] result The result of a sending operation - * @param[in] remote_address The address of the remote device - * @param[in] server The GATT server handle - * @param[in] characteristic The characteristic's GATT handle - * @param[in] completed If this callback is for the last remote device which enables a CCCD, it will be true. Or it will be false. - * @param[in] user_data The user data passed from the requesting function - * - * @see bt_gatt_server_notify() - */ -typedef void (*bt_gatt_server_notification_sent_cb) (int result, - char *remote_address, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void *user_data); - /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Device LE connection update structure. @@ -463,7 +363,6 @@ typedef struct { unsigned int time_out; /**< Supervision timeout (msec) */ } bt_le_conn_update_s; - /** * Structure to DPM device list */ diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index b1ee0c3..77453b8 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -591,7 +591,7 @@ static bt_gatt_server_write_value_requested_cb __bt_gatt_attribute_get_value_cha return NULL; } -static bt_gatt_server_notification_state_change_cb __bt_gatt_attribute_get_notification_change_cb( +static bt_gatt_server_characteristic_notification_state_changed_cb __bt_gatt_attribute_get_notification_change_cb( bt_gatt_h service, bt_gatt_h attribute, void **user_data) { gchar *svc_path = (gchar *)service; @@ -1700,7 +1700,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us } case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED: { bt_gatt_char_notify_change_t *value_change = param->param_data; - bt_gatt_server_notification_state_change_cb cb; + bt_gatt_server_characteristic_notification_state_changed_cb cb; void *user_data = NULL; cb = __bt_gatt_attribute_get_notification_change_cb(value_change->service_handle, value_change->att_handle, &user_data); diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c index e510ab3..cfbdf2a 100644 --- a/src/bluetooth-gatt.c +++ b/src/bluetooth-gatt.c @@ -2135,8 +2135,8 @@ int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, return BT_ERROR_NONE; } -int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, - bt_gatt_server_notification_state_change_cb callback, +int bt_gatt_server_set_characteristic_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_characteristic_notification_state_changed_cb callback, void *user_data) { bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle; @@ -2291,6 +2291,8 @@ int bt_gatt_server_start(void) { int ret = BT_ERROR_NONE; + BT_CHECK_GATT_SUPPORT(); + if (!is_gatt_server_started) { ret = bluetooth_gatt_register_application(); @@ -2306,7 +2308,7 @@ int bt_gatt_server_start(void) return ret; } -int bt_gatt_server_send_response(int request_id, int request_type, +int bt_gatt_server_send_response(int request_id, bluetooth_gatt_att_request_type_e request_type, int offset, int resp_status, char *value, int value_length) { int ret = BT_ERROR_NONE; @@ -2325,7 +2327,7 @@ int bt_gatt_server_send_response(int request_id, int request_type, return ret; } -int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm, +int bt_gatt_server_notify_characteristic_changed_value(bt_gatt_h characteristic, bt_gatt_server_notification_sent_cb callback, const char *device_address, void *user_data) { diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 363c128..79d59f9 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -1497,7 +1497,7 @@ static void __bt_adapter_le_scan_result_cb( } void __bt_gatt_server_read_value_requested_cb( - char *remote_address, int request_id, + const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, void *user_data) { @@ -2341,7 +2341,7 @@ void __bt_HP_client_cp_req_status_changed_cb(bt_gatt_h chr, } void __bt_gatt_server_notification_sent_cb(int result, - char *remote_address, bt_gatt_server_h server, + const char *remote_address, bt_gatt_server_h server, bt_gatt_h characteristic, bool completed, void *user_data) { TC_PRT("result [%s]", __bt_get_error_message(result)); @@ -2350,10 +2350,10 @@ void __bt_gatt_server_notification_sent_cb(int result, TC_PRT("characteristic : %p", characteristic); } -void __bt_gatt_server_write_value_requested_cb(char *remote_address, +void __bt_gatt_server_write_value_requested_cb(const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, - char *value, int len, void *user_data) + const char *value, int len, void *user_data) { int i, resp_status = BT_ERROR_NONE; TC_PRT("remote_address : %s", remote_address); @@ -5872,7 +5872,7 @@ int test_input_callback(void *data) bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_notification_state_change_cb(characteristic, + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -5904,7 +5904,7 @@ int test_input_callback(void *data) TC_PRT("Value[%d], returns %s\n", char_value[0], __bt_get_error_message(ret)); /* notify only client remote_addr */ - ret = bt_gatt_server_notify(battery_h.chr, true, + ret = bt_gatt_server_notify_characteristic_changed_value(battery_h.chr, __bt_gatt_server_notification_sent_cb, remote_addr, NULL); TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); @@ -5942,7 +5942,7 @@ int test_input_callback(void *data) bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_notification_state_change_cb(characteristic, + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -5988,8 +5988,8 @@ int test_input_callback(void *data) char_value, __bt_get_error_message(ret)); /* Notify all client devices */ - ret = bt_gatt_server_notify(heart_rate_h.chr, - true, __bt_gatt_server_notification_sent_cb, + ret = bt_gatt_server_notify_characteristic_changed_value(heart_rate_h.chr, + __bt_gatt_server_notification_sent_cb, NULL, NULL); TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); @@ -6025,7 +6025,7 @@ int test_input_callback(void *data) bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_notification_state_change_cb(characteristic, + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -6056,7 +6056,7 @@ int test_input_callback(void *data) TC_PRT("bt_gatt_set_value(value : 1.23) : %s\n", __bt_get_error_message(ret)); /* notify only client remote_addr */ - ret = bt_gatt_server_notify(thermometer_h.chr, true, + ret = bt_gatt_server_notify_characteristic_changed_value(thermometer_h.chr, __bt_gatt_server_notification_sent_cb, remote_addr, NULL); TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret));