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 */
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;
#include <stdbool.h>
#include <tizen_error.h>
-#include "bluetooth_type.h"
+#include <bluetooth_type.h>
#ifdef __cplusplus
extern "C"
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
* 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
/**
* @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
*/
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);
+
/**
* @}
*/
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
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
/**
* @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
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
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 {
/**
* @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;
/**
* @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;
/**
* @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()
/**
* @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()
* @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.
*/
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.
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
*/
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.
unsigned int time_out; /**< Supervision timeout (msec) */
} bt_le_conn_update_s;
-
/**
* Structure to DPM device list
*/
#include <stdbool.h>
#include <tizen_error.h>
-#include "bluetooth_type.h"
+#include <bluetooth_type.h>
#ifdef __cplusplus
extern "C"
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
* 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
/**
* @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
*/
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);
+
/**
* @}
*/
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
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
/**
* @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
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
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 {
/**
* @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;
/**
* @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;
/**
* @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()
/**
* @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()
* @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.
*/
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.
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
*/
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.
unsigned int time_out; /**< Supervision timeout (msec) */
} bt_le_conn_update_s;
-
/**
* Structure to DPM device list
*/
#include <stdbool.h>
#include <tizen_error.h>
-#include "bluetooth_type.h"
+#include <bluetooth_type.h>
#ifdef __cplusplus
extern "C"
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
/**
* @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
/**
* @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.
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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.
* 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
/**
* @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
*/
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.
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
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
/**
* @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
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
/**
* @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 {
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 {
/**
* @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;
/**
* @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()
* @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.
*/
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.
*/
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
*/
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.
unsigned int time_out; /**< Supervision timeout (msec) */
} bt_le_conn_update_s;
-
/**
* Structure to DPM device list
*/
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;
}
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);
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;
{
int ret = BT_ERROR_NONE;
+ BT_CHECK_GATT_SUPPORT();
+
if (!is_gatt_server_started) {
ret = bluetooth_gatt_register_application();
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;
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)
{
}
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)
{
}
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));
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);
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));
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));
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));
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));
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));
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));