summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/bt_chat_client.c453
-rw-r--r--test/bt_chat_server.c281
-rw-r--r--test/bt_infinite_spp_test.c512
-rw-r--r--test/bt_infinite_spp_test_client.service11
-rw-r--r--test/bt_infinite_spp_test_server.service11
-rw-r--r--test/bt_onoff.c131
-rw-r--r--test/bt_unit_test.c5440
-rw-r--r--test/bt_unit_test.h354
-rw-r--r--test/capi.network.bluetooth.infinite.spp.test.rule4
-rw-r--r--test/capi.network.bluetooth.test.rule2
-rw-r--r--test/gatt_profile_test_suite/CMakeLists.txt22
-rw-r--r--test/gatt_profile_test_suite/bt_unit_test_gatt.c121
-rw-r--r--test/gatt_profile_test_suite/bt_unit_test_gatt.h43
-rw-r--r--test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c472
-rw-r--r--test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h64
-rw-r--r--test/gatt_profile_test_suite/capi.network.bluetooth.test.gatt.rule2
17 files changed, 6955 insertions, 976 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7715cac..e5a75bd 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,3 +15,11 @@ FOREACH(src ${sources})
ADD_EXECUTABLE(${src_name} ${src})
TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
ENDFOREACH()
+
+INSTALL(TARGETS bt_unit_test DESTINATION bin)
+INSTALL(TARGETS bt_onoff DESTINATION bin)
+INSTALL(TARGETS bt_infinite_spp_test DESTINATION bin)
+INSTALL(FILES capi.network.bluetooth.test.rule DESTINATION /etc/smack/accesses2.d/)
+INSTALL(FILES capi.network.bluetooth.infinite.spp.test.rule DESTINATION /etc/smack/accesses2.d/)
+
+ADD_SUBDIRECTORY(gatt_profile_test_suite)
diff --git a/test/bt_chat_client.c b/test/bt_chat_client.c
deleted file mode 100644
index bfdd5e8..0000000
--- a/test/bt_chat_client.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <bluetooth.h>
-#include <dlog.h>
-#include <glib.h>
-#include <string.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "BT_CHAT_CLIENT"
-
-/**
- * Variables
- **/
-static GMainLoop* g_mainloop = NULL;
-static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
-static int socket_fd = -1;
-static char* bt_address = NULL;
-static char* server_name = "chat_server";
-static char quit_command[5] = "Quit";
-static int bonding_state = BT_ERROR_OPERATION_FAILED;
-
-
-/**
- * Callback functions
- **/
-gboolean timeout_func(gpointer data)
-{
- LOGE("[%s] Callback: Timeout.", __FUNCTION__);
- g_main_loop_quit((GMainLoop*)data);
- return FALSE;
-}
-
-void bt_state_changed_impl(int result, bt_adapter_state_e adapter_state, void* user_data)
-{
- if(adapter_state == BT_ADAPTER_ENABLED)
- {
- if(result == BT_ERROR_NONE)
- {
- LOGI("[%s] Callback: BT was enabled successfully.", __FUNCTION__);
- bt_state = BT_ADAPTER_ENABLED;
- }
- else
- {
- LOGE("[%s] Callback: Failed to enable BT.", __FUNCTION__);
- }
- }
-
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
-}
-
-void bt_socket_connection_state_changed_impl(int result, bt_socket_connection_state_e connection_state,
- bt_socket_connection_s *connection, void *user_data)
-{
- if(result == BT_ERROR_NONE)
- {
- LOGI("[%s] Callback: Result is BT_ERROR_NONE.", __FUNCTION__);
- }
- else
- {
- LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", __FUNCTION__);
- }
-
- if(connection_state == BT_SOCKET_CONNECTED)
- {
- LOGI("[%s] Callback: Connected.", __FUNCTION__);
- if(result == BT_ERROR_NONE && connection != NULL)
- {
- socket_fd = connection->socket_fd;
- LOGI("[%s] Callback: Socket of connection - %d.", __FUNCTION__, socket_fd);
- LOGI("[%s] Callback: Role of connection - %d.", __FUNCTION__, connection->local_role);
- LOGI("[%s] Callback: Address of connection - %s.", __FUNCTION__, connection->remote_address);
-
- if(bt_socket_send_data(socket_fd, quit_command, strlen(quit_command)) == BT_ERROR_NONE)
- {
- LOGI("[%s] Callback: Send quit command.", __FUNCTION__);
- }
- else
- {
- LOGE("[%s] Callback: bt_socket_send_data() failed.", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
- }
- }
- else
- {
- LOGI("[%s] Callback: Failed to connect", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
- }
- }
- else
- {
- LOGI("[%s] Callback: Disconnected.", __FUNCTION__);
- }
-}
-
-void bt_socket_data_received_impl(bt_socket_received_data_s *data, void *user_data)
-{
- if(socket_fd == data->socket_fd)
- {
- if(data->data_size > 0)
- {
- if(!strncmp(data->data, quit_command, data->data_size))
- {
- LOGI("[%s] Callback: Quit command.", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
- }
- }
- else
- {
- LOGE("[%s] Callback: No data.", __FUNCTION__);
- }
- }
- else
- {
- LOGI("[%s] Callback: Another socket - %d.", __FUNCTION__, data->socket_fd);
- }
-}
-
-bool bt_adapter_bonded_device_impl(bt_device_info_s *device_info, void *user_data)
-{
- int i = 0;
- if(device_info != NULL)
- {
- if(device_info->remote_name != NULL && !strcmp(device_info->remote_name, (char*)user_data))
- {
- LOGI("[%s] Callback: chat_server is found in bonded list.", __FUNCTION__);
- if( device_info->remote_address != NULL )
- {
- LOGI("[%s] Callback: Address of chat_server - %s.", __FUNCTION__, device_info->remote_address);
- bt_address = strdup(device_info->remote_address);
- LOGI("[%s] Callback: The number of service_count - %d.", __FUNCTION__, device_info->service_count);
- if(device_info->service_count <= 0)
- {
- bonding_state = BT_ERROR_SERVICE_SEARCH_FAILED;
- }
- else
- {
- bonding_state = BT_ERROR_NONE;
- for(i=0; i<device_info->service_count; i++)
- {
- LOGI("[%s] Callback: service[%d] - %s", __FUNCTION__, i+1, device_info->service_uuid[i]);
- }
- LOGI("[%s] Callback: is_bonded - %d.", __FUNCTION__, device_info->is_bonded);
- LOGI("[%s] Callback: is_connected - %d.", __FUNCTION__, device_info->is_connected);
- LOGI("[%s] Callback: is_authorized - %d.", __FUNCTION__, device_info->is_authorized);
- }
- }
- else
- {
- LOGE("[%s] Callback: Address of chat_server is NULL.", __FUNCTION__);
- }
-
- return false;
- }
- }
-
- return true;
-}
-
-void bt_adapter_device_discovery_state_changed_impl(int result, bt_adapter_device_discovery_state_e discovery_state,
- bt_adapter_device_discovery_info_s *discovery_info, void *user_data)
-{
- if(discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND)
- {
- if(discovery_info->remote_address != NULL && !strcmp(discovery_info->remote_name, server_name))
- {
- LOGI("[%s] Callback: chat_server is found.", __FUNCTION__);
- LOGI("[%s] Callback: Address of chat_server - %s.", __FUNCTION__, discovery_info->remote_address);
- LOGI("[%s] Callback: Device major class - %d.", __FUNCTION__, discovery_info->bt_class.major_device_class);
- LOGI("[%s] Callback: Device minor class - %d.", __FUNCTION__, discovery_info->bt_class.minor_device_class);
- LOGI("[%s] Callback: Service major class - %d.", __FUNCTION__, discovery_info->bt_class.major_service_class_mask);
- bt_address = strdup(discovery_info->remote_address);
- LOGI("[%s] Callback: is_bonded - %d.", __FUNCTION__, discovery_info->is_bonded);
- bt_adapter_stop_device_discovery();
- }
- else
- {
- LOGE("[%s] Callback: Another device is found.", __FUNCTION__);
- }
- }
- else if(discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED)
- {
- LOGI("[%s] Callback: device discovery finished.", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
- }
-}
-
-void bt_device_bond_created_impl(int result, bt_device_info_s *device_info, void *user_data)
-{
- if(device_info != NULL && !strcmp(device_info->remote_address, bt_address))
- {
- bonding_state = result;
- if(result == BT_ERROR_NONE)
- {
- LOGI("[%s] Callback: A bond with chat_server is created.", __FUNCTION__);
- LOGI("[%s] Callback: The number of service - %d.", __FUNCTION__, device_info->service_count);
-
- int i = 0;
- for(i=0; i<device_info->service_count; i++)
- {
- LOGI("[%s] Callback: service[%d] - %s", __FUNCTION__, i+1, device_info->service_uuid[i]);
- }
- LOGI("[%s] Callback: is_bonded - %d.", __FUNCTION__, device_info->is_bonded);
- LOGI("[%s] Callback: is_connected - %d.", __FUNCTION__, device_info->is_connected);
- }
- else
- {
- LOGE("[%s] Callback: Creating a bond is failed.", __FUNCTION__);
- }
- }
- else
- {
- LOGE("[%s] Callback: A bond with another device is created.", __FUNCTION__);
- }
-
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
-}
-
-void bt_device_service_searched_impl(int result, bt_device_sdp_info_s* sdp_info, void* user_data)
-{
- if(sdp_info != NULL && !strcmp(sdp_info->remote_address, bt_address))
- {
- bonding_state = result;
- if(result == BT_ERROR_NONE)
- {
- LOGI("[%s] Callback: Services of chat_service are found.", __FUNCTION__);
- LOGI("[%s] Callback: The number of service - %d.", __FUNCTION__, sdp_info->service_count);
-
- int i = 0;
- for(i = 0; i < sdp_info->service_count; i++)
- {
- LOGI("[%s] Callback: service[%d] - %s", __FUNCTION__, i+1, sdp_info->service_uuid[i]);
- }
- }
- }
- else
- {
- LOGE("[%s] Callback: Services of another device are found.", __FUNCTION__);
- }
-
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
-}
-
-
-
-
-int main()
-{
- g_mainloop = g_main_loop_new(NULL, FALSE);
- const char* my_uuid="11011101-0000-1000-8000-00805F9B34FB";
- int timeout_id = -1;
-
- LOGI("[%s] Client starts.", __FUNCTION__);
-
- if(bt_initialize() != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_initialize() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_adapter_get_state(&bt_state) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_get_state() failed.", __FUNCTION__);
- return -1;
- }
-
- // Enable BT
- if(bt_state == BT_ADAPTER_DISABLED)
- {
- if(bt_adapter_set_state_changed_cb(bt_state_changed_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_adapter_enable() == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_adapter_state_changed_cb will be called.", __FUNCTION__);
- timeout_id = g_timeout_add (60000, timeout_func, g_mainloop);
- g_main_loop_run(g_mainloop);
- g_source_remove(timeout_id);
- }
- else
- {
- LOGE("[%s] bt_adapter_enable() failed.", __FUNCTION__);
- return -1;
- }
- }
- else
- {
- LOGI("[%s] BT was already enabled.", __FUNCTION__);
- }
-
- // Device discovery
- if(bt_state == BT_ADAPTER_ENABLED)
- {
- if(bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_impl, server_name) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_foreach_bonded_device() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_address == NULL)
- {
- if(bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_impl, NULL)
- != BT_ERROR_NONE )
- {
- LOGE("[%s] bt_adapter_set_device_discovery_state_changed_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_adapter_start_device_discovery() == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_adapter_device_discovery_state_changed_cb will be called.", __FUNCTION__);
- g_main_loop_run(g_mainloop);
- }
- else
- {
- LOGE("[%s] bt_adapter_start_device_discovery() failed.", __FUNCTION__);
- return -1;
- }
- }
- else
- {
- LOGI("[%s] chat_server is found in bonded device list.", __FUNCTION__);
- }
- }
- else
- {
- LOGE("[%s] BT is not enabled.", __FUNCTION__);
- return -1;
- }
-
- // Create bond with a server
- if(bonding_state == BT_ERROR_SERVICE_SEARCH_FAILED)
- {
- if(bt_device_set_service_searched_cb(bt_device_service_searched_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_device_set_service_searched_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_device_start_service_search(bt_address) == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_device_service_searched_cb will be called.", __FUNCTION__);
- g_main_loop_run(g_mainloop);
- }
- else
- {
- LOGE("[%s] bt_device_start_service_search() failed.", __FUNCTION__);
- return -1;
- }
- }
- else if(bonding_state != BT_ERROR_NONE)
- {
- if(bt_device_set_bond_created_cb(bt_device_bond_created_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_device_set_bond_created_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_device_create_bond(bt_address) == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_device_bond_created_cb will be called.", __FUNCTION__);
- g_main_loop_run(g_mainloop);
- }
- else
- {
- LOGE("[%s] bt_device_create_bond() failed.", __FUNCTION__);
- return -1;
- }
- }
-
- // Connecting socket as a client
- if( bonding_state == BT_ERROR_NONE )
- {
- if( bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_impl, NULL) != BT_ERROR_NONE )
- {
- LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if( bt_socket_set_data_received_cb(bt_socket_data_received_impl, NULL) != BT_ERROR_NONE )
- {
- LOGE("[%s] bt_socket_set_data_received_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if( bt_socket_connect_rfcomm(bt_address, my_uuid) == BT_ERROR_NONE )
- {
- LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", __FUNCTION__);
- g_main_loop_run(g_mainloop);
- }
- else
- {
- LOGE("[%s] bt_socket_connect_rfcomm() failed.", __FUNCTION__);
- return -1;
- }
-
- if( bt_socket_disconnect_rfcomm(socket_fd) != BT_ERROR_NONE )
- {
- LOGE("[%s] bt_socket_disconnect_rfcomm() failed.", __FUNCTION__);
- return -1;
- }
- }
- else
- {
- LOGE("[%s] Bond is not created.", __FUNCTION__);
- return -1;
- }
-
- bt_deinitialize();
-
- LOGI("[%s] Client ends.", __FUNCTION__);
- return 0;
-}
diff --git a/test/bt_chat_server.c b/test/bt_chat_server.c
deleted file mode 100644
index 95493a1..0000000
--- a/test/bt_chat_server.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <bluetooth.h>
-#include <dlog.h>
-#include <glib.h>
-#include <string.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "BT_CHAT_SERVER"
-
-/**
- * Variables
- **/
-static GMainLoop* g_mainloop = NULL;
-static bt_adapter_visibility_mode_e visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
-static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
-static int service_socket = -1;
-static int connected_socket = -1;
-static char* quit_command = "Quit";
-
-
-/**
- * Callback functions
- **/
-gboolean timeout_func(gpointer data)
-{
- LOGE("[%s] Timeout.", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit((GMainLoop*)data);
- }
-
- return FALSE;
-}
-
-void bt_state_changed_impl(int result, bt_adapter_state_e adapter_state, void* user_data)
-{
- if( adapter_state == BT_ADAPTER_ENABLED )
- {
- if( result == BT_ERROR_NONE )
- {
- LOGI("[%s] Callback: BT was enabled successfully.", __FUNCTION__);
- bt_state = BT_ADAPTER_ENABLED;
- }
- else
- {
- LOGE("[%s] Callback: Failed to enable BT.", __FUNCTION__);
- }
- }
-
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
-}
-
-void bt_socket_connection_state_changed_impl(int result, bt_socket_connection_state_e connection_state,
- bt_socket_connection_s *connection, void *user_data)
-{
- if( result == BT_ERROR_NONE )
- {
- LOGI("[%s] Callback: Result is BT_ERROR_NONE.", __FUNCTION__);
- }
- else
- {
- LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", __FUNCTION__);
- }
-
- if( connection_state == BT_SOCKET_CONNECTED )
- {
- LOGI("[%s] Callback: Connected.", __FUNCTION__);
- if( connection != NULL )
- {
- connected_socket = connection->socket_fd;
- LOGI("[%s] Callback: Socket of connection - %d.", __FUNCTION__, connected_socket);
- LOGI("[%s] Callback: Role of connection - %d.", __FUNCTION__, connection->local_role);
- LOGI("[%s] Callback: Address of connection - %s.", __FUNCTION__, connection->remote_address);
- }
- else
- {
- LOGI("[%s] Callback: No connection data", __FUNCTION__);
- }
- }
- else
- {
- LOGI("[%s] Callback: Disconnected.", __FUNCTION__);
- LOGI("[%s] Callback: Socket of connection - %d.", __FUNCTION__, connected_socket);
- LOGI("[%s] Callback: Role of connection - %d.", __FUNCTION__, connection->local_role);
- LOGI("[%s] Callback: Address of connection - %s.", __FUNCTION__, connection->remote_address);
- }
-}
-
-void bt_socket_data_received_impl(bt_socket_received_data_s *data, void *user_data)
-{
- if( data->data_size > 0 )
- {
- if( !strncmp(data->data, quit_command, data->data_size) )
- {
- LOGI("[%s] Callback: Quit command.", __FUNCTION__);
- if(g_mainloop)
- {
- g_main_loop_quit(g_mainloop);
- }
- }
-
- if( bt_socket_send_data(connected_socket, quit_command, strlen(quit_command)) == BT_ERROR_NONE )
- {
- LOGI("[%s] Callback: Send quit command.", __FUNCTION__);
- }
- else
- {
- LOGE("[%s] Callback: bt_socket_send_data() failed.", __FUNCTION__);
- }
- }
- else
- {
- LOGE("[%s] Callback: No data.", __FUNCTION__);
- }
-}
-
-
-int main()
-{
- g_mainloop = g_main_loop_new(NULL, FALSE);
- const char* my_uuid="11011101-0000-1000-8000-00805F9B34FB";
- int timeout_id = -1;
-
- LOGI("[%s] Server starts.", __FUNCTION__);
-
- if(bt_initialize() != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_initialize() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_adapter_get_state(&bt_state) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_get_state() failed.", __FUNCTION__);
- return -1;
- }
-
- // Enable BT
- if(bt_state == BT_ADAPTER_DISABLED)
- {
- if(bt_adapter_set_state_changed_cb(bt_state_changed_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_adapter_enable() == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_adapter_state_changed_cb will be called.", __FUNCTION__);
- timeout_id = g_timeout_add (60000, timeout_func, g_mainloop);
- g_main_loop_run(g_mainloop);
- g_source_remove(timeout_id);
- }
- else
- {
- LOGE("[%s] bt_adapter_enable() failed.", __FUNCTION__);
- return -1;
- }
- }
- else
- {
- LOGI("[%s] BT was already enabled.", __FUNCTION__);
- }
-
- // Set name as "chat_server"
- if(bt_state == BT_ADAPTER_ENABLED)
- {
- char* name = NULL;
- if(bt_adapter_get_name(&name) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_get_name() failed.", __FUNCTION__);
- return -1;
- }
-
- if(strncmp(name, "chat_server", strlen(name)) != 0)
- {
- if(bt_adapter_set_name("chat_server") != BT_ERROR_NONE)
- {
- if (NULL != name)
- free(name);
- LOGE("[%s] bt_adapter_set_name() failed.", __FUNCTION__);
- return -1;
- }
- }
- if (NULL != name)
- free(name);
- }
- else
- {
- LOGE("[%s] BT is not enabled.", __FUNCTION__);
- return -1;
- }
- // Set visibility as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE
- if(bt_adapter_get_visibility(&visibility_mode) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_get_visibility() failed.", __FUNCTION__);
- return -1;
- }
-
- if(visibility_mode != BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE)
- {
- if(bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_adapter_set_visibility() failed.", __FUNCTION__);
- return -1;
- }
- visibility_mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE;
- }
- else
- {
- LOGI("[%s] Visibility mode was already set as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE.", __FUNCTION__);
- }
-
- // Connecting socket as a server
- if(bt_socket_create_rfcomm(my_uuid, &service_socket) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_socket_create_rfcomm() failed.", __FUNCTION__);
- return -1;
- }
- LOGI("[%s] socket is created - %d.", __FUNCTION__, service_socket);
-
- if(bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_socket_set_data_received_cb(bt_socket_data_received_impl, NULL) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_socket_set_data_received_cb() failed.", __FUNCTION__);
- return -1;
- }
-
- if(bt_socket_listen_and_accept_rfcomm(service_socket, 5) == BT_ERROR_NONE)
- {
- LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", __FUNCTION__);
- g_main_loop_run(g_mainloop);
- }
- else
- {
- LOGE("[%s] bt_socket_listen_and_accept_rfcomm() failed.", __FUNCTION__);
- return -1;
- }
-
- sleep(5); // Wait for completing delivery
- if(bt_socket_destroy_rfcomm(service_socket) != BT_ERROR_NONE)
- {
- LOGE("[%s] bt_socket_destroy_rfcomm() failed.", __FUNCTION__);
- return -1;
- }
- else
- {
- LOGE("[%s] bt_socket_destroy_rfcomm() succeeded.", __FUNCTION__);
- }
-
- bt_deinitialize();
-
- LOGI("[%s] Server ends.", __FUNCTION__);
- return 0;
-}
diff --git a/test/bt_infinite_spp_test.c b/test/bt_infinite_spp_test.c
new file mode 100644
index 0000000..cde3b6e
--- /dev/null
+++ b/test/bt_infinite_spp_test.c
@@ -0,0 +1,512 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <dlog.h>
+#include <glib.h>
+#include <sys/time.h>
+#include <bluetooth.h>
+
+#undef LOG_TAG
+#define LOG_TAG "BT_SPP_TEST"
+
+#define BT_DBG(fmt, args...) \
+ SLOGD(fmt, ##args)
+#define BT_INFO(fmt, args...) \
+ SLOGI(fmt, ##args)
+#define BT_ERR(fmt, args...) \
+ SLOGE(fmt, ##args)
+
+typedef enum
+{
+ BT_SPP_TEST_ROLE_SERVER = 0x00,
+ BT_SPP_TEST_ROLE_CLIENT,
+} bt_spp_test_role_e;
+
+#define BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH "/opt/usr/media/Others/.bt_dump/spp_test_addr"
+#define BT_INFINITE_SPP_TEST_RESULT_FILE_PATH "/opt/usr/media/Others/.bt_dump/spp_result.log"
+
+bool __bt_connect_spp(void);
+static gboolean __bt_send_data(gpointer user_data);
+bool __bt_verify_data(char *data, int data_size);
+bool __bt_bond_remote_device(void);
+bool __bt_is_paired(void);
+
+static GMainLoop* g_mainloop = NULL;
+
+static bt_spp_test_role_e spp_role = BT_SPP_TEST_ROLE_SERVER;
+static char remote_addr[18] = {0,};
+static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
+
+const char *spp_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66";
+static int server_fd = -1;
+static int socket_fd = -1;
+static bool is_receive_complete = false;
+
+static int packet_size = 65536;
+static char *buf = NULL;
+static int total_count = 32;
+static int sent_count = 0;
+static int receive_count = 0;
+static int receive_index = 0;
+
+static struct timeval start_time = {0,};
+static struct timeval end_time = {0,};
+static struct timeval diff_time = {0,};
+
+static int sum_time_ms = 0;
+static int avg_time_ms = 0;
+static int total_test_count = 0;
+
+void __bt_create_log_dump(void)
+{
+ char *argv[] = {NULL};
+
+ execv("/usr/bin/all_log_dump.sh", argv);
+
+ if (g_mainloop)
+ g_main_loop_quit(g_mainloop);
+ else
+ exit(0);
+}
+
+static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, void *user_data)
+{
+ if (data == NULL) {
+ BT_ERR("data is NULL");
+ return;
+ }
+ BT_INFO("FD = %d, Buffer len = %d", data->socket_fd, data->data_size);
+
+ if (__bt_verify_data(data->data, data->data_size) == false)
+ __bt_create_log_dump();
+
+ if (is_receive_complete == true)
+ g_idle_add(__bt_send_data, NULL);
+}
+
+static void __bt_device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data)
+{
+ if (result != BT_ERROR_NONE) {
+ BT_ERR("result[0x%X]", result);
+ return;
+ }
+
+ if (strcmp(device_info->remote_address, remote_addr) == 0) {
+ if (__bt_connect_spp() == false)
+ BT_ERR("__bt_connect_spp() failed.");
+ }
+}
+
+static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data)
+{
+ bool *is_paired = (bool*)user_data;
+
+ if (strcmp(device_info->remote_address, remote_addr) == 0) {
+ BT_INFO("remote_addr is exist.");
+ *is_paired = true;
+ return false;
+ }
+
+ return true;
+}
+
+void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ BT_INFO("result [0x%04x] state = %d", result, adapter_state);
+
+ if (result == BT_ERROR_NONE) {
+ bt_state = adapter_state;
+ if (adapter_state == BT_ADAPTER_ENABLED) {
+ if (__bt_is_paired() == true)
+ __bt_connect_spp();
+ else
+ __bt_bond_remote_device();
+ }
+ }
+}
+
+void __bt_socket_connection_state_changed_cb(int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data)
+{
+ if (connection_state == BT_SOCKET_CONNECTED) {
+ BT_INFO("RFCOMM connected, result [0x%04x] Fd = %d, device add = %s, Role = %s",
+ result, connection->socket_fd, connection->remote_address,
+ (connection->local_role == BT_SOCKET_SERVER) ? "SERVER" : "CLIENT");
+
+ if (connection->socket_fd > 0) {
+ socket_fd = connection->socket_fd;
+ if (spp_role == BT_SPP_TEST_ROLE_CLIENT)
+ g_idle_add(__bt_send_data, NULL);
+ } else {
+ BT_ERR("socket_fd is INVALID");
+ }
+ } else {
+ BT_INFO("RFCOMM disconnected, result [0x%04x] Fd = %d, device add = %s",
+ result, connection->socket_fd, connection->remote_address);
+ __bt_create_log_dump();
+ }
+}
+
+void __bt_spp_calc_speed(void)
+{
+ int total_time_ms;
+ FILE *fp = NULL;
+ static char str_speed[30] = "\0";
+ int speed;
+
+ diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec;
+ diff_time.tv_usec = end_time.tv_usec - start_time.tv_usec;
+
+ if(diff_time.tv_usec < 0)
+ {
+ diff_time.tv_sec = diff_time.tv_sec - 1;
+ diff_time.tv_usec = diff_time.tv_usec + 1000000;
+ }
+
+ fp = fopen(BT_INFINITE_SPP_TEST_RESULT_FILE_PATH, "a+");
+ /* Fix : NULL_RETURNS */
+ if (fp == NULL) {
+ BT_ERR("Cannot open file: %s\n", BT_INFINITE_SPP_TEST_RESULT_FILE_PATH);
+ return;
+ }
+ total_time_ms = (diff_time.tv_sec * 1000);
+ total_time_ms += diff_time.tv_usec / 1000;
+
+ speed = (packet_size * total_count * 8) / total_time_ms;
+
+ BT_INFO("%s @ %d kbps", "2MB", speed);
+ sprintf(str_speed, "%s @ %d kbps", "2MB", speed);
+ fprintf(fp, "%s\n", str_speed);
+
+ total_test_count++;
+ sum_time_ms += total_time_ms;
+ if (total_test_count % 10 == 0) {
+ avg_time_ms = sum_time_ms / total_test_count;
+ speed = (packet_size * total_count * 8) / avg_time_ms;
+ BT_INFO("[AVG(%d times)] %d kbps", total_test_count, speed);
+ sprintf(str_speed, "[AVG(%d times)] %d kbps", total_test_count, speed);
+ fprintf(fp, "%s\n", str_speed);
+ }
+
+ if (total_test_count == 1000) {
+ sum_time_ms = 0;
+ avg_time_ms = 0;
+ total_test_count = 0;
+ }
+
+ fclose(fp);
+}
+
+void __bt_make_data(void)
+{
+ int i;
+ int j;
+ char w = 0x20;
+
+ memset(buf, 0x00, packet_size);
+ for (i = 0; i < packet_size / 256; i++) {
+ for (j = 0; j < 256; j++) {
+ buf[i * 256 + j] = w;
+ }
+
+ w++;
+ if (w > 0x7e)
+ w = 0x20;
+ }
+}
+
+bool __bt_verify_data(char *data, int data_size)
+{
+ int i;
+
+ if (receive_count == 0 && receive_index == 0)
+ gettimeofday(&start_time, NULL);
+
+ for (i = 0; i < data_size; i++) {
+ if (data[i] != buf[receive_index]) {
+ BT_ERR("data error. rcv_cnt=%d, data[%d]=%d, buf[%d]=%d", receive_count, i, data[i], receive_index, buf[receive_index]);
+ return false;
+ }
+
+ receive_index++;
+ if (receive_index == packet_size) {
+ receive_index = 0;
+ receive_count++;
+
+ if (receive_count == total_count)
+ is_receive_complete = true;
+ }
+ }
+
+ if (is_receive_complete == true) {
+ gettimeofday(&end_time, NULL);
+ __bt_spp_calc_speed();
+ receive_count = 0;
+ receive_index = 0;
+ }
+
+ return true;
+}
+
+static gboolean __bt_send_data(gpointer user_data)
+{
+ int ret = BT_ERROR_NONE;
+ int write = 0;
+ int state = 0;
+ struct timeval tv_write_timeout = {0, };
+ fd_set wfds;
+ int fail_count = 0;
+
+ tv_write_timeout.tv_sec = 1;
+
+ is_receive_complete = false;
+
+ if (sent_count == 0)
+ gettimeofday(&start_time, NULL);
+
+ while (write < packet_size) {
+ FD_ZERO(&wfds);
+ FD_SET(socket_fd, &wfds);
+ state = select(socket_fd + 1, NULL, &wfds, NULL, &tv_write_timeout);
+ if (state == -1) {
+ BT_ERR("select() error.[0x%X]", ret);
+ __bt_create_log_dump();
+ return FALSE;
+ } else {
+ if (FD_ISSET(socket_fd, &wfds)) {
+ ret = bt_socket_send_data(socket_fd, buf + write, packet_size - write);
+ if(ret <= 0) {
+ BT_ERR("bt_socket_send_data() failed.[0x%X]", ret);
+ __bt_create_log_dump();
+ return FALSE;
+ } else {
+ write += ret;
+ }
+ fail_count = 0;
+ } else {
+ BT_ERR("socket is NOT ready.(fail_count = %d)", fail_count);
+ if (fail_count++ == 10) {
+ BT_ERR("__bt_send_data failed.");
+ __bt_create_log_dump();
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ sent_count++;
+ if (sent_count == total_count) {
+ BT_INFO("Last packet.");
+ gettimeofday(&end_time, NULL);
+ __bt_spp_calc_speed();
+ sent_count = 0;
+ } else {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+bool __bt_connect_spp(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (spp_role == BT_SPP_TEST_ROLE_SERVER) {
+ if (server_fd < 0) {
+ ret = bt_socket_create_rfcomm(spp_secure_uuid, &server_fd);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_socket_create_rfcomm() failed.[0x%X]", ret);
+ return false;
+ }
+ }
+
+ ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_socket_listen_and_accept_rfcomm() failed.[0x%X]", ret);
+ return false;
+ }
+ } else {
+ ret = bt_socket_connect_rfcomm(remote_addr, spp_secure_uuid);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_socket_connect_rfcomm() failed.[0x%X]", ret);
+ bt_socket_destroy_rfcomm(server_fd);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool __bt_bond_remote_device(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_device_set_bond_created_cb() failed.[0x%X]", ret);
+ return false;
+ }
+
+ if (spp_role == BT_SPP_TEST_ROLE_CLIENT) {
+ ret = bt_device_create_bond(remote_addr);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_device_create_bond() failed.[0x%X]", ret);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool __bt_is_paired(void)
+{
+ int ret = BT_ERROR_NONE;
+ bool is_paired = false;
+
+ ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, &is_paired);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_adapter_foreach_bonded_device() failed.[0x%X]", ret);
+ return false;
+ }
+
+ return is_paired;
+}
+
+bool __bt_init(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_initialize();
+ if(ret != BT_ERROR_NONE) {
+ BT_ERR("bt_initialize() failed.[0x%X]", ret);
+ return false;
+ }
+
+ ret = bt_adapter_get_state(&bt_state);
+ if(ret != BT_ERROR_NONE) {
+ BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret);
+ return false;
+ }
+
+ ret = bt_adapter_set_state_changed_cb(__bt_adapter_state_changed_cb, NULL);
+ if(ret != BT_ERROR_NONE) {
+ BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret);
+ return false;
+ }
+
+ ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_socket_set_connection_state_changed_cb() failed.[0x%X]", ret);
+ return false;
+ }
+
+ ret = bt_socket_set_data_received_cb(__bt_socket_data_received_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("bt_socket_set_data_received_cb() failed.[0x%X]", ret);
+ return false;
+ }
+
+ if (buf == NULL) {
+ buf = malloc(packet_size);
+ if (buf == NULL) {
+ BT_ERR("Out of memory");
+ return false;
+ }
+ __bt_make_data();
+ }
+
+ return true;
+}
+
+void __bt_deinit(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (buf)
+ free(buf);
+
+ if (server_fd >= 0)
+ bt_socket_destroy_rfcomm(server_fd);
+
+ ret = bt_socket_unset_data_received_cb();
+ if (ret != BT_ERROR_NONE)
+ BT_ERR("bt_socket_unset_data_received_cb() failed.[0x%X]", ret);
+
+ ret = bt_socket_unset_connection_state_changed_cb();
+ if (ret != BT_ERROR_NONE)
+ BT_ERR("bt_socket_unset_connection_state_changed_cb() failed.[0x%X]", ret);
+
+ ret = bt_device_unset_bond_created_cb();
+ if (ret != BT_ERROR_NONE)
+ BT_ERR("bt_device_unset_bond_created_cb() failed.[0x%X]", ret);
+
+ ret = bt_deinitialize();
+ if(ret != BT_ERROR_NONE)
+ BT_ERR("bt_deinitialize() failed.[0x%X]", ret);
+}
+
+bool __bt_set_remote_address(void)
+{
+ FILE *fp = NULL;
+
+ if ((fp = fopen(BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH, "r")) == NULL) {
+ BT_ERR("remote_addr file is NOT exist.");
+ return false;
+ }
+
+ if (fgets(remote_addr, 18, fp) == NULL) {
+ BT_ERR("remote_addr is INVALID.");
+ fclose(fp);
+ return false;
+ }
+
+ fclose(fp);
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc == 2 && strcmp(argv[1], "client") == 0)
+ spp_role = BT_SPP_TEST_ROLE_CLIENT;
+ BT_INFO("SPP test role is %s", spp_role==BT_SPP_TEST_ROLE_SERVER?"SERVER":"CLIENT");
+
+ if (__bt_set_remote_address() == false)
+ return -1;
+
+ if (__bt_init() == false)
+ goto fail;
+
+ if (bt_state == BT_ADAPTER_ENABLED) {
+ if (__bt_is_paired() == true) {
+ if (__bt_connect_spp() == false)
+ goto fail;
+ } else {
+ if (__bt_bond_remote_device() == false)
+ goto fail;
+ }
+ }
+
+ g_mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(g_mainloop);
+
+fail:
+ if (g_mainloop)
+ g_main_loop_unref(g_mainloop);
+
+ __bt_deinit();
+
+ return 0;
+}
diff --git a/test/bt_infinite_spp_test_client.service b/test/bt_infinite_spp_test_client.service
new file mode 100644
index 0000000..f425cb8
--- /dev/null
+++ b/test/bt_infinite_spp_test_client.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=BT SPP test infinitely
+PartOf=bluetooth-hciattach@bt.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/bt_infinite_spp_test client
+RemainAfterExit=yes
+
+[Install]
+RequiredBy=bluetooth-hciattach@bt.service
diff --git a/test/bt_infinite_spp_test_server.service b/test/bt_infinite_spp_test_server.service
new file mode 100644
index 0000000..917658b
--- /dev/null
+++ b/test/bt_infinite_spp_test_server.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=BT SPP test infinitely
+PartOf=bluetooth-hciattach@bt.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/bt_infinite_spp_test
+RemainAfterExit=yes
+
+[Install]
+RequiredBy=bluetooth-hciattach@bt.service
diff --git a/test/bt_onoff.c b/test/bt_onoff.c
new file mode 100644
index 0000000..f95106a
--- /dev/null
+++ b/test/bt_onoff.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file bt_onoff.c
+ * @brief This is the source file for bt activation/deactivation.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+
+#include "bluetooth.h"
+
+#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
+#define TC_PRT(format, args...) PRT(format"\n", ##args)
+
+GMainLoop *main_loop = NULL;
+static guint onoff_timer = 0;
+
+static void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ TC_PRT("state(%d), error(%d)", adapter_state, result);
+
+ if (onoff_timer)
+ g_source_remove(onoff_timer);
+ onoff_timer = 0;
+
+ if (result != BT_ERROR_NONE) {
+ char *argv[] = {NULL};
+ execv("all_log_dump.sh", argv);
+ }
+
+ if (main_loop)
+ g_main_loop_quit(main_loop);
+ else
+ exit(0);
+}
+
+static gboolean __bt_onoff_timeout_cb(gpointer data)
+{
+ TC_PRT("Timed out");
+
+ char *argv[] = {NULL};
+ execv("all_log_dump.sh", argv);
+
+ if (main_loop)
+ g_main_loop_quit(main_loop);
+ else
+ exit(0);
+
+ return FALSE;
+}
+
+int main(int argc, char* argv[])
+{
+ int ret;
+ bt_adapter_state_e state;
+
+ if(bt_initialize() != BT_ERROR_NONE)
+ {
+ TC_PRT("bt_initialize() failed.");
+ return -1;
+ }
+ if (bt_adapter_set_state_changed_cb(__bt_adapter_state_changed_cb, NULL) != BT_ERROR_NONE)
+ {
+ TC_PRT("bt_adapter_set_state_changed_cb() failed.");
+ goto DONE;
+ }
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ bt_adapter_get_state(&state);
+ ret = bt_adapter_get_state(&state);
+ TC_PRT("state(%d), error(%d)", state, ret);
+
+ onoff_timer = g_timeout_add(20000, (GSourceFunc)__bt_onoff_timeout_cb, NULL);
+
+ if (argc <= 1) {
+ if (state == BT_ADAPTER_DISABLED)
+ ret = bt_adapter_enable();
+ else
+ ret = bt_adapter_disable();
+ TC_PRT("bt_adapter_%s() error(%d)", state==BT_ADAPTER_DISABLED?"enable":"disable", ret);
+ } else {
+ if (argv[1][0] == '0') {
+ if (state == BT_ADAPTER_DISABLED) {
+ TC_PRT("Already disabled");
+ goto DONE;
+ } else {
+ ret = bt_adapter_disable();
+ TC_PRT("bt_adapter_disable() error(%d)", ret);
+ if (ret != BT_ERROR_NONE)
+ goto DONE;
+ }
+ } else {
+ if (state == BT_ADAPTER_ENABLED) {
+ TC_PRT("Already eabled");
+ goto DONE;
+ } else {
+ ret = bt_adapter_enable();
+ TC_PRT("bt_adapter_enable() error(%d)", ret);
+ if (ret != BT_ERROR_NONE)
+ goto DONE;
+ }
+ }
+ }
+
+ g_main_loop_run(main_loop);
+
+DONE:
+ if (onoff_timer)
+ g_source_remove(onoff_timer);
+ onoff_timer = 0;
+ bt_adapter_unset_state_changed_cb();
+ bt_deinitialize();
+
+ return 0;
+}
diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c
index 2ce27f4..8415988 100644
--- a/test/bt_unit_test.c
+++ b/test/bt_unit_test.c
@@ -28,88 +28,767 @@
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <glib.h>
-#include <dbus/dbus-glib.h>
+#include <ctype.h>
+#include <time.h>
#include "bluetooth.h"
-
-#define BUFFER_LEN 10
-#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
-#define TC_PRT(format, args...) PRT(format"\n", ##args)
+#include "bluetooth_internal.h"
+#include "bluetooth_private.h"
+#include "bluetooth-telephony-api.h"
+#include "bt_unit_test.h"
const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB";
const char *opp_uuid = "00001105-0000-1000-8000-00805f9b34fb";
+const char *custom_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66";
+
+static bt_unit_test_table_e current_tc_table;
+static char remote_addr[18] = "F6:FB:8F:D8:C8:7C";
+static bool input_automated_test_delay = false;
+
+static bool need_to_set_params = false;
+static int g_test_id = -1;
+static tc_params_t g_test_param = {0,};
static int server_fd;
static int client_fd;
+static int custom_server_fd;
+static int custom_client_fd;
-GMainLoop *main_loop = NULL;
+static int bt_onoff_cnt = 0;
+static int bt_onoff_cnt_success = 0;
+static int bt_onoff_cnt_fail = 0;
+static time_t bt_onoff_timer;
+
+static gboolean is_sub_index = FALSE;
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+int service_index;
+int char_service_index;
+static int selected_service_index = -1;
+static int selected_char_index = 0;
+#endif
+static bt_advertiser_h advertiser = NULL;
+static bt_advertiser_h advertiser_list[3] = {NULL, };
+static int advertiser_index = 0;
+
+bt_gatt_client_h client = NULL;
+
+bt_gatt_server_h server = NULL;
typedef struct {
- const char *tc_name;
- int tc_code;
-} tc_table_t;
+ bt_gatt_h svc;
+ bt_gatt_h chr;
+ bt_gatt_h desc;
+} gatt_handle_t;
+gatt_handle_t battery_h;
+gatt_handle_t heart_rate_h;
+gatt_handle_t thermometer_h;
+gatt_handle_t custom_h;
+
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+bt_gatt_attribute_h service_clone[MAX_SERVICES];
+bt_gatt_attribute_h characteristics[MAX_SERVICES];
+bt_gatt_attribute_h characteristics_services[MAX_SERVICES];
+#endif
+
+static unsigned char *hash = NULL;
+static unsigned char *randomizer = NULL;
+int hash_len;
+int rand_len;
+
+bt_call_list_h call_list;
+GMainLoop *main_loop = NULL;
+
+tc_table_t tc_main[] = {
+ /* Categories */
+ {"SET ADDRESS" , BT_UNIT_TEST_FUNCTION_SET_ADDRESS},
+ {"bt_initialize" , BT_UNIT_TEST_FUNCTION_INITIALIZE},
+ {"bt_deinitialize" , BT_UNIT_TEST_FUNCTION_DEINITIALIZE},
+ {"Adapter" , BT_UNIT_TEST_TABLE_ADAPTER},
+ {"Adapter LE" , BT_UNIT_TEST_TABLE_ADAPTER_LE},
+ {"Device" , BT_UNIT_TEST_TABLE_DEVICE},
+ {"Socket" , BT_UNIT_TEST_TABLE_SOCKET},
+ {"Opp" , BT_UNIT_TEST_TABLE_OPP},
+ {"Audio(ag, a2dp, call)" , BT_UNIT_TEST_TABLE_AUDIO},
+ {"Pan(nap, panu)" , BT_UNIT_TEST_TABLE_PAN},
+ {"Gatt" , BT_UNIT_TEST_TABLE_GATT},
+ {"Avrcp" , BT_UNIT_TEST_TABLE_AVRCP},
+ {"Hid" , BT_UNIT_TEST_TABLE_HID},
+#ifdef TIZEN_WEARABLE
+ {"HF Role" , BT_UNIT_TEST_TABLE_HF},
+ {"PBAP Client" , BT_UNIT_TEST_TABLE_PBAP_CLIENT},
+#endif
+ {"Automated test" , BT_UNIT_TEST_TABLE_AUTOMATED_TEST},
+ {"Initialize All" , BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL},
+ {"FINISH" , BT_UNIT_TEST_TABLE_FINISH},
+ {NULL , 0x0000},
+};
+
+tc_table_t tc_adapter[] = {
+ /* Adapter functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_adapter_get_state" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE},
+ {"bt_adapter_enable" , BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE},
+ {"bt_adapter_disable" , BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE},
+ {"bt_adapter_recover" , BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER},
+ {"bt_adapter_start_device_discovery" , BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY},
+ {"bt_adapter_stop_device_discovery" , BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY},
+ {"bt_adapter_is_discovering" , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING},
+ {"bt_adapter_foreach_bonded_device" , BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE},
+ {"bt_adapter_get_bonded_device_info" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO},
+ {"bt_adapter_is_service_used" , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED},
+ {"bt_adapter_get_visibility" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY},
+ {"bt_adapter_set_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB},
+ {"bt_adapter_unset_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB},
+ {"bt_adapter_get_local_oob_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA},
+ {"bt_adapter_set_remote_oob_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA},
+ {"bt_adapter_remove_remote_oob_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA},
+ {"bt_adapter_set_visibility_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB},
+ {"bt_adapter_unset_visibility_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB},
+ {"bt_adapter_set_visibility_duration_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB},
+ {"bt_adapter_unset_visibility_duration_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB},
+ {"bt_adapter_set_connectable_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB},
+ {"bt_adapter_unset_connectable_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB},
+ {"bt_adapter_get_connectable" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE},
+ {"bt_adapter_set_connectable" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE},
+ {"bt_adapter_get_version" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION},
+ {"bt_adapter_get_local_info" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO},
+ {"bt_adapter_set_manufacturer_data_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB},
+ {"bt_adapter_unset_manufacturer_data_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB},
+ {"bt_adapter_set_manufacturer_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA},
+ {"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_table[] = {
+tc_table_t tc_adapter_le[] = {
/* Adapter functions */
- {"bt_initialize" , 1},
- {"bt_deinitialize" , 2},
- {"bt_adapter_get_state" , 3},
- {"bt_adapter_enable" , 4},
- {"bt_adapter_disable" , 5},
- {"bt_adapter_start_device_discovery" , 6},
- {"bt_adapter_stop_device_discovery" , 7},
- {"bt_adapter_is_discovering" , 8},
- {"bt_adapter_get_bonded_device_info" , 9},
- {"bt_adapter_is_service_used" , 10},
- {"bt_adapter_set_device_discovery_state_changed_cb" , 11},
- {"bt_adapter_unset_device_discovery_state_changed_cb" , 12},
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_adapter_le_get_state" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE},
+ {"bt_adapter_le_enable" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE},
+ {"bt_adapter_le_disable" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE},
+ {"bt_adapter_le_set_scan_mode" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE},
+ {"bt_adapter_le_start_scan" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN},
+ {"bt_adapter_le_stop_scan" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN},
+#ifndef TIZEN_WEARABLE
+ {"bt_adapter_le_start_device_discovery" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_DEVICE_DISCOVERY},
+ {"bt_adapter_le_stop_device_discovery" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY},
+#endif
+ {"bt_adapter_le_add_advertising_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA},
+ {"bt_adapter_le_set_advertising_mode" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE},
+ {"bt_adapter_le_set_advertising_filter_policy" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY},
+ {"bt_adapter_le_set_advertising_connectable" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE},
+ {"bt_adapter_le_start_advertising_new" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW},
+#ifndef TIZEN_WEARABLE
+ {"bt_adapter_le_start_advertising" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING},
+#endif
+ {"bt_adapter_le_stop_advertising" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING},
+ {"bt_adapter_le_add_white_list" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST},
+ {"bt_adapter_le_remove_white_list" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST},
+#ifndef TIZEN_WEARABLE
+ {"bt_adapter_le_clear_white_list" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_CLEAR_WHITE_LIST},
+#endif
+ {"bt_adapter_le_enable_privacy" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY},
+ {"Register scan filter (Device Address)" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS},
+ {"Register scan filter (Service UUID)" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID},
+ {"Register scan filter (Service Solicitation UUID)" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID},
+ {"Unregister all scan filters" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS},
+#ifndef TIZEN_WEARABLE
+ {"bt_adapter_le_set_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB},
+ {"bt_adapter_le_unset_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB},
+#endif
+ {"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_device[] = {
+ /* Device functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_device_set_authorization (true)" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE},
+ {"bt_device_set_authorization (false)" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE},
+ {"bt_device_set_authorization_changed_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB},
+ {"bt_device_unset_authorization_changed_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB},
+ {"bt_device_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB},
+ {"bt_device_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB},
+ {"bt_device_foreach_connected_profiles" , BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES},
+ {"bt_device_is_profile_connected" , BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED},
+ {"bt_device_set_bond_created_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB},
+ {"bt_device_set_bond_destroyed_cb" , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB},
+ {"bt_device_create_bond" , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND},
+ {"bt_device_create_bond_by_type" , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE},
+ {"bt_device_destroy_bond" , BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND},
+ {"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_socket[] = {
/* Socket functions */
- {"bt_socket_create_rfcomm" , 50},
- {"bt_socket_destroy_rfcomm" , 51},
- {"bt_socket_listen_and_accept_rfcomm" , 52},
- {"bt_socket_listen" , 53},
- {"bt_socket_accept" , 54},
- {"bt_socket_reject" , 55},
- {"bt_socket_connect_rfcomm" , 56},
- {"bt_socket_disconnect_rfcomm" , 57},
- {"bt_socket_send_data" , 58},
- {"bt_socket_set_data_received_cb" , 59},
- {"bt_socket_unset_data_received_cb" , 60},
- {"bt_socket_set_connection_requested_cb" , 61},
- {"bt_socket_unset_connection_requested_cb" , 62},
- {"bt_socket_set_connection_state_changed_cb" , 63},
- {"bt_socket_unset_connection_state_changed_cb" , 64},
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_socket_create_rfcomm" , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM},
+ {"bt_socket_destroy_rfcomm" , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM},
+ {"bt_socket_listen_and_accept_rfcomm" , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM},
+ {"bt_socket_listen" , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN},
+ {"bt_socket_accept" , BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT},
+ {"bt_socket_reject" , BT_UNIT_TEST_FUNCTION_SOCKET_REJECT},
+ {"bt_socket_connect_rfcomm" , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM},
+ {"bt_socket_disconnect_rfcomm" , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM},
+ {"bt_socket_send_data" , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA},
+ {"bt_socket_create_rfcomm with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID},
+ {"bt_socket_destroy_rfcomm with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID},
+ {"bt_socket_listen_and_accept_rfcomm with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID},
+ {"bt_socket_connect_rfcomm with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID},
+ {"bt_socket_disconnect_rfcomm with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID},
+ {"bt_socket_send_data with custom uuid" , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID},
+ {"bt_socket_set_data_received_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB},
+ {"bt_socket_unset_data_received_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB},
+ {"bt_socket_set_connection_requested_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB},
+ {"bt_socket_unset_connection_requested_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB},
+ {"bt_socket_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB},
+ {"bt_socket_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_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},
+};
+tc_table_t tc_opp[] = {
/* OPP functions */
- {"bt_opp_client_initialize" , 70},
- {"bt_opp_client_deinitialize" , 71},
- {"bt_opp_client_add_file" , 72},
- {"bt_opp_client_clear_files" , 73},
- {"bt_opp_client_push_files" , 74},
- {"bt_opp_client_cancel_push" , 75},
-
- /* -----------------------------------------*/
- {"Finish" , 0x00ff},
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_opp_client_initialize" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE},
+ {"bt_opp_client_deinitialize" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE},
+ {"bt_opp_client_add_file" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE},
+ {"bt_opp_client_clear_files" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES},
+ {"bt_opp_client_push_files" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES},
+ {"bt_opp_client_cancel_push" , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH},
+ {"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_audio[] = {
+ /* AG functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_audio_initialize" , BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE},
+ {"bt_audio_deinitialize" , BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE},
+ {"bt_audio_connect" , BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT},
+ {"bt_audio_disconnect" , BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT},
+ {"bt_audio_source_connect" , BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_CONNECT},
+ {"bt_audio_source_disconnect" , BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_DISCONNECT},
+ {"bt_audio_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB},
+ {"bt_audio_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB},
+ {"bt_a2dp_source_audio_set_connection_state_cb", BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB},
+ {"bt_a2dp_source_audio_unset_connection_state_cb", BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB},
+ {"bt_ag_open_sco" , BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO},
+ {"bt_ag_close_sco" , BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO},
+ {"bt_ag_is_sco_opened" , BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED},
+ {"bt_ag_set_sco_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB},
+ {"bt_ag_unset_sco_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB},
+ {"bt_ag_is_connected" , BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED},
+ {"BT_AG_CALL_EVENT_IDLE" , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE},
+ {"BT_AG_CALL_EVENT_ANSWERED" , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED},
+ {"BT_AG_CALL_EVENT_DIALING" , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING},
+ {"BT_AG_CALL_EVENT_ALERTING" , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING},
+ {"BT_AG_CALL_EVENT_INCOMING" , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING},
+ {"bt_call_list_create" , BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE},
+ {"bt_call_list_destroy" , BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY},
+ {"bt_call_list_reset" , BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET},
+ {"bt_call_list_add" , BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD},
+ {"bt_ag_notify_call_list" , BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST},
+ {"bt_ag_set_call_handling_event_cb" , BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB},
+ {"bt_ag_is_nrec_enabled" , BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED},
+
+ /* A2DP SCMS-T functions */
+ {"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_pan[] = {
+ /* Network functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_nap_activate" , BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE},
+ {"bt_nap_deactivate" , BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE},
+ {"bt_nap_disconnect_all" , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL},
+ {"bt_nap_disconnect" , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT},
+ {"bt_panu_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB},
+ {"bt_panu_connect" , BT_UNIT_TEST_FUNCTION_PANU_CONNECT},
+ {"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_gatt[] = {
+ /* Gatt functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_gatt_connect" , BT_UNIT_TEST_FUNCTION_GATT_CONNECT},
+ {"bt_gatt_disconnect" , BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT},
+ {"bt_gatt_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB},
+ {"bt_gatt_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB},
+ {"bt_gatt_client_create" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE},
+ {"bt_gatt_client_destroy" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY},
+ {"bt_gatt_client_get_remote_address" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS},
+ {"bt_gatt_client_print_all" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL},
+ {"bt_gatt_client_read_value" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE},
+ {"bt_gatt_client_write_value" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE},
+ {"bt_gatt_client_set_char_value_changed_cb" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB},
+ {"bt_gatt_client_unset_char_value_changed_cb" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB},
+ {"bt_gatt_client_foreach_services" , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES},
+ {"bt_gatt_server_initialize" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE},
+ {"bt_gatt_server_deinitilaize" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE},
+ {"bt_gatt_server_unregister_all_services" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES},
+ {"Register Battery Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC},
+ {"Change Battery Level" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL},
+ {"Register Heart Rate Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC},
+ {"Notify Heart Rate Measurement" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT},
+ {"Register Thermometer Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC},
+ {"Change Thermometer Measurement" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT},
+ {"Register Device Information Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC},
+ {"Register Link Loss Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC},
+ {"Register Custom Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC},
+ {"Change Custom Value" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL},
+ {"ANCS (Pair)" , BT_UNIT_TEST_FUNCTION_ANCS_PAIR},
+ {"ANCS (Watch notification)" , BT_UNIT_TEST_FUNCTION_ANCS_WATCH},
+ {"ANCS (Positive action)" , BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION},
+ {"ANCS (Negative action)" , BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION},
+ {"ANCS (Get Noti. Attr.)" , BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR},
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+ {"bt_gatt_foreach_primary_services" , BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES},
+ {"bt_gatt_discover_characteristics" , BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS},
+ {"bt_gatt_discover_characteristic_descriptor" , BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS},
+ {"bt_gatt_get_service_uuid" , BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID},
+ {"bt_gatt_foreach_included_services" , BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES},
+ {"bt_gatt_set_characteristic_changed_cb" , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB},
+ {"bt_gatt_unset_characteristic_changed_cb" , BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB},
+ {"bt_gatt_get_characteristic_declaration" , BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION},
+ {"bt_gatt_set_characteristic_value" , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE},
+ {"bt_gatt_set_characteristic_value_request" , BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST},
+ {"bt_gatt_read_characteristic_value" , BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE},
+ {"bt_gatt_watch_characteristic_changes" , BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES},
+ {"bt_gatt_unwatch_characteristic_changes" , BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES},
+#endif
+ {"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" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_avrcp_target_initialize" , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE},
+ {"bt_avrcp_target_deinitialize" , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE},
+ {"bt_avrcp_set_equalizer_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB},
+ {"bt_avrcp_set_repeat_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB},
+ {"bt_avrcp_set_shuffle_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB},
+ {"bt_avrcp_set_scan_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB},
+ {"bt_avrcp_unset_equalizer_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB},
+ {"bt_avrcp_unset_repeat_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB},
+ {"bt_avrcp_unset_shuffle_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB},
+ {"bt_avrcp_unset_scan_mode_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB},
+ {"bt_avrcp_control_initialize" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE},
+ {"bt_avrcp_control_deinitialize" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE},
+ {"bt_avrcp_control_connect" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT},
+ {"bt_avrcp_control_disconnect" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT},
+ {"bt_avrcp_control_player_PLAY" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY},
+ {"bt_avrcp_control_player_STOP" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP},
+ {"bt_avrcp_control_player_PAUSE" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE},
+ {"bt_avrcp_control_player_FF" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF},
+ {"bt_avrcp_control_player_RW" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW},
+ {"bt_avrcp_control_player_NEXT" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT},
+ {"bt_avrcp_control_player_PREV" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV},
+ {"bt_avrcp_control_player_GET_REPEAT" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT},
+ {"bt_avrcp_control_player_SET_REPEAT" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT},
+ {"bt_avrcp_control_player_GET_SHUFFLE" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE},
+ {"bt_avrcp_control_player_SET_SHUFFLE" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE},
+ {"bt_avrcp_control_player_GET_POSITION" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION},
+ {"bt_avrcp_control_player_GET_PLAY STATUS" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS},
+ {"bt_avrcp_control_player_GET_TRACK_INFO" ,BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO},
+ {"bt_avrcp_set_song_position_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB},
+ {"bt_avrcp_set_play_status_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB},
+ {"bt_avrcp_set_track_info_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB},
+ {"bt_avrcp_unset_song_position_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB},
+ {"bt_avrcp_unset_play_status_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB},
+ {"bt_avrcp_unset_track_info_changed_cb" , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_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},
+};
+
+tc_table_t tc_hid[] = {
+ /* HID functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_hid_host_initialize" , BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE},
+ {"bt_hid_host_deinitialize" , BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE},
+ {"bt_hid_host_connect" , BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT},
+ {"bt_hid_host_disconnect" , BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT},
+ {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+ {NULL , 0x0000},
+};
+
+#ifdef TIZEN_WEARABLE
+tc_table_t tc_hf[] = {
+ /* Handsfree role functions */
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_hf_initialize" , BT_UNIT_TEST_FUNCTION_HF_INITIALIZE},
+ {"bt_hf_deinitialize" , BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE},
+ {"(CALL Handling) bt_hf_notify_call_event(answer)" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER},
+ {"(CALL Handling) bt_hf_notify_call_event(initiate)" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT},
+ {"(CALL Handling) bt_hf_notify_call_event(terminate)" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM},
+ {"(CALL Status) bt_hf_get_call_status_info_list" , BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST},
+ {"(CALL Status) bt_hf_set_call_handling_event_cb()" , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB},
+ {"(CALL Status) bt_hf_unset_call_handling_event_cb" , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB},
+ {"(CALL Status) bt_hf_set_call_status_updated_event_cb" , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB},
+ {"(CALL Status) bt_hf_unset_call_status_updated_event_cb" , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB},
+ {"(Volume) bt_hf_notify_speaker_gain" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN},
+ {"(Volume) bt_hf_set_speaker_gain_changed_cb" , BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB},
+ {"(Volume) bt_hf_unset_speaker_gain_changed_cb" , BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB},
+ {"(Voice-recog) bt_hf_notify_voice_recognition_state(true)" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE},
+ {"(Voice-recog) bt_hf_notify_voice_recognition_state(false)" , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE},
+ {"(SCO) bt_hf_is_sco_opened" , BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED},
+ {"(SCO) bt_hf_get_codec_id" , BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID},
+ {"(SCO) bt_hf_set_sco_state_changed_cb()" , BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB},
+ {"(SCO) bt_hf_unset_sco_state_changed_cb()" , BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_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},
+};
+
+tc_table_t tc_pbap_client[] = {
+ /* PBAP Functions*/
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"bt_pbap_init()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE},
+ {"bt_pbap_deinit()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE},
+ {"bt_pbap_connect()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT},
+ {"bt_pbap_disconnect()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT},
+ {"bt_pbap_get_phonebook_size()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE},
+ {"bt_pbap_get_phonebook()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL},
+ {"bt_pbap_get_list()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST},
+ {"bt_pbap_pull_vcard()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL},
+ {"bt_pbap_phonebook_search()", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH},
+ {"bt_pbap_get_list() Maxlist=0", BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO},
+
+ {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+ {NULL , 0x0000},
+};
+#endif
+
+tc_table_t tc_automated_test[] = {
+ /* Automated test Functions*/
+ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK},
+ {"On/Off repeat test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST},
+ {"On/Off repeat(1sec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY},
+ {"On/Off repeat(Nsec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY},
{NULL , 0x0000},
};
+static void __bt_initialize_all(void);
+
+void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len,
+ void *user_data);
+
void tc_usage_print(void)
{
int i = 0;
+ tc_table_t* tc_table = NULL;
+
+ switch (current_tc_table) {
+ case BT_UNIT_TEST_TABLE_SET_ADDRESS:
+ TC_PRT("Key 0 : usage BACK");
+ TC_PRT("Input the address of remote device.(e.g., F6:FB:8F:D8:C8:7C)\n\n");
+ return;
+ case BT_UNIT_TEST_TABLE_ADAPTER:
+ tc_table = tc_adapter;
+ break;
+ case BT_UNIT_TEST_TABLE_ADAPTER_LE:
+ tc_table = tc_adapter_le;
+ break;
+ case BT_UNIT_TEST_TABLE_DEVICE:
+ tc_table = tc_device;
+ break;
+ case BT_UNIT_TEST_TABLE_SOCKET:
+ tc_table = tc_socket;
+ break;
+ case BT_UNIT_TEST_TABLE_OPP:
+ tc_table = tc_opp;
+ break;
+ case BT_UNIT_TEST_TABLE_AUDIO:
+ tc_table = tc_audio;
+ break;
+ case BT_UNIT_TEST_TABLE_PAN:
+ tc_table = tc_pan;
+ break;
+ case BT_UNIT_TEST_TABLE_GATT:
+ tc_table = tc_gatt;
+ break;
+ case BT_UNIT_TEST_TABLE_AVRCP:
+ tc_table = tc_avrcp;
+ break;
+ case BT_UNIT_TEST_TABLE_HID:
+ tc_table = tc_hid;
+ break;
+#ifdef TIZEN_WEARABLE
+ case BT_UNIT_TEST_TABLE_HF:
+ tc_table = tc_hf;
+ break;
+ case BT_UNIT_TEST_TABLE_PBAP_CLIENT:
+ tc_table = tc_pbap_client;
+ break;
+#endif
+ case BT_UNIT_TEST_TABLE_AUTOMATED_TEST:
+ if (input_automated_test_delay == true) {
+ TC_PRT("Input the delay for automated test.(e.g., 10)\n\n");
+ return;
+ }
+ tc_table = tc_automated_test;
+ break;
+ case BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL:
+ __bt_initialize_all();
+ TC_PRT("Key 0 : usage BACK");
+ return;
+ case BT_UNIT_TEST_TABLE_MAIN:
+ default:
+ tc_table = tc_main;
+ break;
+ }
while (tc_table[i].tc_name) {
- if (tc_table[i].tc_code != 0x00ff) {
- TC_PRT("Key %d : usage %s", tc_table[i].tc_code,
- tc_table[i].tc_name);
- } else {
- TC_PRT("Key %d : usage %s\n\n", 0x00ff,
+ TC_PRT("Key %d : usage %s", tc_table[i].tc_code,
tc_table[i].tc_name);
+ i++;
+ }
+ printf("\n\n");
+}
+
+static void __bt_free_test_param(tc_params_t *param)
+{
+ int i = 0;
+
+ for (i = 0; i < param->param_count; i++)
+ g_free(param->params[i]);
+ g_free(param->params);
+ param->params = NULL;
+ param->param_count = 0;
+}
+
+static const char* __bt_get_error_message(bt_error_e err)
+{
+ const char* err_str = NULL;
+
+ switch (err) {
+ case BT_ERROR_NONE:
+ err_str = "BT_ERROR_NONE";
+ break;
+ case BT_ERROR_CANCELLED:
+ err_str = "BT_ERROR_CANCELLED";
+ break;
+ case BT_ERROR_INVALID_PARAMETER:
+ err_str = "BT_ERROR_INVALID_PARAMETER";
+ break;
+ case BT_ERROR_OUT_OF_MEMORY:
+ err_str = "BT_ERROR_OUT_OF_MEMORY";
+ break;
+ case BT_ERROR_RESOURCE_BUSY:
+ err_str = "BT_ERROR_RESOURCE_BUSY";
+ break;
+ case BT_ERROR_TIMED_OUT:
+ err_str = "BT_ERROR_TIMED_OUT";
+ break;
+ case BT_ERROR_NOW_IN_PROGRESS:
+ err_str = "BT_ERROR_NOW_IN_PROGRESS";
+ break;
+ case BT_ERROR_NOT_INITIALIZED:
+ err_str = "BT_ERROR_NOT_INITIALIZED";
+ break;
+ case BT_ERROR_NOT_ENABLED:
+ err_str = "BT_ERROR_NOT_ENABLED";
+ break;
+ case BT_ERROR_ALREADY_DONE:
+ err_str = "BT_ERROR_ALREADY_DONE";
+ break;
+ case BT_ERROR_OPERATION_FAILED:
+ err_str = "BT_ERROR_OPERATION_FAILED";
+ break;
+ case BT_ERROR_NOT_IN_PROGRESS:
+ err_str = "BT_ERROR_NOT_IN_PROGRESS";
+ break;
+ case BT_ERROR_REMOTE_DEVICE_NOT_BONDED:
+ err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED";
+ break;
+ case BT_ERROR_AUTH_REJECTED:
+ err_str = "BT_ERROR_AUTH_REJECTED";
+ break;
+ case BT_ERROR_AUTH_FAILED:
+ err_str = "BT_ERROR_AUTH_FAILED";
+ break;
+ case BT_ERROR_REMOTE_DEVICE_NOT_FOUND:
+ err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND";
+ break;
+ case BT_ERROR_SERVICE_SEARCH_FAILED:
+ err_str = "BT_ERROR_SERVICE_SEARCH_FAILED";
+ break;
+ case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED:
+ err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED";
+ break;
+ case BT_ERROR_PERMISSION_DENIED:
+ err_str = "BT_ERROR_PERMISSION_DENIED";
+ break;
+ case BT_ERROR_SERVICE_NOT_FOUND:
+ err_str = "BT_ERROR_SERVICE_NOT_FOUND";
+ break;
+ case BT_ERROR_NOT_SUPPORTED:
+ err_str = "BT_ERROR_NOT_SUPPORTED";
+ break;
+ default:
+ err_str = "NOT Defined";
+ break;
+ }
+
+ return err_str;
+}
+
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+static gboolean __select_index_cb(GIOChannel *chan,
+ GIOCondition cond,
+ gpointer data)
+{
+ char buf[BUFFER_LEN] = { 0 };
+ unsigned int len = 0;
+ int *index = data;
+
+ memset(buf, 0, sizeof(buf));
+
+ if (g_io_channel_read_chars(chan, buf, sizeof(buf),
+ &len, NULL) == G_IO_STATUS_ERROR) {
+ TC_PRT("IO Channel read error");
+ is_sub_index = FALSE;
+ return FALSE;
+ }
+
+ *index = atoi(buf);
+ is_sub_index = FALSE;
+
+ return FALSE;
+}
+
+static void __select_index(void *data, const char *str)
+{
+ GIOChannel *key_io;
+
+ is_sub_index = TRUE;
+
+ if (str)
+ TC_PRT("%s ", str);
+
+ key_io = g_io_channel_unix_new(fileno(stdin));
+
+ g_io_channel_set_encoding(key_io, NULL, NULL);
+ g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL);
+
+ g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ __select_index_cb, data);
+
+ g_io_channel_unref(key_io);
+}
+
+static void __bt_free_gatt_services(void)
+{
+ int i;
+
+ for (i = 0; i < service_index; i++) {
+ bt_gatt_destroy_attribute_handle(service_clone[i]);
+ service_clone[i] = NULL;
+ }
+
+ service_index = 0;
+}
+
+static void __bt_free_gatt_characteristics(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_SERVICES; i++) {
+ if (characteristics[i] == NULL)
+ return;
+
+ bt_gatt_destroy_attribute_handle(characteristics[i]);
+ characteristics[i] = NULL;
+ }
+}
+
+static void __bt_free_gatt_characteristics_services(void)
+{
+ int i;
+
+ for (i = 0; i < char_service_index; i++) {
+ bt_gatt_destroy_attribute_handle(characteristics_services[i]);
+ characteristics_services[i] = NULL;
+ }
+ char_service_index = 0;
+}
+#endif
+
+void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ TC_PRT("__bt_adapter_state_changed_cb");
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ TC_PRT("state: %s",
+ (adapter_state == BT_ADAPTER_ENABLED)?
+ "ENABLED" : "DISABLED");
+}
+
+static void __bt_adapter_device_visibility_mode_changed_cb(int result,
+ bt_adapter_visibility_mode_e visibility_mode,
+ void *user_data)
+{
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ TC_PRT("visibility_mode: %d", visibility_mode);
+}
+
+static void __bt_adapter_device_visibility_duration_changed_cb(int duration,
+ void *user_data)
+{
+ TC_PRT("visibility_duration: %d", duration);
+}
+
+static void __bt_adapter_connectable_changed_cb(int result,
+ bool connectable, void *user_data)
+{
+ if (result != BT_ERROR_NONE) {
+ TC_PRT("connectable change is failed : [0x%04x]", result);
+ return;
+ }
+
+ TC_PRT("%s", connectable ? "Connectable" : "Non-connectable");
+}
+
+static void __bt_adapter_manufacturer_data_changed_cb(char *data,
+ int len, void *user_data)
+{
+ int i;
+
+ TC_PRT("manufacturer data is changed");
+ for (i = 0; i < len; i++) {
+ TC_PRT("[%d] %02x", i, data[i]);
+ }
+}
+
+static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data)
+{
+ int i;
+
+ TC_PRT("remote_address: %s", device_info->remote_address);
+ TC_PRT("remote_name: %s", device_info->remote_name);
+ TC_PRT("service_count: %d", device_info->service_count);
+
+ if (device_info->service_uuid == NULL) {
+ TC_PRT("No uuids");
+ } else {
+ for (i = 0; i < device_info->service_count; i++) {
+ TC_PRT("uuid: %s", device_info->service_uuid[i]);
}
+ }
- i++;
+ if (device_info->manufacturer_data_len > 0) {
+ TC_PRT("manufacturer specific data(len:%d)", device_info->manufacturer_data_len);
+ printf("data [");
+ for (i = 0; i < device_info->manufacturer_data_len; i++)
+ printf("%02x ", device_info->manufacturer_data[i]);
+ printf("]\n");
}
+
+ return true;
}
static void __bt_adapter_device_discovery_state_changed_cb(int result,
@@ -134,12 +813,199 @@ static void __bt_adapter_device_discovery_state_changed_cb(int result,
if (discovery_info->service_uuid == NULL) {
TC_PRT("No uuids");
+ } else {
+ for (i = 0; i < discovery_info->service_count; i++) {
+ TC_PRT("uuid: %s", discovery_info->service_uuid[i]);
+ }
+ }
+
+ if (discovery_info->manufacturer_data_len > 0) {
+ TC_PRT("manufacturer specific data(len:%d)", discovery_info->manufacturer_data_len);
+ printf("data [");
+ for (i = 0; i < discovery_info->manufacturer_data_len; i++)
+ printf("%02x ", discovery_info->manufacturer_data[i]);
+ printf("]\n");
+ }
+}
+
+static void __bt_adapter_le_scan_result_cb(int result,
+ bt_adapter_le_device_scan_result_info_s *info, void *user_data)
+{
+ int i;
+ bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING;
+
+ if (info == NULL) {
+ TC_PRT("No discovery_info!");
return;
}
- for (i = 0; i < discovery_info->service_count; i++) {
- TC_PRT("uuid: %s", discovery_info->service_uuid[i]);
+ TC_PRT("%s Adv %d Scan resp %d RSSI %d Addr_type %d", info->remote_address,
+ info->adv_data_len, info->scan_data_len, info->rssi,
+ info->address_type);
+
+ if (info->adv_data_len > 31 || info->scan_data_len > 31) {
+ TC_PRT("###################");
+ bt_adapter_le_stop_scan();
+ TC_PRT("###################");
+ return;
}
+
+ for (i = 0; i < 2; i++) {
+ char **uuids;
+ char *device_name;
+ int tx_power_level;
+ bt_adapter_le_service_data_s *data_list;
+ int appearance;
+ int manufacturer_id;
+ char *manufacturer_data;
+ int manufacturer_data_len;
+ int count;
+
+ pkt_type += i;
+ if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING && info->adv_data == NULL) continue;
+ if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE && info->scan_data == NULL) break;
+
+ if (bt_adapter_le_get_scan_result_service_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) {
+ int i;
+ for (i = 0; i < count; i++) {
+ TC_PRT("UUID[%d] = %s", i + 1, uuids[i]);
+ g_free(uuids[i]);
+ }
+ g_free(uuids);
+ }
+ if (bt_adapter_le_get_scan_result_device_name(info, pkt_type, &device_name) == BT_ERROR_NONE) {
+ TC_PRT("Device name = %s", device_name);
+ g_free(device_name);
+ }
+ if (bt_adapter_le_get_scan_result_tx_power_level(info, pkt_type, &tx_power_level) == BT_ERROR_NONE) {
+ TC_PRT("TX Power level = %d", tx_power_level);
+ }
+ if (bt_adapter_le_get_scan_result_service_solicitation_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) {
+ int i;
+ for (i = 0; i < count; i++) {
+ TC_PRT("Solicitation UUID[%d] = %s", i + 1, uuids[i]);
+ g_free(uuids[i]);
+ }
+ g_free(uuids);
+ }
+ if (bt_adapter_le_get_scan_result_service_data_list(info, pkt_type, &data_list, &count) == BT_ERROR_NONE) {
+ int i;
+ for (i = 0; i < count; i++)
+ TC_PRT("Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", i + 1, data_list[i].service_uuid[0], data_list[i].service_uuid[1], data_list[i].service_data[0]);
+ bt_adapter_le_free_service_data_list(data_list, count);
+ }
+ if (bt_adapter_le_get_scan_result_appearance(info, pkt_type, &appearance) == BT_ERROR_NONE) {
+ TC_PRT("Appearance = %d", appearance);
+ }
+ if (bt_adapter_le_get_scan_result_manufacturer_data(info, pkt_type, &manufacturer_id, &manufacturer_data, &manufacturer_data_len) == BT_ERROR_NONE) {
+ TC_PRT("Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]", manufacturer_id, manufacturer_data[0], manufacturer_data[1], manufacturer_data_len);
+ g_free(manufacturer_data);
+ }
+ }
+}
+
+void __bt_gatt_server_read_value_requested_cb (char *remote_address,
+ int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle,
+ int offset, void *user_data)
+{
+ char char_value_1[3] = {0, 1, 2};
+
+ TC_PRT("__bt_gatt_server_read_value_requested_cb");
+ TC_PRT("req_id %d", request_id);
+ TC_PRT("server %s", (char *)server);
+ TC_PRT("server %s", (char *)gatt_handle);
+ TC_PRT("Offset %d", offset);
+ /* Get the attribute new values here */
+ bt_gatt_server_send_response(request_id, offset, char_value_1, 3 - offset);
+}
+
+#ifndef TIZEN_WEARABLE
+static void __bt_adapter_le_device_discovery_state_changed_cb(int result,
+ bt_adapter_le_device_discovery_state_e discovery_state,
+ bt_adapter_le_device_discovery_info_s *discovery_info,
+ void *user_data)
+{
+ if (discovery_info == NULL && discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND) {
+ TC_PRT("No discovery_info!");
+ return;
+ }
+
+ if (discovery_state != BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND) {
+ TC_PRT("LE discovery %s", discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED?
+ "Started" : "Finished");
+ } else {
+ TC_PRT("%s Adv %d Scan resp %d RSSI %d Addr_type %d", discovery_info->remote_address,
+ discovery_info->adv_data_len, discovery_info->scan_data_len, discovery_info->rssi,
+ discovery_info->address_type);
+
+ if (discovery_info->adv_data_len > 31 || discovery_info->scan_data_len > 31) {
+ TC_PRT("###################");
+ bt_adapter_le_stop_device_discovery();
+ TC_PRT("###################");
+ return;
+ }
+#if 0
+ /* LE ADV information */
+ int i, ret;
+ int field_len = 0;
+ unsigned char *field_data;
+
+ printf("Adv data [");
+ for (i = 0; i < discovery_info->adv_data_len; i++)
+ printf("%02x ", discovery_info->adv_data[i]);
+ printf("]\n");
+
+ printf("Scan resp data [");
+ for (i = 0; i < discovery_info->scan_data_len; i++)
+ printf("%02x ", discovery_info->scan_data[i]);
+ printf("]\n");
+
+ ret = bt_adapter_le_get_scan_field_data(discovery_info, BT_ADAPTER_LE_PACKET_ADVERTISING,
+ BT_ADAPTER_LE_PACKET_DATA_MANUFACTURER_SPECIFIC_DATA, &field_data, &field_len);
+ if (ret == BT_ERROR_NONE) {
+ printf("Manufacturer specific data [");
+ for (i = 0; i < field_len; i++)
+ printf("%02x ", field_data[i]);
+ printf("]\n");
+ g_free(field_data);
+ }
+
+ ret = bt_adapter_le_get_scan_field_data(discovery_info, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE,
+ BT_ADAPTER_LE_PACKET_DATA_LOCAL_NAME, &field_data, &field_len);
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("%s", field_data);
+ g_free(field_data);
+ }
+#endif
+ }
+}
+#endif
+
+static void __bt_adapter_le_advertising_state_changed_cb(int result,
+ bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data)
+{
+ TC_PRT("Result : %d", result);
+ TC_PRT("Advertiser : %p", advertiser);
+ TC_PRT("Advertising %s [%d]", adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ?
+ "started" : "stopped", adv_state);
+}
+
+static void __bt_adapter_le_advertising_state_changed_cb_2(int result,
+ bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data)
+{
+ TC_PRT("Result : %d", result);
+ TC_PRT("Advertiser : %p", advertiser);
+ TC_PRT("Advertising %s [%d]", adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ?
+ "started" : "stopped", adv_state);
+}
+
+static void __bt_adapter_le_advertising_state_changed_cb_3(int result,
+ bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data)
+{
+ TC_PRT("Result : %d", result);
+ TC_PRT("Advertiser : %p", advertiser);
+ TC_PRT("Advertising %s [%d]", adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ?
+ "started" : "stopped", adv_state);
}
static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, void *user_data)
@@ -167,7 +1033,7 @@ static void __bt_socket_connection_state_changed_cb(int result,
bt_socket_connection_s *connection,
void *user_data)
{
- TC_PRT("result: %d", result);
+ TC_PRT("result: %s", __bt_get_error_message(result));
TC_PRT("connection_state: %d", connection_state);
if (connection == NULL) {
@@ -176,16 +1042,23 @@ static void __bt_socket_connection_state_changed_cb(int result,
}
TC_PRT("socket fd: %d", connection->socket_fd);
+ TC_PRT("server socket fd: %d", connection->server_fd);
TC_PRT("role: %d", connection->local_role);
TC_PRT("remote address: %s", connection->remote_address);
- TC_PRT("service_uuid: %s", connection->service_uuid);
+ if (strcmp(spp_uuid, connection->service_uuid) == 0) {
+ TC_PRT("service_uuid: %s", spp_uuid);
+ client_fd = connection->socket_fd;
+ } else {
+ TC_PRT("service_uuid: %s", connection->service_uuid);
+ custom_client_fd = connection->socket_fd;
+ }
}
void __bt_opp_client_push_responded_cb(int result,
const char *remote_address,
void *user_data)
{
- TC_PRT("result: %d", result);
+ TC_PRT("result: %s", __bt_get_error_message(result));
TC_PRT("remote_address: %s", remote_address);
}
@@ -203,266 +1076,4297 @@ void __bt_opp_client_push_finished_cb(int result,
const char *remote_address,
void *user_data)
{
- TC_PRT("result: %d", result);
+ TC_PRT("result: %s", __bt_get_error_message(result));
TC_PRT("remote_address: %s", remote_address);
}
+void __bt_audio_connection_state_changed_cb(int result,
+ bool connected, const char *remote_address,
+ bt_audio_profile_type_e type, void *user_data)
+{
+ TC_PRT("result [%s]", __bt_get_error_message(result));
+ TC_PRT("connected [%d]", connected);
+ TC_PRT("address [%s]", remote_address);
+ TC_PRT("type [%d]", type);
+}
+
+void __bt_ag_sco_state_changed_cb(int result, bool opened, void *user_data)
+{
+ TC_PRT("result [%s]", __bt_get_error_message(result));
+ TC_PRT("opened [%s]", opened ? "YES" : "NO");
+}
-int test_input_callback(void *data)
+void __bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_e event,
+ unsigned int call_id, void *user_data)
+{
+ TC_PRT("event[%d] call_id[%d]", event, call_id);
+}
+
+void __bt_device_authorization_changed_cb(bt_device_authorization_e authorization,
+ char *remote_address, void *user_data)
+{
+ TC_PRT("__bt_device_authorization_changed_cb [%d]", authorization);
+ TC_PRT("address: %s", remote_address);
+}
+
+void __bt_device_connection_state_changed_cb(bool connected,
+ bt_device_connection_info_s *conn_info,
+ void *user_data)
+{
+ TC_PRT("__bt_device_connection_state_changed_cb [%d]", connected);
+ TC_PRT("address [%s]", conn_info->remote_address);
+ TC_PRT("link type [%d]", conn_info->link);
+ TC_PRT("disconnection reason [%d]", conn_info->disconn_reason);
+}
+
+bool __bt_device_connected_profile(bt_profile_e profile, void *user_data)
+{
+ TC_PRT("__bt_device_connected_profile [%d]", profile);
+ return true;
+}
+
+void __bt_device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data)
+{
+ if(result == BT_ERROR_NONE)
+ {
+ TC_PRT("Callback: A bond is created.");
+ TC_PRT("Callback: The number of service - %d.", device_info->service_count);
+
+ int i = 0;
+ for(i=0; i<device_info->service_count; i++) {
+ TC_PRT("Callback: service[%d] - %s", i+1, device_info->service_uuid[i]);
+ }
+ TC_PRT("Callback: is_bonded - %d.", device_info->is_bonded);
+ TC_PRT("Callback: is_connected - %d.", device_info->is_connected);
+
+ if (device_info->manufacturer_data_len > 0) {
+ TC_PRT("manufacturer specific data(len:%d)", device_info->manufacturer_data_len);
+ printf("data [");
+ for (i = 0; i < device_info->manufacturer_data_len; i++)
+ printf("%02x ", device_info->manufacturer_data[i]);
+ printf("]\n");
+ }
+ } else {
+ TC_PRT("Callback: Creating a bond is failed.");
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ }
+}
+
+void __bt_device_bond_destroyed_cb(int result, char *remote_address, void *user_data)
+{
+ if(result == BT_ERROR_NONE)
+ {
+ TC_PRT("Callback: A bond is destroyed.");
+ TC_PRT("Callback: Address - %s.", remote_address);
+ } else {
+ TC_PRT("Callback: Destroying a bond is failed.");
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ }
+}
+
+void __bt_repeat_test_onoff_count_time_summary()
+{
+ time_t ctimer;
+ struct tm *_tm;
+
+ ctimer = time(NULL);
+ ctimer -= bt_onoff_timer;
+ _tm = gmtime(&ctimer);
+
+ if (_tm == NULL) {
+ /* Fix : NULL_RETURNS */
+ TC_PRT("gmtime failed error ");
+ return;
+ }
+
+ TC_PRT("try: %d, success: %d, fail: %d, time(%dd,%d:%d:%d)\n",
+ bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail,
+ _tm->tm_mday-1, _tm->tm_hour, _tm->tm_min, _tm->tm_sec);
+}
+
+void __bt_gatt_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data)
+{
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ if (connected) {
+ TC_PRT("LE connected(address = %s)", remote_address);
+ /* Fix : STRING_OVERFLOW */
+ strncpy(remote_addr, remote_address, strlen(remote_addr));
+ } else {
+ TC_PRT("LE DISconnected");
+ }
+}
+
+int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h)
+{
+ int ret;
+ int s_val;
+ unsigned int u_val;
+ char *buf;
+ int len;
+
+ if (strcasecmp(type, "int8") == 0) {
+ s_val = atoi(value);
+ buf = (char *)&s_val;
+ len = 1;
+ } else if (strcasecmp(type, "int16") == 0) {
+ s_val = atoi(value);
+ buf = (char *)&s_val;
+ len = 2;
+ } else if (strcasecmp(type, "int32") == 0) {
+ s_val = atoi(value);
+ buf = (char *)&s_val;
+ len = 4;
+ } else if (strcasecmp(type, "uint8") == 0) {
+ u_val = strtoul(value, NULL, 10);
+ buf = (char *)&u_val;
+ len = 1;
+ } else if (strcasecmp(type, "uint16") == 0) {
+ u_val = strtoul(value, NULL, 10);
+ buf = (char *)&u_val;
+ len = 2;
+ } else if (strcasecmp(type, "uint32") == 0) {
+ u_val = strtoul(value, NULL, 10);
+ buf = (char *)&u_val;
+ len = 4;
+ } else if (strcasecmp(type, "str") == 0) {
+ buf = value;
+ len = strlen(buf);
+ } else
+ return BT_ERROR_INVALID_PARAMETER;
+
+ ret = bt_gatt_set_value(h, buf, len);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_set_value is failed : %d", ret);
+
+ return ret;
+}
+
+void __bt_gatt_client_print_value(bt_gatt_h h)
+{
+ int ret;
+ char *str = NULL;
+ char *value = NULL;
+ int len = 0;
+ bool hex_format = false;
+ int i;
+
+ ret = bt_gatt_get_value(h, &value, &len);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_get_value is failed : %d", ret);
+ return;
+ }
+
+ for (i = 0; i < len; i++)
+ if (isalnum(value[i]) == 0) {
+ hex_format = true;
+ break;
+ }
+
+ if (hex_format) {
+ str = g_malloc0(len * 5 + 1);
+ /* Fix : NULL_RETURNS */
+ if (!str) {
+ TC_PRT("BT_ERROR_OUT_OF_MEMORY");
+ goto fail;
+ }
+ for (i = 0; i < len; i++) {
+ if (i > 0)
+ str[i * 5 - 1] = ' ';
+
+ snprintf(&str[i * 5], 5, "0x%02X", value[i]);
+ }
+ } else {
+ str = g_malloc0(len + 1);
+ /* Fix : NULL_RETURNS */
+ if (!str) {
+ TC_PRT("BT_ERROR_OUT_OF_MEMORY");
+ goto fail;
+ }
+ memcpy(str, value, len);
+ }
+
+ TC_PRT("Value : %s", str);
+
+ g_free(str);
+fail:
+ g_free(value);
+}
+
+bool __bt_gatt_print_info_cb(int total, int index, bt_gatt_h gatt_handle, void *user_data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(gatt_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ TC_PRT("[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
+
+ g_free(str);
+ g_free(uuid);
+
+ return true;
+}
+
+void __bt_gatt_client_write_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(gatt_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ TC_PRT("Write %s for %s (%s)", result == BT_ERROR_NONE ? "Success" : "Fail", str ? str : "Unknown", uuid);
+
+ g_free(str);
+ g_free(uuid);
+
+ return;
+}
+
+void __bt_gatt_client_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(gatt_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ TC_PRT("Read %s for %s (%s)", result == BT_ERROR_NONE ? "Success" : "Fail", str ? str : "Unknown", uuid);
+
+ g_free(str);
+ g_free(uuid);
+
+ if (result != BT_ERROR_NONE)
+ return;
+
+ __bt_gatt_client_print_value(gatt_handle);
+
+ return;
+}
+
+bool __bt_gatt_client_foreach_desc_cb(int total, int index, bt_gatt_h desc_handle, void *data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(desc_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ TC_PRT("\t\t[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
+ __bt_gatt_client_print_value(desc_handle);
+
+ g_free(str);
+ g_free(uuid);
+
+ return true;
+}
+
+bool __bt_gatt_client_foreach_chr_cb(int total, int index, bt_gatt_h chr_handle, void *data)
+{
+ int ret;
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(chr_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ TC_PRT("\t[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
+ __bt_gatt_client_print_value(chr_handle);
+
+ g_free(str);
+ g_free(uuid);
+
+ ret = bt_gatt_characteristic_foreach_descriptors(chr_handle,
+ __bt_gatt_client_foreach_desc_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_characteristic_foreach_descriptors is failed : %d", ret);
+
+ return true;
+}
+
+bool __bt_gatt_client_foreach_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data)
{
- int ret = 0;
int test_id = (int)data;
+ int ret;
+ char *uuid = NULL;
+ char *str = NULL;
- switch (test_id) {
- case 0x00ff:
- TC_PRT("Finished");
- g_main_loop_quit(main_loop);
- break;
+ bt_gatt_get_uuid(svc_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
- case 1:
- ret = bt_initialize();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
- break;
- case 2:
- ret = bt_deinitialize();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
- break;
- case 3: {
- bt_adapter_state_e state = BT_ADAPTER_DISABLED;
+ TC_PRT("[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
- ret = bt_adapter_get_state(&state);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ g_free(str);
+ g_free(uuid);
- TC_PRT("state: %d", state);
- break;
+ if (test_id == BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL) {
+ ret = bt_gatt_service_foreach_characteristics(svc_handle,
+ __bt_gatt_client_foreach_chr_cb, (void *)test_id);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret);
+ }
+
+ return true;
+}
+
+static void __ancs_write_completed_cb(int result, bt_gatt_h request_handle,
+ void *user_data)
+{
+ if (result != BT_ERROR_NONE) {
+ TC_PRT("write request is failed : %d", result);
+ return;
+ }
+
+ TC_PRT("write request is done");
+
+ return;
+}
+
+static int __ancs_write_value_to_control_point(bt_gatt_client_h client, char *value, int len)
+{
+ bt_gatt_h ancs_svc = NULL;
+ bt_gatt_h control_point = NULL;
+ char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0";
+ char *chr_uuid = "69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9";
+ int ret;
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &ancs_svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ return ret;
+ }
+
+ ret = bt_gatt_service_get_characteristic(ancs_svc, chr_uuid, &control_point);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed");
+ return ret;
}
- case 4:
- ret = bt_adapter_enable();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_gatt_characteristic_set_write_type(control_point,
+ BT_GATT_WRITE_TYPE_WRITE);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_characteristic_set_write_type is failed : %d", ret);
+ return ret;
+ }
+
+ ret = bt_gatt_set_value(control_point, value, len);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_set_value is failed : %d", ret);
+ return ret;
+ }
+
+ ret = bt_gatt_client_write_value(control_point,
+ __ancs_write_completed_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_write_value is failed : %d", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
+void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len,
+ void *user_data)
+{
+ char *uuid = NULL;
+ int i;
+
+ bt_gatt_get_uuid(chr, &uuid);
+
+ TC_PRT("Value changed for [%s]", uuid);
+ TC_PRT("len [%d]", len);
+ for (i = 0; i < len; i++) {
+ TC_PRT("value %u", value[i]);
+ }
+
+ g_free(uuid);
+
+ return;
+}
+
+void __bt_gatt_server_notification_sent_cb(int result,
+ char *remote_address, bt_gatt_server_h server,
+ bt_gatt_h characteristic, bool completed, void *user_data)
+{
+ TC_PRT("result [%s]", __bt_get_error_message(result));
+ TC_PRT("remote_address : %s", remote_address);
+ TC_PRT("completed : %d", completed);
+ TC_PRT("characteristic : %p", characteristic);
+}
+
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+bool __bt_gatt_primary_service_cb(bt_gatt_attribute_h service, void *user_data)
+{
+ TC_PRT("__bt_gatt_primary_service_cb");
+ TC_PRT("service %s", (char *)service);
+ if (service_index >= MAX_SERVICES)
+ return true;
+
+ bt_gatt_clone_attribute_handle(&service_clone[service_index], service);
+ service_index++;
+ return true;
+}
+
+bool __bt_gatt_characteristics_discovered_cb(int result, int index, int total, bt_gatt_attribute_h characteristic, void *user_data)
+{
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ TC_PRT("index %d", index);
+ TC_PRT("total %d", total);
+ TC_PRT("characteristic %s", (char *)characteristic);
+
+ if (index >= MAX_SERVICES)
+ return true;
+
+ bt_gatt_clone_attribute_handle(&characteristics[index], characteristic);
+ return true;
+}
+
+void __bt_gatt_characteristic_descriptor_discovered_cb(int result,
+ unsigned char characteristic_format, int total,
+ bt_gatt_attribute_h characteristic_descriptor, void *user_data) {
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ TC_PRT("total %d", total);
+ TC_PRT("characteristic_format 0x%02X", characteristic_format);
+ TC_PRT("characteristic_descriptor %s", (char *)characteristic_descriptor);
+}
+
+bool __bt_gatt_included_service_cb(bt_gatt_attribute_h service, void *user_data)
+{
+ char *uuid = NULL;
+ char *name = NULL;
+ unsigned char *value = NULL;
+ int value_length = 0;
+
+ TC_PRT("__bt_gatt_included_service_cb");
+ TC_PRT("service %s", (char *)service);
+
+ if (char_service_index >= MAX_SERVICES)
+ return true;
+
+ bt_gatt_clone_attribute_handle(&characteristics_services[char_service_index], service);
+ char_service_index++;
+
+ bt_gatt_get_characteristic_declaration(service, &uuid, &value, &value_length);
+ bt_gatt_get_uuid_specification_name(uuid, &name);
+ TC_PRT("uuid: %s [%s]", uuid, name);
+
+ g_free(uuid);
+ g_free(name);
+ return true;
+}
+
+void __bt_gatt_characteristic_changed_cb(bt_gatt_attribute_h characteristic, unsigned char *value, int value_length, void *user_data)
+{
+ int i;
+
+ TC_PRT("__bt_gatt_characteristic_changed_cb");
+ TC_PRT("service %s", (char *)characteristic);
+ TC_PRT("value_length %d", value_length);
+
+ for (i = 0; i < value_length; i++) {
+ TC_PRT("value %c", value[i]);
+ }
+
+ return;
+}
+
+void __bt_gatt_char_write_cb(void *user_data)
+{
+ TC_PRT("__bt_gatt_char_write_cb");
+ return;
+}
+
+void __bt_gatt_char_read_cb(unsigned char *value, int value_length, void *user_data)
+{
+ int i;
+
+ TC_PRT("__bt_gatt_char_read_cb");
+
+ TC_PRT("value_length %d", value_length);
+
+ for (i = 0; i < value_length; i++) {
+ TC_PRT("value %u", value[i]);
+ }
+
+ return;
+}
+
+void __bt_gatt_remote_characteristic_write_cb(bt_gatt_attribute_h characteristic,
+ unsigned char *char_value,
+ int char_length, void *user_data)
+{
+ TC_PRT("remote device updated the characteristics in db");
+
+ TC_PRT("updated characteristic is %s", (char *)characteristic);
+ TC_PRT("new char value is %s", char_value);
+}
+#endif
+
+void __bt_avrcp_target_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data)
+{
+ TC_PRT("__bt_avrcp_target_connection_state_changed_cb");
+ TC_PRT("connected %d", connected);
+ TC_PRT("remote_address %s", remote_address);
+}
+
+void __bt_avrcp_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, void *user_data)
+{
+ TC_PRT("__bt_avrcp_equalizer_state_changed_cb");
+ TC_PRT("equalizer %d (1: OFF, 2: ON)", equalizer);
+}
+
+void __bt_avrcp_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, void *user_data)
+{
+ TC_PRT("__bt_avrcp_repeat_mode_changed_cb");
+ TC_PRT("repeat %d (1: OFF, 2: SINGLE, 3: All, 4:GROUP)", repeat);
+}
+
+void __bt_avrcp_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, void *user_data)
+{
+ TC_PRT("__bt_avrcp_shuffle_mode_changed_cb");
+ TC_PRT("shuffle -> %d (1: OFF, 2: All TRACK, 3:GROUP)", shuffle);
+}
+
+void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data)
+{
+ TC_PRT("__bt_avrcp_scan_mode_changed_cb");
+ TC_PRT("scan -> %d", scan);
+}
+
+void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data)
+{
+ TC_PRT("__bt_avrcp_target_connection_state_changed_cb");
+ TC_PRT("connected %d", connected);
+ TC_PRT("remote_address %s", remote_address);
+}
+
+void __bt_avrcp_song_position_changed_cb(unsigned int postion, void *user_data)
+{
+ TC_PRT("__bt_avrcp_song_position_changed_cb");
+ TC_PRT("Position %d", postion);
+}
+
+void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, void *user_data)
+{
+ TC_PRT("__bt_avrcp_player_state_changed_cb");
+ TC_PRT("Player state -> %d (0: stopped, 1: Playing, 2:Paused, 3:FF, 4:REW)", state);
+}
+
+void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, void *user_data)
+{
+ TC_PRT("__bt_avrcp_track_info_changed_cb");
+ TC_PRT("title %s", metadata->title);
+ TC_PRT("artist %s", metadata->artist);
+ TC_PRT("album %s", metadata->album);
+ TC_PRT("genre %s", metadata->genre);
+ TC_PRT("total_tracks %d", metadata->total_tracks);
+ TC_PRT("number %d", metadata->number);
+ TC_PRT("duration %d", metadata->duration);
+}
+
+void panu_conn_state_changed(int result, bool connected,
+ const char *remote_address,
+ bt_panu_service_type_e type,
+ void *user_data)
+{
+ TC_PRT("result [%s]", __bt_get_error_message(result));
+ TC_PRT("connected [%d]", connected);
+ TC_PRT("address [%s]", remote_address);
+ TC_PRT("type [%d]", type);
+
+}
+
+void __bt_hid_host_connection_state_changed_cb(int result,
+ bool connected, const char *remote_address, void *user_data)
+{
+ TC_PRT("__bt_hid_host_connection_state_changed_cb: called");
+ TC_PRT("result: %s", __bt_get_error_message(result));
+}
+
+#ifdef TIZEN_WEARABLE
+void __bt_hf_sco_state_changed_cb(int result, bool opened, void *user_data)
+{
+ TC_PRT("opened [%s]", opened ? "YES" : "NO");
+}
+
+void __bt_hf_set_call_handling_event_cb(bt_hf_call_handling_event_e event,
+ char *phone_number, void *user_data)
+{
+ switch(event) {
+ case BT_HF_CALL_HANDLING_EVENT_ANSWER:
+ TC_PRT("[call_handling_event_cb] event [ANSWER]");
break;
- case 5:
- ret = bt_adapter_disable();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_HF_CALL_HANDLING_EVENT_RELEASE:
+ TC_PRT("[call_handling_event_cb] event [RELEASE]");
break;
- case 6:
- ret = bt_adapter_start_device_discovery();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_HF_CALL_HANDLING_EVENT_REJECT:
+ TC_PRT("[call_handling_event_cb] event [REJECT]");
break;
- case 7:
- ret = bt_adapter_stop_device_discovery();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_HF_CALL_HANDLING_EVENT_RING:
+ TC_PRT("[call_handling_event_cb] event [RING]");
break;
- case 8: {
- bool is_discovering = FALSE;
- ret = bt_adapter_is_discovering(&is_discovering);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
- else
- TC_PRT("is_discovering: %d", is_discovering);
+ case BT_HF_CALL_HANDLING_EVENT_CALL_STARTED:
+ TC_PRT("[call_handling_event_cb] event [CALL_STARTED]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_CALL_ENDED:
+ TC_PRT("[call_handling_event_cb] event [CALL_ENDED]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_ENABLED:
+ TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_ENABLED]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_DISABLED:
+ TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_DISABLED]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_WAITING:
+ TC_PRT("[call_handling_event_cb] event [WAITING]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_HELD:
+ TC_PRT("[call_handling_event_cb] event [HELD]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_UNHELD:
+ TC_PRT("[call_handling_event_cb] event [UNHELD]");
+ break;
+ case BT_HF_CALL_HANDLING_EVENT_SWAPPED:
+ TC_PRT("[call_handling_event_cb] event [SWAPPED]");
+ break;
+ default:
+ TC_PRT("[call_handling_event_cb] event [UNKNOWN]");
+ }
+
+ TC_PRT("[call_handling_event_cb] phone_number [%s]", phone_number);
+}
+
+void __bt_hf_call_status_updated_event_cb(GSList *call_info_list, void *user_data)
+{
+ TC_PRT("[call_status_updated_event_cb]");
+ for (; call_info_list; call_info_list = g_slist_next(call_info_list)) {
+ bt_hf_call_status_info_s *call_info = call_info_list->data;
+ TC_PRT(" > Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]",
+ call_info->number, call_info->direction, call_info->status, call_info->multi_party, call_info->index);
+ }
+
+ bt_hf_free_call_status_info_list(call_info_list);
+}
+
+void __bt_hf_speaker_gain_changed_cb(int gain, void *user_data)
+{
+ TC_PRT("__bt_hf_speaker_gain_changed_cb");
+ TC_PRT("Gain= %d", gain);
+}
+
+void __bt_pbap_enabled_cb(const char *remote_address,
+ int pbap_enabled, void *user_data)
+{
+ TC_PRT("__bt_pbap_enabled_cb");
+ TC_PRT("Remote Device: %s", remote_address);
+ TC_PRT("Connected Status: %d", pbap_enabled);
+}
+
+void __bt_pbap_phonebook_size_cb(const char *remote_address,
+ int size, void *user_data)
+{
+ TC_PRT("__bt_pbap_phonebook_size_cb");
+ TC_PRT("Remote Device: %s", remote_address);
+ TC_PRT("Phonebook Size: %d", size);
+}
+
+void __bt_pbap_phonebook_pull_cb(const char *remote_address,
+ char *vcf_file, int status, void *user_data)
+{
+ TC_PRT("__bt_pbap_phonebook_pull_cb");
+ TC_PRT("Remote Device: %s", remote_address);
+ TC_PRT("Phonebook Download File: %s", vcf_file);
+ TC_PRT("Phonebook Download Status: %s", status? "Successful" : "Unsuccessful");
+}
+
+void __bt_pbap_vcard_list_cb(const char *remote_address,
+ char **vcards, int count, int status, void *user_data)
+{
+ TC_PRT("__bt_pbap_vcard_list_cb");
+ TC_PRT("Remote Device: %s", remote_address);
+ TC_PRT("vCard List: %s", vcards[0]);
+ TC_PRT("vCard Count: %d", count);
+ TC_PRT("Listing Status: %s", status? "Successful" : "Unsuccessful");
+}
+#endif
+
+void __bt_repeat_test_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ unsigned int delay = *(unsigned int*)user_data;
+
+ TC_PRT("__bt_repeat_test_adapter_state_changed_cb");
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ TC_PRT("state: %s, delay(%dsec)",
+ (adapter_state == BT_ADAPTER_ENABLED)?
+ "ENABLED" : "DISABLED", delay);
+
+ if (result != BT_ERROR_NONE) {
+ char *argv[] = {NULL};
+
+ TC_PRT("make dump\n");
+ execv("all_log_dump.sh", argv);
+
+ bt_onoff_cnt_fail++;
+ } else {
+ bt_onoff_cnt_success++;
+
+ if (delay)
+ sleep(delay);
+ }
+
+ if (adapter_state == BT_ADAPTER_DISABLED)
+ bt_adapter_enable();
+ else
+ bt_adapter_disable();
+
+ bt_onoff_cnt++;
+ __bt_repeat_test_onoff_count_time_summary();
+}
+
+static void __bt_initialize_all(void)
+{
+ int ret;
+ TC_PRT("Initialize and set callback functions");
+
+ ret = bt_initialize();
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_adapter_set_state_changed_cb(__bt_adapter_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_adapter_set_connectable_changed_cb(__bt_adapter_connectable_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_device_set_bond_destroyed_cb(__bt_device_bond_destroyed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_gatt_set_connection_state_changed_cb(__bt_gatt_connection_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ ret = bt_adapter_set_device_discovery_state_changed_cb(__bt_adapter_device_discovery_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+#ifndef TIZEN_WEARABLE
+ ret = bt_adapter_le_set_device_discovery_state_changed_cb(__bt_adapter_le_device_discovery_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+#endif
+ ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ return;
+}
+
+int test_set_params(int test_id, char *param)
+{
+ static int param_index = 0;
+ const char *param_type = NULL;
+
+ switch (current_tc_table) {
+ case BT_UNIT_TEST_TABLE_ADAPTER: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA:
+ {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
break;
}
- case 9: {
- char *address;
- bt_device_info_s *device_info = NULL;
- address = g_strdup("00:19:0E:01:61:17");
+ case BT_UNIT_TEST_TABLE_ADAPTER_LE: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE:
+ TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)");
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA:
+ TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS");
+ TC_PRT("\t (Default scan response : Service Data &Local name & Manufacturer data)");
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE:
+ TC_PRT("Input mode \n (0 : Balanced(500 ms), 1 : Low Latency(150 ms), 2 : Low Energy (1000 ms))");
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY:
+ TC_PRT("Input filter_policy \n (0 : No use White List, 1 : Allow scan, 2 : Allow conneciton, 3 : Allow scan & conneciton)");
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE:
+ TC_PRT("Input adv type \n (0 : Non-connectable (ADV_SCAN_IND), 1 : Connectable (ADV_IND) ");
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING:
+ TC_PRT("Input adv slot id \n (Default is 0, Maximum is 2) ");
+ break;
+ }
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
- ret = bt_adapter_get_bonded_device_info((const char *)address,
- &device_info);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
- g_free(address);
+ break;
+ }
- if (device_info) {
- TC_PRT("address: %s", device_info->remote_address);
- TC_PRT("name: %s", device_info->remote_name);
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
}
- bt_adapter_free_device_info(device_info);
break;
}
- case 10: {
- bool used = FALSE;
- ret = bt_adapter_is_service_used(opp_uuid, &used);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_DEVICE: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE : {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
- TC_PRT("used: %d", used);
break;
}
- case 11:
- ret = bt_adapter_set_device_discovery_state_changed_cb(__bt_adapter_device_discovery_state_changed_cb, NULL);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_SOCKET: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
- case 12:
- ret = bt_adapter_unset_device_discovery_state_changed_cb();
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_OPP: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
+ }
+ case BT_UNIT_TEST_TABLE_AUDIO: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
+ }
- /* Socket functions */
- case 50: {
- int socket_fd = 0;
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
- ret = bt_socket_create_rfcomm(spp_uuid, &socket_fd);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
- } else {
- TC_PRT("socket_fd: %d", socket_fd);
- server_fd = socket_fd;
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
}
- case 51:
- ret = bt_socket_destroy_rfcomm(server_fd);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_PAN: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
- case 52:
- ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_GATT: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL;
+ }
+
+ if (param_index > 0) {
+ g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: {
+ if (param_index == 0) {
+ g_test_param.param_count = 3;
+ g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count);
+ }
+
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len + 1);
+ /* Remove new line character */
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input Service UUID");
+ break;
+ case 1:
+ TC_PRT("Input Characteristic UUID");
+ break;
+ case 2:
+ TC_PRT("Input Descriptor UUID or nothing");
+ break;
+ }
+
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: {
+ if (param_index == 0) {
+ g_test_param.param_count = 5;
+ g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count);
+ }
+
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len + 1);
+ /* Remove new line character */
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input Service UUID");
+ break;
+ case 1:
+ TC_PRT("Input Characteristic UUID");
+ break;
+ case 2:
+ TC_PRT("Input Descriptor UUID or nothing");
+ break;
+ case 3:
+ TC_PRT("Input Value Type (avail. : uint8, uint16, uint32, int8, int16, int32, str)");
+ break;
+ case 4:
+ TC_PRT("Input Value");
+ break;
+ }
+
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: {
+ if (param_index == 0) {
+ g_test_param.param_count = 2;
+ g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count);
+ }
+
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len + 1);
+ /* Remove new line character */
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input Service UUID");
+ break;
+ case 1:
+ TC_PRT("Input Characteristic UUID");
+ break;
+ }
+
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: {
+ if (param_index == 0) {
+ g_test_param.param_count = 2;
+ g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count);
+ }
+
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len + 1);
+ /* Remove new line character */
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input Service UUID");
+ break;
+ case 1:
+ TC_PRT("Input Characteristic UUID");
+ break;
+ }
+
+ param_index++;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION:
+ case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION:
+ case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: {
+ if (param_index == 0) {
+ g_test_param.param_count = 1;
+ g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len + 1);
+ /* Remove new line character */
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+ test_input_callback((void *)test_id);
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+ break;
+ }
+
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
- case 53:
- ret = bt_socket_listen(server_fd, 1);
- if (ret < BT_ERROR_NONE)
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_AVRCP: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
+
break;
- case 54: {
- int socket_fd = 0;
+ }
+ case BT_UNIT_TEST_TABLE_HID: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
- ret = bt_socket_accept(server_fd, &socket_fd);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
- } else {
- TC_PRT("socket_fd: %d", socket_fd);
- client_fd = socket_fd;
+ break;
+ }
+#ifdef TIZEN_WEARABLE
+ case BT_UNIT_TEST_TABLE_HF: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
}
+
break;
}
- case 55:
- ret = bt_socket_reject(server_fd);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_PBAP_CLIENT: {
+ switch (test_id) {
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
}
+
break;
- case 56: {
- char *address;
+ }
+#endif
+ default:
+ TC_PRT("There is no param to set\n");
+ need_to_set_params = false;
+ break;
+ }
- address = g_strdup("00:02:48:F4:3E:D2");
+ return 0;
+}
- ret = bt_socket_connect_rfcomm(address, spp_uuid);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+int test_input_callback(void *data)
+{
+ int ret = 0;
+ int test_id = (int)data;
+
+ switch (current_tc_table) {
+ case BT_UNIT_TEST_TABLE_MAIN: {
+ switch (test_id) {
+ case 0x00ff:
+ TC_PRT("Finished");
+ g_main_loop_quit(main_loop);
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_INITIALIZE:
+ ret = bt_initialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_DEINITIALIZE:
+ ret = bt_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ default:
+ break;
}
- g_free(address);
break;
}
- case 57:
- ret = bt_socket_disconnect_rfcomm(client_fd);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_ADAPTER: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE: {
+ bt_adapter_state_e state = BT_ADAPTER_DISABLED;
+
+ ret = bt_adapter_get_state(&state);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("state: %d", state);
+ break;
}
- break;
- case 58:
- ret = bt_socket_send_data(client_fd, "Sending test\0", 20);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE:
+ ret = bt_adapter_enable();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE:
+ ret = bt_adapter_disable();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER:
+ ret = bt_adapter_recover();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY:
+ ret = bt_adapter_start_device_discovery();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY:
+ ret = bt_adapter_stop_device_discovery();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING: {
+ bool is_discovering = FALSE;
+ ret = bt_adapter_is_discovering(&is_discovering);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ else
+ TC_PRT("is_discovering: %d", is_discovering);
+
+ break;
}
- break;
- case 59:
- ret = bt_socket_set_data_received_cb(__bt_socket_data_received_cb, NULL);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE: {
+ ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO: {
+ bt_device_info_s *device_info = NULL;
+
+ ret = bt_adapter_get_bonded_device_info(remote_addr,
+ &device_info);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ if (device_info) {
+ TC_PRT("address: %s", device_info->remote_address);
+ TC_PRT("name: %s", device_info->remote_name);
+ }
+
+ bt_adapter_free_device_info(device_info);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED: {
+ bool used = FALSE;
+
+ ret = bt_adapter_is_service_used(opp_uuid, &used);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("used: %d", used);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY: {
+ bt_adapter_visibility_mode_e visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
+ int time = 0;
+
+ ret = bt_adapter_get_visibility(&visibility_mode, &time);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("mode: %d", visibility_mode);
+ TC_PRT("time: %d", time);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB:
+ ret = bt_adapter_set_device_discovery_state_changed_cb(__bt_adapter_device_discovery_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB:
+ ret = bt_adapter_unset_device_discovery_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA: {
+ ret = bt_adapter_get_local_oob_data(&hash, &randomizer, &hash_len, &rand_len);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ TC_PRT("hash = [%s]", hash);
+ TC_PRT("randomizer = [%s]", randomizer);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA: {
+ ret = bt_adapter_set_remote_oob_data(remote_addr, hash, randomizer, hash_len, rand_len);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA: {
+ ret = bt_adapter_remove_remote_oob_data(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB:
+ ret = bt_adapter_set_visibility_mode_changed_cb(__bt_adapter_device_visibility_mode_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB:
+ ret = bt_adapter_unset_visibility_mode_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB:
+ ret = bt_adapter_set_visibility_duration_changed_cb(
+ __bt_adapter_device_visibility_duration_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB:
+ ret = bt_adapter_unset_visibility_duration_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB: {
+ ret = bt_adapter_set_connectable_changed_cb(__bt_adapter_connectable_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
}
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB: {
+ ret = bt_adapter_unset_connectable_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE: {
+ bool connectable = false;
+
+ ret = bt_adapter_get_connectable(&connectable);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ TC_PRT("%s", connectable ? "Connectable" : "Non-connectable");
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: {
+ bool connectable = false;
+
+ bt_adapter_get_connectable(&connectable);
+
+ if (g_test_param.param_count > 0) {
+ if (g_strrstr(g_test_param.params[0], "true"))
+ connectable = true;
+ else
+ connectable = false;
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_set_connectable(!connectable);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION: {
+ char *version = NULL;
+
+ ret = bt_adapter_get_version(&version);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ else {
+ TC_PRT("Version: [%s]",version);
+ g_free(version);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO: {
+ char *chipset = NULL;
+ char *firmware = NULL;
+ char *stack_version = NULL;
+ char *profiles = NULL;
+
+ ret = bt_adapter_get_local_info(&chipset, &firmware, &stack_version, &profiles);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ else {
+ TC_PRT("Local info: [%s, %s, %s]", chipset, firmware, stack_version);
+ TC_PRT("Local info(Profiles):\n%s", profiles);
+ g_free(chipset);
+ g_free(firmware);
+ g_free(stack_version);
+ g_free(profiles);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB:
+ {
+ ret = bt_adapter_set_manufacturer_data_changed_cb(__bt_adapter_manufacturer_data_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB:
+ ret = bt_adapter_unset_manufacturer_data_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA:
+ {
+ char data[20] = {0x03, 0xFF, 0x01, 0x02};
+ int len = 4;
+ int i = 0;
+
+ if (g_test_param.param_count > 0) {
+ len = 0;
+ for (i = 0; i < (strlen(g_test_param.params[0]) - 1); i += 2) {
+ if (g_test_param.params[0][i] >= 'A' && g_test_param.params[0][i] <= 'F')
+ data[i/2] = (g_test_param.params[0][i] - 'A' + 0X0A) << 4;
+ else
+ data[i/2] = (g_test_param.params[0][i] - '0') << 4;
+
+ if (g_test_param.params[0][i+1] >= 'A' && g_test_param.params[0][i+1] <= 'F')
+ data[i/2] += (g_test_param.params[0][i+1] - 'A' + 0X0A);
+ else
+ data[i/2] += (g_test_param.params[0][i+1] - '0');
+ len++;
+ }
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_set_manufacturer_data(data, len);
+
+ 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;
+
+ default:
+ break;
+ }
+
break;
- case 60:
- ret = bt_socket_unset_data_received_cb();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+
+ case BT_UNIT_TEST_TABLE_ADAPTER_LE: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE: {
+ bt_adapter_le_state_e le_state = BT_ADAPTER_LE_DISABLED;
+
+ ret = bt_adapter_le_get_state(&le_state);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("le_state: %d", le_state);
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE: {
+ ret = bt_adapter_le_enable();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE: {
+ ret = bt_adapter_le_disable();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: {
+ int mode = BT_ADAPTER_LE_SCAN_MODE_BALANCED;
+
+ if (g_test_param.param_count > 0) {
+ mode = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_le_set_scan_mode(mode);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN:
+ ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN:
+ ret = bt_adapter_le_stop_scan();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+#ifndef TIZEN_WEARABLE
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_DEVICE_DISCOVERY:
+ ret = bt_adapter_le_start_device_discovery();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY:
+ ret = bt_adapter_le_stop_device_discovery();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+#endif
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: {
+ int adv_data_type = 3; // default all
+ int manufacturer_id = 117;
+ char *manufacture = NULL;
+ char manufacture_0[] = {0x0, 0x0, 0x0, 0x0};
+ char manufacture_1[] = {0x01, 0x01, 0x01, 0x01};
+ char manufacture_2[] = {0x02, 0x02, 0x02, 0x02};
+ char manufacture_3[] = {0x03, 0x03, 0x03, 0x03};
+ char service_data[] = {0x01, 0x02, 0x03};
+ const char *time_svc_uuid_16 = "1805";
+ const char *battery_svc_uuid_16 = "180f";
+ const char *heart_rate_svc_uuid_16 = "180d";
+ const char *lmmediate_alert_svc_uuid_16 = "1802";
+ const char *ancs_uuid_128 = "7905F431-B5CE-4E99-A40F-4B1E122D00D0";
+ int appearance = 192; // 192 is generic watch
+
+ advertiser = advertiser_list[advertiser_index];
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ } else {
+ ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("clear advertising data [0x%04x]", ret);
+ ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("clear scan response data [0x%04x]", ret);
+ }
+
+ if (g_test_param.param_count > 0) {
+ adv_data_type = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ switch (adv_data_type) {
+ case 0: // service uuid
+ ret = bt_adapter_le_add_advertising_service_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_uuid [0x%04x]", ret);
+
+ manufacture = manufacture_0;
+ break;
+
+ case 1: // service solicitation
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ manufacture = manufacture_1;
+ break;
+
+ case 2: // appearance & tx power level
+ ret = bt_adapter_le_set_advertising_appearance(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, appearance);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add appearance data [0x%04x]", ret);
+
+ ret = bt_adapter_le_set_advertising_tx_power_level(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, true);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add appearance data [0x%04x]", ret);
+ manufacture = manufacture_2;
+ break;
+
+ case 3: // All
+ ret = bt_adapter_le_add_advertising_service_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_set_advertising_appearance(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, appearance);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add appearance data [0x%04x]", ret);
+
+ ret = bt_adapter_le_set_advertising_tx_power_level(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, true);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add tx_power_level [0x%04x]", ret);
+
+ manufacture = manufacture_3;
+ break;
+
+ case 4: // ANCS
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, ancs_uuid_128);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+
+ 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);
+
+ return 0;
+
+ default:
+ TC_PRT("No adv data");
+ break;
+ }
+
+ /* Default scsn response data */
+ ret = bt_adapter_le_add_advertising_service_data(advertiser,
+ BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16,
+ service_data, sizeof(service_data));
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add service_data [0x%04x]", ret);
+
+ 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);
+
+ ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser,
+ BT_ADAPTER_LE_PACKET_SCAN_RESPONSE,
+ manufacturer_id,
+ manufacture, sizeof(manufacture_0));
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add manufacturer data [0x%04x]", ret);
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: {
+ int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED;
+
+ advertiser = advertiser_list[advertiser_index];
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ }
+
+ if (g_test_param.param_count > 0) {
+ mode = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_le_set_advertising_mode(advertiser, mode);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add scan response data [0x%04x]", ret);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: {
+ int filter_policy = BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_CONN_WL;
+
+ advertiser = advertiser_list[advertiser_index];
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ }
+
+ if (g_test_param.param_count > 0) {
+ filter_policy = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_le_set_advertising_filter_policy(advertiser, filter_policy);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add scan response data [0x%04x]", ret);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: {
+ int type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE;
+
+ advertiser = advertiser_list[advertiser_index];
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ }
+
+ if (g_test_param.param_count > 0) {
+ type = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_le_set_advertising_connectable(advertiser, type);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("add scan response data [0x%04x]", ret);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW: {
+ 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];
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ }
+ 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;
+ }
+#ifndef TIZEN_WEARABLE
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING: {
+ bt_adapter_le_advertising_state_changed_cb cb;
+ bt_adapter_le_advertising_params_s adv_params = { 0, };
+
+ 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];
+
+ adv_params.interval_min= 500;
+ adv_params.interval_max= 500;
+ adv_params.type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE;
+
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ TC_PRT("created le advertiser(%d)", ret);
+ advertiser_list[advertiser_index] = advertiser;
+ }
+ advertiser_index++;
+ advertiser_index %= 3;
+
+ TC_PRT("type: %d", adv_params.type);
+
+ ret = bt_adapter_le_start_advertising(advertiser, &adv_params, cb, NULL);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+ break;
+ }
+#endif
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: {
+ int slot_id = 0;
+
+ if (g_test_param.param_count > 0) {
+ slot_id = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+
+ advertiser = advertiser_list[slot_id];
+
+ TC_PRT("advertiser: %p", advertiser);
+
+ ret = bt_adapter_le_stop_advertising(advertiser);
+
+ if(advertiser_index > 0)
+ advertiser_index--;
+ else
+ advertiser_index = 2;
+
+ advertiser_list[slot_id] = NULL;
+
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST: {
+ ret = bt_adapter_le_add_white_list(remote_addr, BT_DEVICE_PUBLIC_ADDRESS);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST: {
+ ret = bt_adapter_le_remove_white_list(remote_addr, BT_DEVICE_PUBLIC_ADDRESS);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+#ifndef TIZEN_WEARABLE
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_CLEAR_WHITE_LIST: {
+ ret = bt_adapter_le_clear_white_list();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+#endif
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: {
+ static bool enable_privacy = false;
+
+ if (enable_privacy == false)
+ enable_privacy = true;
+ else
+ enable_privacy = false;
+
+ if (g_test_param.param_count > 0) {
+ if (g_strrstr(g_test_param.params[0], "true"))
+ enable_privacy = true;
+ else
+ enable_privacy = false;
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_adapter_le_enable_privacy(enable_privacy);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS: {
+ bt_scan_filter_h scan_filter;
+
+ ret = bt_adapter_le_create_scan_filter(&scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, remote_addr);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_register_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_destroy_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID: {
+ bt_scan_filter_h scan_filter;
+
+ ret = bt_adapter_le_create_scan_filter(&scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_scan_filter_set_service_uuid(scan_filter, "1805");
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_register_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_destroy_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID: {
+ bt_scan_filter_h scan_filter;
+
+ ret = bt_adapter_le_create_scan_filter(&scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(scan_filter, "1805");
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_register_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_destroy_scan_filter(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS: {
+ ret = bt_adapter_le_unregister_all_scan_filters();
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+
+#ifndef TIZEN_WEARABLE
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB:
+ ret = bt_adapter_le_set_device_discovery_state_changed_cb(__bt_adapter_le_device_discovery_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB:
+ ret = bt_adapter_le_unset_device_discovery_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+#endif
+
+ 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 61:
- ret = bt_socket_set_connection_requested_cb(__bt_socket_connection_requested_cb, NULL);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+
+ case BT_UNIT_TEST_TABLE_DEVICE: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE: {
+ ret = bt_device_set_authorization(remote_addr, BT_DEVICE_AUTHORIZED);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE: {
+ ret = bt_device_set_authorization(remote_addr, BT_DEVICE_UNAUTHORIZED);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB:
+ ret = bt_device_set_authorization_changed_cb(__bt_device_authorization_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB:
+ ret = bt_device_unset_authorization_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB:
+ ret = bt_device_set_connection_state_changed_cb(__bt_device_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB:
+ ret = bt_device_unset_connection_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES: {
+ ret = bt_device_foreach_connected_profiles(remote_addr, __bt_device_connected_profile, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: {
+ bool connected_status = false;
+ bt_profile_e profile = BT_PROFILE_HSP;
+
+ if (g_test_param.param_count > 0) {
+ profile = atoi(g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_device_is_profile_connected(remote_addr, profile, &connected_status);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ }
+ TC_PRT("Profile [%s]", connected_status ? "Connected" : "Disconnected");
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB : {
+ ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB : {
+ ret = bt_device_set_bond_destroyed_cb(__bt_device_bond_destroyed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND : {
+ ret = bt_device_create_bond(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE : {
+ bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE;
+
+ if (g_test_param.param_count > 0) {
+ link_type = atoi(g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_device_create_bond_by_type(remote_addr, link_type);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND : {
+ ret = bt_device_destroy_bond(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE: {
+ bool bredr_connected = false;
+ bool le_connected = false;
+
+ ret = bt_device_get_connection_state(remote_addr,
+ BT_DEVICE_CONNECTION_LINK_BREDR,
+ &bredr_connected);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_device_get_connection_state(remote_addr,
+ BT_DEVICE_CONNECTION_LINK_LE,
+ &le_connected);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ }
+
+ TC_PRT("BR/EDR [%s], LE [%s]",
+ bredr_connected ? "Connected" : "Disconnected",
+ le_connected ? "Connected" : "Disconnected");
+
+ 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 62:
- ret = bt_socket_unset_connection_requested_cb();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_SOCKET: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM: {
+ int socket_fd = 0;
+
+ ret = bt_socket_create_rfcomm(spp_uuid, &socket_fd);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ TC_PRT("socket_fd: %d", socket_fd);
+ server_fd = socket_fd;
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM:
+ ret = bt_socket_destroy_rfcomm(server_fd);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM:
+ ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN:
+ ret = bt_socket_listen(server_fd, 1);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT: {
+ int socket_fd = 0;
+
+ ret = bt_socket_accept(server_fd);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ TC_PRT("socket_fd: %d", socket_fd);
+ client_fd = socket_fd;
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_REJECT:
+ ret = bt_socket_reject(server_fd);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM: {
+ ret = bt_socket_connect_rfcomm(remote_addr, spp_uuid);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM:
+ ret = bt_socket_disconnect_rfcomm(client_fd);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: {
+ char data[] = "Sending test";
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_socket_send_data(client_fd, g_test_param.params[0], strlen(g_test_param.params[0]) + 1);
+
+ __bt_free_test_param(&g_test_param);
+ } else {
+ ret = bt_socket_send_data(client_fd, data, sizeof(data));
+ }
+
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: {
+ int socket_fd = 0;
+
+ ret = bt_socket_create_rfcomm(custom_uuid, &socket_fd);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ TC_PRT("socket_fd: %d", socket_fd);
+ custom_server_fd = socket_fd;
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID:
+ ret = bt_socket_destroy_rfcomm(custom_server_fd);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID:
+ ret = bt_socket_listen_and_accept_rfcomm(custom_server_fd, 1);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: {
+ ret = bt_socket_connect_rfcomm(remote_addr, custom_uuid);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID:
+ ret = bt_socket_disconnect_rfcomm(custom_client_fd);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID: {
+ char data[] = "Sending test";
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_socket_send_data(custom_client_fd, g_test_param.params[0], strlen(g_test_param.params[0]) + 1);
+
+ __bt_free_test_param(&g_test_param);
+ } else {
+ ret = bt_socket_send_data(custom_client_fd, data, sizeof(data));
+ }
+
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB:
+ ret = bt_socket_set_data_received_cb(__bt_socket_data_received_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB:
+ ret = bt_socket_unset_data_received_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB:
+ ret = bt_socket_set_connection_requested_cb(__bt_socket_connection_requested_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB:
+ ret = bt_socket_unset_connection_requested_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB:
+ ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB:
+ ret = bt_socket_unset_connection_state_changed_cb();
+ 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;
+
+ default:
+ break;
+ }
+
break;
- case 63:
- ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_OPP: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE:
+ ret = bt_opp_client_initialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE:
+ ret = bt_opp_client_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE:
+ ret = bt_opp_client_add_file("/opt/media/Images/image1.jpg");
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES:
+ ret = bt_opp_client_clear_files();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES: {
+ ret = bt_opp_client_push_files(remote_addr,__bt_opp_client_push_responded_cb,
+ __bt_opp_client_push_progress_cb,
+ __bt_opp_client_push_finished_cb,
+ NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH:
+ ret = bt_opp_client_cancel_push();
+ 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;
+
+ default:
+ break;
}
+
break;
- case 64:
- ret = bt_socket_unset_connection_state_changed_cb();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_AUDIO: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE:
+ ret = bt_audio_initialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE:
+ ret = bt_audio_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: {
+ bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL;
+
+ if (g_test_param.param_count > 0) {
+ audio_profile = atoi(g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_audio_connect(remote_addr, audio_profile);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: {
+ bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL;
+
+ if (g_test_param.param_count > 0) {
+ audio_profile = atoi(g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_audio_disconnect(remote_addr, audio_profile);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB:
+ ret = bt_audio_set_connection_state_changed_cb(
+ __bt_audio_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB:
+ ret = bt_audio_unset_connection_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB:
+ ret = bt_a2dp_source_audio_set_connection_state_changed_cb(
+ __bt_audio_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB:
+ ret = bt_a2dp_source_audio_unset_connection_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO:
+ ret = bt_ag_open_sco();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO:
+ ret = bt_ag_close_sco();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED: {
+ bool opened = false;
+ ret = bt_ag_is_sco_opened(&opened);
+ TC_PRT("opend[%s]", opened ? "YES" : "NO");
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB:
+ ret = bt_ag_set_sco_state_changed_cb(__bt_ag_sco_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB:
+ ret = bt_ag_unset_sco_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED: {
+ bool connected = false;
+ ret = bt_ag_is_connected(&connected);
+ TC_PRT("returns %s\n", connected ? "Connected" : "Disconnected");
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE: {
+ unsigned int call_id = 1;
+
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_IDLE, call_id, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED: {
+ unsigned int call_id = 1;
+ bool sco_required = true;
+
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_ANSWERED, call_id, NULL);
+ if (sco_required)
+ bt_ag_open_sco();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: {
+ unsigned int call_id = 1;
+ bool sco_required = TRUE;
+ const char *phone_number;
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_DIALING,
+ call_id, g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ } else {
+ phone_number = g_strdup("01012345678");
+
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_DIALING,
+ call_id, phone_number);
+ }
+
+ if (sco_required)
+ bt_ag_open_sco();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING: {
+ unsigned int call_id = 1;
+
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_ALERTING,
+ call_id, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: {
+ unsigned int call_id = 1;
+ const char *phone_number;
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_INCOMING,
+ call_id, g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ } else {
+ phone_number = g_strdup("01012345678");
+
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_INCOMING,
+ call_id, phone_number);
+ }
+
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE:
+ ret = bt_call_list_create(&call_list);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY:
+ ret = bt_call_list_destroy(call_list);
+ call_list = NULL;
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET:
+ ret = bt_call_list_reset(call_list);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: {
+ const char *phone_number;
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_call_list_add(call_list, 1, BT_AG_CALL_STATE_ACTIVE, g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ } else {
+ phone_number = g_strdup("01012345678");
+
+ ret = bt_call_list_add(call_list, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
+ }
+
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST:
+ ret = bt_ag_notify_call_list(call_list);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB:
+ ret = bt_ag_set_call_handling_event_cb(
+ __bt_ag_set_call_handling_event_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED: {
+ bool enabled = false;
+ ret = bt_ag_is_nrec_enabled(&enabled);
+ TC_PRT("opend[%s]", enabled ? "YES" : "NO");
+ if (ret < BT_ERROR_NONE) {
+ 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;
+
+ default:
+ break;
+ }
+
break;
- case 70:
- ret = bt_opp_client_initialize();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_PAN: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE:
+ ret = bt_nap_activate();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE:
+ ret = bt_nap_deactivate();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL:
+ ret = bt_nap_disconnect_all();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT: {
+ ret = bt_nap_disconnect(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB: {
+ ret = bt_panu_set_connection_state_changed_cb(panu_conn_state_changed,
+ NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PANU_CONNECT: {
+ ret = bt_panu_connect(remote_addr, BT_PANU_SERVICE_TYPE_NAP);
+ 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;
+
+ default:
+ break;
+ }
+
break;
- case 71:
- ret = bt_opp_client_deinitialize();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_GATT: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_GATT_CONNECT : {
+ bool auto_connect = false;
+
+ if (g_test_param.param_count > 0) {
+ if (g_strrstr(g_test_param.params[0], "true"))
+ auto_connect = true;
+ else
+ auto_connect = false;
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_gatt_connect(remote_addr, auto_connect);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT : {
+ ret = bt_gatt_disconnect(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB : {
+ ret = bt_gatt_set_connection_state_changed_cb(__bt_gatt_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB : {
+ ret = bt_gatt_unset_connection_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE: {
+ if (client) {
+ bt_gatt_client_destroy(client);
+ client = NULL;
+ }
+ ret = bt_gatt_client_create(remote_addr, &client);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY: {
+ if (!client)
+ break;
+
+ ret = bt_gatt_client_destroy(client);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ client = NULL;
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS: {
+ char *addr = NULL;
+
+ ret = bt_gatt_client_get_remote_address(client, &addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ if (addr) {
+ TC_PRT("remote addr : %s\n", addr);
+ g_free(addr);
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL: {
+ ret = bt_gatt_client_foreach_services(client,
+ __bt_gatt_client_foreach_svc_cb, (void *)test_id);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: {
+ char *svc_uuid = NULL;
+ char *chr_uuid = NULL;
+ char *desc_uuid = NULL;
+ bt_gatt_h svc = NULL;
+ bt_gatt_h chr = NULL;
+ bt_gatt_h desc = NULL;
+
+ if (g_test_param.param_count < 3) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ svc_uuid = g_test_param.params[0];
+ chr_uuid = g_test_param.params[1];
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ if (strlen(g_test_param.params[2]) > 0) {
+ desc_uuid = g_test_param.params[2];
+ ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ ret = bt_gatt_client_read_value(desc,
+ __bt_gatt_client_read_complete_cb, NULL);
+ } else {
+ ret = bt_gatt_client_read_value(chr,
+ __bt_gatt_client_read_complete_cb, NULL);
+ }
+
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_read_value is failed : %d", ret);
+ }
+
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: {
+ char *svc_uuid = NULL;
+ char *chr_uuid = NULL;
+ char *desc_uuid = NULL;
+ bt_gatt_h svc = NULL;
+ bt_gatt_h chr = NULL;
+ bt_gatt_h desc = NULL;
+
+ if (g_test_param.param_count < 5) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ svc_uuid = g_test_param.params[0];
+ chr_uuid = g_test_param.params[1];
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ if (strlen(g_test_param.params[2]) > 0) {
+ desc_uuid = g_test_param.params[2];
+ ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = __bt_gatt_client_set_value(g_test_param.params[3],
+ g_test_param.params[4], desc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_set_value is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_client_write_value(desc,
+ __bt_gatt_client_write_complete_cb, NULL);
+ } else {
+ ret = __bt_gatt_client_set_value(g_test_param.params[3],
+ g_test_param.params[4], chr);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_set_value is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_client_write_value(chr,
+ __bt_gatt_client_write_complete_cb, NULL);
+ }
+
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_write_value is failed : %d", ret);
+ }
+
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: {
+ char *svc_uuid = NULL;
+ char *chr_uuid = NULL;
+ bt_gatt_h svc = NULL;
+ bt_gatt_h chr = NULL;
+
+ if (g_test_param.param_count < 2) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ svc_uuid = g_test_param.params[0];
+ chr_uuid = g_test_param.params[1];
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_client_set_characteristic_value_changed_cb(chr,
+ __bt_gatt_client_value_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret);
+
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: {
+ char *svc_uuid = NULL;
+ char *chr_uuid = NULL;
+ bt_gatt_h svc = NULL;
+ bt_gatt_h chr = NULL;
+
+ if (g_test_param.param_count < 2) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ svc_uuid = g_test_param.params[0];
+ chr_uuid = g_test_param.params[1];
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+
+ ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret);
+
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES: {
+ ret = bt_gatt_client_foreach_services(client,
+ __bt_gatt_client_foreach_svc_cb, (void *)test_id);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed");
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE : {
+
+ ret = bt_gatt_server_initialize();
+
+ TC_PRT("returns %s \n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE : {
+
+ ret = bt_gatt_server_deinitialize();
+
+ TC_PRT("returns %s \n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES: {
+ ret = bt_gatt_server_unregister_all_services(server);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ bt_gatt_h descriptor = NULL;
+ char *service_uuid = "180f"; // Battery Service
+ char *char_uuid = "2a19"; // Battery Level
+ char *desc_uuid = "2902"; // CCCD
+ char char_value[1] = {80}; // 80%
+ char desc_value[2] = {0, 0}; // Notification & Indication disabled
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY;
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, sizeof(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
+ ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor);
+ TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor);
+ TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+
+ battery_h.svc = service;
+ battery_h.chr = characteristic;
+ battery_h.desc = descriptor;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL: {
+ char char_value[1] = {1 + (rand()%100)};
+ if (!server) {
+ TC_PRT("bt gatt server is not created");
+ break;
+ }
+ ret = bt_gatt_set_value(battery_h.chr, char_value, 1);
+ TC_PRT("Value[%d], returns %s\n", char_value[0], __bt_get_error_message(ret));
+
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ bt_gatt_h descriptor = NULL;
+ char *service_uuid = "180d"; // Heart Rate Service
+ char *char_uuid = "2a37"; // Heart Rate Measurement
+ char *desc_uuid = "2902"; // CCCD
+ char char_value_1[3] = {1, 0x38, 0}; // Flag + Measurement value (56)
+ char desc_value[2] = {1, 0}; // Notification enabled
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; // READ property added for testing
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value_1, sizeof(char_value_1), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ heart_rate_h.chr = characteristic;
+
+ bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL);
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
+ ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor);
+ TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor);
+ TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret));
+
+ char_uuid = "2a38"; // Body Sensor Location
+ permissions = BT_GATT_PERMISSION_READ;
+ properties = BT_GATT_PROPERTY_READ;
+ char char_value_2 = 4; // Hand
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ &char_value_2, sizeof(char_value_2), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+
+ heart_rate_h.svc = service;
+ heart_rate_h.desc = descriptor;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT: {
+ int char_value = 60 + (rand()%60);
+ if (!server) {
+ TC_PRT("bt gatt server is not created");
+ break;
+ }
+ ret = bt_gatt_set_int_value(heart_rate_h.chr, BT_DATA_TYPE_UINT16, char_value, 1);
+ TC_PRT("bt_gatt_set_value(value : %d) : %s\n", char_value, __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_notify(heart_rate_h.chr, false, __bt_gatt_server_notification_sent_cb, NULL);
+ TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ bt_gatt_h descriptor = NULL;
+ char *service_uuid = "1809"; // Health Thermometer Service
+ char *char_uuid = "2a1c"; // Temperature Measurement
+ char *desc_uuid = "2902"; // CCCD
+ char char_value[5] = {0, 0x85, 0xff, 0xff, 0xfe}; // Flag + Temperature Measurement Value (Celsius, -1.23)
+ char desc_value[2] = {2, 0}; // Indication enabled
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_INDICATE | BT_GATT_PROPERTY_READ; // READ property added for testing
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, sizeof(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
+ ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor);
+ TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor);
+ TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+
+ thermometer_h.chr = characteristic;
+ thermometer_h.svc = service;
+ thermometer_h.desc = descriptor;
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT: {
+ if (!server) {
+ TC_PRT("bt gatt server is not created");
+ break;
+ }
+ ret = bt_gatt_set_float_value(thermometer_h.chr, BT_DATA_TYPE_FLOAT, 123, -2, 1);
+ TC_PRT("bt_gatt_set_value(value : 1.23) : %s\n", __bt_get_error_message(ret));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ char *service_uuid = "180a"; // Device Infromation Service
+ char *char_uuid = NULL;
+ char *char_value;
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_READ;
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ char_uuid = "2a29"; // Manufacturer Name String
+ char_value = g_strdup("Samsung");
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, strlen(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+ g_free(char_value);
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ char_uuid = "2a24"; // Model Number String
+ char_value = g_strdup("TIZEN_HR 0408");
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, strlen(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+ g_free(char_value);
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ char_uuid = "2a28"; // S/W Revision String
+ char_value = g_strdup("NC2");
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, strlen(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+ g_free(char_value);
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ char_uuid = "2a26"; // Firmware Revision Name String
+ char_value = g_strdup("Firmware Ver 04");
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, strlen(char_value), &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+ g_free(char_value);
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ char *service_uuid = "1803"; // Link Loss Service
+ char *char_uuid = "2a06"; // Alert Level
+ char char_value[1] = {2}; // high alert
+ int value_length = 1;
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE;
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, value_length, &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC: {
+ bt_gatt_h service = NULL;
+ bt_gatt_h characteristic = NULL;
+ bt_gatt_h descriptor = NULL;
+ char *service_uuid = "000018f2-0000-1000-8000-00805f9b34fb";
+ char *char_uuid = "00002af6-0000-1000-8000-00805f9b34fb";
+ char *desc_uuid = "00002a56-0000-1000-8000-00805f9b34fb";
+ char char_value[4] = {10, 20, 30, 40};
+ char desc_value[4] = {12, 34, 56, 78};
+ int value_length = 4;
+ int permissions = BT_GATT_PERMISSION_READ;
+ int properties = BT_GATT_PROPERTY_BROADCAST | BT_GATT_PROPERTY_READ |
+ BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_NOTIFY;
+
+ ret = bt_gatt_server_initialize();
+ TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret));
+
+ if (server == NULL) {
+ ret = bt_gatt_server_create(&server);
+ TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service);
+ TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_create(char_uuid, permissions, properties,
+ char_value, value_length, &characteristic);
+ TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_service_add_characteristic(service, characteristic);
+ TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, value_length, &descriptor);
+ TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor);
+ TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret));
+
+ ret = bt_gatt_server_register_service(server, service);
+ TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
+
+ custom_h.svc = service;
+ custom_h.chr = characteristic;
+ custom_h.desc = descriptor;
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL: {
+ char char_value[4] = {50, 60, 70, 80};
+ if (!server) {
+ TC_PRT("bt gatt server is not created");
+ break;
+ }
+ ret = bt_gatt_set_value(custom_h.chr, char_value, 4);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_PAIR: {
+ bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE;
+
+ if (g_test_param.param_count > 0) {
+ link_type = atoi(g_test_param.params[0]);
+
+ __bt_free_test_param(&g_test_param);
+ }
+
+ ret = bt_device_create_bond_by_type(remote_addr, link_type);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_WATCH: {
+ bt_gatt_h ancs_svc = NULL;
+ bt_gatt_h noti_source = NULL;;
+ char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0";
+ char *chr_uuid = "9FBF120D-6301-42D9-8C58-25E699A21DBD";
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &ancs_svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(ancs_svc, chr_uuid, &noti_source);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ break;
+ }
+
+ ret = bt_gatt_client_set_characteristic_value_changed_cb(noti_source,
+ __bt_gatt_client_value_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret);
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: {
+ char value[6];
+ char *noti_id = NULL;
+ int id;
+
+ if (g_test_param.param_count == 0) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ noti_id = g_test_param.params[0];
+ id = atoi(noti_id);
+
+ value[0] = 0x02;
+ memcpy(&value[1], &id, sizeof(int));
+ value[5] = 0x00;
+
+ __ancs_write_value_to_control_point(client, value, sizeof(value));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: {
+ char value[6];
+ char *noti_id = NULL;
+ int id;
+
+ if (g_test_param.param_count == 0) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ noti_id = g_test_param.params[0];
+ id = atoi(noti_id);
+
+ value[0] = 0x02;
+ memcpy(&value[1], &id, sizeof(int));
+ value[5] = 0x01;
+
+ __ancs_write_value_to_control_point(client, value, sizeof(value));
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: {
+ bt_gatt_h ancs_svc = NULL;
+ bt_gatt_h data_source = NULL;;
+ char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0";
+ char *chr_uuid = "22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB";
+
+ char value[19];
+ char *noti_id = NULL;
+ int id;
+
+ if (g_test_param.param_count == 0) {
+ TC_PRT("Input parameters first");
+ break;
+ }
+
+ ret = bt_gatt_client_get_service(client, svc_uuid, &ancs_svc);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_get_service is failed : %d", ret);
+ break;
+ }
+
+ ret = bt_gatt_service_get_characteristic(ancs_svc, chr_uuid, &data_source);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret);
+ break;
+ }
+
+ ret = bt_gatt_client_set_characteristic_value_changed_cb(data_source,
+ __bt_gatt_client_value_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret);
+ }
+
+ noti_id = g_test_param.params[0];
+ id = atoi(noti_id);
+
+ value[0] = 0x00;
+ memcpy(&value[1], &id, sizeof(int));
+ value[5] = 0x00;
+ value[6] = 0x01;
+ value[7] = 0xff;
+ value[8] = 0x00;
+ value[9] = 0x02;
+ value[10] = 0xff;
+ value[11] = 0x00;
+ value[12] = 0x03;
+ value[13] = 0xff;
+ value[14] = 0x00;
+ value[15] = 0x04;
+ value[16] = 0x05;
+ value[17] = 0x06;
+ value[18] = 0x07;
+
+ __ancs_write_value_to_control_point(client, value, sizeof(value));
+
+ break;
+ }
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+ case BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES: {
+ __bt_free_gatt_services();
+
+ ret = bt_gatt_foreach_primary_services(remote_addr, __bt_gatt_primary_service_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE)
+ __select_index(&selected_service_index, "Select primary service :");
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS: {
+ __bt_free_gatt_characteristics();
+
+ if (selected_service_index < 0) {
+ TC_PRT("Need to select primary service \n");
+ break;
+ }
+
+ ret = bt_gatt_discover_characteristics(service_clone[selected_service_index], __bt_gatt_characteristics_discovered_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE)
+ __select_index(&selected_char_index, "Select index :");
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS: {
+ ret = bt_gatt_discover_characteristic_descriptor(characteristics[selected_char_index],
+ __bt_gatt_characteristic_descriptor_discovered_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID: {
+ char *uuid = NULL;
+ char *name = NULL;
+
+ if (selected_service_index < 0) {
+ TC_PRT("Need to select primary service \n");
+ break;
+ }
+
+ ret = bt_gatt_get_service_uuid(service_clone[selected_service_index], &uuid);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ bt_gatt_get_uuid_specification_name(uuid, &name);
+ TC_PRT("uuid: %s [%s]", uuid, name);
+ g_free(name);
+ g_free(uuid);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES: {
+ __bt_free_gatt_characteristics_services();
+
+ if (selected_service_index < 0) {
+ TC_PRT("Need to select primary service \n");
+ break;
+ }
+
+ ret = bt_gatt_foreach_included_services(service_clone[selected_service_index], __bt_gatt_included_service_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB: {
+ ret = bt_gatt_set_characteristic_changed_cb(__bt_gatt_characteristic_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB: {
+ ret = bt_gatt_unset_characteristic_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION: {
+ int i;
+ char *uuid = NULL;
+ char *name = NULL;
+ unsigned char *value = NULL;
+ int value_length = 0;
+
+ ret = bt_gatt_get_characteristic_declaration(characteristics_services[0], &uuid, &value, &value_length);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ bt_gatt_get_uuid_specification_name(uuid, &name);
+ TC_PRT("uuid: %s [%s]", uuid, name);
+
+ for (i = 0; i < value_length; i++) {
+ TC_PRT("value %c", value[i]);
+ }
+
+ g_free(uuid);
+ g_free(name);
+ g_free(value);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE: {
+ unsigned char value[] = { 1 };
+ if (selected_char_index == 0) {
+ TC_PRT("Need to select charateristic value \n");
+ break;
+ }
+
+ ret = bt_gatt_set_characteristic_value(characteristics[selected_char_index], value, 1);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST: {
+ unsigned char value[] = { 1 };
+ if (selected_char_index == 0) {
+ TC_PRT("Need to select charateristic value \n");
+ break;
+ }
+
+ ret = bt_gatt_set_characteristic_value_request(characteristics[selected_char_index], value, 1,
+ __bt_gatt_char_write_cb);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE : {
+ if (selected_char_index == 0) {
+ TC_PRT("Need to select charateristic value \n");
+ break;
+ }
+
+ ret = bt_gatt_read_characteristic_value(characteristics[selected_char_index], __bt_gatt_char_read_cb);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES: {
+ if (selected_service_index < 0) {
+ TC_PRT("Need to select primary service \n");
+ break;
+ }
+
+ ret = bt_gatt_watch_characteristic_changes(service_clone[selected_service_index]);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES: {
+ ret = bt_gatt_unwatch_characteristic_changes(service_clone[selected_service_index]);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+#endif
+ 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 72:
- ret = bt_opp_client_add_file("/opt/media/Images/image1.jpg");
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_AVRCP: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE:
+ ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE:
+ ret = bt_avrcp_target_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB:
+ ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_equalizer_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB:
+ ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_repeat_mode_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB:
+ ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_shuffle_mode_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB:
+ ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_scan_mode_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB:
+ ret = bt_avrcp_unset_equalizer_state_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB:
+ ret = bt_avrcp_unset_repeat_mode_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB:
+ ret = bt_avrcp_unset_shuffle_mode_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB:
+ ret = bt_avrcp_unset_scan_mode_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE:
+ ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE:
+ ret = bt_avrcp_control_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT:
+ ret = bt_avrcp_control_connect(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT:
+ ret = bt_avrcp_control_disconnect(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_STOP);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PAUSE);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_FAST_FORWARD);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_REWIND);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT:
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_NEXT);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV: {
+ ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PREVIOUS);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT: {
+ bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_GROUP;
+ ret = bt_avrcp_control_get_repeat_mode(&mode);
+ TC_PRT("Repet mode : %d returns %s\n", mode, __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT: {
+ ret = bt_avrcp_control_set_repeat_mode(2);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE: {
+ bt_avrcp_shuffle_mode_e mode = BT_AVRCP_SHUFFLE_MODE_ALL_TRACK;
+ ret = bt_avrcp_control_get_shuffle_mode(&mode);
+ TC_PRT("Shuffle mode %d returns %s\n", mode, __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE: {
+ ret = bt_avrcp_control_set_shuffle_mode(1);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION: {
+ unsigned int position = 0;
+ ret = bt_avrcp_control_get_position(&position);
+ TC_PRT("position %d returns %s\n", position, __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS: {
+ unsigned int status = 0;
+ ret = bt_avrcp_control_get_play_status(&status);
+ TC_PRT("status %d returns %s\n", status, __bt_get_error_message(ret));
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO: {
+ bt_avrcp_metadata_attributes_info_s *track;
+ ret = bt_avrcp_control_get_track_info(&track);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Title. %s\n", track->title);
+ TC_PRT("Artist %s\n", track->artist);
+ TC_PRT("Album %s\n", track->album);
+ TC_PRT("Genre %s\n", track->genre);
+ TC_PRT("Total tracks %d\n", track->total_tracks);
+ TC_PRT("Number %d\n", track->number);
+ TC_PRT("Duration %d\n", track->duration);
+ bt_avrcp_control_free_track_info(track);
+ }
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB:
+ ret = bt_avrcp_set_song_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB:
+ ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB:
+ ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB:
+ ret = bt_avrcp_unset_song_position_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB:
+ ret = bt_avrcp_unset_play_status_changed_cb();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+
+ case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB:
+ ret = bt_avrcp_unset_track_info_changed_cb();
+ 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;
+
+ default:
+ break;
}
+
break;
- case 73:
- ret = bt_opp_client_clear_files();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ }
+ case BT_UNIT_TEST_TABLE_HID: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE:
+ ret = bt_hid_host_initialize(__bt_hid_host_connection_state_changed_cb,
+ NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE:
+ ret = bt_hid_host_deinitialize();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT: {
+ ret = bt_hid_host_connect(remote_addr);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT: {
+ ret = bt_hid_host_disconnect(remote_addr);
+ 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;
+
+ default:
+ break;
+ }
+
break;
- case 74: {
- char *address;
+ }
+#ifdef TIZEN_WEARABLE
+ case BT_UNIT_TEST_TABLE_HF: {
+ switch (test_id) {
+ case BT_UNIT_TEST_FUNCTION_HF_INITIALIZE:
+ ret = bt_hf_initialize();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE:
+ ret = bt_hf_deinitialize();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER:
+ ret = bt_hf_notify_call_event(BT_HF_CALL_EVENT_ANSWER, "9663868998");
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN:
+ ret = bt_hf_notify_speaker_gain(10);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB:
+ ret = bt_hf_set_speaker_gain_changed_cb(__bt_hf_speaker_gain_changed_cb, NULL);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB:
+ ret = bt_hf_unset_speaker_gain_changed_cb();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE:
+ ret = bt_hf_notify_voice_recognition_state(true);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM:
+ ret = bt_hf_notify_call_event(BT_HF_CALL_EVENT_IDLE, "9663868998");
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT:
+ ret = bt_hf_notify_call_event(BT_HF_CALL_EVENT_DIAL, "9663868998");
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE:
+ ret = bt_hf_notify_voice_recognition_state(false);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED: {
+ bool is_opened = false;
+ ret = bt_hf_is_sco_opened(&is_opened);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("Sco is opened [%s]", is_opened ? "YES" : "NO");
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID: {
+ unsigned int codec_id = 0;
+ ret = bt_hf_get_codec_id(&codec_id);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("Codec ID [%d]", codec_id);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST: {
+ GSList *list;
+ ret = bt_hf_get_call_status_info_list(&list);
- address = g_strdup("00:02:37:A9:17:9E");
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else {
+ for (; list; list = g_slist_next(list)) {
+ bt_hf_call_status_info_s *call_info = list->data;
+ TC_PRT("Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]",
+ call_info->number, call_info->direction, call_info->status, call_info->multi_party, call_info->index);
+ }
+ bt_hf_free_call_status_info_list(list);
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB:
+ ret = bt_hf_set_sco_state_changed_cb(
+ __bt_hf_sco_state_changed_cb, NULL);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB:
+ ret = bt_hf_unset_sco_state_changed_cb();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB:
+ ret = bt_hf_set_call_handling_event_cb(__bt_hf_set_call_handling_event_cb, NULL);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB:
+ ret = bt_hf_unset_call_handling_event_cb();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB:
+ ret = bt_hf_set_call_status_updated_event_cb(__bt_hf_call_status_updated_event_cb, NULL);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB:
+ ret = bt_hf_unset_call_status_updated_event_cb();
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ } else if (ret == BT_ERROR_NONE) {
+ TC_PRT("Success");
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
+ need_to_set_params = true;
+ TC_PRT("Select the function again");
+ break;
- ret = bt_opp_client_push_files(address,__bt_opp_client_push_responded_cb,
- __bt_opp_client_push_progress_cb,
- __bt_opp_client_push_finished_cb,
- NULL);
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ default:
+ break;
}
+
break;
}
- case 75:
- ret = bt_opp_client_cancel_push();
- if (ret < BT_ERROR_NONE) {
- TC_PRT("failed with [0x%04x]", ret);
+ case BT_UNIT_TEST_TABLE_PBAP_CLIENT: {
+ switch (test_id) {
+
+ /*PBAP Test Cases */
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE:
+ ret = bt_pbap_init();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE:
+ ret = bt_pbap_deinit();
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT: {
+ ret = bt_pbap_connect(remote_addr, __bt_pbap_enabled_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT: {
+ ret = bt_pbap_disconnect(remote_addr, __bt_pbap_enabled_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE: {
+ ret = bt_pbap_get_phonebook_size(remote_addr, 0, 0, __bt_pbap_phonebook_size_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
}
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL: {
+ long long unsigned fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG;
+ ret = bt_pbap_get_phonebook(remote_addr, 0, 0, 0, 0, 0, 100,
+ fields, __bt_pbap_phonebook_pull_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST: {
+ ret = bt_pbap_get_list(remote_addr, 0, 0, 0, 0, 100,
+ __bt_pbap_vcard_list_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL: {
+ long long unsigned fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG;
+ ret = bt_pbap_pull_vcard(remote_addr, 0, 0, 0, 0, fields,
+ __bt_pbap_phonebook_pull_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH: {
+ ret = bt_pbap_phonebook_search(remote_addr, 0, 0,
+ 0, "abc",
+ 0, 0, 100,
+ __bt_pbap_vcard_list_cb, NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO: {
+ ret = bt_pbap_get_list(remote_addr, 0, 0, 0, 0, 0,
+ __bt_pbap_vcard_list_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;
+
+ default:
+ break;
+ }
+
break;
+ }
+#endif
+ case BT_UNIT_TEST_TABLE_AUTOMATED_TEST: {
+ static unsigned int delay = 0;
+ bt_onoff_cnt = 0;
+ bt_onoff_cnt_success = 0;
+ bt_onoff_cnt_fail = 0;
+ bt_onoff_timer = time(NULL);
+
+ if (input_automated_test_delay == true) {
+ delay = test_id;
+ test_id = BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY;
+ }
+
+ switch (test_id) {
+ /*Automated Test Cases */
+ case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST: {
+ bt_adapter_state_e state = BT_ADAPTER_DISABLED;
+ delay = 0;
+
+ ret = bt_adapter_set_state_changed_cb(__bt_repeat_test_adapter_state_changed_cb, &delay);
+ TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_get_state(&state);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("Current state: %d", state);
+
+ if (state == BT_ADAPTER_DISABLED)
+ bt_adapter_enable();
+ else
+ bt_adapter_disable();
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY: {
+ bt_adapter_state_e state = BT_ADAPTER_DISABLED;
+ delay = 1;
+
+ ret = bt_adapter_set_state_changed_cb(__bt_repeat_test_adapter_state_changed_cb, &delay);
+ TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_get_state(&state);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("Current state: %d", state);
+ if (state == BT_ADAPTER_DISABLED)
+ bt_adapter_enable();
+ else
+ bt_adapter_disable();
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY: {
+ bt_adapter_state_e state = BT_ADAPTER_DISABLED;
+
+ input_automated_test_delay = false;
+
+ ret = bt_adapter_set_state_changed_cb(__bt_repeat_test_adapter_state_changed_cb, &delay);
+ TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_get_state(&state);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ TC_PRT("Current state: %d", state);
+
+ if (state == BT_ADAPTER_DISABLED)
+ bt_adapter_enable();
+ else
+ bt_adapter_disable();
+ break;
+ }
+ default:
+ break;
+ }
+
+ break;
+ }
default:
break;
}
@@ -478,31 +5382,81 @@ static gboolean key_event_cb(GIOChannel *chan,
unsigned int len = 0;
int test_id;
+ bool is_call_api = false;
+
+ if (is_sub_index)
+ return TRUE;
memset(buf, 0, sizeof(buf));
- if(g_io_channel_read_chars(chan, buf, sizeof(buf),
+ if (g_io_channel_read_chars(chan, buf, sizeof(buf),
&len, NULL) == G_IO_STATUS_ERROR) {
TC_PRT("IO Channel read error");
return FALSE;
}
- TC_PRT("%s", buf);
- tc_usage_print();
+ if (need_to_set_params == true) {
+ if (g_test_id == -1) {
+ test_id = atoi(buf);
+ g_test_id = test_id;
+ }
+ test_set_params(g_test_id, buf);
+ return TRUE;
+ } else {
+ TC_PRT("%s", buf);
+ test_id = atoi(buf);
+
+ g_test_id = -1;
+ need_to_set_params = false;
+ }
- test_id = atoi(buf);
+ if (current_tc_table == BT_UNIT_TEST_TABLE_MAIN) {
+ if (buf[0] == '0' && buf[2] == 0)
+ current_tc_table = BT_UNIT_TEST_TABLE_SET_ADDRESS;
+ else if(test_id >= BT_UNIT_TEST_TABLE_ADAPTER && test_id < BT_UNIT_TEST_TABLE_FINISH)
+ current_tc_table = test_id;
+ else
+ is_call_api = true;
+ } else {
+ if (buf[0] == '0' && buf[2] == 0) {
+ current_tc_table = BT_UNIT_TEST_TABLE_MAIN;
+ } else if (current_tc_table == BT_UNIT_TEST_TABLE_AUTOMATED_TEST
+ && test_id == BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY
+ && input_automated_test_delay == false) {
+ input_automated_test_delay = true;
+ } else {
+ is_call_api = true;
+ }
+ }
- if(test_id)
+ tc_usage_print();
+
+ if (current_tc_table == BT_UNIT_TEST_TABLE_SET_ADDRESS && is_call_api == true) {
+ memcpy (remote_addr, buf, 17);
+ remote_addr[17] = 0;
+ } else if (test_id && is_call_api)
g_idle_add(test_input_callback, (void *)test_id);
return TRUE;
}
+void sig_handler(int signo)
+{
+ if (signo == SIGINT) {
+ if (bt_onoff_cnt > 0)
+ __bt_repeat_test_onoff_count_time_summary();
+
+ bt_deinitialize();
+ exit(0);
+ }
+}
+
int main()
{
GIOChannel *key_io;
- g_type_init();
+// g_type_init();
+ current_tc_table = BT_UNIT_TEST_TABLE_MAIN;
key_io = g_io_channel_unix_new(fileno(stdin));
@@ -516,10 +5470,12 @@ int main()
main_loop = g_main_loop_new(NULL, FALSE);
+ if (signal(SIGINT, sig_handler) == SIG_ERR)
+ TC_PRT("\n can't catch SIGINT\n");
+
g_main_loop_run(main_loop);
bt_deinitialize();
return 0;
}
-
diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h
new file mode 100644
index 0000000..cc02183
--- /dev/null
+++ b/test/bt_unit_test.h
@@ -0,0 +1,354 @@
+/*
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__
+#define __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BUFFER_LEN 49
+#define MAX_SERVICES 10
+#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
+#define TC_PRT(format, args...) PRT(format"\n", ##args)
+
+typedef enum
+{
+ BT_UNIT_TEST_TABLE_MAIN = 1,
+ BT_UNIT_TEST_TABLE_SET_ADDRESS,
+ BT_UNIT_TEST_TABLE_ADAPTER,
+ BT_UNIT_TEST_TABLE_ADAPTER_LE,
+ BT_UNIT_TEST_TABLE_DEVICE,
+ BT_UNIT_TEST_TABLE_SOCKET,
+ BT_UNIT_TEST_TABLE_OPP,
+ BT_UNIT_TEST_TABLE_AUDIO,
+ BT_UNIT_TEST_TABLE_PAN,
+ BT_UNIT_TEST_TABLE_GATT,
+ BT_UNIT_TEST_TABLE_AVRCP,
+ BT_UNIT_TEST_TABLE_HID,
+#ifdef TIZEN_WEARABLE
+ BT_UNIT_TEST_TABLE_HF,
+ BT_UNIT_TEST_TABLE_PBAP_CLIENT,
+#endif
+ BT_UNIT_TEST_TABLE_AUTOMATED_TEST,
+ BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL,
+ BT_UNIT_TEST_TABLE_FINISH = 0xFF,
+} bt_unit_test_table_e;
+
+typedef enum
+{
+ BT_UNIT_TEST_FUNCTION_BACK = 0,
+ BT_UNIT_TEST_FUNCTION_SET_ADDRESS = 0,
+ BT_UNIT_TEST_FUNCTION_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE = 1,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE = 1,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN,
+#ifndef TIZEN_WEARABLE
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_DEVICE_DISCOVERY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY,
+#endif
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW,
+#ifndef TIZEN_WEARABLE
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING,
+#endif
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST,
+#ifndef TIZEN_WEARABLE
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_CLEAR_WHITE_LIST,
+#endif
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS,
+#ifndef TIZEN_WEARABLE
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
+#endif
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1,
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE,
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES,
+ BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED,
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB,
+ BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND,
+ BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE,
+ BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND,
+ BT_UNIT_TEST_FUNCTION_DEVICE_ENABLE_RSSI_MONITOR,
+ BT_UNIT_TEST_FUNCTION_DEVICE_DISABLE_RSSI_MONITOR,
+ BT_UNIT_TEST_FUNCTION_DEVICE_GET_RSSI_STRENGTH,
+ BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE,
+ BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM = 1,
+ BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM,
+ BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM,
+ BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN,
+ BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT,
+ BT_UNIT_TEST_FUNCTION_SOCKET_REJECT,
+ BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM,
+ BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM,
+ BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA,
+ BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID,
+ BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB,
+ BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB,
+ BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB,
+ BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB,
+ BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES,
+ BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH,
+ BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT,
+ BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_CONNECT,
+ BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB,
+ BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB,
+ BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO,
+ BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO,
+ BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED,
+ BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED,
+ BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE,
+ BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED,
+ BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING,
+ BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING,
+ BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING,
+ BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE,
+ BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY,
+ BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET,
+ BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD,
+ BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST,
+ BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED,
+ BT_UNIT_TEST_FUNCTION_AG_IS_WBS_MODE,
+ BT_UNIT_TEST_FUNCTION_AG_SET_VENDOR_CMD_CB,
+ BT_UNIT_TEST_FUNCTION_AG_UNSET_VENDOR_CMD_CB,
+ BT_UNIT_TEST_FUNCTION_AG_NOTIFY_VENDOR_CMD,
+ BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_ENABLE,
+ BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_DISABLE,
+ BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE = 1,
+ BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE,
+ BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL,
+ BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PANU_CONNECT,
+ BT_UNIT_TEST_FUNCTION_GATT_CONNECT = 1,
+ BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC,
+ BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL,
+ BT_UNIT_TEST_FUNCTION_ANCS_PAIR,
+ BT_UNIT_TEST_FUNCTION_ANCS_WATCH,
+ BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION,
+ BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION,
+ BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR,
+#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
+ BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES,
+ BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS,
+ BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS,
+ BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID,
+ BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES,
+ BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION,
+ BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE,
+ BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST,
+ BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE,
+ BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES,
+ BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES,
+#endif
+ BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS,
+ BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT,
+ BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT,
+#ifdef TIZEN_WEARABLE
+ BT_UNIT_TEST_FUNCTION_HF_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM,
+ BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST,
+ BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN,
+ BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB,
+ BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE,
+ BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED,
+ BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID,
+ BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VENDOR_CMD,
+ BT_UNIT_TEST_FUNCTION_HF_SET_VENDOR_CMD_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_HF_UNSET_VENDOR_CMD_EVENT_CB,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE = 1,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH,
+ BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO,
+#endif
+ BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST = 1,
+ BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY,
+ BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY,
+
+ BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF,
+} bt_unit_test_function_e;
+
+typedef struct {
+ const char *tc_name;
+ int tc_code;
+} tc_table_t;
+
+typedef struct {
+ int param_count;
+ char **params;
+} tc_params_t;
+
+#define BT_UNIT_TEST_PARAM_TYPE_BOOL "bool(true, false)"
+#define BT_UNIT_TEST_PARAM_TYPE_INT "int(1, 2, 10, 777...)"
+#define BT_UNIT_TEST_PARAM_TYPE_FLOAT "float(1.5, 0.625...)"
+#define BT_UNIT_TEST_PARAM_TYPE_STRING "string(abc, HAHA..)"
+#define BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY "byte array(03FF0102, 0015836CF7B2...)"
+
+int test_input_callback(void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ */
diff --git a/test/capi.network.bluetooth.infinite.spp.test.rule b/test/capi.network.bluetooth.infinite.spp.test.rule
new file mode 100644
index 0000000..a5a4466
--- /dev/null
+++ b/test/capi.network.bluetooth.infinite.spp.test.rule
@@ -0,0 +1,4 @@
+capi-network-bluetooth-infinite-spp-test-server bt-service::public w
+capi-network-bluetooth-infinite-spp-test-server bt-service::platform rw
+capi-network-bluetooth-infinite-spp-test-client bt-service::public w
+capi-network-bluetooth-infinite-spp-test-client bt-service::platform rw
diff --git a/test/capi.network.bluetooth.test.rule b/test/capi.network.bluetooth.test.rule
new file mode 100644
index 0000000..59d60ad
--- /dev/null
+++ b/test/capi.network.bluetooth.test.rule
@@ -0,0 +1,2 @@
+capi-network-bluetooth-test bt-service::public w
+capi-network-bluetooth-test bt-service::platform rw
diff --git a/test/gatt_profile_test_suite/CMakeLists.txt b/test/gatt_profile_test_suite/CMakeLists.txt
new file mode 100644
index 0000000..dccbadd
--- /dev/null
+++ b/test/gatt_profile_test_suite/CMakeLists.txt
@@ -0,0 +1,22 @@
+SET(fw_test "${fw_name}-test")
+PROJECT(bt_unit_test_gatt C)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+
+SET(SOURCES
+bt_unit_test_gatt.c
+bt_unit_test_gatt_hr_profile.c
+)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${fw_name} ${${fw_test}_LDFLAGS})
+
+INSTALL(TARGETS bt_unit_test_gatt DESTINATION bin)
+INSTALL(FILES capi.network.bluetooth.test.gatt.rule DESTINATION /etc/smack/accesses2.d/)
+
diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt.c b/test/gatt_profile_test_suite/bt_unit_test_gatt.c
new file mode 100644
index 0000000..db2c966
--- /dev/null
+++ b/test/gatt_profile_test_suite/bt_unit_test_gatt.c
@@ -0,0 +1,121 @@
+#include "bt_unit_test_gatt.h"
+#include <getopt.h>
+
+GMainLoop *main_loop = NULL;
+gatt_test_role_e role = GATT_ROLE_INVALID;
+bool gatt_debug = false;
+
+typedef void (*gatt_test_signal_handler) (int signo);
+
+gatt_test_signal_handler profile_signal_handler_cb = NULL;
+
+void sig_handler(int signo)
+{
+/* TODO: decide on what more to be done here. Should each profile register callback for this */
+ if(profile_signal_handler_cb)
+ profile_signal_handler_cb(signo);
+ exit(0);
+}
+
+static struct option main_options[] = {
+ { "heart-rate-profile", optional_argument, NULL, 'H' },
+ { "client", no_argument, NULL, 'c' },
+ { "server", no_argument, NULL, 's' },
+ { "help", no_argument, NULL, 'h' },
+ { }
+};
+
+
+void usage()
+{
+ USR_PRT("Usage:\tbt_unit_test_gatt <Role> [option[parameter]]\n\n"\
+ "\t Role:\n"\
+ "\t -c client role\n"\
+ "\t -s server role\n\n"\
+ "\t [option..]:\n"\
+ "\t -H <bd-addr> Heart rate Profile\n"\
+ "\t -d Debug enable\n"\
+ "\t -h Help Menu\n");
+}
+
+int main(int argc, char *argv[])
+{
+ GIOChannel *key_io;
+ int opt;
+ bool profile_selected = false;
+ char buf[BUFFER_LEN] = { 0 };
+// g_type_init();
+
+ key_io = g_io_channel_unix_new(fileno(stdin));
+
+ g_io_channel_set_encoding(key_io, NULL, NULL);
+ g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL);
+
+ while ((opt = getopt_long(argc, argv,
+ "H:hcsd", main_options, NULL)) != -1) {
+ switch(opt) {
+ case 'c':
+ if (role == GATT_ROLE_SERVER) {
+ USR_PRT(" both <role> can't be selected");
+ goto fail;
+ } else {
+ role = GATT_ROLE_CLIENT;
+ }
+ break;
+ case 's':
+ if (role == GATT_ROLE_CLIENT) {
+ USR_PRT("both <role> can't be selected");
+ goto fail;
+ } else {
+ role = GATT_ROLE_SERVER;
+ }
+ break;
+ case 'H':
+ if (role == GATT_ROLE_INVALID) {
+ USR_PRT("<role> parameter is missing");
+ usage();
+ exit(0);
+ }else if(role == GATT_ROLE_CLIENT) {
+ hr_client_initialize();
+ USR_PRT("Launching Heart rate profile test-suite");
+ memcpy(buf, optarg, sizeof(buf));
+ hr_client_accept_input(buf);
+ g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ hr_client_key_event_cb, NULL);
+ g_io_channel_unref(key_io);
+ profile_selected = true;
+ profile_signal_handler_cb = hr_client_signal_handler;
+ } else {
+ //Heart-rate profile server
+ profile_selected = true;
+ }
+ break;
+ case 'd':
+ gatt_debug = true;
+ break;
+ case 'h':
+ default:
+ usage();
+ exit(0);
+ }
+ }
+
+ if(profile_selected == false) {
+ USR_PRT("No profile selected: So, nothing to do");
+ goto fail;
+ }
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ if (signal(SIGINT, sig_handler) == SIG_ERR)
+ USR_PRT("\n can't catch SIGINT\n");
+
+ g_main_loop_run(main_loop);
+
+ bt_deinitialize();
+
+ return 0;
+fail:
+ usage();
+ exit(0);
+}
diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt.h b/test/gatt_profile_test_suite/bt_unit_test_gatt.h
new file mode 100644
index 0000000..76df892
--- /dev/null
+++ b/test/gatt_profile_test_suite/bt_unit_test_gatt.h
@@ -0,0 +1,43 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <glib.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "bluetooth.h"
+#include "bluetooth_internal.h"
+#include "bluetooth_private.h"
+#include "bluetooth-telephony-api.h"
+
+#define PRT(format, args...) do { \
+ if (gatt_debug)\
+ printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args);\
+}while(0)
+
+#define DBG_PRT(format, args...) PRT(format"\n", ##args)
+#define USR_PRT(format, args...) printf(format"\n", ##args)
+#define BUFFER_LEN 49
+
+typedef enum
+{
+ GATT_ROLE_INVALID = 0x00,
+ GATT_ROLE_CLIENT,
+ GATT_ROLE_SERVER,
+}gatt_test_role_e;
+
+
+int hr_client_initialize(void);
+void hr_client_signal_handler(int);
+
+void hr_client_accept_input(char *buf);
+
+gboolean hr_client_key_event_cb(GIOChannel *chan, GIOCondition cond,
+ gpointer data);
+
+
diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c
new file mode 100644
index 0000000..41bea37
--- /dev/null
+++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c
@@ -0,0 +1,472 @@
+#include "bt_unit_test_gatt_hr_profile.h"
+
+extern bool gatt_debug;
+
+static hr_test_gatt_state_e test_cursor = BT_GATT_TEST_HR_INITIALIZATION;
+static bool input_valid = false;
+static bt_gatt_h hr_control_point_handle = NULL;
+
+static void __hr_client_scan_result_cb(int result,
+ bt_adapter_le_device_scan_result_info_s *info, void *user_data)
+{
+ if (info == NULL) {
+ DBG_PRT("No discovery_info!");
+ return;
+ }
+ if(!strcmp(info->remote_address, remote_addr)) {
+ bt_adapter_le_stop_scan();
+ if(bt_gatt_connect(remote_addr, false) != BT_ERROR_NONE)
+ test_cursor = BT_GATT_TEST_UNRECOVERABLE;
+ }
+}
+
+void __hr_client_search_and_connect()
+{
+ int ret;
+ ret = bt_adapter_le_start_scan(__hr_client_scan_result_cb, NULL);
+ if(ret != BT_ERROR_NONE)
+ test_cursor = BT_GATT_TEST_UNRECOVERABLE;
+}
+
+void __hr_client_initiate_connection()
+{
+ int ret;
+ USR_PRT("Make sure the remote device is turned on and visible");
+ USR_PRT("Please wait.. while we connect the device");
+
+ test_cursor = BT_GATT_TEST_TABLE_CONNECTING;
+
+ ret = bt_gatt_connect(remote_addr, false);
+ if(ret != BT_ERROR_NONE)
+ __hr_client_search_and_connect();
+}
+
+static void __hr_client_reset_energy_expended_cb(int result, bt_gatt_h request_handle,
+ void *user_data)
+{
+ if (result != BT_ERROR_NONE) {
+ USR_PRT("Reset of Energy expended value failed");
+ DBG_PRT("result code %d", result);
+ return;
+ }
+
+ USR_PRT("Reset of Energy expended value is complete");
+ return;
+}
+
+void __hr_client_reset_energy_expended()
+{
+ if (hr_control_point_handle) {
+ char reset = 0x01;
+ USR_PRT("Attempting to reset the energy expended");
+ bt_gatt_characteristic_set_write_type(hr_control_point_handle,
+ BT_GATT_WRITE_TYPE_WRITE);
+ bt_gatt_set_value(hr_control_point_handle, &reset, sizeof(reset));
+ bt_gatt_client_write_value(hr_control_point_handle, __hr_client_reset_energy_expended_cb, NULL);
+ } else
+ USR_PRT("Heart rate control point is not supported");
+}
+void __hr_client_measurement_cb(bt_gatt_h chr, char *value, int len,
+ void *user_data)
+{
+ int value_cursor = 0;
+ char flags;
+ DBG_PRT("len [%d]", len);
+ if(len < 1) {
+ DBG_PRT("invalid notification");
+ }
+ flags = value[0];
+ value_cursor++;
+
+ if((flags & HR_VALUE_FORMAT_MASK)) {
+ USR_PRT("Heart Rate Measurement Value %x %x", value[value_cursor], value[value_cursor+1]);
+ value_cursor += 2;
+ }else {
+ USR_PRT("Heart Rate Measurement Value %x", value[value_cursor]);
+ value_cursor++;
+ }
+
+ switch(flags & HR_SENSOR_CONTACT_STATUS_BIT_MASK) {
+ case 0x00:
+ USR_PRT("Sensor Contact feature is not supported in the current connection");
+ break;
+ case 0x02:
+ USR_PRT("Sensor Contact feature is not supported in the current connection");
+ break;
+ case 0x04:
+ USR_PRT("Sensor Contact feature is supported, but contact is not detected ");
+ break;
+ case 0x06:
+ USR_PRT("Sensor Contact feature is supported and contact is detected");
+ break;
+ default:
+ USR_PRT("unreachable code");
+ }
+ if(flags & HR_ENERGY_EXPENDED_BIT_MASK) {
+ USR_PRT("Energy Expended %x %x KJ", value[value_cursor], value[value_cursor + 1]);
+ if((value[value_cursor] == 0xff) && (value[value_cursor + 1] == 0xff))
+ __hr_client_reset_energy_expended();
+ value_cursor += 2;
+ }
+
+ if(flags & HR_RR_INTERVAL_BIT_MASK) {
+ while(value_cursor <= (len - 2)) {
+ USR_PRT("RR Interval %x %x", value[value_cursor], value[value_cursor+1]);
+ value_cursor += 2;
+ }
+ }
+
+}
+
+void __hr_client_print_sensor_loc(bt_gatt_h h)
+{
+ int ret;
+ char *value = NULL;
+ int len = 0;
+
+ ret = bt_gatt_get_value(h, &value, &len);
+ if (ret != BT_ERROR_NONE) {
+ DBG_PRT("bt_gatt_get_value is failed : %d", ret);
+ return;
+ }
+
+ if(len > 1) {
+ DBG_PRT("invalid sensor location value");
+ return;
+ }
+
+ switch(value[0]) {
+ case 0:
+ USR_PRT("location : other");
+ break;
+ case 1:
+ USR_PRT("location : Chest");
+ break;
+ case 2:
+ USR_PRT("location : Wrist");
+ break;
+ case 3:
+ USR_PRT("location : Finger");
+ break;
+ case 4:
+ USR_PRT("location : Hand");
+ break;
+ case 5:
+ USR_PRT("location : Ear Lobe");
+ break;
+ case 6:
+ USR_PRT("location : Foot");
+ break;
+ default:
+ USR_PRT("Invalid Location value.");
+ }
+ g_free(value);
+}
+
+void __hr_client_body_sensor_loc_cb(int result, bt_gatt_h gatt_handle, void *data)
+{
+
+ DBG_PRT("Read %s", result == BT_ERROR_NONE ? "Success" : "Fail");
+
+ if (result != BT_ERROR_NONE)
+ return;
+
+ __hr_client_print_sensor_loc(gatt_handle);
+
+ return;
+}
+void __hr_client_dev_inf_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
+{
+ int ret;
+ char *str = NULL;
+ char *value = NULL;
+ int len = 0;
+ bool hex_format = false;
+ int i;
+
+ if (result != BT_ERROR_NONE) {
+ USR_PRT("error occured in reading");
+ DBG_PRT("error number =%d", result);
+ return;
+ }
+
+ ret = bt_gatt_get_value(gatt_handle, &value, &len);
+ if (ret != BT_ERROR_NONE) {
+ USR_PRT("error occured in reading");
+ DBG_PRT("error number =%d", result);
+ return;
+ }
+
+ for (i = 0; i < len; i++)
+ if (isalnum(value[i]) == 0) {
+ hex_format = true;
+ break;
+ }
+
+ if (hex_format) {
+ str = g_malloc0(len * 5 + 1);
+ for (i = 0; i < len; i++) {
+ if (i > 0)
+ str[i * 5 - 1] = ' ';
+
+ snprintf(&str[i * 5], 5, "0x%02X", value[i]);
+ }
+ } else {
+ str = g_malloc0(len + 1);
+ memcpy(str, value, len);
+ }
+
+ USR_PRT("Value : %s", str);
+
+ g_free(str);
+ g_free(value);
+ return;
+}
+
+bool __hr_client_dev_inf_service_cb(int total, int index, bt_gatt_h chr_handle, void *data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(chr_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ if(!strcasecmp(uuid, manufacture_name_string)){
+ USR_PRT("Reading Manufacturer name. Printed data is in Hexa decimal");
+ } else if(!strcasecmp(uuid, model_number_string)){
+ DBG_PRT("Reading Model Number. Printed data is in Hexa decimal");
+ } else if(!strcasecmp(uuid, serial_number_string)){
+ USR_PRT("Serial Number. Printed data is in Hexa decimaal");
+ } else if(!strcasecmp(uuid, firmware_revision_string)){
+ USR_PRT("Firmware Revision. Printed data is in Hexa decimal");
+ } else if(!strcasecmp(uuid, hardware_revision_string)){
+ USR_PRT("Hardware Rivision. Printed data is in Hexa decimal");
+ } else if(!strcasecmp(uuid, software_revision_string)){
+ USR_PRT("Software revision. Printed data is in Hexa decimaal");
+ } else if(!strcasecmp(uuid, system_id)){
+ USR_PRT("System id. Printed data is in Hexa decimal");
+ USR_PRT("this is a 8 byte value.");
+ USR_PRT("The first 40 bits is Manufacturer Identifier.");
+ USR_PRT("Remaining 24 bits is Organizationally Unique Identifier.");
+ } else if(!strcasecmp(uuid, regulatory_certification_data_list)){
+ USR_PRT("IEEE 11073-20601 Regulatory Certification Data List");
+ USR_PRT("Printed data is a opaque data structure, application to make sense");
+ } else if(!strcasecmp(uuid, PnP_id)){
+ USR_PRT("PnP id. Printed data is in Hexa decimal");
+ USR_PRT("First byte is Vendor ID Source: 0X01 means SIG assigned, 0x02 means USB Implementer Forum");
+ USR_PRT("Next 2 byte is Vendor ID");
+ USR_PRT("Next 2 byte is Product ID");
+ USR_PRT("Next 2 byte is Product version");
+ }
+
+ bt_gatt_client_read_value(chr_handle, __hr_client_dev_inf_read_complete_cb, NULL);
+
+ g_free(str);
+ g_free(uuid);
+
+ return true;
+}
+
+bool __hr_client_hr_service_cb(int total, int index, bt_gatt_h chr_handle, void *data)
+{
+ char *uuid = NULL;
+ char *str = NULL;
+
+ bt_gatt_get_uuid(chr_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &str);
+
+ if(!strcasecmp(uuid, heart_rate_measurement_uuid)){
+ DBG_PRT("Enabling notification for %s characteristic" ,str ? str : "Unknown");
+ if(bt_gatt_client_set_characteristic_value_changed_cb(chr_handle,
+ __hr_client_measurement_cb, NULL) != BT_ERROR_NONE)
+ DBG_PRT("registerinig Notification failed");
+ } else if(!strcasecmp(uuid, body_sensor_location)){
+ DBG_PRT("Reading Body sensor location");
+ bt_gatt_client_read_value(chr_handle, __hr_client_body_sensor_loc_cb, NULL);
+ } else if(!strcasecmp(uuid, heart_rate_control_point)){
+ USR_PRT("Energy Expended feature is supported");
+ if(hr_control_point_handle)
+ g_free(hr_control_point_handle);
+ hr_control_point_handle = g_strdup(chr_handle);
+ }
+ g_free(str);
+ g_free(uuid);
+
+ return true;
+}
+
+bool __hr_client_monitor_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data)
+{
+ char *svc_str = NULL;
+ char *uuid = NULL;
+
+ bt_gatt_get_uuid(svc_handle, &uuid);
+ bt_gatt_get_uuid_specification_name(uuid, &svc_str);
+ DBG_PRT("%s service (uuid = %s)", svc_str ? svc_str : uuid, uuid);
+
+ if(!strcasecmp(uuid, heart_rate_service_uuid)){
+ DBG_PRT("%s service", svc_str ? svc_str : uuid);
+ bt_gatt_service_foreach_characteristics(svc_handle,
+ __hr_client_hr_service_cb, NULL);
+ } else if(!strcasecmp(uuid, device_information_service_uuid)){
+ DBG_PRT("%s service", svc_str ? svc_str : uuid);
+ bt_gatt_service_foreach_characteristics(svc_handle,
+ __hr_client_dev_inf_service_cb, NULL);
+ }
+ g_free(svc_str);
+ g_free(uuid);
+
+ return true;
+}
+void __hr_client_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data)
+{
+ if(!strcmp(remote_address, remote_addr)) {
+ if (connected) {
+ DBG_PRT("Connected to the remote device");
+ test_cursor = BT_GATT_TEST_TABLE_SERVICE;
+ if (gatt_client) {
+ bt_gatt_client_destroy(gatt_client);
+ gatt_client = NULL;
+ if(hr_control_point_handle)
+ g_free(hr_control_point_handle);
+ }
+ if(bt_gatt_client_create(remote_addr, &gatt_client) != BT_ERROR_NONE) {
+ test_cursor = BT_GATT_TEST_UNRECOVERABLE;
+ DBG_PRT("GATT_Client creation failed");
+ return;
+ }
+ if(bt_gatt_client_foreach_services(gatt_client,
+ __hr_client_monitor_svc_cb, NULL) != BT_ERROR_NONE) {
+ test_cursor = BT_GATT_TEST_UNRECOVERABLE;
+ return;
+ }
+ test_cursor = BT_GATT_TEST_TABLE_MONITOR_SERVICES;
+ } else {
+ USR_PRT("Connection to the remote device is removed");
+ USR_PRT("Attempting to re-connect to the device");
+ USR_PRT("Make sure the remote device is turned on and in range");
+ test_cursor = BT_GATT_TEST_TABLE_CONNECTING;
+ bt_gatt_connect(remote_addr, true);
+ }
+ }
+
+}
+
+int __hr_client_validate_input_bd_addr (char *bd_addr)
+{
+ /*have to design better check for validity check of the input*/
+ if (bd_addr == NULL || strlen(bd_addr) < 16) {
+ input_valid = false;
+ return BT_ERROR_INVALID_PARAMETER;
+ }
+ input_valid = true;
+ return BT_ERROR_NONE;
+}
+
+void hr_client_accept_input(char *buf)
+{
+ if (__hr_client_validate_input_bd_addr(buf) != BT_ERROR_NONE) {
+ USR_PRT("invalid bluetooth address");
+ } else {
+ memcpy (remote_addr, buf, 17);
+ remote_addr[17] = 0;
+ if (test_cursor == BT_GATT_TEST_HR_INITIALIZED)
+ __hr_client_initiate_connection();
+ }
+
+}
+int hr_client_initialize(void)
+{
+ int ret = BT_ERROR_NONE;
+ test_cursor = BT_GATT_TEST_HR_INITIALIZATION;
+
+ ret = bt_initialize();
+ if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE)
+ DBG_PRT("Initialized");
+ else
+ goto fail;
+
+ ret = bt_adapter_enable();
+ if(ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE)
+ DBG_PRT("Adapter enabled");
+ else
+ goto fail;
+
+ ret = bt_gatt_set_connection_state_changed_cb(__hr_client_connection_state_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ goto fail;
+
+ test_cursor = BT_GATT_TEST_HR_INITIALIZED;
+ return ret;
+fail:
+ DBG_PRT("Initiailization error returns %d", ret);
+ return ret;
+}
+
+void hr_client_signal_handler(int signno)
+{
+ bt_gatt_disconnect(remote_addr);
+ bt_gatt_unset_connection_state_changed_cb();
+}
+
+gboolean hr_client_key_event_cb(GIOChannel *chan,
+ GIOCondition cond,
+ gpointer data)
+{
+ char buf[BUFFER_LEN] = { 0 };
+ unsigned int len = 0;
+
+ if (g_io_channel_read_chars(chan, buf, sizeof(buf),
+ &len, NULL) == G_IO_STATUS_ERROR) {
+ DBG_PRT("IO Channel read error");
+ return FALSE;
+ }
+
+ if (test_cursor == BT_GATT_TEST_UNRECOVERABLE) {
+ USR_PRT("Unrecoverable error, please reboot");
+ } else if (test_cursor == BT_GATT_TEST_HR_INITIALIZATION) {
+ if(hr_client_initialize() != BT_ERROR_NONE) {
+ USR_PRT("Initialization failed please reboot");
+ } else {
+ DBG_PRT("Initialization is successfull");
+ if(!input_valid) {
+ USR_PRT("In-put remote BD-ADDR in the below format");
+ USR_PRT("00:11:22:33:44:55");
+ test_cursor = BT_GATT_TEST_TABLE_SET_ADDRESS;
+ } else {
+ __hr_client_initiate_connection();
+ }
+ }
+ } else if (test_cursor == BT_GATT_TEST_HR_INITIALIZED) {
+ if(!input_valid) {
+ USR_PRT("In-put remote BD-ADDR in the below format");
+ USR_PRT("00:11:22:33:44:55");
+ test_cursor = BT_GATT_TEST_TABLE_SET_ADDRESS;
+ } else {
+ __hr_client_initiate_connection();
+ }
+ } else if (test_cursor == BT_GATT_TEST_TABLE_SET_ADDRESS) {
+ if (__hr_client_validate_input_bd_addr(buf) != BT_ERROR_NONE) {
+ USR_PRT("invalid bluetooth address");
+ USR_PRT("In-put remote BD-ADDR in the below format");
+ USR_PRT("00:11:22:33:44:55");
+ test_cursor = BT_GATT_TEST_TABLE_SET_ADDRESS;
+ } else {
+ memcpy (remote_addr, buf, 17);
+ remote_addr[17] = 0;
+ __hr_client_initiate_connection();
+ }
+ } else if (test_cursor == BT_GATT_TEST_TABLE_CONNECT) {
+ __hr_client_initiate_connection();
+ USR_PRT("Please wait.. while we connect the device");
+ } else if (test_cursor == BT_GATT_TEST_TABLE_CONNECTING) {
+ USR_PRT("Please wait.. while we connect the device");
+ } else if (test_cursor == BT_GATT_TEST_TABLE_SERVICE) {
+ USR_PRT("Quering supported services..");
+ } else if (test_cursor == BT_GATT_TEST_TABLE_MONITOR_SERVICES) {
+ // DBG_PRT("TODO");
+ }
+
+ return TRUE;
+}
+
diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h
new file mode 100644
index 0000000..fc31f18
--- /dev/null
+++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h
@@ -0,0 +1,64 @@
+
+#include "bt_unit_test_gatt.h"
+
+bt_gatt_client_h gatt_client = NULL;
+char remote_addr[18] = "00:11:22:33:44:55";
+
+/* Mandatory Services for HR profile*/
+
+//Heart Rate service begin
+char *heart_rate_service_uuid = "0000180D-0000-1000-8000-00805F9B34FB";
+/*Mandatory Characteristics for this service, in HR profile*/
+char *heart_rate_measurement_uuid = "00002A37-0000-1000-8000-00805F9B34FB";
+char *body_sensor_location = "00002A38-0000-1000-8000-00805F9B34FB";
+/*optional characteristics for this service, in HR profile */
+char *heart_rate_control_point= "00002A39-0000-1000-8000-00805F9B34FB";
+//Heart Rate service end
+
+//Device Information Service begin
+char *device_information_service_uuid = "0000180A-0000-1000-8000-00805F9B34FB";
+/*Mandatory Characteristics for this service, in HR profile*/
+char *manufacture_name_string = "00002A29-0000-1000-8000-00805F9B34FB";
+/*optional characteristics for this service, in HR profile */
+char *model_number_string = "00002A24-0000-1000-8000-00805F9B34FB";
+char *serial_number_string = "00002A25-0000-1000-8000-00805F9B34FB";
+char *firmware_revision_string = "00002A26-0000-1000-8000-00805F9B34FB";
+char *hardware_revision_string = "00002A27-0000-1000-8000-00805F9B34FB";
+char *software_revision_string = "00002A28-0000-1000-8000-00805F9B34FB";
+char *system_id = "00002A23-0000-1000-8000-00805F9B34FB";
+char *regulatory_certification_data_list = "00002A2A-0000-1000-8000-00805F9B34FB";
+char *PnP_id = "00002A50-0000-1000-8000-00805F9B34FB";
+//Device Information Service end
+
+/* Mandatory Services for HR profile end */
+
+
+/* Optional services for HR profile */
+
+// there are no optional services for this profile
+
+/* Optional services for HR profile end */
+
+
+typedef enum
+{
+ HR_VALUE_FORMAT_MASK = 0x01,
+ HR_SENSOR_CONTACT_STATUS_BIT_MASK = 0x06,
+ HR_ENERGY_EXPENDED_BIT_MASK = 0x08,
+ HR_RR_INTERVAL_BIT_MASK = 0x10,
+}gatt_hr_measurement_property_e;
+
+
+typedef enum
+{
+ BT_GATT_TEST_UNRECOVERABLE = 1,
+ BT_GATT_TEST_INITIALIZATION,
+ BT_GATT_TEST_HR_INITIALIZATION,
+ BT_GATT_TEST_HR_INITIALIZED,
+ BT_GATT_TEST_TABLE_SET_ADDRESS,
+ BT_GATT_TEST_TABLE_CONNECT,
+ BT_GATT_TEST_TABLE_CONNECTING,
+ BT_GATT_TEST_TABLE_SERVICE,
+ BT_GATT_TEST_TABLE_MONITOR_SERVICES,
+ BT_UNIT_TEST_TABLE_FINISH = 0xFF,
+} hr_test_gatt_state_e;
diff --git a/test/gatt_profile_test_suite/capi.network.bluetooth.test.gatt.rule b/test/gatt_profile_test_suite/capi.network.bluetooth.test.gatt.rule
new file mode 100644
index 0000000..096ce47
--- /dev/null
+++ b/test/gatt_profile_test_suite/capi.network.bluetooth.test.gatt.rule
@@ -0,0 +1,2 @@
+capi-network-bluetooth-test-gatt bt-service::public w
+capi-network-bluetooth-test-gatt bt-service::platform rw