#ifndef __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__
#define __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__
-#include <dlog.h>
#include <stdbool.h>
#include <stdio.h>
-#include <bluetooth-api.h>
-#include <bluetooth-audio-api.h>
-#include <bluetooth-telephony-api.h>
-#include <bluetooth-media-control.h>
-#include <bluetooth-hid-api.h>
-#include <bluetooth-ipsp-api.h>
-
-#ifdef TIZEN_FEATURE_GATT_RELAY
-#include <bluetooth-gatt-server-api.h>
-#endif
-#ifdef TIZEN_GATT_CLIENT
-#include <bluetooth-gatt-client-api.h>
-#endif
+#include "bt-adaptation-common.h"
+#include "bt-adaptation-adapter.h"
+#include "bt-adaptation-device.h"
+#include "bt-adaptation-gatt.h"
#include "bluetooth.h"
#include "bluetooth_internal.h"
#define BT_DBG(fmt, args...) BT_PRT(fmt"\n", ##args)
#define BT_ERR(fmt, args...) BT_PRT(fmt"\n", ##args)
-#define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
-#define MAP_UUID "00001134-0000-1000-8000-00805f9b34fb"
-
-/* Manufacture ID for Apple iBeacons */
-#define COMPANY_ID_APPLE 0x004C
-
-/* Priximity Services UUID */
-#define PXP_IMMEDIATE_ALERT_SVC_UUID "1802"
-#define PXP_LINK_LOSS_SVC_UUID "1803"
-#define PXP_TX_POWER_SVC_UUID "1804"
-
/**
* @internal
* @brief Bluetooth callback.
bt_gatt_client_service_changed_cb service_changed_cb;
void *service_changed_user_data;
void *att_mtu_changed_user_data;
-#ifdef TIZEN_GATT_CLIENT
int client_id;
-#endif
} bt_gatt_client_s;
typedef struct {
void *parent;
char *path;
char *uuid;
-#ifdef TIZEN_FEATURE_GATT_RELAY
int handle;
-#endif
} bt_gatt_common_s;
typedef struct {
void *parent;
char *path;
char *uuid;
-#ifdef TIZEN_FEATURE_GATT_RELAY
int handle;
int numhandles;
-#endif
+
bool is_included_service;
bt_gatt_service_type_e service_type;
GSList *included_services;
GSList *characteristics;
-#ifdef TIZEN_GATT_CLIENT
int instance_id; /* Instance ID of the service object */
bt_gatt_handle_info_t svc_include_handles;
bt_gatt_handle_info_t charc_handles;
-#endif
+
char **include_handles;
char **char_handles;
} bt_gatt_service_s;
void *parent;
char *path;
char *uuid;
-#ifdef TIZEN_FEATURE_GATT_RELAY
int handle;
- bluetooth_device_address_t address;
-#endif
+ unsigned char addr[BT_ADDR_HEX_LEN];
+
int permissions;
int properties;
bt_gatt_write_type_e write_type;
GSList *descriptors;
-#ifdef TIZEN_GATT_CLIENT
int instance_id; /* Instance ID of the characteristic object */
bt_gatt_handle_info_t descriptor_handles;
-#endif
+
char **desc_handles;
bt_gatt_client_characteristic_value_changed_cb value_changed_cb;
int value_length;
char *value;
-#ifdef TIZEN_GATT_CLIENT
bt_gatt_client_request_completed_cb read_cb;
void *read_user_data;
bt_gatt_client_request_completed_cb write_cb;
void *write_user_data;
-#endif
} bt_gatt_characteristic_s;
typedef struct {
void *parent;
char *path;
char *uuid;
-#ifdef TIZEN_FEATURE_GATT_RELAY
int handle;
-#endif
-#ifdef TIZEN_GATT_CLIENT
+
int instance_id; /* Instance ID of the descriptor object */
-#endif
int permissions;
bt_gatt_server_write_value_requested_cb write_value_requested_cb;
int value_length;
char *value;
-#ifdef TIZEN_GATT_CLIENT
bt_gatt_client_request_completed_cb read_cb;
void *read_user_data;
bt_gatt_client_request_completed_cb write_cb;
void *write_user_data;
-#endif
} bt_gatt_descriptor_s;
typedef struct {
bt_gatt_client_request_completed_cb cb;
} bt_gatt_client_cb_data_s;
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Called when RSSI monitoring is enabled.
- * @since_tizen 3.0
- *
- * @param[in] remote_address Remote Device address
- * @param[in] link_type Link type for the connection (@c 0 = BR/EDR link, @c 1 = LE link).
- * @param[in] rssi_enabled RSSI monitoring status (@c 1 = enabled, @c 0 = disabled)
- * @param[in] user_data The user data passed from the callback registration function
- * @see bt_device_enable_rssi_monitor()
- * @see bt_device_disable_rssi_monitor()
- */
-typedef void (*bt_rssi_monitor_enabled_cb)(const char *remote_address,
- bt_device_connection_link_type_e link_type,
- int rssi_enabled, void *user_data);
-
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Called when RSSI Alert is received.
- * @since_tizen 3.0
- *
- * @param[in] remote_address Remote Device address
- * @param[in] link_type Link type for the connection (@c 0 = BR/EDR link, @c 1 = LE link).
- * @param[in] rssi_alert_type RSSI Alert type (@c 1 = High Alert (In-Range Alert), @c 2 = Low Alert)
- * @param[in] rssi_alert_dbm RSSI Alert signal strength value
- * @param[in] user_data The user data passed from the callback registration function
- * @see bt_device_enable_rssi_monitor()
- * @see bt_device_disable_rssi_monitor()
- */
-typedef void (*bt_rssi_alert_cb)(char *bt_address,
- bt_device_connection_link_type_e link_type,
- int rssi_alert_type, int rssi_alert_dbm, void *user_data);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Called when Raw RSSI signal strength is received.
- * @since_tizen 3.0
- *
- * @param[in] remote_address Remote Device address
- * @param[in] link_type Link type for the connection (@c 0 = BR/EDR link, @c 1 = LE link).
- * @param[in] rssi_dbm Raw RSSI signal strength value
- * @param[in] user_data The user data passed from the callback registration function
- * @see bt_device_get_rssi_strength()
- */
-typedef void (*bt_rssi_strength_cb)(char *bt_address,
- bt_device_connection_link_type_e link_type,
- int rssi_dbm, void *user_data);
-
-
typedef void (*_bt_gatt_client_value_changed_cb)(char *char_path,
unsigned char *value, int value_length, void *user_data);
-#ifdef TIZEN_GATT_CLIENT
typedef void (*_bt_gatt_client_val_changed_cb)(unsigned char *uuid, char *remote_address,
char *value, int value_length, void *user_data);
void _bt_handle_gatt_client_desc_write_completed_event(int result,
void *resp);
-#endif
/**
* @internal
#define BT_CHECK_INPUT_PARAMETER(arg) \
if (arg == NULL) { \
- LOGE("[%s] INVALID_PARAMETER(0%s=NULL)", __FUNCTION__, #arg); \
+ BT_PRT("INVALID_PARAMETER(0%s=NULL)", #arg); \
return BT_ERROR_INVALID_PARAMETER; \
}
#define BT_CHECK_INPUT_PARAMETER_UINT(arg) \
if (arg < -1) { \
- LOGE("[%s] INVALID_PARAMETER_UINT(%s=%d)", __FUNCTION__, #arg, arg); \
+ BT_PRT("INVALID_PARAMETER_UINT(%s=%d)", #arg, arg); \
return BT_ERROR_INVALID_PARAMETER; \
}
#define BT_CHECK_INPUT_PARAMETER_BOOL(arg) \
if (arg < -1 || arg > 1) { \
- LOGE("[%s] INVALID_PARAMETER_BOOL(%s=%d)", __FUNCTION__, #arg, arg); \
+ BT_PRT("INVALID_PARAMETER_BOOL(%s=%d)", #arg, arg); \
return BT_ERROR_INVALID_PARAMETER; \
}
#define BT_CHECK_INIT_STATUS() \
if (_bt_check_init_status() == BT_ERROR_NOT_INITIALIZED) { \
- LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \
+ BT_PRT("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); \
return BT_ERROR_NOT_INITIALIZED; \
}
#define BT_CHECK_ADAPTER_STATUS() \
if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) { \
- LOGE("[%s] BT_ERROR_NOT_ENABLED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_ENABLED); \
+ BT_PRT("BT_ERROR_NOT_ENABLED(0x%08x)", BT_ERROR_NOT_ENABLED); \
return BT_ERROR_NOT_ENABLED; \
}
*/
int _bt_get_error_code(int origin_error);
-
-/**
- * @internal
- * @brief Convert Bluetooth F/W bluetooth_device_info_t to capi bt_device_info_s.
- */
-int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev);
-
-
/**
* @internal
* @brief Filter Advertising data based on AD type.
* @internal
* @brief Convert Bluetooth F/W bluetooth_device_address_t to string.
*/
-int _bt_convert_address_to_string(char **addr_str, bluetooth_device_address_t *addr_hex);
+int _bt_convert_address_to_string(char **addr_str, unsigned char *addr);
/**
* @internal
* @brief Convert string to Bluetooth F/W bluetooth_device_address_t.
*/
-void _bt_convert_address_to_hex(bluetooth_device_address_t *addr_hex, const char *addr_str);
+void _bt_convert_address_to_hex(unsigned char **addr, const char *addr_str);
void _handle_gatt_client_read_completed_event(int result, bt_gatt_resp_data_t *resp);
*/
char* _bt_convert_uuid_to_uuid128(const char *uuid);
-/**
- * @internal
- * @brief Convert the visibility mode
- */
-bt_adapter_visibility_mode_e _bt_get_bt_visibility_mode_e(bluetooth_discoverable_mode_t mode);
-
-/**
- * @internal
- * @brief Since the Audio call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_audio_event_proxy(int event, bt_audio_event_param_t *param, void *user_data);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_HF_MODULE
- * @brief Enumerations for the device state event from Audio-Gateway device
- * @since_tizen 3.0
- */
-typedef enum {
- BT_HF_REMOTE_DEVICE_STATE_BATTERY_LEVEL = 0x00, /**< Battery charge level of AG (ranges from 0 to 5) */
- BT_HF_REMOTE_DEVICE_STATE_SIGNAL_STRENGTH, /**< Signal strength level of AG (ranges from 0 to 5) */
- BT_HF_REMOTE_DEVICE_STATE_NETWORK_SERVICE, /**< Network service availability (0:no service , 1:available) */
- BT_HF_REMOTE_DEVICE_STATE_VOICE_RECOGNITON, /**< Voice Recognition State (0:disabled , 1:enabled) */
-} bt_hf_remote_device_state_e;
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_HF_MODULE
- * @brief Called when a device status changed event happend from Audio-Gateway device
- * @since_tizen 3.0
- *
- * @param[in] event The device state chagned event from remote Audio-Gateway device
- * @param[in] value The new values to be changed.
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @see bt_hf_set_remote_device_state_changed_cb()
- * @see bt_hf_unset_remote_device_state_changed_cb()
- */
-typedef void (*bt_hf_remote_device_state_changed_cb) (bt_hf_remote_device_state_e state, int value, void *user_data);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_HF_MODULE
- * @brief Called when a vendor command event happened from Hands-Free.
- * @since_tizen 2.3.2
- * @remarks The @a meesage of cmd must be released with free() by you.
- *
- * @param[in] cmd The information of vendor command
- * @param[in] user_data The user data passed from the callback registration function
- * @see bt_hf_set_vendor_dep_cmd_event_cb()
- * @see bt_hf_unset_vendor_dep_cmd_event_cb()
- */
-typedef void (*bt_hf_vendor_dep_cmd_event_cb) (bt_hf_vendor_dep_at_cmd_s cmd, void *user_data);
-
-/**
- * @internal
- * @brief Since the HF call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_hf_event_proxy(int event, bt_hf_event_param_t *param, void *user_data);
-
-/**
- * @internal
- * @brief Since the Telephony call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_telephony_event_proxy(int event, telephony_event_param_t *param, void *user_data);
-
-/**
- * @internal
- * @brief Since the AVRCP call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_avrcp_event_proxy(int event, media_event_param_t *param, void *user_data);
-
-/**
- * @internal
- * @brief Since the HID call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_hid_event_proxy(int event, hid_event_param_t *param, void *user_data);
-
void _bt_adapter_le_invoke_advertising_state_cb(int handle, int result, bt_adapter_le_advertising_state_e adv_state);
bool _bt_gatt_is_legacy_client_mode(void);
const GSList* _bt_gatt_get_server_list(void);
-#ifdef TIZEN_GATT_CLIENT
bt_gatt_h _bt_gatt_client_add_service(bt_gatt_client_h client,
const char *uuid, int instance_id);
-#else
-bt_gatt_h _bt_gatt_client_add_service(bt_gatt_client_h client, const char *path);
-#endif
int _bt_gatt_client_update_services(bt_gatt_client_h client);
int _bt_gatt_client_update_descriptors(bt_gatt_h characteristic);
-#ifdef TIZEN_FEATURE_GATT_RELAY
-/**
- * @internal
- * @brief Since the GATT Server call back and event proxy call backs have different prototype it is wrapper function.
- */
-void _bt_gatt_server_event_proxy(int event, gatt_server_event_param_t *param, void *user_data);
-#endif
-
-
-#ifdef TIZEN_GATT_CLIENT
-void _bt_gatt_client_event_proxy(int event,
- gatt_client_event_param_t *param, void *user_data);
-#endif
-
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE
- * @brief Reads the maximum data length of LE packets supported by the controller.
- * @since_tizen 3.0
- *
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @see bt_initialize
- */
-int bt_adapter_le_read_maximum_data_length(
- int *max_tx_octets, int *max_tx_time,
- int *max_rx_octets, int *max_rx_time);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE
- * @brief Writes the Host suggested default data length of LE packets to the controller.
- * @since_tizen 3.0
- *
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @see bt_initialize
- */
-int bt_adapter_le_write_host_suggested_default_data_length(
- const unsigned int def_tx_Octets, const unsigned int def_tx_Time);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE
- * @brief Reads the Host suggested data length values of LE packets from the controller.
- * @since_tizen 3.0
- *
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @see bt_initialize
- */
-int bt_adapter_le_read_suggested_default_data_length(
- unsigned int *def_tx_Octets, unsigned int *def_tx_Time);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE
- * @brief Allows the host to suggest to controller, the data length parameters to be used
- * for a given LE Connection.
- * @since_tizen 3.0
- *
- * @retval #BT_ERROR_NONE Successful
- * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED Not supported
- *
- * @see bt_initialize
- */
-int bt_device_le_set_data_length(const char *remote_address,
- unsigned int max_tx_Octets, unsigned int max_tx_Time);
-
-/**
- * @internal
- * @brief LE data length changed callback
- */
-typedef void (*_bt_le_set_data_length_changed_cb)
- (int result, const char *remote_address, int max_tx_octets,
- int max_tx_time, int max_rx_octets, int max_rx_time, void *user_data);
-
-int bt_device_le_set_data_length_change_cb(
- _bt_le_set_data_length_changed_cb callback, void *user_data);
-
-/**
- * @internal
- * @brief Reads if the Proximity profile is registered or not.
- */
-int _bt_check_proximity_is_initialized(bool *is_initialized);
-
-/**
- * @internal
- * @brief Calls the connection state changed callback for proximity profile.
- */
-int _bt_proximity_connection_set_state_changed(int result, const char *remote_address, bool connected);
-
-/**
- * @internal
- * @brief Send GATT connection state changed status with remote TDS provider.
- */
-void _bt_tds_update_seeker_connection_state_changed(int result, const char *remote_address, bool connected);
-
-/**
- * @internal
- * @brief Send GATT connection state changed status with remote HRP collector.
- */
-void __bt_hrp_le_connection_state_changed_cb(int result, const char *remote_address, bool connected);
-
-/**
- * @internal
- * @brief Parses TDS AD Type data recived in scan, to extract meaningful transport specific data.
- */
-int _bt_tds_parse_transport_blocks(bt_tds_transport_block_list_s **info, char *data, int data_len);
-
-/**
- * @internal
- * @brief Handles complete TDS specific data to be sent to application.
- */
-void _bt_tds_send_complete_transport_data(int result, const char *address, char *data, int data_len);
-
-/**
- * @internal
- * @brief Send Result of TDS specific CCCD enabled event of Remote TDS provider.
- */
-void _bt_tds_control_point_enabled_update(int result, const char *remote_address);
-
-/**
- * @internal
- * @brief Send Result of TDS control point activate ACK event.
- */
-void _bt_tds_control_point_activation_result_update(int result, const char *remote_address);
-
-/**
- * @internal
- * @brief Send TDS Indication response from remote TDS provider.
- */
-void _bt_tds_control_point_indication_response_update(const char *address, bluetooth_tds_indication_res_t *info);
-
-/**
- * @internal
- * @brief Sends GATT primary service status changed of Remote Provider.
- */
-void _bt_tds_check_service_changed(char *address, bt_gatt_service_change_t *service_change);
-
-/**
- * @internal
- * @brief Send GATT connection state changed status with remote OTP Server.
- */
-void _bt_otp_client_connection_state_changed(int result, const char *remote_address, bool connected);
-
-/**
- * @internal
- * @brief Send GATT Read Response status got from remote OTP Server.
- */
-void _bt_otp_client_read_value_response(int result, char *char_path,
- char *char_value, int val_len);
-
-/**
- * @internal
- * @brief Send GATT Write Response status got from remote OTP Server.
- */
-void _bt_otp_client_write_value_response(int result, char *handle);
-
-/**
- * @internal
- * @brief Send GATT Notification Enabled Response status got from remote OTP Server.
- */
-void _bt_otp_client_notification_enabled(int result, char *handle);
-
-/**
- * @internal
- * @brief Send GATT Indicate Response status got from remote OTP Server.
- */
-void _bt_otp_client_indication(int result, bluetooth_otp_resp_info_t *info);
-
-/**
- * @internal
- * @brief Send OTC connection status to application.
- */
-void _bt_otc_connection_state_changed(int result, bluetooth_otc_info_t *otc_info);
-
-/**
- * @internal
- * @brief Sends GATT primary service status changed of Remote Server.
- */
-void _bt_otp_check_service_changed(char *address, bt_gatt_service_change_t *service_change);
#ifdef __cplusplus
}
*/
#include <stdbool.h>
+#include <string.h>
#include <math.h>
-#include <bluetooth-api.h>
+
+#include "bt-adaptation-gatt.h"
#include "bluetooth.h"
#include "bluetooth_private.h"
#include "bluetooth_internal.h"
#include "bluetooth_type_internal.h"
-#ifdef TIZEN_FEATURE_GATT_RELAY
-#include "bluetooth-gatt-server-api.h"
-/* TODO_40 : 4.0 merge - Need to check if it is ok to use the grobal variable or not. */
-int instance_id;
-#endif
-
-#ifdef TIZEN_GATT_CLIENT
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <arpa/inet.h>
-#include "bluetooth-gatt-client-api.h"
-#endif
#define BT_ADDR_STR_LEN 17
static GSList *gatt_client_list = NULL;
-
static GSList *gatt_handle_list = NULL;
-
static GSList *gatt_server_list = NULL;
+
+int instance_id;
static bool is_gatt_server_initialized = false;
static bool is_gatt_server_started = false;
#define BT_CHECK_GATT_SERVER_INIT_STATUS() { \
if (__bt_check_gatt_server_init_status() == BT_ERROR_NOT_INITIALIZED) { \
- LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, \
- BT_ERROR_NOT_INITIALIZED); \
+ BT_PRT("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); \
return BT_ERROR_NOT_INITIALIZED; \
} \
}
} \
} \
-#ifdef TIZEN_GATT_CLIENT
static void __bt_gatt_free_service(bt_gatt_h gatt_handle);
/* LCOV_EXCL_START */
memcpy(&(uuid[14]), &uuid5, 2);
return;
}
-#endif
static int __bt_check_gatt_server_init_status(void)
{
bt_gatt_descriptor_destroy(gatt_handle);
}
-#ifdef TIZEN_GATT_CLIENT
bt_gatt_h _bt_gatt_client_add_service(bt_gatt_client_h client,
const char *uuid, int instance_id)
{
int ret;
bt_gatt_client_s *client_s = (bt_gatt_client_s*)client;
bt_gatt_service_s *svc = NULL;
- bt_gatt_service_property_t property;
- bt_gatt_handle_property_t service;
+ bt_gatt_svc_prop_t property;
+ bt_gatt_handle_prop_t service;
if (client == NULL || uuid == NULL) {
BT_ERR("Invalid parameter");
return NULL;
}
- memset(&property, 0x00, sizeof(bt_gatt_service_property_t));
- memset(&service, 0x00, sizeof(bt_gatt_handle_property_t));
+ memset(&property, 0x00, sizeof(bt_gatt_svc_prop_t));
+ memset(&service, 0x00, sizeof(bt_gatt_handle_prop_t));
__bt_string_to_uuid_hex(uuid, service.uuid);
service.instance_id = instance_id;
BT_INFO("GATT client add service: get all properties of this service");
- ret = bluetooth_gatt_client_get_service_property(client_s->remote_address,
+ ret = bt_adapt_gatt_client_get_svc_property(client_s->remote_address,
&service, &property);
- ret = _bt_get_error_code(ret);
+
if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_service_property is failed");
+ BT_ERR("bt_adapt_gatt_client_get_svc_property is failed");
return NULL;
}
memcpy(&svc->charc_handles, &property.char_handle, sizeof(bt_gatt_handle_info_t));
BT_INFO("Total number of Characteristic handles [%d]", svc->charc_handles.count);
- bluetooth_gatt_free_service_property(&property);
+ bt_adapt_gatt_free_svc_property(&property);
client_s->services = g_slist_append(client_s->services, svc);
BT_INFO("GATT service added , current count of Client services [%d]",
return svc;
}
-#else
-bt_gatt_h _bt_gatt_client_add_service(bt_gatt_client_h client, const char *path)
-{
- int ret;
- bt_gatt_client_s *client_s = client;
- bt_gatt_service_s *svc = NULL;
- bt_gatt_service_property_t property;
-
- if (client == NULL || path == NULL) {
- BT_ERR("Invalid parameter");
- return NULL;
- }
-
- memset(&property, 0x00, sizeof(property));
-
- ret = bluetooth_gatt_get_service_property(path, &property);
- ret = _bt_get_error_code(ret);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_service_property is failed");
- return NULL;
- }
-
- svc = __bt_gatt_service_create(property.uuid,
- BT_GATT_SERVICE_TYPE_PRIMARY);
- if (svc == NULL) {
- BT_ERR("svc is NULL");
- return NULL;
- }
- svc->role = BT_GATT_ROLE_CLIENT;
- svc->parent = (void *)client_s;
- svc->is_included_service = false;
- svc->path = g_strdup(path);
-
- svc->include_handles = property.include_handles.handle;
- property.include_handles.handle = NULL;
-
- svc->char_handles = property.char_handle.handle;
- property.char_handle.handle = NULL;
-
- bluetooth_gatt_free_service_property(&property);
- client_s->services = g_slist_append(client_s->services, svc);
-
- return svc;
-}
-#endif
-#ifdef TIZEN_GATT_CLIENT
int _bt_gatt_client_update_services(bt_gatt_client_h client)
{
bt_gatt_client_s *client_s = client;
- bluetooth_device_address_t addr_hex = { {0, } };
bt_gatt_handle_info_t prim_svc;
int ret;
int i;
BT_INFO("Update services for remote GATT server [%s]",
client_s->remote_address);
- _bt_convert_address_to_hex(&addr_hex, client_s->remote_address);
- ret = bluetooth_gatt_client_get_primary_services(&addr_hex, &prim_svc);
- ret = _bt_get_error_code(ret);
+ ret = bt_adapt_gatt_client_get_primary_services(client_s->remote_address, &prim_svc);
+
if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_client_get_primary_services is failed");
+ BT_ERR("bt_adapt_gatt_client_get_primary_services is failed");
return ret;
}
}
return BT_ERROR_NONE;
}
-#else
-int _bt_gatt_client_update_services(bt_gatt_client_h client)
-{
- bt_gatt_client_s *client_s = client;
- bluetooth_device_address_t addr_hex = { {0, } };
- bt_gatt_handle_info_t prim_svc;
- int ret;
- int i;
-
- if (!client_s->connected) {
- BT_INFO("Not connected");
- return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
- }
-
- if (client_s->services_discovered) {
- BT_INFO("Already discovered");
- return BT_ERROR_ALREADY_DONE;
- }
-
- _bt_convert_address_to_hex(&addr_hex, client_s->remote_address);
-
- ret = bluetooth_gatt_get_primary_services(&addr_hex, &prim_svc);
- ret = _bt_get_error_code(ret);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_primary_services is failed");
- return ret;
- }
-
- if (client_s->services)
- g_slist_free_full(client_s->services, __bt_gatt_free_service);
-
- client_s->services = NULL;
-
- if (prim_svc.count == 0) {
- BT_INFO("There is no service");
- return BT_ERROR_NONE;
- }
-
- client_s->services_discovered = true;
- for (i = 0; i < prim_svc.count; i++) {
- if (!_bt_gatt_client_add_service(client, prim_svc.handle[i])) {
- BT_ERR("_bt_gatt_client_add_service is failed [%s]",
- prim_svc.handle[i]);
- client_s->services_discovered = false;
- }
- }
- g_strfreev(prim_svc.handle);
-
- return BT_ERROR_NONE;
-}
-#endif
int _bt_gatt_client_update_include_services(bt_gatt_h service)
{
bt_gatt_service_s *svc = service;
+ bt_gatt_client_s *client_s;
GSList *include_list = NULL;
int i;
if (svc->include_handles == NULL)
return BT_ERROR_NONE;
+ client_s = (bt_gatt_client_s*)svc->parent;
+
for (i = 0; svc->include_handles[i]; i++) {
bt_gatt_service_s *sec_svc = NULL;
- bt_gatt_service_property_t sec_property;
+ bt_gatt_handle_prop_t service;
+ bt_gatt_svc_prop_t sec_property;
int ret;
+ memset(&service, 0x00, sizeof(bt_gatt_handle_prop_t));
memset(&sec_property, 0x00, sizeof(sec_property));
- ret = bluetooth_gatt_get_service_property(
- svc->include_handles[i], &sec_property);
- ret = _bt_get_error_code(ret);
+ ret = bt_adapt_gatt_client_get_svc_property(client_s->remote_address,
+ &service, &sec_property);
+
if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_service_property is failed");
+ BT_ERR("bt_adapt_gatt_client_get_svc_property is failed");
continue;
}
include_list = g_slist_append(include_list, sec_svc);
next:
- bluetooth_gatt_free_service_property(&sec_property);
+ bt_adapt_gatt_free_svc_property(&sec_property);
}
g_strfreev(svc->include_handles);
return BT_ERROR_NONE;
}
-#ifdef TIZEN_GATT_CLIENT
int _bt_gatt_client_update_characteristics(bt_gatt_h service)
{
bt_gatt_service_s *svc = service;
bt_gatt_client_s *client_s;
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t char_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t char_handle;
GSList *chr_list = NULL;
int i;
if (svc->charc_handles.count == 0)
return BT_ERROR_NONE;
- memset(&svc_handle, 0x00, sizeof(bt_gatt_handle_property_t));
- memset(&char_handle, 0x00, sizeof(bt_gatt_handle_property_t));
+ memset(&svc_handle, 0x00, sizeof(bt_gatt_handle_prop_t));
+ memset(&char_handle, 0x00, sizeof(bt_gatt_handle_prop_t));
client_s = (bt_gatt_client_s*)svc->parent;
for (i = 0; i < svc->charc_handles.count; i++) {
bt_gatt_characteristic_s *chr = NULL;
- bt_gatt_char_property_t char_property;
+ bt_gatt_char_prop_t char_property;
int ret;
memset(&char_property, 0x00, sizeof(char_property));
char_handle.instance_id = svc->charc_handles.inst_id[i];
BT_INFO("Retrieve Characteristics properties");
- ret = bluetooth_gatt_client_get_characteristics_property(
+ ret = bt_adapt_gatt_client_get_char_property(
client_s->remote_address,
&svc_handle,
&char_handle,
&char_property);
- ret = _bt_get_error_code(ret);
+
if (ret != BT_ERROR_NONE) {
BT_ERR("bluetooth_gatt_get_characteristics_property is failed");
continue;
}
BT_INFO("Characteristics properties are retreived, not create charc object");
- ret = bt_gatt_characteristic_create(char_property.uuid, 0,
+ ret = bt_gatt_characteristic_create((const char *)char_property.uuid, 0,
char_property.permission,
(char *)char_property.val,
(int)char_property.val_len, (bt_gatt_h *)&chr);
chr_list = g_slist_append(chr_list, chr);
next:
- bluetooth_gatt_free_char_property(&char_property);
+ bt_adapt_gatt_free_char_property(&char_property);
}
memset(&svc->charc_handles, 0x00, sizeof(bt_gatt_handle_info_t));
return BT_ERROR_NONE;
}
-#else
-int _bt_gatt_client_update_characteristics(bt_gatt_h service)
-{
- bt_gatt_service_s *svc = service;
- GSList *chr_list = NULL;
- int i;
-
- if (svc == NULL)
- return BT_ERROR_INVALID_PARAMETER;
-
- if (svc->char_handles == NULL)
- return BT_ERROR_NONE;
-
- for (i = 0; svc->char_handles[i]; i++) {
- bt_gatt_characteristic_s *chr = NULL;
- bt_gatt_char_property_t char_property;
- int ret;
-
- memset(&char_property, 0x00, sizeof(char_property));
-
- ret = bluetooth_gatt_get_characteristics_property(
- svc->char_handles[i], &char_property);
- ret = _bt_get_error_code(ret);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_characteristics_property is failed");
- continue;
- }
-
- ret = bt_gatt_characteristic_create(char_property.uuid, 0,
- char_property.permission,
- (char *)char_property.val,
- (int)char_property.val_len, (bt_gatt_h *)&chr);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bt_gatt_characteristic_create is failed");
- goto next;
- }
-
- if (char_property.permission & BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE)
- chr->write_type = BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE;
- else if (char_property.permission & BT_GATT_PROPERTY_WRITE)
- chr->write_type = BT_GATT_WRITE_TYPE_WRITE;
-
- chr->path = g_strdup(svc->char_handles[i]);
- chr->parent = (void *)svc;
- chr->role = BT_GATT_ROLE_CLIENT;
- chr->desc_handles = char_property.char_desc_handle.handle;
- char_property.char_desc_handle.handle = NULL;
-
- chr_list = g_slist_append(chr_list, chr);
-next:
- bluetooth_gatt_free_char_property(&char_property);
- }
-
- g_strfreev(svc->char_handles);
- svc->char_handles = NULL;
-
- g_slist_free_full(svc->characteristics, __bt_gatt_free_characteristic);
-
- svc->characteristics = chr_list;
-
- return BT_ERROR_NONE;
-}
-#endif
-
-#ifdef TIZEN_GATT_CLIENT
int _bt_gatt_client_update_descriptors(bt_gatt_h characteristic)
{
bt_gatt_characteristic_s *chr = characteristic;
bt_gatt_service_s *svc;
bt_gatt_client_s *client_s;
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t char_handle;
- bt_gatt_handle_property_t desc_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t char_handle;
+ bt_gatt_handle_prop_t desc_handle;
BT_INFO("+");
if (chr == NULL)
return BT_ERROR_NONE;
svc = (bt_gatt_service_s*)chr->parent;
- memset(&svc_handle, 0x00, sizeof(bt_gatt_handle_property_t));
- memset(&char_handle, 0x00, sizeof(bt_gatt_handle_property_t));
- memset(&desc_handle, 0x00, sizeof(bt_gatt_handle_property_t));
+ memset(&svc_handle, 0x00, sizeof(bt_gatt_handle_prop_t));
+ memset(&char_handle, 0x00, sizeof(bt_gatt_handle_prop_t));
+ memset(&desc_handle, 0x00, sizeof(bt_gatt_handle_prop_t));
client_s = (bt_gatt_client_s*)svc->parent;
for (i = 0; i < chr->descriptor_handles.count; i++) {
bt_gatt_descriptor_s *desc = NULL;
- bt_gatt_char_descriptor_property_t desc_property;
+ bt_gatt_char_desc_prop_t desc_property;
int ret;
memset(&desc_property, 0x00, sizeof(desc_property));
BT_INFO("Retreieve Desceriptor Properties from remote [%s]",
client_s->remote_address);
- ret = bluetooth_gatt_client_get_char_descriptor_property(
+ ret = bt_adapt_gatt_client_get_char_desc_property(
client_s->remote_address,
&svc_handle,
&char_handle,
&desc_handle,
&desc_property);
- ret = _bt_get_error_code(ret);
+
if (ret != BT_ERROR_NONE) {
BT_ERR("bluetooth_gatt_get_char_descriptor_property is failed");
continue;
desc->role = BT_GATT_ROLE_CLIENT;
desc_list = g_slist_append(desc_list, desc);
next:
- bluetooth_gatt_free_desc_property(&desc_property);
+ bt_adapt_gatt_free_desc_property(&desc_property);
}
return BT_ERROR_NONE;
}
-#else
-int _bt_gatt_client_update_descriptors(bt_gatt_h characteristic)
-{
- bt_gatt_characteristic_s *chr = characteristic;
- GSList *desc_list = NULL;
- int i;
-
- if (chr == NULL)
- return BT_ERROR_INVALID_PARAMETER;
-
- if (chr->desc_handles == NULL)
- return BT_ERROR_NONE;
-
- for (i = 0; chr->desc_handles[i]; i++) {
- bt_gatt_descriptor_s *desc = NULL;
- bt_gatt_char_descriptor_property_t desc_property;
- int ret;
-
- memset(&desc_property, 0x00, sizeof(desc_property));
-
- ret = bluetooth_gatt_get_char_descriptor_property(
- chr->desc_handles[i], &desc_property);
- ret = _bt_get_error_code(ret);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bluetooth_gatt_get_char_descriptor_property is failed");
- continue;
- }
-
- ret = bt_gatt_descriptor_create(desc_property.uuid, 0,
- (char*)desc_property.val,
- (int)desc_property.val_len,
- (bt_gatt_h *)&desc);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bt_gatt_characteristic_create is failed");
- goto next;
- }
-
- desc->path = g_strdup(chr->desc_handles[i]);
- desc->parent = (void *)characteristic;
- desc->role = BT_GATT_ROLE_CLIENT;
-
- desc_list = g_slist_append(desc_list, desc);
-next:
- bluetooth_gatt_free_desc_property(&desc_property);
- }
-
- g_strfreev(chr->desc_handles);
- chr->desc_handles = NULL;
-
- g_slist_free_full(chr->descriptors, __bt_gatt_free_descriptor);
-
- chr->descriptors = desc_list;
-
- return BT_ERROR_NONE;
-}
-#endif
-#ifdef TIZEN_GATT_CLIENT
/* LCOV_EXCL_STOP */
int bt_gatt_connect(const char *address, bool auto_connect)
{
int ret;
- bluetooth_device_address_t bd_addr = { {0,} };
bt_gatt_client_s *client_s;
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(address);
- _bt_convert_address_to_hex(&bd_addr, address);
/* Find any client attached with remote address or not */
client_s = _bt_gatt_get_client(address);
if (client_s) {
BT_INFO("GATT client instance is already present for the rmeote addr [%s] client_id[%d]",
address, client_s->client_id);
- ret = _bt_get_error_code(bluetooth_connect_le(&bd_addr,
- auto_connect, client_s->client_id));
+ ret = bt_adapt_gatt_connect(address, auto_connect, client_s->client_id);
} else {
BT_INFO("GATT client instance is NOT present for the remote addr [%s]",
address);
- ret = _bt_get_error_code(bluetooth_connect_le(&bd_addr,
- auto_connect, 0/* Default Client ID */));
-
+ ret = bt_adapt_gatt_connect(address, auto_connect, 0);
}
if (ret != BT_ERROR_NONE)
return ret;
}
-#else
-int bt_gatt_connect(const char *address, bool auto_connect)
-{
- int ret;
- bluetooth_device_address_t bd_addr = { {0,} };
-
- BT_CHECK_GATT_CLIENT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(address);
- _bt_convert_address_to_hex(&bd_addr, address);
-
- ret = _bt_get_error_code(bluetooth_connect_le(&bd_addr,
- auto_connect ? TRUE : FALSE));
-
- if (ret != BT_ERROR_NONE)
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
-
- return ret;
-}
-#endif
int bt_gatt_disconnect(const char *address)
{
int ret;
- bluetooth_device_address_t bd_addr = { {0,} };
-#ifdef TIZEN_GATT_CLIENT
bt_gatt_client_s *client_s;
-#endif
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(address);
- _bt_convert_address_to_hex(&bd_addr, address);
-#ifdef TIZEN_GATT_CLIENT
/* Find any client attached with remote address or not */
client_s = _bt_gatt_get_client(address);
if (client_s) {
BT_INFO("GATT client instance is already present for the remote addr [%s] client interface [%d]",
address, client_s->client_id);
- ret = _bt_get_error_code(bluetooth_disconnect_le(&bd_addr, client_s->client_id));
+ ret = bt_adapt_gatt_disconnect(address, client_s->client_id);
} else {
BT_INFO("GATT client instance is NOT present for the remote addr [%s]",
address);
- ret = _bt_get_error_code(bluetooth_disconnect_le(&bd_addr, 0 /* Default CLient ID */));
+ ret = bt_adapt_gatt_disconnect(address, 0);
}
-#else
- ret = _bt_get_error_code(bluetooth_disconnect_le(&bd_addr));
-#endif
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
static void __bt_gatt_free_characteristic(bt_gatt_h gatt_handle)
{
int ret;
-#ifdef TIZEN_GATT_CLIENT
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t chr_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t chr_handle;
bt_gatt_service_s *service_s;
bt_gatt_client_s *client_s;
-#endif
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)gatt_handle;
if (gatt_handle_list)
gatt_handle_list = g_slist_remove(gatt_handle_list, gatt_handle);
-#ifdef TIZEN_GATT_CLIENT
service_s = (bt_gatt_service_s*)chr->parent;
if (!service_s) {
BT_ERR("service_s is null");
__bt_string_to_uuid_hex(chr->uuid, chr_handle.uuid);
chr_handle.instance_id = chr->instance_id;
-#endif
+
if (chr->role == BT_GATT_ROLE_CLIENT && chr->value_changed_cb &&
chr->properties &
(BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_INDICATE)) {
BT_DBG("Unwatch characteristic");
- ret = _bt_get_error_code(bluetooth_gatt_unwatch_characteristics(
- chr->path));
+ ret = bt_adapt_gatt_client_unwatch_char(client_s->remote_address, &svc_handle, &chr_handle, chr->instance_id);
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
}
fail:
g_slist_free_full(chr->descriptors, __bt_gatt_free_descriptor);
-#ifndef TIZEN_GATT_CLIENT
- g_strfreev(chr->desc_handles);
-#endif
-
g_free(chr->path);
g_free(chr->uuid);
g_free(chr->value);
gatt_handle_list = g_slist_remove(gatt_handle_list, gatt_handle);
if (svc->role == BT_GATT_ROLE_SERVER) {
-#ifdef TIZEN_FEATURE_GATT_RELAY
if (is_gatt_server_initialized) {
BT_INFO("GATT Server Delete Service: service handle [%d] Inst ID [%d]", svc->handle, instance_id);
- ret = _bt_get_error_code(bluetooth_gatt_server_delete_service(svc->handle, instance_id));
+ ret = bt_adapt_gatt_server_delete_service(svc->handle, instance_id);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)",
_bt_convert_error_to_string(ret), ret);
}
}
-#else
- ret = _bt_get_error_code(bluetooth_gatt_unregister_service(svc->path));
- if (ret != BT_ERROR_NONE)
- BT_ERR("%s(0x%08x) : Failed to unregister service",
- _bt_convert_error_to_string(ret), ret);
-#endif
}
g_strfreev(svc->include_handles);
int value_length)
{
int ret;
+ int k;
char **val = NULL;
int *val_len = NULL;
bt_gatt_common_s *handle = (bt_gatt_common_s *)gatt_handle;
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle;
-#ifdef TIZEN_FEATURE_GATT_RELAY
- int k;
- bluetooth_gatt_server_update_value_t param;
-#endif
-
BT_INFO("+");
BT_CHECK_GATT_SUPPORT();
BT_CHECK_INIT_STATUS();
return BT_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_GATT_RELAY
if (handle->role == BT_GATT_ROLE_SERVER && handle->handle) {
-
- memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
-
/* DEBUG */
for (k = 0; k < value_length; k++)
BT_DBG("New Value[%d] = [0x%x]", k, value[k]);
- param.length = value_length;
- memcpy(¶m.data.data[0], value, value_length);
-
- param.attribute_handle = handle->handle;
- ret = _bt_get_error_code(bluetooth_gatt_server_update_characteristic(instance_id,
- ¶m));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
- }
-#else
- if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path,
- value, value_length));
+ ret = bt_adapt_gatt_server_update_char(instance_id, handle->handle, value, value_length);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
}
}
-#endif
+
g_free(*val);
*val = NULL;
if (value_length > 0)
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle;
-#ifdef TIZEN_FEATURE_GATT_RELAY
- bluetooth_gatt_server_update_value_t param;
-#endif
-
BT_CHECK_GATT_SUPPORT();
BT_CHECK_INIT_STATUS();
}
if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
-#ifdef TIZEN_FEATURE_GATT_RELAY
- memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
- memcpy(¶m.data.data[0], *val, *val_len);
-
- param.length = *val_len;
- param.attribute_handle = handle->handle;
- ret = _bt_get_error_code(bluetooth_gatt_server_update_characteristic(instance_id,
- ¶m));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path,
- *val, *val_len));
-#endif
+ ret = bt_adapt_gatt_server_update_char(instance_id, handle->handle, (const char *)*val, *val_len);
+
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle;
-#ifdef TIZEN_FEATURE_GATT_RELAY
- bluetooth_gatt_server_update_value_t param;
-#endif
-
BT_CHECK_GATT_SUPPORT();
BT_CHECK_INIT_STATUS();
}
if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
-#ifdef TIZEN_FEATURE_GATT_RELAY
- memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
- memcpy(¶m.data.data[0], *val, *val_len);
-
- param.length = *val_len;
- param.attribute_handle = handle->handle;
-
- ret = _bt_get_error_code(bluetooth_gatt_server_update_characteristic(instance_id,
- ¶m));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path,
- *val, *val_len));
-#endif
+ ret = bt_adapt_gatt_server_update_char(instance_id, handle->handle, (const char *)val, *val_len);
+
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
return NULL;
svc->type = BT_GATT_TYPE_SERVICE;
-#ifdef TIZEN_FEATURE_GATT_RELAY
svc->uuid = _bt_convert_uuid_to_uuid128(uuid);
-#else
- if (strlen(uuid) == 8)
- svc->uuid = _bt_convert_uuid_to_uuid128(uuid);
- else
- svc->uuid = strdup(uuid);
-#endif
+
if (svc->uuid == NULL) {
g_free(svc);
return NULL;
return BT_ERROR_OUT_OF_MEMORY;
svc->role = BT_GATT_ROLE_SERVER;
svc->is_included_service = false;
-#ifdef TIZEN_FEATURE_GATT_RELAY
+
BT_INFO("Current handle count of service [%d]", svc->numhandles);
svc->numhandles = 1; /* Initalize numhandles to 1 */
-#endif
+
*service = (bt_gatt_h)svc;
/* Add service to list of GATT handles */
svc->included_services = g_slist_append(svc->included_services,
included_svc);
included_svc->parent = (void *)service;
-#ifdef TIZEN_FEATURE_GATT_RELAY
+
if (svc) {
BT_INFO("Current handle count of service [%d]", svc->numhandles);
svc->numhandles = 1; /* Initalize numhandles to 1 */
}
-#endif
return BT_ERROR_NONE;
}
BT_INFO("Get Characteristic rom service, charc uuid [%s], total charcs of this service [%d]",
uuid, svc->charc_handles.count);
-#ifdef TIZEN_GATT_CLIENT
+
if (svc->charc_handles.count > 0) {
-#else
- if (svc->char_handles) {
-#endif
ret = _bt_gatt_client_update_characteristics(svc);
if (ret != BT_ERROR_NONE) {
BT_ERR("_bt_gatt_client_update_characteristics failed");
BT_CHECK_INPUT_PARAMETER(service);
BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-#ifdef TIZEN_GATT_CLIENT
BT_INFO("Total num of characteristics [%d]", svc->charc_handles.count);
if (svc->charc_handles.count > 0) {
-#else
- if (svc->char_handles) {
-#endif
int ret;
ret = _bt_gatt_client_update_characteristics(svc);
BT_INFO("Characteristic UUID : [%s] len [%zd] permissions [%d] properties [%d]",
uuid, strlen(uuid), permissions, properties);
-#ifdef TIZEN_FEATURE_GATT_RELAY
chr->uuid = _bt_convert_uuid_to_uuid128(uuid);
-#else
- if (strlen(uuid) == 8)
- chr->uuid = _bt_convert_uuid_to_uuid128(uuid);
- else
- chr->uuid = g_strdup(uuid);
-#endif
if (chr->uuid == NULL) {
ret = BT_ERROR_OUT_OF_MEMORY;
BT_ERR("Wrong type of GATT handle : %d", chr->type);
return BT_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_GATT_CLIENT
if (chr->descriptor_handles.count > 0) {
-#else
- if (chr->desc_handles) {
-#endif
ret = _bt_gatt_client_update_descriptors(chr);
if (ret != BT_ERROR_NONE) {
BT_ERR("_bt_gatt_client_update_descriptors is failed");
return BT_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_GATT_CLIENT
BT_INFO("Total Descriptors for the current characteristic [%d]", chr->descriptor_handles.count);
if (chr->descriptor_handles.count > 0) {
-#else
- if (chr->desc_handles) {
-#endif
int ret;
ret = _bt_gatt_client_update_descriptors(chr);
desc->role = BT_GATT_ROLE_SERVER;
BT_INFO("Descriptor UUID : [%s] len [%zd] permissions [%d]", uuid, strlen(uuid), permissions);
-#ifdef TIZEN_FEATURE_GATT_RELAY
+
desc->uuid = _bt_convert_uuid_to_uuid128(uuid);
-#else
- if (strlen(uuid) == 8)
- desc->uuid = _bt_convert_uuid_to_uuid128(uuid);
- else
- desc->uuid = g_strdup(uuid);
-#endif
if (desc->uuid == NULL) {
ret = BT_ERROR_OUT_OF_MEMORY;
}
if (!is_gatt_server_initialized) {
-#ifdef TIZEN_FEATURE_GATT_RELAY
-// ret = _bt_get_error_code(bluetooth_gatt_server_init(&instance_id, _bt_gatt_server_event_proxy, NULL));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_init());
-#endif
+// ret = bt_adapt_gatt_server_init(&instance_id, _bt_gatt_server_event_proxy, NULL);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)",
g_slist_free(gatt_server_list);
gatt_server_list = NULL;
-#ifdef TIZEN_FEATURE_GATT_RELAY
- ret = _bt_get_error_code(bluetooth_gatt_server_deinit());
+ ret = bt_adapt_gatt_server_deinit();
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)",
_bt_convert_error_to_string(ret), ret);
}
- ret = _bt_get_error_code(bluetooth_gatt_server_unregister(instance_id));
+ ret = bt_adapt_gatt_server_unregister(instance_id);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)",
_bt_convert_error_to_string(ret), ret);
}
-#else
- ret = _bt_get_error_code(bluetooth_gatt_deinit());
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- }
-#endif
is_gatt_server_initialized = false;
is_gatt_server_started = false;
instance_id = -1;
return BT_ERROR_NONE;
}
-#ifdef TIZEN_FEATURE_GATT_RELAY
static int __gatt_service_add_num_handle(bt_gatt_service_s *service)
{
int handles_count = 0;
int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service)
{
int ret = BT_ERROR_NONE;
- bluetooth_gatt_server_attribute_params_t param;
bt_gatt_server_s *serv = (bt_gatt_server_s *)server;
bt_gatt_service_s *svc = (bt_gatt_service_s *)service;
GSList *char_l;
__gatt_service_add_num_handle(svc);
BT_INFO("Service number of total handles [%d]", svc->numhandles);
- ret = _bt_get_error_code(bluetooth_gatt_server_add_service(svc->uuid, svc->type,
- svc->numhandles, instance_id, &svc->handle));
+ ret = bt_adapt_gatt_server_add_service(svc->uuid, svc->type,
+ svc->numhandles, instance_id, &svc->handle);
BT_INFO("Service added handle [%d]", svc->handle);
bt_gatt_characteristic_s *chr = char_l->data;
/* Add Characteristic to GATT database */
- memset(¶m, 0x00, sizeof(param));
- param.permissions = chr->permissions;
- param.properties = chr->properties;
- param.service_handle = svc->handle;
- param.instance_id = instance_id;
BT_INFO("GATT Server Add Char: UUID [%s] permission [%d] properties [%d] service handle [%d] Inst ID [%d]",
chr->uuid, chr->permissions, chr->properties, svc->handle, instance_id);
- ret = _bt_get_error_code(bluetooth_gatt_server_add_new_characteristic(chr->uuid, ¶m, &chr->handle));
+ ret = bt_adapt_gatt_server_add_new_char(chr->uuid, chr->permissions, chr->properties, svc->handle, instance_id, &chr->handle);
BT_INFO("Char added handle [%d]", chr->handle);
BT_INFO("GATT Server Add Descriptor: UUID [%s] permission [%d] service handle [%d] Inst ID [%d]",
desc->uuid, desc->permissions, svc->handle, instance_id);
- ret = _bt_get_error_code(bluetooth_gatt_server_add_descriptor(desc->uuid, (bt_gatt_permission_t)desc->permissions,
- svc->handle, instance_id, &desc->handle));
+ ret = bt_adapt_gatt_server_add_desc(desc->uuid, (bt_gatt_permission_e)desc->permissions,
+ svc->handle, instance_id, &desc->handle);
BT_INFO("Descriptor added handle [%d]", desc->handle);
return ret;
fail:
- bluetooth_gatt_unregister_service(svc->path);
+// bluetooth_gatt_unregister_service(svc->path);
return ret;
}
-#else
-int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service)
-{
- int ret = BT_ERROR_NONE;
-
- bt_gatt_server_s *serv = (bt_gatt_server_s *)server;
- bt_gatt_service_s *svc = (bt_gatt_service_s *)service;
- GSList *char_l;
-
- BT_CHECK_GATT_SERVER_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_GATT_SERVER_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(server);
- BT_CHECK_INPUT_PARAMETER(service);
-
- if (g_slist_find(serv->services, svc)) {
- BT_ERR("Already added service.");
- return BT_ERROR_ALREADY_DONE;
- }
-
- if (is_gatt_server_started) {
- BT_ERR("Already Server started");
- return BT_ERROR_OPERATION_FAILED;
- }
-
- ret = _bt_get_error_code(bluetooth_gatt_add_service(svc->uuid,
- &svc->path));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
-
- for (char_l = svc->characteristics; char_l; char_l = g_slist_next(char_l)) {
- GSList *desc_l;
- bt_gatt_characteristic_s *chr = char_l->data;
-
- ret = _bt_get_error_code(bluetooth_gatt_add_new_characteristic(
- svc->path, chr->uuid,
- (bt_gatt_permission_t)chr->permissions,
- (bt_gatt_characteristic_property_t)chr->properties,
- &chr->path));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- goto fail;
- }
-
- ret = _bt_get_error_code(bluetooth_gatt_set_characteristic_value(chr->path,
- chr->value, chr->value_length));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- goto fail;
- }
-
- for (desc_l = chr->descriptors; desc_l; desc_l = g_slist_next(desc_l)) {
- bt_gatt_descriptor_s *desc = desc_l->data;
-
- ret = _bt_get_error_code(bluetooth_gatt_add_descriptor(
- chr->path, desc->uuid,
- (bt_gatt_permission_t)desc->permissions,
- &desc->path));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- goto fail;
- }
-
- ret = _bt_get_error_code(bluetooth_gatt_set_descriptor_value(desc->path,
- desc->value, desc->value_length));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- goto fail;
- }
- }
- }
-
- ret = _bt_get_error_code(bluetooth_gatt_register_service(svc->path));
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- goto fail;
- }
-
- serv->services = g_slist_append(serv->services, svc);
- svc->parent = (void *)server;
-
- return ret;
-
-fail:
- BT_ERR("Registering Service failed!!!!!");
- bluetooth_gatt_unregister_service(svc->path);
-
- return ret;
-}
-#endif
int bt_gatt_server_unregister_service(bt_gatt_server_h server,
bt_gatt_h service)
g_slist_free_full(serv->services, __bt_gatt_free_service);
serv->services = NULL;
-#ifndef TIZEN_FEATURE_GATT_RELAY
- ret = bluetooth_gatt_unregister_application();
-#endif
is_gatt_server_started = false;
return ret;
BT_CHECK_GATT_SERVER_INIT_STATUS();
if (!is_gatt_server_started) {
-#ifdef TIZEN_FEATURE_GATT_RELAY
-{
GSList *l;
GSList *l1;
bt_gatt_service_s *service = (bt_gatt_service_s *)l1->data;
BT_DBG("Service handle [%d] Service UUID [%s]", service->handle, service->uuid);
/* Mark the service Registered */
- ret = _bt_get_error_code(bluetooth_gatt_server_start_service(service->handle, instance_id));
+ ret = bt_adapt_gatt_server_start_service(service->handle, instance_id);
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
}
}
-}
-#else
- ret = bluetooth_gatt_register_application();
-#endif
+
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
int offset, int resp_status, char *value, int value_length)
{
int ret = BT_ERROR_NONE;
+ bt_gatt_att_data_t resp;
+
BT_CHECK_GATT_SERVER_SUPPORT();
BT_CHECK_INIT_STATUS();
return BT_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_GATT_RELAY
- bluetooth_gatt_att_data_t resp;
- bluetooth_gatt_server_response_params_t param;
-
memset(&resp, 0x00, sizeof(resp));
- memset(¶m, 0x00, sizeof(param));
/* Copy response data */
resp.length = value_length;
resp.offset = offset;
memcpy(&resp.data[0], value, value_length);
- /* Copy Response parameters */
- param.req_type = request_type;
- param.request_id = request_id;
- param.response_status = resp_status;
- param.auth_req = 0; /* Default value set to 0 as Platform API does not provide this option */
-
BT_INFO("GATT Server Send Response: Response type [%d]", request_type);
BT_INFO("Req ID [%d] data_len [%d] offset [%d] Resp Status [%d]",
request_id, value_length, offset, resp_status);
- ret = _bt_get_error_code(bluetooth_gatt_server_send_response(¶m, &resp));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_send_response(request_id,
- request_type, resp_status,
- offset, value, value_length));
-#endif
+ ret = bt_adapt_gatt_server_send_response(request_type, request_id, resp_status, 0, &resp);
+
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
{
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic;
bt_gatt_common_s *handle = (bt_gatt_common_s *)characteristic;
- bluetooth_device_address_t addr_hex = { {0,} };
+ int attribute_handle;
+ bool need_confirmation;
+ bt_gatt_att_data_t indication;
+ int k;
int ret = BT_ERROR_NONE;
BT_CHECK_GATT_SERVER_SUPPORT();
BT_VALIDATE_GATT_HANDLE(characteristic);
- _bt_convert_address_to_hex(&addr_hex, device_address);
-
-#ifdef TIZEN_FEATURE_GATT_RELAY
-{
- int attribute_handle;
- bluetooth_gatt_att_data_t indication;
- bluetooth_gatt_server_indication_params_t param;
- int k;
-
if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) {
attribute_handle = chr->handle;
} else {
indication.offset = 0; /* Default value */
memcpy(&indication.data[0], chr->value, chr->value_length);
- /* Copy Indication parameters */
- param.atrribute_handle = attribute_handle;
-
if (chr->properties & BT_GATT_PROPERTY_INDICATE) {
BT_DBG("Characteritsic [%d]has Indicate Property", attribute_handle);
- param.need_confirmation = TRUE;
+ need_confirmation = TRUE;
} else {
- param.need_confirmation = FALSE;
+ need_confirmation = FALSE;
BT_DBG("Enable Notifcation for the characteristic [%d]", attribute_handle);
}
- param.instance_id = instance_id;
- ret = _bt_get_error_code(bluetooth_gatt_server_send_indication(&addr_hex, ¶m, &indication));
+
+ ret = bt_adapt_gatt_server_send_indication(device_address, chr->handle, need_confirmation, instance_id, &indication);
BT_INFO("Sent Indication to Remote GATT client: result [%d]", ret);
if (ret != BT_ERROR_NONE) {
} /* LCOV_EXCL_STOP */
/* Save the Remote GATT client address to be used for notification later on */
- memcpy(&chr->address.addr, &addr_hex.addr, BLUETOOTH_ADDRESS_LENGTH);
-}
-#else
- if (chr->value_length > 0 && chr->value) {
- if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = bluetooth_gatt_server_set_notification(handle->path,
- &addr_hex);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- return ret;
- }
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(
- handle->path,
- chr->value,
- chr->value_length));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)",
- _bt_convert_error_to_string(ret), ret);
- return ret;
- }
- }
- }
-#endif
+ _bt_convert_address_to_hex((unsigned char **)&chr->addr, device_address);
+
chr->notified_cb = callback;
chr->notified_user_data = user_data;
return BT_ERROR_NONE;
}
-#ifdef TIZEN_GATT_CLIENT
int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client)
{
int ret = BT_ERROR_NONE;
bt_gatt_client_s *client_s;
bool connected = false;
GSList *l;
- bluetooth_device_address_t bd_addr = { {0,} };
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
}
/* Attempt to Register GATT Client instance */
- _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
-#if 0
- ret = bluetooth_gatt_client_init(&client_s->client_id, &bd_addr,
- _bt_gatt_client_event_proxy);
-#endif
+ ret = bt_adapt_gatt_client_init(remote_address, &client_s->client_id);
- if (BLUETOOTH_ERROR_NONE != ret) {
+ if (BT_ERROR_NONE != ret) {
free(client_s->remote_address);
free(client_s);
return ret;
return ret; /* LCOV_EXCL_STOP */
}
-#else
-int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client)
-{
- int ret = BT_ERROR_NONE;
- bt_gatt_client_s *client_s;
- bool connected = false;
- GSList *l;
-
- BT_CHECK_GATT_CLIENT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_START */
-
- for (l = gatt_client_list; l; l = g_slist_next(l)) {
- bt_gatt_client_s *c = (bt_gatt_client_s *)l->data;
-
- if ((c == NULL) || (c->remote_address == NULL)) {
- BT_ERR("bt_gatt_client_create Error Parameter are NULL..\n");
- continue;
- } else if (!g_ascii_strcasecmp(c->remote_address, remote_address)) {
- BT_ERR("Gatt client for %s is already created",
- remote_address);
- return BT_ERROR_ALREADY_DONE;
- }
- }
-
- client_s = g_malloc0(sizeof(*client_s));
- if (client_s == NULL) {
- ret = BT_ERROR_OUT_OF_MEMORY;
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
-
- client_s->remote_address = g_strdup(remote_address);
- if (client_s->remote_address == NULL) {
- g_free(client_s);
- ret = BT_ERROR_OUT_OF_MEMORY;
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
-
- if (bt_device_is_profile_connected(remote_address, BT_PROFILE_GATT,
- &connected) != BT_ERROR_NONE)
- BT_ERR("bt_device_is_profile_connected is failed");
- else
- client_s->connected = connected;
-
- ret = _bt_gatt_client_update_services(client_s);
- if (ret != BT_ERROR_NONE) {
- BT_INFO("_bt_gatt_client_update_services returns 0x%X. "
- "It could be updated when service is available.", ret);
- ret = BT_ERROR_NONE;
- }
-
- *client = (bt_gatt_client_h)client_s;
- gatt_client_list = g_slist_append(gatt_client_list, client_s);
-
- BT_INFO("GATT Client Handle is created");
-
- return ret; /* LCOV_EXCL_STOP */
-}
-#endif
int bt_gatt_client_destroy(bt_gatt_client_h client)
{
BT_INFO("Destroy GATT client: Client interface ID [%d] REmote address [%s]",
client_s->client_id, client_s->remote_address);
- if (client_s->service_changed_cb) {
- bluetooth_device_address_t bd_addr = { {0,} };
-
- _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
-#ifdef TIZEN_GATT_CLIENT
- bluetooth_gatt_client_set_service_change_watcher(&bd_addr, FALSE);
-#else
- bluetooth_gatt_set_service_change_watcher(&bd_addr, FALSE);
-#endif
- }
+ if (client_s->service_changed_cb)
+ bt_adapt_gatt_client_set_service_change_watcher(client_s->remote_address, FALSE);
g_slist_free_full(client_s->services, __bt_gatt_free_service);
gatt_client_list = g_slist_remove(gatt_client_list, client_s);
-#ifdef TIZEN_GATT_CLIENT
/* Unregister GATT Client instance: Unregister should never fail */
- bluetooth_gatt_client_deinit(client_s->client_id);
+ bt_adapt_gatt_client_deinit(client_s->client_id);
g_free(client_s->remote_address);
-#endif
g_free(client_s);
return BT_ERROR_NONE; /* LCOV_EXCL_STOP */
}
}
- if (result == BLUETOOTH_ATT_ERROR_NONE) {
+ if (result == BT_ERROR_NONE) {
bt_gatt_set_value(handle,
(char *)resp->value, (int)resp->len);
}
}
/* LCOV_EXCL_STOP */
-#ifdef TIZEN_GATT_CLIENT
int bt_gatt_client_read_value(bt_gatt_h gatt_handle,
bt_gatt_client_request_completed_cb callback, void *user_data)
{
bt_gatt_common_s *c = (bt_gatt_common_s *)gatt_handle;
BT_INFO("+");
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t chr_handle;
- bt_gatt_handle_property_t desc_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t chr_handle;
+ bt_gatt_handle_prop_t desc_handle;
bt_gatt_service_s *service_s;
bt_gatt_characteristic_s *charc_s;
bt_gatt_client_s *client_s;
__bt_string_to_uuid_hex(chr->uuid, chr_handle.uuid);
chr_handle.instance_id = chr->instance_id;
- ret = _bt_get_error_code(
- bluetooth_gatt_client_read_characteristic_value(
+ ret = bt_adapt_gatt_client_read_char_value(
client_s->remote_address,
&svc_handle,
- &chr_handle));
+ &chr_handle);
if (ret == BT_ERROR_NONE) {
BT_INFO("Characteristic read scheduled successfully, set callback");
__bt_string_to_uuid_hex(desc->uuid, desc_handle.uuid);
desc_handle.instance_id = desc->instance_id;
- ret = _bt_get_error_code(
- bluetooth_gatt_client_read_descriptor_value(
+ ret = bt_adapt_gatt_client_read_desc_value(
client_s->remote_address,
&svc_handle,
&chr_handle,
- &desc_handle));
+ &desc_handle);
if (ret == BT_ERROR_NONE) {
BT_INFO("Descriptor read scheduled successfully, set callback");
BT_INFO("Result [%d]", ret);
return ret; /* LCOV_EXCL_STOP */
}
-#else
-int bt_gatt_client_read_value(bt_gatt_h gatt_handle,
- bt_gatt_client_request_completed_cb callback, void *user_data)
-{
- int ret = BT_ERROR_NONE;
- bt_gatt_common_s *c = (bt_gatt_common_s *)gatt_handle;
-
- BT_CHECK_GATT_CLIENT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(gatt_handle);
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_START */
-
- if (c->type == BT_GATT_TYPE_CHARACTERISTIC) {
- bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
-
- if (chr->read_cb) {
- BT_ERR("read request is now in progress");
- return BT_ERROR_NOW_IN_PROGRESS;
- }
-
- ret = _bt_get_error_code(
- bluetooth_gatt_read_characteristic_value(chr->path, gatt_handle));
- if (ret == BT_ERROR_NONE) {
- chr->read_cb = callback;
- chr->read_user_data = user_data;
- } else {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- }
- } else if (c->type == BT_GATT_TYPE_DESCRIPTOR) {
- bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle;
-
- if (desc->read_cb) {
- BT_ERR("read request is now in progress");
- return BT_ERROR_NOW_IN_PROGRESS;
- }
-
- ret = _bt_get_error_code(
- bluetooth_gatt_read_descriptor_value(desc->path, gatt_handle));
- if (ret == BT_ERROR_NONE) {
- desc->read_cb = callback;
- desc->read_user_data = user_data;
- } else {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- }
- } else {
- ret = BT_ERROR_INVALID_PARAMETER;
- BT_ERR("Invalid handle type for read ");
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-#endif
-#ifdef TIZEN_GATT_CLIENT
int bt_gatt_client_write_value(bt_gatt_h gatt_handle,
bt_gatt_client_request_completed_cb callback, void *user_data)
{
int ret = BT_ERROR_NONE;
bt_gatt_common_s *c = (bt_gatt_common_s *)gatt_handle;
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t chr_handle;
- bt_gatt_handle_property_t desc_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t chr_handle;
+ bt_gatt_handle_prop_t desc_handle;
bt_gatt_service_s *service_s;
bt_gatt_characteristic_s *charc_s;
bt_gatt_client_s *client_s;
- bluetooth_gatt_att_data_t write_data;
+ bt_gatt_att_data_t write_data;
BT_INFO("+");
BT_CHECK_GATT_CLIENT_SUPPORT();
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
int k;
- memset(&write_data, 0x00, sizeof(bluetooth_gatt_att_data_t));
+ memset(&write_data, 0x00, sizeof(bt_gatt_att_data_t));
write_data.length = chr->value_length;
BT_INFO("Char write value length [%d]", write_data.length);
for (k = 0; k < chr->value_length; k++)
if (chr->write_type == BT_GATT_WRITE_TYPE_WRITE) {
BT_INFO("Write characteristic: write type [%d]", chr->write_type);
- ret = _bt_get_error_code(
- bluetooth_gatt_client_write_characteristic_value_by_type(
+ ret = bt_adapt_gatt_client_write_char_value_by_type(
client_s->remote_address,
&svc_handle,
&chr_handle,
&write_data,
- BLUETOOTH_GATT_TYPE_WRITE));
+ BT_GATT_WRITE_TYPE_WRITE);
} else if (chr->write_type == BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE) {
BT_INFO("Write characteristic: write type [%d]", chr->write_type);
- ret = _bt_get_error_code(
- bluetooth_gatt_client_write_characteristic_value_by_type(
+ ret = bt_adapt_gatt_client_write_char_value_by_type(
client_s->remote_address,
&svc_handle,
&chr_handle,
&write_data,
- BLUETOOTH_GATT_TYPE_WRITE_NO_RESPONSE));
+ BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE);
} else {
BT_ERR("Unknow write type : %d", chr->write_type);
ret = BT_ERROR_OPERATION_FAILED;
service_s = (bt_gatt_service_s*)charc_s->parent;
client_s = (bt_gatt_client_s*)service_s->parent;
- memset(&write_data, 0x00, sizeof(bluetooth_gatt_att_data_t));
+ memset(&write_data, 0x00, sizeof(bt_gatt_att_data_t));
write_data.length = desc->value_length;
BT_INFO("Desc write value length [%d]", write_data.length);
memcpy(&write_data.data[0], desc->value, desc->value_length);
__bt_string_to_uuid_hex(desc->uuid, desc_handle.uuid);
desc_handle.instance_id = desc->instance_id;
- ret = _bt_get_error_code(
- bluetooth_gatt_client_write_descriptor_value(
+ ret = bt_adapt_gatt_client_write_desc_value(
client_s->remote_address,
&svc_handle,
&chr_handle,
&desc_handle,
&write_data,
- BLUETOOTH_GATT_TYPE_WRITE_NO_RESPONSE));
+ BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
} else {
return ret; /* LCOV_EXCL_STOP */
}
-#else
-int bt_gatt_client_write_value(bt_gatt_h gatt_handle,
- bt_gatt_client_request_completed_cb callback, void *user_data)
-{
- bt_gatt_common_s *c = (bt_gatt_common_s *)gatt_handle;
- bt_gatt_property_e write_prop = BT_GATT_PROPERTY_WRITE;
- int ret = BT_ERROR_NONE;
-
- BT_CHECK_GATT_CLIENT_SUPPORT();
- BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(gatt_handle); /* LCOV_EXCL_START */
-
- if (c->type == BT_GATT_TYPE_CHARACTERISTIC) {
- bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)gatt_handle;
-
- if (chr->write_cb) {
- BT_ERR("write request is now in progress");
- return BT_ERROR_NOW_IN_PROGRESS;
- }
-
- ret = __get_write_prop(chr->write_type, &write_prop);
- if (ret != BT_ERROR_NONE)
- return BT_ERROR_OPERATION_FAILED;
-
- ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value_by_type(
- chr->path, (guint8 *)chr->value,
- chr->value_length, write_prop,
- gatt_handle));
- if (ret == BT_ERROR_NONE) {
- chr->write_cb = callback;
- chr->write_user_data = user_data;
- } else {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- }
- } else if (c->type == BT_GATT_TYPE_DESCRIPTOR) {
- bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle;
-
- if (desc->write_cb) {
- BT_ERR("write request is now in progress");
- return BT_ERROR_NOW_IN_PROGRESS;
- }
-
- ret = _bt_get_error_code(bluetooth_gatt_write_descriptor_value(
- desc->path, (guint8 *)desc->value,
- desc->value_length, gatt_handle));
- if (ret == BT_ERROR_NONE) {
- desc->write_cb = callback;
- desc->write_user_data = user_data;
- } else {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- }
- } else {
- BT_ERR("Invalid handle type for write");
- ret = BT_ERROR_INVALID_PARAMETER;
- }
-
- return ret; /* LCOV_EXCL_STOP */
-}
-#endif
/* LCOV_EXCL_START */
static bt_gatt_client_h __find_gatt_client(const char *remote_address)
}
/* LCOV_EXCL_STOP */
-#ifndef TIZEN_GATT_CLIENT
-static gboolean __get_bdaddr_from_path(const char *path, char *addr)
-{
- int i;
- char *tmp;
-
- /*
- * e.g.
- * /org/bluez/hci0/dev_E7_56_2A_AA_0C_FD/service001b
- */
- tmp = g_strstr_len(path, strlen(path), "dev_");
- if (tmp == NULL)
- return FALSE;
- tmp += 4;
-
- for (i = 0; *tmp != '\0' && i < BT_ADDR_STR_LEN; i++, tmp++) {
- if (*tmp == '_')
- addr[i] = ':';
- else
- addr[i] = *tmp;
- }
- addr[i] = '\0';
-
- BT_DBG("path : %s, addr : %s", path, addr);
-
- return TRUE;
-}
-#endif
-
-#ifdef TIZEN_GATT_CLIENT
/* LCOV_EXCL_START */
void __uuid_hex_to_string(unsigned char *uuid, char *str)
{
memcpy(&uuid4, &(uuid[10]), 4);
memcpy(&uuid5, &(uuid[14]), 2);
- snprintf((char *)str, BLUETOOTH_UUID_STRING_MAX, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
+ snprintf((char *)str, BT_UUID_STR_MAX, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
ntohl(uuid0), ntohs(uuid1),
ntohs(uuid2), ntohs(uuid3),
ntohl(uuid4), ntohs(uuid5));
return;
}
+#if 0
static bt_gatt_characteristic_s* __gatt_get_characteristic_handle(
unsigned char *svc_uuid,
int svc_inst,
bt_gatt_service_s *svc;
bt_gatt_characteristic_s *chr;
- char uuid_string[BLUETOOTH_UUID_STRING_MAX];
- char svc_uuid_string[BLUETOOTH_UUID_STRING_MAX];
+ char uuid_string[BT_UUID_STR_MAX];
+ char svc_uuid_string[BT_UUID_STR_MAX];
__uuid_hex_to_string(svc_uuid, svc_uuid_string);
__uuid_hex_to_string(uuid, uuid_string) ;
bt_gatt_characteristic_s *chr;
bt_gatt_descriptor_s *desc;
- char uuid_string[BLUETOOTH_UUID_STRING_MAX];
- char svc_uuid_string[BLUETOOTH_UUID_STRING_MAX];
- char char_uuid_string[BLUETOOTH_UUID_STRING_MAX];
+ char uuid_string[BT_UUID_STR_MAX];
+ char svc_uuid_string[BT_UUID_STR_MAX];
+ char char_uuid_string[BT_UUID_STR_MAX];
__uuid_hex_to_string(uuid, uuid_string);
__uuid_hex_to_string(svc_uuid, svc_uuid_string);
}
return NULL;
}
+#endif
static void __gatt_value_changed_cb(unsigned char *uuid, char *remote_address,
char *value, int value_length, void *user_data)
bt_gatt_service_s *svc;
bt_gatt_characteristic_s *chr;
BT_INFO("+");
- char uuid_string[BLUETOOTH_UUID_STRING_MAX];
+ char uuid_string[BT_UUID_STR_MAX];
__uuid_hex_to_string(uuid, uuid_string) ;
BT_INFO("Address [%s] Char UUID [%s]", remote_address, uuid_string);
}
}
}
-/* LCOV_EXCL_STOP */
-#else
-static void __value_changed_cb(char *char_path,
- char *value, int value_length, void *user_data)
-{
- GSList *l;
- GSList *ll;
- bt_gatt_client_h client;
- bt_gatt_client_s *client_s;
- bt_gatt_service_s *svc;
- bt_gatt_characteristic_s *chr;
- char remote_address[BT_ADDR_STR_LEN + 1] = { 0, };
-
- BT_DBG("%s", char_path);
-
- if (__get_bdaddr_from_path(char_path, remote_address) == FALSE) {
- BT_ERR("Cannot get addr from path : %s", char_path);
- return;
- }
-
- client = __find_gatt_client(remote_address);
- if (client == NULL) {
- BT_ERR("Cannot find client [%s]", remote_address);
- return;
- }
-
- client_s = (bt_gatt_client_s *)client;
- for (l = client_s->services; l; l = g_slist_next(l)) {
- svc = (bt_gatt_service_s *)l->data;
- for (ll = svc->characteristics; ll; ll = g_slist_next(ll)) {
- chr = (bt_gatt_characteristic_s *)ll->data;
-
- if ((chr == NULL) || (chr->path == NULL)) {
- BT_ERR("__value_changed_cb Error Parameter are NULL..\n");
- continue;
- } else if (g_ascii_strcasecmp(chr->path, char_path) == 0) {
- if (chr->value_changed_cb)
- chr->value_changed_cb(chr, value,
- value_length,
- chr->value_changed_user_data);
-
- bt_gatt_set_value(chr, value, value_length);
- return;
- }
- }
- }
-}
-#endif
int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic,
bt_gatt_client_characteristic_value_changed_cb callback,
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic;
gboolean is_indicate = false;
-#ifdef TIZEN_GATT_CLIENT
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t chr_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t chr_handle;
bt_gatt_service_s *service_s;
bt_gatt_client_s *client_s;
-#else
- char *name = NULL;
- bt_gatt_service_s *svc = (bt_gatt_service_s *)chr->parent;
-#endif
BT_INFO("+");
chr->value_changed_cb = callback;
chr->value_changed_user_data = user_data;
-#ifdef TIZEN_GATT_CLIENT
-
service_s = (bt_gatt_service_s*)chr->parent;
client_s = (bt_gatt_client_s*)service_s->parent;
__bt_string_to_uuid_hex(chr->uuid, chr_handle.uuid);
chr_handle.instance_id = chr->instance_id;
-#endif
BT_INFO("Characteristic properties [%d] charc UUID [%s]",
chr->properties, chr->uuid);
if (chr->properties &
(BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_INDICATE)) {
-#ifdef TIZEN_GATT_CLIENT
- ret = _bt_get_error_code(bluetooth_gatt_client_watch_characteristics(
+ ret = bt_adapt_gatt_client_watch_char(
client_s->remote_address,
&svc_handle,
&chr_handle,
client_s->client_id,
TRUE,
- is_indicate));
-#else
- bt_get_uuid_name(svc->uuid, &name);
- ret = _bt_get_error_code(bluetooth_gatt_watch_characteristics(
- chr->path, name));
- g_free(name);
-#endif
+ is_indicate);
+
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)",
_bt_convert_error_to_string(ret), ret);
else {
-#ifdef TIZEN_GATT_CLIENT
BT_INFO("Set Char val changed callback at index [%d]", BT_EVENT_GATT_CLIENT_VALUE_CHANGED);
_bt_set_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED,
__gatt_value_changed_cb, NULL);
-#else
- _bt_set_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED,
- __value_changed_cb, NULL);
-#endif
BT_INFO("Char value changed callback registsred successfully");
}
} else {
int ret;
bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic;
gboolean is_indicate = false;;
-#ifdef TIZEN_GATT_CLIENT
- bt_gatt_handle_property_t svc_handle;
- bt_gatt_handle_property_t chr_handle;
+ bt_gatt_handle_prop_t svc_handle;
+ bt_gatt_handle_prop_t chr_handle;
bt_gatt_service_s *service_s;
bt_gatt_client_s *client_s;
-#endif
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_INFO("+");
-#ifdef TIZEN_GATT_CLIENT
service_s = (bt_gatt_service_s*)chr->parent;
client_s = (bt_gatt_client_s*)service_s->parent;
__bt_string_to_uuid_hex(chr->uuid, chr_handle.uuid);
chr_handle.instance_id = chr->instance_id;
-#endif
if (chr->properties & BT_GATT_PROPERTY_INDICATE)
is_indicate = true;
if (chr->properties &
(BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_INDICATE)) {
-#ifdef TIZEN_GATT_CLIENT
- ret = _bt_get_error_code(bluetooth_gatt_client_watch_characteristics(
+ ret = bt_adapt_gatt_client_watch_char(
client_s->remote_address,
&svc_handle,
&chr_handle,
client_s->client_id,
FALSE,
- is_indicate));
-#else
- ret = _bt_get_error_code(
- bluetooth_gatt_unwatch_characteristics(chr->path));
-#endif
+ is_indicate);
if (ret != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)",
_bt_convert_error_to_string(ret), ret);
bt_gatt_client_service_changed_cb callback, void *user_data)
{
int ret;
- bluetooth_device_address_t bd_addr = { {0,} };
bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
BT_CHECK_GATT_CLIENT_SUPPORT();
return BT_ERROR_NONE;
}
- _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
-#ifdef TIZEN_GATT_CLIENT
- ret = _bt_get_error_code(bluetooth_gatt_client_set_service_change_watcher(&bd_addr, TRUE));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_set_service_change_watcher(&bd_addr, TRUE));
-#endif
+ ret = bt_adapt_gatt_client_set_service_change_watcher(client_s->remote_address, TRUE);
if (ret == BT_ERROR_NONE) {
BT_INFO("Service Changed callback registered");
int bt_gatt_client_unset_service_changed_cb(bt_gatt_client_h client)
{
int ret;
- bluetooth_device_address_t bd_addr = { {0,} };
bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(client);
- _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
-#ifdef TIZEN_GATT_CLIENT
- ret = _bt_get_error_code(bluetooth_gatt_client_set_service_change_watcher(&bd_addr, FALSE));
-#else
- ret = _bt_get_error_code(bluetooth_gatt_set_service_change_watcher(&bd_addr, FALSE));
-#endif
+ ret = bt_adapt_gatt_client_set_service_change_watcher(client_s->remote_address, FALSE);
+
if (ret == BT_ERROR_NONE) {
BT_INFO("Service Changed callback unregistered [%s]", client_s->remote_address);
client_s->service_changed_cb = NULL;
return BT_ERROR_NONE;
}
-#ifdef TIZEN_GATT_CLIENT
+#if 0
/* LCOV_EXCL_START */
void _bt_handle_gatt_client_char_read_completed_event(int result,
void *resp)
int bt_gatt_client_request_att_mtu_change(bt_gatt_client_h client, unsigned int mtu)
{
int ret;
- bluetooth_device_address_t addr_hex = { {0,} };
bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
BT_CHECK_GATT_CLIENT_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(client);
- _bt_convert_address_to_hex(&addr_hex, client_s->remote_address);
-
- ret = _bt_get_error_code(bluetooth_request_att_mtu(&addr_hex, mtu));
+ ret = bt_adapt_request_att_mtu(client_s->remote_address, mtu);
if (BT_ERROR_NONE != ret)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
int bt_gatt_client_get_att_mtu(bt_gatt_client_h client, unsigned int *mtu)
{
- bluetooth_device_address_t addr_hex = { {0,} };
int ret;
unsigned int mtu_value = 0;
bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(client);
- _bt_convert_address_to_hex(&addr_hex, client_s->remote_address);
-
- ret = _bt_get_error_code(bluetooth_get_att_mtu(&addr_hex, &mtu_value));
+ ret = bt_adapt_get_att_mtu(client_s->remote_address, &mtu_value);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
#include "bluetooth_internal.h"
#include "bluetooth_extension.h"
#include "bluetooth_private.h"
-#include "bluetooth-telephony-api.h"
+//#include "bluetooth-telephony-api.h"
#include "bt_unit_test.h"
const char *spp_uuid = "00001101-0000-1000-8000-00805F9B7777";
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA},
{"Unregister all scan filters"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS},
- {"bt_adater_le_read_maximum_data_length"
- , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH},
- {"bt_adater_le_wite_host_suggested_def_data_length"
- , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH},
- {"bt_adater_le_read_host_suggested_def_data_length"
- , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH},
- {"bt_adapter_le_is_2m_phy_supported"
- , BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT},
- {"bt_adapter_le_is_coded_phy_supported"
- , BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT},
{"Select this menu to set parameters and then select the function again."
, BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
{NULL , 0x0000},
, BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB},
{"bt_device_get_att_mtu"
, BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU},
- {"bt_device_le_set_data_length"
- , BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH},
- {"bt_device_le_data_length_changed_cb"
- , BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB},
{"Select this menu to set parameters and then select the function again."
, BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
{NULL , 0x0000},
{NULL , 0x0000},
};
-tc_table_t tc_pxp[] = {
- /* HPS functions */
- {"BACK"
- , BT_UNIT_TEST_FUNCTION_BACK},
- {"Proximity Reporter(Register)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER},
- {"Proximity Reporter(Unregister)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER},
- {"Proximity Reporter(Start Advertising Proximity Reporter)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING},
- {"Proximity Reporter (Set State Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB},
- {"Proximity Reporter (UnSet State Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB},
- {"Proximity Reporter (Set Property Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB},
- {"Proximity Reporter (UnSet Property Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB},
- {"Proximity Reporter(Read Linkloss Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT},
- {"Proximity Reporter(Read Immediate Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT},
- {"Proximity Monitor(Create)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE},
- {"Proximity Monitor(Destroy)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY},
- {"Proximity Monitor(Connect)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT},
- {"Proximity Monitor(Disconnect)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT},
- {"Proximity Monitor (Set State Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB},
- {"Proximity Monitor (UnSet State Changed callback)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB},
- {"Proximity Monitor(Set LE Scan Filter for Proximity UUID)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID},
- {"Proximity Monitor(Unet LE Scan Filter for Proximity UUID)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID},
- {"Proximity Monitor(Write Linkloss Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT},
- {"Proximity Monitor(Write Immediate Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT},
- {"Proximity Monitor(Read Linkloss Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT},
- {"Proximity Monitor(Read Immediate Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT},
- {"Proximity Monitor(Read Signal Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL},
- {"Select this menu to set parameters and then select the function again."
- , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
- {NULL , 0x0000},
-};
-
tc_table_t tc_avrcp[] = {
/* AVRCP functions */
{"BACK"
case BT_UNIT_TEST_TABLE_DPM:
tc_table = tc_DPM;
break;
- case BT_UNIT_TEST_TABLE_PXP:
- tc_table = tc_pxp;
- break;
case BT_UNIT_TEST_TABLE_HF:
tc_table = tc_hf;
break;
/* Get the attribute new values here */
bt_gatt_server_send_response(request_id,
- BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, offset,
+ BT_GATT_REQUEST_TYPE_READ, offset,
resp_status, char_value_1, 3 - offset);
}
"ENABLED" : "DISABLED");
}
-static void __bt_le_set_data_length_changed_cb(int result,
- const char *remote_address, int max_tx_octets,
- int max_tx_time, int max_rx_octets,
- int max_rx_time, void *user_data)
-{
- TC_PRT("__bt_le_set_data_length_changed_cb \n");
- TC_PRT("max_tx_octets: %d max_tx_time: %d"
- "max_rx_octets: %d max_rx_time: %d",
- max_tx_octets, max_tx_time,
- max_rx_octets, max_rx_time);
- TC_PRT("result: %s", __bt_get_error_message(result));
-}
-
void __bt_opp_client_push_responded_cb(int result,
const char *remote_address, void *user_data)
{
TC_PRT("prop_value : %d", prop_value);
}
-void __bt_proximity_monitor_connection_state_changed_cb(int result, const char *remote_address,
- bt_proximity_monitor_h monitor_s, bool connected, int supported_service, void *user_data)
-{
- TC_PRT("result: %s", __bt_get_error_message(result));
- if (result == BT_ERROR_NONE) {
- if (connected) {
- TC_PRT("PXP connected(address = %s)", remote_address);
- TC_PRT("PXP Reporter supported Service\n");
- if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT)
- TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n");
- if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT)
- TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n");
- if (supported_service & BT_PROXIMITY_TX_POWER)
- TC_PRT("BT_PROXIMITY_TX_POWER");
- } else {
- TC_PRT("PXP DISconnected");
- }
- }
-}
-
-void __bt_proximity_reporter_connection_state_changed_cb(int result, const char *remote_address,
- bt_proximity_reporter_h reporter_s, bool connected, int supported_service, void *user_data)
-{
- TC_PRT("result: %s", __bt_get_error_message(result));
- if (result == BT_ERROR_NONE) {
- if (connected) {
- TC_PRT("PXP connected(address = %s)", remote_address);
- TC_PRT("PXP Reporter supported Service\n");
- if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT)
- TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n");
- if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT)
- TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n");
- if (supported_service & BT_PROXIMITY_TX_POWER)
- TC_PRT("BT_PROXIMITY_TX_POWER");
- } else {
- TC_PRT("PXP DISconnected");
- }
- }
-}
-
void __tds_activation_req_cb(char *rem_bd_addr,
bt_tds_transport_e transport, unsigned char *buf, int len, void *user_data)
{
printf("%d ", value[i]);
bt_gatt_server_send_response(request_id,
- BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE, offset,
+ BT_GATT_REQUEST_TYPE_WRITE, offset,
resp_status, NULL, 0);
printf("\n");
}
break;
}
-
- case BT_UNIT_TEST_TABLE_PXP: {
- switch (test_id) {
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT:
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT:
- param_count = 1;
- TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH");
- break;
- default:
- TC_PRT("There is no param to set\n");
- need_to_set_params = false;
- break;
- }
- break;
- }
-
case BT_UNIT_TEST_TABLE_AVRCP: {
switch (test_id) {
default:
break;
}
-
- case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: {
-
- TC_PRT("Testing: Write Host suggested default LE Data length");
-
- unsigned int def_tx_octects = 30;
- unsigned int def_tx_time = 330;
- ret = bt_adapter_le_write_host_suggested_default_data_length(
- def_tx_octects, def_tx_time);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: {
-
- TC_PRT("Read host suggested default LE Data length");
-
- unsigned int def_tx_octets = 0;
- unsigned int def_tx_time = 0;
- ret = bt_adapter_le_read_suggested_default_data_length(
- &def_tx_octets, &def_tx_time);
- TC_PRT("host suggested default le data length values are %d %d",
- def_tx_octets, def_tx_time);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT: {
-
- TC_PRT("Check LE 2M PHY Feature support");
- bool is_2m_phy_supported = FALSE;
-
- ret = bt_adapter_le_is_2m_phy_supported(&is_2m_phy_supported);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- TC_PRT("LE 2M PHY Support [%s]", is_2m_phy_supported ? "YES" : "NO");
- break;
- }
- case BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT: {
-
- TC_PRT("Check LE CODED PHY Feature support");
- bool is_coded_phy_supported = FALSE;
-
- ret = bt_adapter_le_is_coded_phy_supported(&is_coded_phy_supported);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- TC_PRT("LE CODED PHY Support [%s]", is_coded_phy_supported ? "YES" : "NO");
- break;
- }
case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
need_to_set_params = true;
TC_PRT("Select the function again");
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}
- case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: {
-
- TC_PRT("Set LE Data length paramters cmd");
-
- unsigned int tx_octets = 50;
- unsigned int tx_time = 500;
-
- if (g_test_param.param_count > 0) {
- tx_octets = atoi(g_test_param.params[0]);
- tx_time = atoi(g_test_param.params[1]);
-
- __bt_free_test_param(&g_test_param);
- }
-
- TC_PRT("settting le data length values tx octects: %d tx time: %d",
- tx_octets, tx_time);
- ret = bt_device_le_set_data_length(remote_addr,
- tx_octets, tx_time);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB: {
-
- TC_PRT("Setting LE Data length change callback");
-
- ret = bt_device_le_set_data_length_change_cb(
- __bt_le_set_data_length_changed_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- break;
- }
case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
need_to_set_params = true;
TC_PRT("Select the function again");
}
break;
}
-
- case BT_UNIT_TEST_TABLE_PXP: {
- switch (test_id) {
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER: {
- if (reporter) {
- ret = bt_proximity_reporter_destroy(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- reporter = NULL;
- }
- ret = bt_proximity_reporter_create(&reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER: {
- ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
-
- ret = bt_proximity_reporter_destroy(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- reporter = NULL;
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE: {
- if (monitor) {
- ret = bt_proximity_monitor_disconnect(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_monitor_destroy(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- monitor = NULL;
- }
- ret = bt_proximity_monitor_create(remote_addr, &monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
-
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY: {
- ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_proximity_monitor_destroy(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- monitor = NULL;
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: {
- ret = bt_proximity_monitor_connect(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: {
- ret = bt_proximity_monitor_disconnect(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB: {
- ret = bt_proximity_monitor_set_connection_state_changed_cb(monitor,
- __bt_proximity_monitor_connection_state_changed_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB: {
- ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB: {
- ret = bt_proximity_reporter_set_connection_state_changed_cb(reporter,
- __bt_proximity_reporter_connection_state_changed_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB: {
- ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB: {
- ret = bt_proximity_reporter_set_property_changed_cb(reporter,
- __bt_proximity_reporter_property_changed_cb,
- NULL);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB: {
- ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID: {
- if (pxp_scan_filter) {
- ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- pxp_scan_filter = NULL;
- }
- ret = bt_adapter_le_scan_filter_create(&pxp_scan_filter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_adapter_le_scan_filter_set_type(pxp_scan_filter,
- BT_ADAPTER_LE_SCAN_FILTER_TYPE_PROXIMITY_UUID);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_adapter_le_scan_filter_register(pxp_scan_filter);
- if (ret != BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID: {
- ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
-
- ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- pxp_scan_filter = NULL;
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING: {
- /* Add Reporter service in advertising data */
- advertiser = advertiser_list[advertiser_index];
- if (advertiser == NULL) {
- ret = bt_adapter_le_create_advertiser(&advertiser);
- if (ret != BT_ERROR_NONE) {
- TC_PRT("created le advertiser(%d)", ret);
- break;
- }
-
- advertiser_list[advertiser_index] = advertiser;
- ret = bt_adapter_le_set_advertising_device_name(advertiser,
- BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
- if (ret != BT_ERROR_NONE) {
- TC_PRT("set device name [0x%04x]", ret);
- break;
- }
- }
-
- ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
- BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_IMMEDIATE_ALERT_SVC_UUID);
- if (ret != BT_ERROR_NONE) {
- TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
- break;
- }
-
- ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
- BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_LINK_LOSS_SVC_UUID);
- if (ret != BT_ERROR_NONE) {
- TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
- break;
- }
-
- /* Start advertising PXP Reporter service */
- bt_adapter_le_advertising_state_changed_cb cb;
-
- if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb;
- else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2;
- else cb = __bt_adapter_le_advertising_state_changed_cb_3;
-
- advertiser = advertiser_list[advertiser_index];
-
- advertiser_index++;
- advertiser_index %= 3;
-
- TC_PRT("advertiser: %p", advertiser);
-
- ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: {
- int alert_value;
- if (g_test_param.param_count < 1) {
- TC_PRT("Input parameters first");
- break;
- }
-
- alert_value = atoi(g_test_param.params[0]);
- ret = bt_proximity_monitor_set_linkloss_alert(monitor, alert_value);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: {
- int alert_value;
- if (g_test_param.param_count < 1) {
- TC_PRT("Input parameters first");
- break;
- }
-
- alert_value = atoi(g_test_param.params[0]);
- ret = bt_proximity_monitor_set_immediate_alert(monitor, alert_value);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- break;
- }
-
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT: {
- int alert_level = 0;
- ret = bt_proximity_monitor_get_linkloss_alert(monitor, &alert_level);
- TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT: {
- int alert_level = 0;
- ret = bt_proximity_monitor_get_immediate_alert(monitor, &alert_level);
- TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL: {
- int alert_level = 0;
- ret = bt_proximity_monitor_get_signal_level(monitor, &alert_level);
- TC_PRT("returns %s, signal_level: %d\n", __bt_get_error_message(ret), alert_level);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT: {
- int alert_level = 0;
- ret = bt_proximity_reporter_get_linkloss_alert(remote_addr, &alert_level);
- TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT: {
- int alert_level = 0;
- ret = bt_proximity_reporter_get_immediate_alert(remote_addr, &alert_level);
- TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
- break;
- }
- case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
- need_to_set_params = true;
- TC_PRT("Select the function again");
- break;
-
- default:
- break;
- }
- break;
- }
-
case BT_UNIT_TEST_TABLE_HF: {
switch (test_id) {
case BT_UNIT_TEST_FUNCTION_HF_INITIALIZE:
}
case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP: {
ret = bt_tds_provider_send_activation_resp(
- tds_act_address, BLUETOOTH_ERROR_NONE, provider);
+ tds_act_address, BT_ERROR_NONE, provider);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}