*/
int bt_hdp_unset_data_received_cb(void);
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_foreach_services or bt_gatt_client_get_service instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Gets the primary services of GATT(Generic Attribute Profile).
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] remote_address The address of the remote device
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the 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_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_ENABLED Not enabled
- * @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.
- * @post @a callback will be called if there are primary services.
- * @see bt_gatt_primary_service_cb()
- */
-int bt_gatt_foreach_primary_services(const char *remote_address, bt_gatt_primary_service_cb callback, void *user_data) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. This function call is not required because characteristic discovery is happened automatically.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Discovers the characteristics in service, asynchronously.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] service The attribute handle of service
- * @param[in] callback The result callback
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_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.
- * @post @a callback will be called.
- * @see bt_gatt_characteristics_discovered_cb()
- */
-int bt_gatt_discover_characteristics(bt_gatt_attribute_h service, bt_gatt_characteristics_discovered_cb callback, void *user_data) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_get_uuid instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Gets the UUID of service.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @remarks @a uuid must be released with free() by you.
- * @param[in] service The attribute handle of service
- * @param[out] uuid The UUID of service
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED Operation failed
- * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory
- * @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.
- */
-int bt_gatt_get_service_uuid(bt_gatt_attribute_h service, char **uuid) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_service_foreach_included_services or bt_gatt_service_get_included_service instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Gets the included services in service.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] service The attribute handle of service
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the 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_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_ENABLED Not enabled
- * @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.
- * @post @a callback will be called if there are included services.
- * @see bt_gatt_included_service_cb()
- */
-int bt_gatt_foreach_included_services(bt_gatt_attribute_h service, bt_gatt_included_service_cb callback, void *user_data) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_set_characteristic_value_changed_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Registers a callback function that will be invoked when a characteristic value is changed.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @pre The Bluetooth service must be initialized with bt_initialize().
- * @see bt_gatt_unset_characteristic_changed_cb()
- */
-int bt_gatt_set_characteristic_changed_cb(bt_gatt_characteristic_changed_cb callback, void *user_data) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_unset_characteristic_value_changed_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Unregisters a callback function that will be invoked when a characteristic is changed.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @pre The Bluetooth service must be initialized with bt_initialize().
- * @see bt_gatt_set_characteristic_changed_cb()
- */
-int bt_gatt_unset_characteristic_changed_cb(void) TIZEN_DEPRECATED_API;
-
-/**
- * @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.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] service The attribute handle of service
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @pre The Bluetooth service must be initialized with bt_initialize().
- * @see bt_gatt_unset_characteristic_changed_cb()
- */
-int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service) TIZEN_DEPRECATED_API;
-
-/**
- * @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.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] service The attribute handle of service
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @pre The Bluetooth service must be initialized with bt_initialize().
- * @see bt_gatt_set_characteristic_changed_cb()
- */
-int bt_gatt_unwatch_characteristic_changes(bt_gatt_attribute_h service) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_get_value or bt_gatt_get_uuid after bt_gatt_client_read_value instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Gets the characteristic declaration.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @remarks @a uuid and @a value must be released with free() by you.
- * @param[in] characteristic The attribute handle of characteristic
- * @param[out] uuid The UUID of service
- * @param[out] value The value of characteristic (byte array)
- * @param[out] value_length The length of value
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED Operation failed
- * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory
- * @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_set_characteristic_value()
- */
-int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic, char **uuid, unsigned char **value, int *value_length) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_set_value and bt_gatt_client_write_value instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Sets the value of characteristic.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] characteristic The attribute handle of characteristic
- * @param[in] value The value of characteristic (byte array)
- * @param[in] value_length The length of value
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_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_get_characteristic_declaration()
- */
-int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic, const unsigned char *value, int value_length) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_set_value and bt_gatt_client_write_value instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Sets the value of characteristic request.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] characteristic The attribute handle of characteristic
- * @param[in] value The value of characteristic (byte array)
- * @param[in] value_length The length of value
- * @param[in] callback The result callback
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_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_get_characteristic_declaration()
- */
-int bt_gatt_set_characteristic_value_request(bt_gatt_attribute_h characteristic, const unsigned char *value,
- int value_length, bt_gatt_characteristic_write_cb callback) TIZEN_DEPRECATED_API;
-
-/**
-* @deprecated Deprecated since 2.3.1. GATT handle clone is not allowed. Instead, all handles for client role must be got from GATT client handle.
-* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
-* @brief Clones the attribute handle.
-* @since_tizen @if WEARABLE @else 2.3 @endif
-* @remarks @a clone must be released with bt_gatt_destroy_attribute_handle().
-* @param[out] clone The cloned attribute handle
-* @param[in] origin The origin attribute handle
-* @return 0 on success, otherwise 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_attribute_handle()
-*/
-int bt_gatt_clone_attribute_handle(bt_gatt_attribute_h *clone,
- bt_gatt_attribute_h origin) TIZEN_DEPRECATED_API;
-
-/**
-* @deprecated Deprecated since 2.3.1. GATT handle clone and destroy are not allowed.
-* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
-* @brief Destroys the attribute handle.
-* @since_tizen @if WEARABLE @else 2.3 @endif
-* @param[in] handle The attribute handle
-* @return 0 on success, otherwise 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_clone_attribute_handle()
-*/
-int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle) TIZEN_DEPRECATED_API;
-
-/**
- * @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.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] char_handle The attribute handle of characteristic
- * @param[in] callback The result callback
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_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_get_characteristic_declaration()
- */
-int bt_gatt_read_characteristic_value(bt_gatt_attribute_h char_handle,
- bt_gatt_characteristic_read_cb callback) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 2.3.1. This function call is not required because descriptor discovery is happened automatically.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Discovers the characteristic descriptors of a characteristic within its definition, asynchronously.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] characteristic_handle The attribute handle of characteristic
- * @param[in] callback The result callback
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #BT_ERROR_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.
- * @post @a callback will be called.
- * @see bt_gatt_characteristic_descriptor_discovered_cb()
- */
-int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristic_handle,
- bt_gatt_characteristic_descriptor_discovered_cb callback,
- void *user_data) TIZEN_DEPRECATED_API;
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
* @brief Gets the value of a characteristic or descriptor's GATT handle.
BT_EVENT_GATT_CLIENT_READ_DESCRIPTOR, /**< GATT descriptor value read callback */
BT_EVENT_GATT_CLIENT_WRITE_DESCRIPTOR, /**< GATT descriptor value write callback */
BT_EVENT_GATT_SERVER_READ_REQUESTED, /**< GATT Characteristic/Descriptor Read Requested callback*/
- BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY, /**< GATT characteristic discovered callback */
- BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY, /**< GATT characteristic descriptor discovered callback */
- BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY, /**< GATT characteristic value changed callback */
- BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY, /**< GATT characteristic value read callback */
- BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY, /**< GATT characteristic value write callback */
BT_EVENT_IPSP_INIT_STATE_CHANGED, /**< IPSP Init status changed callback */
BT_EVENT_IPSP_CONNECTION_STATUS, /**< IPSP connection status callback */
BT_EVENT_LE_DATA_LENGTH_CHANGED, /** LE data length changed callback */
BT_PBAP_ORDER_PHONETIC, /**< Filter order phonetic */
} bt_pbap_sort_order_e;
-/**
- * @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).
- * @since_tizen @if WEARABLE @else 2.3 @endif
- */
-typedef void *bt_gatt_attribute_h;
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
* @brief The handle of a service, characteristic or descriptor.
*/
typedef void (*bt_hdp_data_received_cb) (unsigned int channel, const char *data, unsigned int size, void *user_data);
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_foreach_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called when you get the primary services repeatedly.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @param[in] service The attribute handle of service
- * @param[in] user_data The user data passed from the foreach function
- * @return @c true to continue with the next iteration of the loop,
- * \n @c false to break out of the loop.
- * @pre bt_gatt_foreach_primary_services() will invoke this function.
- * @see bt_gatt_foreach_primary_services()
- */
-typedef bool (*bt_gatt_primary_service_cb) (bt_gatt_attribute_h service, void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. This is not required because characteristic discovery is happened automatically.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called after the characteristics are discovered by bt_gatt_discover_characteristics().
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @remarks If bt_gatt_discover_characteristics() failed, then this callback function is called only once with 0 total and NULL characteristic_handle.
- * @param[in] result The result of discovering
- * @param[in] index The index of characteristics in a service, starts from 0
- * @param[in] total The total number of characteristics in a service
- * @param[in] characteristic The attribute handle of characteristic
- * @param[in] user_data The user data passed from the request function
- * @return @c true to continue with the next iteration of the loop,
- * \n @c false to break out of the loop.
- * @pre bt_gatt_discover_characteristics() will invoke this callback.
- * @see bt_gatt_discover_characteristics()
- */
-typedef bool (*bt_gatt_characteristics_discovered_cb) (int result, int index, int total, bt_gatt_attribute_h characteristic, void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_foreach_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called when you get the included services repeatedly.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @param[in] service The attribute handle of service
- * @param[in] user_data The user data passed from the foreach function
- * @return @c true to continue with the next iteration of the loop,
- * \n @c false to break out of the loop.
- * @pre bt_gatt_foreach_included_services() will invoke this function.
- * @see bt_gatt_foreach_included_services()
- */
-typedef bool (*bt_gatt_included_service_cb) (bt_gatt_attribute_h service, void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_characteristic_value_changed_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called when a characteristic in service is changed.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @param[in] characteristic The attribute handle of characteristic
- * @param[in] value The value of characteristic (byte array)
- * @param[in] value_length The length of value
- * @param[in] user_data The user data passed from the callback registration function
- * @see bt_gatt_set_characteristic_changed_cb()
- * @see bt_gatt_unset_characteristic_changed_cb()
- */
-typedef void (*bt_gatt_characteristic_changed_cb) (bt_gatt_attribute_h characteristic, unsigned char *value, int value_length, void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_request_completed_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called when a characteristic value is written.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @see bt_gatt_set_characteristic_value()
- */
-typedef void (*bt_gatt_characteristic_write_cb) (void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_request_completed_cb instead.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called when a characteristic value is read.
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @param[in] value The value of characteristic (byte array)
- * @param[in] value_length The length of value
- * @param[in] user_data The user data passed from the foreach function
- * @see bt_gatt_read_characteristic_value()
- */
-typedef void (*bt_gatt_characteristic_read_cb) (unsigned char *value,
- int value_length, void *user_data);
-
-/**
- * @deprecated Deprecated since 2.3.1. This is not required because descriptor discovery is happened automatically.
- * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
- * @brief Called after the characteristics descriptors are discovered by bt_gatt_discover_characteristic_descriptor().
- * @since_tizen @if WEARABLE @else 2.3 @endif
- *
- * @param[in] result The result of discovering
- * @param[in] characteristic_format The format of the information data.
- * characteristic_format = 0x01 indicates UUIDs are 16-bits
- * characteristic_format = 0x02 indicates UUIDs are 128-bits
- * @param[in] total The total number of elements in characteristic_descriptor
- * @param[in] characteristic descriptor The attribute handle and the UUID of characteristic descriptor
- * @param[in] user_data The user data passed from the request function
- * @see bt_gatt_discover_characteristic_descriptor()
- */
-typedef void (*bt_gatt_characteristic_descriptor_discovered_cb) (int result,
- unsigned char characteristic_format, int total,
- bt_gatt_attribute_h characteristic_descriptor, void *user_data);
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
* @brief Called when you get GATT handles repeatedly
device_addr = NULL;
break;
}
- case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- BT_INFO("BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED");
- if (_bt_gatt_is_legacy_client_mode()) {
- bt_gatt_discovered_char_t *svc_char = param->param_data;
- int i;
-
- if (svc_char == NULL)
- return;
- for (i = 1; i <= svc_char->handle_info.count; i++) {
- ((bt_gatt_characteristics_discovered_cb)bt_event_slot_container[event_index].callback)
- (_bt_get_error_code(param->result), i, svc_char->handle_info.count, svc_char->handle_info.handle[i-1],
- bt_event_slot_container[event_index].user_data);
- }
- _bt_unset_cb(BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY);
- }
- break;
- } else {
- break; /* goto default */
- }
case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
char_val = (bt_gatt_char_value_t *)(param->param_data);
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT && _bt_gatt_is_legacy_client_mode()) {
- if (_bt_gatt_is_legacy_client_mode()) {
- bt_gatt_char_value_t *char_val = param->param_data;
-
- if (char_val == NULL)
- return;
- ((bt_gatt_characteristic_changed_cb)bt_event_slot_container[event_index].callback)
- (char_val->char_handle, char_val->char_value, char_val->val_len,
- bt_event_slot_container[event_index].user_data);
- break;
- }
- }
if (char_val == NULL)
return;
break;
case BLUETOOTH_EVENT_GATT_READ_CHAR:
BT_INFO("BLUETOOTH_EVENT_GATT_READ_CHAR");
-
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT && _bt_gatt_is_legacy_client_mode()) {
- if (_bt_gatt_is_legacy_client_mode()) {
- bt_gatt_char_value_t *char_val = param->param_data;
-
- ((bt_gatt_characteristic_read_cb)bt_event_slot_container[event_index].callback)
- (char_val->char_value, char_val->val_len,
- bt_event_slot_container[event_index].user_data);
- _bt_unset_cb(BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY);
- break;
- }
- }
_handle_gatt_client_read_completed_event(param->result,
param->param_data);
break;
case BLUETOOTH_EVENT_GATT_WRITE_CHAR:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT && _bt_gatt_is_legacy_client_mode()) {
- if (_bt_gatt_is_legacy_client_mode()) {
- ((bt_gatt_characteristic_write_cb)bt_event_slot_container[event_index].callback)
- (bt_event_slot_container[event_index].user_data);
-
- _bt_unset_cb(BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY);
- break;
- }
- }
-
+ BT_INFO("BLUETOOTH_EVENT_GATT_WRITE_CHAR");
_handle_gatt_client_write_completed_event(param->result,
param->param_data);
break;
#endif
break;
}
- case BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- BT_INFO("BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED");
- if (_bt_gatt_is_legacy_client_mode()) {
- bt_gatt_char_property_t *char_desc = param->param_data;
-
- if (char_desc == NULL)
- return;
- ((bt_gatt_characteristic_descriptor_discovered_cb)
- bt_event_slot_container[event_index].callback)(_bt_get_error_code(param->result),
- char_desc->format.format, char_desc->val_len, char_desc->description,
- bt_event_slot_container[event_index].user_data);
- _bt_unset_cb(BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY);
- }
- break;
- } else {
- break; /* goto default */
- }
case BLUETOOTH_EVENT_GATT_SERVER_CHARACTERISTIC_VALUE_CHANGED: {
const GSList *server_list = NULL;
BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_CHARACTERISTIC_VALUE_CHANGED");
}
-static int __bt_get_gatt_client_cb_index(int event)
-{
- switch (event) {
- case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
- if (_bt_gatt_is_legacy_client_mode())
- return BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY;
- else
- return BT_EVENT_GATT_CLIENT_VALUE_CHANGED;
- case BLUETOOTH_EVENT_GATT_READ_CHAR:
- if (_bt_gatt_is_legacy_client_mode())
- return BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY;
- else
- return BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC;
- case BLUETOOTH_EVENT_GATT_WRITE_CHAR:
- if (_bt_gatt_is_legacy_client_mode())
- return BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY;
- else
- return BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC;
- }
-
- return -1;
-}
/* LCOV_EXCL_STOP */
static int __bt_get_cb_index(int event)
{
return BT_EVENT_HID_DEVICE_CONNECTION_STATUS;
case BLUETOOTH_HID_DEVICE_DATA_RECEIVED:
return BT_EVENT_HID_DEVICE_DATA_RECEIVED;
- case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED:
- if (!TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT)
- return -1; /* default */
- return BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY;
- case BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED:
- if (!TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT)
- return -1; /* default */
- return BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY;
case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT)
- return __bt_get_gatt_client_cb_index(event);
return BT_EVENT_GATT_CLIENT_VALUE_CHANGED;
case BLUETOOTH_EVENT_GATT_READ_CHAR:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT)
- return __bt_get_gatt_client_cb_index(event);
return BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC;
case BLUETOOTH_EVENT_GATT_WRITE_CHAR:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT)
- return __bt_get_gatt_client_cb_index(event);
return BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC;
case BLUETOOTH_EVENT_GATT_READ_DESC:
return BT_EVENT_GATT_CLIENT_READ_DESCRIPTOR;
return BT_ERROR_NONE;
}
-bool _bt_gatt_is_legacy_client_mode(void)
-{
- if (gatt_client_list) {
- BT_INFO("New GATT Client APIs");
- return false;
- }
-
- BT_INFO("Legacy GATT Client APIs");
- return true;
-}
-
/* LCOV_EXCL_STOP */
-int bt_gatt_foreach_primary_services(const char *remote_address,
- bt_gatt_primary_service_cb callback,
- void *user_data)
-{
- BT_INFO("DEPRECATION WARNING: bt_gatt_foreach_primary_services() is deprecated and will be removed from next release.");
-
- int i;
- int ret;
- bool foreach_call = true;
- bluetooth_device_address_t addr_hex = { {0,} };
- bt_gatt_handle_info_t *prim_svc;
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(remote_address);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- prim_svc = g_new0(bt_gatt_handle_info_t, 1);
-
- _bt_convert_address_to_hex(&addr_hex, remote_address);
-
- ret = _bt_get_error_code(bluetooth_gatt_get_primary_services(&addr_hex,
- prim_svc));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x) : Failed to run function",
- _bt_convert_error_to_string(ret), ret);
- g_free(prim_svc);
- return ret;
- }
-
- for (i = 0; i < prim_svc->count; i++) {
- if (prim_svc->handle[i] == NULL)
- continue;
-
- BT_INFO("handle: %s", prim_svc->handle[i]);
-
- if (foreach_call == true &&
- !callback((bt_gatt_attribute_h)prim_svc->handle[i],
- user_data)) {
- foreach_call = false;
- }
-
- /* Application should clone the handle using API in callback */
- /* bt_gatt_clone_attribute_handle */
- g_free(prim_svc->handle[i]);
- }
-
- g_free(prim_svc->handle);
- g_free(prim_svc);
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_discover_characteristics(bt_gatt_attribute_h service,
- bt_gatt_characteristics_discovered_cb callback,
- void *user_data)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_discover_characteristics() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(service);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- ret = _bt_get_error_code(bluetooth_gatt_discover_service_characteristics((const char *)service));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- _bt_set_cb(BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY,
- callback, user_data);
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_get_service_uuid(bt_gatt_attribute_h service, char **uuid)
-{
- int i;
- int ret;
- bt_gatt_service_property_t property;
- BT_INFO("DEPRECATION WARNING: bt_gatt_get_service_uuid() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(service);
-
- memset(&property, 0x00, sizeof(bt_gatt_service_property_t)); /* LCOV_EXCL_START */
-
- ret = _bt_get_error_code(bluetooth_gatt_get_service_property((const char *)service,
- &property));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- *uuid = g_strdup(property.uuid);
-
- if (property.include_handles.count != 0 &&
- property.include_handles.handle) {
- for (i = 0; i < property.include_handles.count; i++)
- g_free(property.include_handles.handle[i]);
-
- g_free(property.include_handles.handle);
- }
- if (property.char_handle.count != 0 &&
- property.char_handle.handle) {
- for (i = 0; i < property.char_handle.count; i++)
- g_free(property.char_handle.handle[i]);
-
- g_free(property.char_handle.handle);
- }
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_foreach_included_services(bt_gatt_attribute_h service,
- bt_gatt_included_service_cb callback,
- void *user_data)
-{
- BT_INFO("DEPRECATION WARNING: bt_gatt_foreach_included_services() is deprecated and will be removed from next release.");
-
- int i;
- int ret;
- bool foreach_call = true;
- bt_gatt_service_property_t property;
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(service);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- memset(&property, 0x00, sizeof(bt_gatt_service_property_t));
-
- ret = _bt_get_error_code(bluetooth_gatt_get_service_property((const char *)service,
- &property));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- if (property.char_handle.count != 0 &&
- property.char_handle.handle) {
- for (i = 0; i < property.char_handle.count; i++)
- g_free(property.char_handle.handle[i]);
-
- g_free(property.char_handle.handle);
- }
- if (property.include_handles.count == 0 ||
- property.include_handles.handle == NULL) {
- return ret;
- }
-
- for (i = 0; i < property.include_handles.count; i++) {
- if (property.include_handles.handle[i] == NULL)
- continue;
-
- if (foreach_call == true &&
- !callback((bt_gatt_attribute_h)property.include_handles.handle[i],
- user_data)) {
- foreach_call = false;
- }
-
- g_free(property.include_handles.handle[i]);
- }
- g_free(property.include_handles.handle);
- }
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_set_characteristic_changed_cb(bt_gatt_characteristic_changed_cb callback,
- void *user_data)
-{
- BT_INFO("DEPRECATION WARNING: bt_gatt_set_characteristic_changed_cb() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(callback);
-
- _bt_set_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY,
- callback, user_data);
-
- return BT_ERROR_NONE;
-}
-
-int bt_gatt_unset_characteristic_changed_cb()
-{
- BT_INFO("DEPRECATION WARNING: bt_gatt_unset_characteristic_changed_cb() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
-
- _bt_unset_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY);
-
- return BT_ERROR_NONE;
-}
-
-int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_watch_characteristic_changes() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(service);
-
- ret = _bt_get_error_code(bluetooth_gatt_watch_characteristics((const char *)service, NULL)); /* LCOV_EXCL_LINE */
-
- if (ret != BT_ERROR_NONE) /* LCOV_EXCL_LINE */
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret),
- ret); /* LCOV_EXCL_LINE */
-
- return ret; /* LCOV_EXCL_LINE */
-}
-
-int bt_gatt_unwatch_characteristic_changes(bt_gatt_attribute_h service)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_unwatch_characteristic_changes() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(service);
-
- ret = _bt_get_error_code(bluetooth_gatt_unwatch_characteristics((const char *)service)); /* LCOV_EXCL_LINE */
-
- if (ret != BT_ERROR_NONE) /* LCOV_EXCL_LINE */
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret),
- ret); /* LCOV_EXCL_LINE */
-
- return ret; /* LCOV_EXCL_LINE */
-}
-
-int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic,
- char **uuid, unsigned char **value,
- int *value_length)
-{
- int ret;
- bt_gatt_char_property_t property;
- BT_INFO("DEPRECATION WARNING: bt_gatt_get_characteristic_declaration() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic);
-
- memset(&property, 0x00, sizeof(bt_gatt_char_property_t));
-
- ret = _bt_get_error_code(bluetooth_gatt_get_characteristics_property((const char *)characteristic,
- &property)); /* LCOV_EXCL_START */
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- if (property.uuid) {
- *uuid = g_strdup(property.uuid);
- g_free(property.uuid);
- }
-
- if (property.val && property.val_len != 0) {
- *value = g_memdup(property.val, property.val_len);
- *value_length = property.val_len;
- g_free(property.val);
- }
-
- g_free(property.name);
-
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic,
- const unsigned char *value,
- int value_length)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_set_characteristic_value() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic);
- BT_CHECK_INPUT_PARAMETER(value); /* LCOV_EXCL_START */
-
- if (value_length <= 0)
- return BT_ERROR_INVALID_PARAMETER;
-
- ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value((const char *)characteristic,
- (const guint8*)value, value_length));
-
- if (ret != BT_ERROR_NONE)
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_set_characteristic_value_request(bt_gatt_attribute_h characteristic,
- const unsigned char *value, int value_length,
- bt_gatt_characteristic_write_cb callback)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_set_characteristic_value_request() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic);
- BT_CHECK_INPUT_PARAMETER(value); /* LCOV_EXCL_START */
-
- if (value_length <= 0)
- return BT_ERROR_INVALID_PARAMETER;
-
- ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value_request(
- (const char *)characteristic,
- (const guint8*)value, value_length));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- _bt_set_cb(BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY,
- callback, characteristic);
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_clone_attribute_handle(bt_gatt_attribute_h *clone,
- bt_gatt_attribute_h origin)
-{
- int error = BT_ERROR_NONE;
- BT_INFO("DEPRECATION WARNING: bt_gatt_clone_attribute_handle() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(origin);
-
- *clone = g_strdup((char *)origin); /* LCOV_EXCL_LINE */
-
- return error; /* LCOV_EXCL_LINE */
-}
-
-int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle)
-{
- int error = BT_ERROR_NONE;
- BT_INFO("DEPRECATION WARNING: bt_gatt_destroy_attribute_handle() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(handle);
-
- g_free(handle); /* LCOV_EXCL_LINE */
-
- return error; /* LCOV_EXCL_LINE */
-}
-
-int bt_gatt_read_characteristic_value(bt_gatt_attribute_h characteristic,
- bt_gatt_characteristic_read_cb callback)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_read_characteristic_value() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- ret = _bt_get_error_code(bluetooth_gatt_read_characteristic_value((const char *)characteristic, NULL));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- _bt_set_cb(BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY,
- callback, NULL);
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
-int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristic_handle,
- bt_gatt_characteristic_descriptor_discovered_cb callback,
- void *user_data)
-{
- int ret;
- BT_INFO("DEPRECATION WARNING: bt_gatt_discover_characteristic_descriptor() is deprecated and will be removed from next release.");
-
- BT_CHECK_GATT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic_handle);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- ret = _bt_get_error_code(bluetooth_gatt_discover_characteristic_descriptor
- ((const char *)characteristic_handle));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- } else {
- _bt_set_cb(BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY,
- callback, user_data);
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-
int bt_gatt_connect(const char *address, bool auto_connect)
{
int ret;
static int total_time = 0;
static struct timeval check_time = {0,};
-static gboolean is_sub_index = FALSE;
int service_index;
int char_service_index;
-static int selected_service_index = -1;
-static int selected_char_index = 0;
static bt_advertiser_h advertiser = NULL;
static bt_advertiser_h advertiser_list[3] = {NULL, };
bt_otp_client_h otp_client;
-bt_gatt_attribute_h service_clone[MAX_SERVICES];
-bt_gatt_attribute_h characteristics[MAX_SERVICES];
-bt_gatt_attribute_h characteristics_services[MAX_SERVICES];
-
static unsigned char *hash = NULL;
static unsigned char *randomizer = NULL;
int hash_len;
, BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION},
{"ANCS (Get Noti. Attr.)"
, BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR},
- {"bt_gatt_foreach_primary_services"
- , BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES},
- {"bt_gatt_discover_characteristics"
- , BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS},
- {"bt_gatt_discover_characteristic_descriptor"
- , BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS},
- {"bt_gatt_get_service_uuid"
- , BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID},
- {"bt_gatt_foreach_included_services"
- , BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES},
- {"bt_gatt_set_characteristic_changed_cb"
- , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB},
- {"bt_gatt_unset_characteristic_changed_cb"
- , BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB},
- {"bt_gatt_get_characteristic_declaration"
- , BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION},
- {"bt_gatt_set_characteristic_value"
- , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE},
- {"bt_gatt_set_characteristic_value_request"
- , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST},
- {"bt_gatt_read_characteristic_value"
- , BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE},
- {"bt_gatt_watch_characteristic_changes"
- , BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES},
- {"bt_gatt_unwatch_characteristic_changes"
- , BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES},
{"Select this menu to set parameters and then select the function again."
, BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
{NULL , 0x0000},
return err_str;
}
-static gboolean __select_index_cb(GIOChannel *chan,
- GIOCondition cond,
- gpointer data)
-{
- char buf[BUFFER_LEN] = { 0 };
-#ifdef ARCH64
- unsigned long len = 0;
-#else
- unsigned int len = 0;
-#endif
- int *index = data;
-
- memset(buf, 0, sizeof(buf));
-
- if (g_io_channel_read_chars(chan, buf, sizeof(buf),
- &len, NULL) == G_IO_STATUS_ERROR) {
- TC_PRT("IO Channel read error");
- is_sub_index = FALSE;
- return FALSE;
- }
-
- *index = atoi(buf);
- is_sub_index = FALSE;
-
- return FALSE;
-}
-
-static void __select_index(void *data, const char *str)
-{
- GIOChannel *key_io;
-
- is_sub_index = TRUE;
-
- if (str)
- TC_PRT("%s ", str);
-
- key_io = g_io_channel_unix_new(fileno(stdin));
-
- g_io_channel_set_encoding(key_io, NULL, NULL);
- g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL);
-
- g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- __select_index_cb, data);
-
- g_io_channel_unref(key_io);
-}
-
-static void __bt_free_gatt_services(void)
-{
- int i;
-
- for (i = 0; i < service_index; i++) {
- bt_gatt_destroy_attribute_handle(service_clone[i]);
- service_clone[i] = NULL;
- }
-
- service_index = 0;
-}
-
-static void __bt_free_gatt_characteristics(void)
-{
- int i;
-
- for (i = 0; i < MAX_SERVICES; i++) {
- if (characteristics[i] == NULL)
- return;
-
- bt_gatt_destroy_attribute_handle(characteristics[i]);
- characteristics[i] = NULL;
- }
-}
-
-static void __bt_free_gatt_characteristics_services(void)
-{
- int i;
-
- for (i = 0; i < char_service_index; i++) {
- bt_gatt_destroy_attribute_handle(characteristics_services[i]);
- characteristics_services[i] = NULL;
- }
- char_service_index = 0;
-}
-
void __bt_adapter_state_changed_cb(int result,
bt_adapter_state_e adapter_state, void *user_data)
{
return true;
}
-bool __bt_gatt_primary_service_cb(bt_gatt_attribute_h service,
- void *user_data)
-{
- TC_PRT("__bt_gatt_primary_service_cb");
- TC_PRT("service %s", (char *)service);
- if (service_index >= MAX_SERVICES)
- return true;
-
- bt_gatt_clone_attribute_handle(&service_clone[service_index], service);
- service_index++;
- return true;
-}
-
-bool __bt_gatt_characteristics_discovered_cb(int result,
- int index, int total, bt_gatt_attribute_h characteristic, void *user_data)
-{
- TC_PRT("result: %s", __bt_get_error_message(result));
- TC_PRT("index %d", index);
- TC_PRT("total %d", total);
- TC_PRT("characteristic %s", (char *)characteristic);
-
- if (index >= MAX_SERVICES)
- return true;
-
- bt_gatt_clone_attribute_handle(&characteristics[index], characteristic);
- return true;
-}
-
-void __bt_gatt_characteristic_descriptor_discovered_cb(int result,
- unsigned char characteristic_format, int total,
- bt_gatt_attribute_h characteristic_descriptor, void *user_data)
-{
- TC_PRT("result: %s", __bt_get_error_message(result));
- TC_PRT("total %d", total);
- TC_PRT("characteristic_format 0x%02X", characteristic_format);
- TC_PRT("characteristic_descriptor %s", (char *)characteristic_descriptor);
-}
-
-bool __bt_gatt_included_service_cb(bt_gatt_attribute_h service,
- void *user_data)
-{
- char *uuid = NULL;
- char *name = NULL;
- unsigned char *value = NULL;
- int value_length = 0;
-
- TC_PRT("__bt_gatt_included_service_cb");
- TC_PRT("service %s", (char *)service);
-
- if (char_service_index >= MAX_SERVICES)
- return true;
-
- bt_gatt_clone_attribute_handle(&characteristics_services[char_service_index], service);
- char_service_index++;
-
- bt_gatt_get_characteristic_declaration(service, &uuid,
- &value, &value_length);
- bt_get_uuid_name(uuid, &name);
- TC_PRT("uuid: %s [%s]", uuid, name);
-
- g_free(value);
- g_free(uuid);
- g_free(name);
- return true;
-}
-
-void __bt_gatt_characteristic_changed_cb(bt_gatt_attribute_h characteristic,
- unsigned char *value, int value_length, void *user_data)
-{
- int i;
-
- TC_PRT("__bt_gatt_characteristic_changed_cb");
- TC_PRT("service %s", (char *)characteristic);
- TC_PRT("value_length %d", value_length);
-
- for (i = 0; i < value_length; i++)
- TC_PRT("value %c", value[i]);
-
- return;
-}
-
void __bt_gatt_char_write_cb(void *user_data)
{
TC_PRT("__bt_gatt_char_write_cb");
return;
}
-void __bt_gatt_remote_characteristic_write_cb(bt_gatt_attribute_h characteristic,
- unsigned char *char_value,
- int char_length, void *user_data)
-{
- TC_PRT("remote device updated the characteristics in db");
-
- TC_PRT("updated characteristic is %s", (char *)characteristic);
- TC_PRT("new char value is %s", char_value);
-}
-
void __bt_avrcp_target_connection_state_changed_cb(bool connected,
const char *remote_address, void *user_data)
{
break;
}
- case BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- __bt_free_gatt_services();
-
- ret = bt_gatt_foreach_primary_services(remote_addr,
- __bt_gatt_primary_service_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- if (ret == BT_ERROR_NONE)
- __select_index(&selected_service_index,
- "Select primary service :");
- break;
- } else {
- break; /* go to default */
- }
- case BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- __bt_free_gatt_characteristics();
-
- if (selected_service_index < 0) {
- TC_PRT("Need to select primary service \n");
- break;
- }
-
- ret = bt_gatt_discover_characteristics(
- service_clone[selected_service_index],
- __bt_gatt_characteristics_discovered_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- if (ret == BT_ERROR_NONE)
- __select_index(&selected_char_index, "Select index :");
- break;
- } else {
- break; /* goto default */
- }
- case BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- ret = bt_gatt_discover_characteristic_descriptor(
- characteristics[selected_char_index],
- __bt_gatt_characteristic_descriptor_discovered_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- char *uuid = NULL;
- char *name = NULL;
-
- if (selected_service_index < 0) {
- TC_PRT("Need to select primary service \n");
- break;
- }
-
- ret = bt_gatt_get_service_uuid(
- service_clone[selected_service_index],
- &uuid);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- } else {
- bt_get_uuid_name(uuid, &name);
- TC_PRT("uuid: %s [%s]", uuid, name);
- g_free(name);
- g_free(uuid);
- }
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- __bt_free_gatt_characteristics_services();
-
- if (selected_service_index < 0) {
- TC_PRT("Need to select primary service \n");
- break;
- }
-
- ret = bt_gatt_foreach_included_services(
- service_clone[selected_service_index],
- __bt_gatt_included_service_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- ret = bt_gatt_set_characteristic_changed_cb(
- __bt_gatt_characteristic_changed_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- ret = bt_gatt_unset_characteristic_changed_cb();
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- int i;
- char *uuid = NULL;
- char *name = NULL;
- unsigned char *value = NULL;
- int value_length = 0;
-
- ret = bt_gatt_get_characteristic_declaration(
- characteristics_services[0],
- &uuid, &value, &value_length);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- } else {
- bt_get_uuid_name(uuid, &name);
- TC_PRT("uuid: %s [%s]", uuid, name);
-
- for (i = 0; i < value_length; i++)
- TC_PRT("value %c", value[i]);
-
- g_free(uuid);
- g_free(name);
- g_free(value);
- }
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- unsigned char value[] = { 1 };
- if (selected_char_index == 0) {
- TC_PRT("Need to select charateristic value \n");
- break;
- }
-
- ret = bt_gatt_set_characteristic_value(
- characteristics[selected_char_index],
- value, 1);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- unsigned char value[] = { 1 };
- if (selected_char_index == 0) {
- TC_PRT("Need to select charateristic value \n");
- break;
- }
-
- ret = bt_gatt_set_characteristic_value_request(
- characteristics[selected_char_index],
- value, 1, __bt_gatt_char_write_cb);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- if (selected_char_index == 0) {
- TC_PRT("Need to select charateristic value \n");
- break;
- }
-
- ret = bt_gatt_read_characteristic_value(
- characteristics[selected_char_index],
- __bt_gatt_char_read_cb);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
-
- case BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- if (selected_service_index < 0) {
- TC_PRT("Need to select primary service \n");
- break;
- }
-
- ret = bt_gatt_watch_characteristic_changes(
- service_clone[selected_service_index]);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
- case BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES:
- if (TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT) {
- ret = bt_gatt_unwatch_characteristic_changes(
- service_clone[selected_service_index]);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- } else {
- break; /* goto default */
- }
case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
need_to_set_params = true;
TC_PRT("Select the function again");
int test_id;
bool is_call_api = false;
- if (is_sub_index)
- return TRUE;
-
memset(buf, 0, sizeof(buf));
if (g_io_channel_read_chars(chan, buf, sizeof(buf),