From b68511fd70589eefdd4e4d5d5e46bcfce5c95a77 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 9 Feb 2012 14:08:12 +0900 Subject: [PATCH] Merge with lastest private git --- CMakeLists.txt | 3 + TC/_export_env.sh | 15 - TC/_export_target_env.sh | 14 - TC/bluetooth_TC/Makefile | 71 - TC/bluetooth_TC/tslist | 26 - TC/bluetooth_TC/uts_bluetooth_authorize_device.c | 312 ----- TC/bluetooth_TC/uts_bluetooth_authorize_device.h | 52 - TC/bluetooth_TC/uts_bluetooth_bond_device.c | 271 ---- TC/bluetooth_TC/uts_bluetooth_bond_device.h | 49 - TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c | 256 ---- TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h | 48 - TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c | 311 ----- TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h | 48 - .../uts_bluetooth_cancel_service_search.c | 315 ----- .../uts_bluetooth_cancel_service_search.h | 48 - TC/bluetooth_TC/uts_bluetooth_check_adapter.c | 334 ----- TC/bluetooth_TC/uts_bluetooth_check_adapter.h | 49 - TC/bluetooth_TC/uts_bluetooth_disable_adapter.c | 420 ------ TC/bluetooth_TC/uts_bluetooth_disable_adapter.h | 48 - TC/bluetooth_TC/uts_bluetooth_enable_adapter.c | 336 ----- TC/bluetooth_TC/uts_bluetooth_enable_adapter.h | 48 - .../uts_bluetooth_get_bonded_device_list.c | 139 -- .../uts_bluetooth_get_bonded_device_list.h | 49 - .../uts_bluetooth_get_discoverable_mode.c | 267 ---- .../uts_bluetooth_get_discoverable_mode.h | 48 - TC/bluetooth_TC/uts_bluetooth_get_local_address.c | 271 ---- TC/bluetooth_TC/uts_bluetooth_get_local_address.h | 48 - TC/bluetooth_TC/uts_bluetooth_get_local_name.c | 269 ---- TC/bluetooth_TC/uts_bluetooth_get_local_name.h | 48 - TC/bluetooth_TC/uts_bluetooth_get_remote_device.c | 311 ----- TC/bluetooth_TC/uts_bluetooth_get_remote_device.h | 49 - TC/bluetooth_TC/uts_bluetooth_is_discovering.c | 316 ----- TC/bluetooth_TC/uts_bluetooth_is_discovering.h | 48 - TC/bluetooth_TC/uts_bluetooth_register_callback.c | 218 ---- TC/bluetooth_TC/uts_bluetooth_register_callback.h | 48 - TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c | 414 ------ TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h | 57 - .../uts_bluetooth_rfcomm_create_socket.c | 260 ---- .../uts_bluetooth_rfcomm_create_socket.h | 49 - TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c | 304 ----- TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h | 49 - TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c | 239 ---- TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h | 51 - .../uts_bluetooth_rfcomm_remove_socket.c | 265 ---- .../uts_bluetooth_rfcomm_remove_socket.h | 49 - ...ts_bluetooth_rfcomm_sock_deregister_with_uuid.c | 268 ---- ...ts_bluetooth_rfcomm_sock_deregister_with_uuid.h | 48 - .../uts_bluetooth_rfcomm_sock_register_with_uuid.c | 266 ---- .../uts_bluetooth_rfcomm_sock_register_with_uuid.h | 48 - TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c | 391 ------ TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h | 52 - TC/bluetooth_TC/uts_bluetooth_search_service.c | 266 ---- TC/bluetooth_TC/uts_bluetooth_search_service.h | 48 - .../uts_bluetooth_set_discoverable_mode.c | 254 ---- .../uts_bluetooth_set_discoverable_mode.h | 48 - TC/bluetooth_TC/uts_bluetooth_set_local_name.c | 266 ---- TC/bluetooth_TC/uts_bluetooth_set_local_name.h | 48 - TC/bluetooth_TC/uts_bluetooth_start_discovery.c | 378 ------ TC/bluetooth_TC/uts_bluetooth_start_discovery.h | 54 - TC/bluetooth_TC/uts_bluetooth_unbond_device.c | 290 ----- TC/bluetooth_TC/uts_bluetooth_unbond_device.h | 48 - TC/build.sh | 17 - TC/clean.sh | 19 - TC/execute.sh | 17 - TC/making_new_tet_scen.py | 69 - TC/tet_captured | 1 - TC/tet_scen | 31 - TC/tetbuild.cfg | 5 - TC/tetclean.cfg | 5 - TC/tetexec.cfg | 5 - TC/tslist.txt | 1 - bluetooth-frwk-agent/CMakeLists.txt | 1 - bluetooth-frwk-agent/bluetooth-agent-cb.c | 5 +- bluetooth-frwk-agent/sc_core_agent.c | 85 ++ bluetooth-frwk-agent/sc_core_agent.xml | 10 + bluetooth-map-agent/bluetooth_map_agent.c | 701 +++++----- bluetooth-map-agent/bluetooth_map_agent.xml | 2 +- bluetooth-media-control/CMakeLists.txt | 7 +- .../bluetooth-media-control-api.c | 633 --------- bluetooth-media-control/bluetooth-media-control.c | 171 +++ ...dia-control-api.h => bluetooth-media-control.h} | 110 +- bluetooth-media-control/test/CMakeLists.txt | 34 - .../test/bluetooth-media-control-test.c | 228 ---- bluetooth-pb-agent/CMakeLists.txt | 2 - bluetooth-pb-agent/bluetooth_pb_agent.c | 136 +- bluetooth-pb-agent/bluetooth_pb_agent.xml | 6 + debian/bluetooth-frwk-test.install.in | 1 - debian/changelog | 8 + debian/control | 6 - debian/rules | 3 + lib/CMakeLists.txt | 10 +- lib/bluetooth-api-common.c | 16 +- lib/bluetooth-api-common.h | 15 + lib/bluetooth-api.h | 208 ++- lib/bluetooth-gap-api.c | 270 +++- lib/bluetooth-hdp-api.c | 67 +- lib/bluetooth-hid-api.c | 446 +++++++ lib/bluetooth-hid-api.h | 148 +++ lib/bluetooth-network-api.c | 15 +- lib/bluetooth-obex-server-api.c | 374 +++--- lib/bluetooth-obex-server-api.h | 10 +- lib/bluetooth-opc-api.c | 4 +- lib/bluetooth-rfcomm-api.c | 178 ++- lib/bluetooth-sdp-api.c | 151 +-- lib/obex-agent.c | 2 +- lib/test/CMakeLists.txt | 34 - lib/test/bluetooth-frwk-test.c | 1356 -------------------- packaging/bluetooth-frwk.spec | 13 - 108 files changed, 2310 insertions(+), 13039 deletions(-) delete mode 100644 TC/_export_env.sh delete mode 100644 TC/_export_target_env.sh delete mode 100644 TC/bluetooth_TC/Makefile delete mode 100644 TC/bluetooth_TC/tslist delete mode 100644 TC/bluetooth_TC/uts_bluetooth_authorize_device.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_authorize_device.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_bond_device.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_bond_device.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_check_adapter.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_check_adapter.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_disable_adapter.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_disable_adapter.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_enable_adapter.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_enable_adapter.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_local_address.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_local_address.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_local_name.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_local_name.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_remote_device.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_get_remote_device.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_is_discovering.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_is_discovering.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_register_callback.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_register_callback.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_search_service.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_search_service.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_set_local_name.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_set_local_name.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_start_discovery.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_start_discovery.h delete mode 100644 TC/bluetooth_TC/uts_bluetooth_unbond_device.c delete mode 100644 TC/bluetooth_TC/uts_bluetooth_unbond_device.h delete mode 100644 TC/build.sh delete mode 100644 TC/clean.sh delete mode 100755 TC/execute.sh delete mode 100755 TC/making_new_tet_scen.py delete mode 100644 TC/tet_captured delete mode 100644 TC/tet_scen delete mode 100644 TC/tetbuild.cfg delete mode 100644 TC/tetclean.cfg delete mode 100644 TC/tetexec.cfg delete mode 100644 TC/tslist.txt delete mode 100644 bluetooth-media-control/bluetooth-media-control-api.c create mode 100644 bluetooth-media-control/bluetooth-media-control.c rename bluetooth-media-control/{bluetooth-media-control-api.h => bluetooth-media-control.h} (58%) delete mode 100644 bluetooth-media-control/test/CMakeLists.txt delete mode 100644 bluetooth-media-control/test/bluetooth-media-control-test.c delete mode 100644 debian/bluetooth-frwk-test.install.in create mode 100644 lib/bluetooth-hid-api.c create mode 100644 lib/bluetooth-hid-api.h delete mode 100644 lib/test/CMakeLists.txt delete mode 100644 lib/test/bluetooth-frwk-test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index fca953f..179cde8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # API library ADD_SUBDIRECTORY(lib) +# API library +ADD_SUBDIRECTORY(bluetooth-media-control) + # Bluetooth FW Agent ADD_SUBDIRECTORY(bluetooth-frwk-agent) diff --git a/TC/_export_env.sh b/TC/_export_env.sh deleted file mode 100644 index 3c478e2..0000000 --- a/TC/_export_env.sh +++ /dev/null @@ -1,15 +0,0 @@ -export ARCH=target - -CURRENT_USER=`echo $HOME` -export TET_INSTALL_PATH=$CURRENT_USER/sbs/TETware # tetware root path -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH - -export TET_ROOT=$TET_TARGET_PATH - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh deleted file mode 100644 index ad0b28f..0000000 --- a/TC/_export_target_env.sh +++ /dev/null @@ -1,14 +0,0 @@ -export ARCH=target - -export TET_INSTALL_PATH=/mnt/nfs/sbs/TETware # path to mount -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH - -export TET_ROOT=$TET_TARGET_PATH - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/TC/bluetooth_TC/Makefile b/TC/bluetooth_TC/Makefile deleted file mode 100644 index 56fc34f..0000000 --- a/TC/bluetooth_TC/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -PKG_CONFIG_PATH=/usr/lib/pkgconfig -export PKG_CONFIG_PATH -CC ?= gcc - -################################################### -# add your TestCase List Here -# -# e.g., -# TC1 = utc_frameworkName_apiName_func -# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func -TARGETS = uts_bluetooth_register_callback \ -uts_bluetooth_check_adapter \ -uts_bluetooth_enable_adapter \ -uts_bluetooth_authorize_device \ -uts_bluetooth_start_discovery \ -uts_bluetooth_cancel_discovery \ -uts_bluetooth_bond_device \ -uts_bluetooth_search_service \ -uts_bluetooth_cancel_service_search \ -uts_bluetooth_get_bonded_device_list \ -uts_bluetooth_unbond_device \ -uts_bluetooth_cancel_bonding \ -uts_bluetooth_get_discoverable_mode \ -uts_bluetooth_get_local_address \ -uts_bluetooth_get_local_name \ -uts_bluetooth_get_remote_device \ -uts_bluetooth_set_discoverable_mode \ -uts_bluetooth_set_local_name \ -uts_bluetooth_is_discovering \ -uts_bluetooth_rfcomm_create_socket \ -uts_bluetooth_rfcomm_remove_socket \ -uts_bluetooth_rfcomm_listen \ -uts_bluetooth_rfcomm_connect \ -uts_bluetooth_rfcomm_disconnect \ -uts_bluetooth_rfcomm_write \ -uts_bluetooth_disable_adapter - -################################################### -# add your Package Config Info Here -# -# e.g., -# PKGS=calendar -PKGS=bluetooth-api glib-2.0 - -LDFLAGS = `pkg-config --libs $(PKGS)` -LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s - -CFLAGS = -I. `pkg-config --cflags $(PKGS)` -CFLAGS += -I$(TET_ROOT)/inc/tet3 -CFLAGS += -Wall - -################################################### -# Modify here -# depending on the Test Case you want to build -# -# e.g., -# TCLIST = $(TC1) $(TC2) - - -all: $(TARGETS) - -$(TARGETS): %: %.c - $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) - -clean: - rm -f $(TARGETS) - rm -f tet_captured - rm -f tet_lock - rm -f *~ diff --git a/TC/bluetooth_TC/tslist b/TC/bluetooth_TC/tslist deleted file mode 100644 index d76baef..0000000 --- a/TC/bluetooth_TC/tslist +++ /dev/null @@ -1,26 +0,0 @@ -uts_bluetooth_register_callback -uts_bluetooth_check_adapter -uts_bluetooth_enable_adapter -uts_bluetooth_authorize_device -uts_bluetooth_start_discovery -uts_bluetooth_cancel_discovery -uts_bluetooth_bond_device -uts_bluetooth_search_service -uts_bluetooth_cancel_service_search -uts_bluetooth_get_bonded_device_list -uts_bluetooth_unbond_device -uts_bluetooth_cancel_bonding -uts_bluetooth_get_discoverable_mode -uts_bluetooth_get_local_address -uts_bluetooth_get_local_name -uts_bluetooth_get_remote_device -uts_bluetooth_set_discoverable_mode -uts_bluetooth_set_local_name -uts_bluetooth_is_discovering -uts_bluetooth_rfcomm_create_socket -uts_bluetooth_rfcomm_remove_socket -uts_bluetooth_rfcomm_listen -uts_bluetooth_rfcomm_connect -uts_bluetooth_rfcomm_disconnect -uts_bluetooth_rfcomm_write -uts_bluetooth_disable_adapter diff --git a/TC/bluetooth_TC/uts_bluetooth_authorize_device.c b/TC/bluetooth_TC/uts_bluetooth_authorize_device.c deleted file mode 100644 index 99837e4..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_authorize_device.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_authorize_device.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_authorize_device_1(void) -{ - bluetooth_device_address_t device_address={{0}}; - gboolean authorized; - int return_17; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - authorized =TRUE; - return_17=bluetooth_authorize_device(NULL,authorized); - if( return_17>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_authorize_device_2(void) -{ - bluetooth_device_address_t device_address={{0}}; - gboolean authorized; - int return_17; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - authorized=FALSE; - return_17=bluetooth_authorize_device(NULL,authorized); - if( return_17>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -#if 0 -void utc_bluetooth_authorize_device_3(void) -{ - bluetooth_device_address_t* device_address; - gboolean authorized; - int return_17; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_17=bluetooth_authorize_device(NULL, 0); - if( return_17>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#endif diff --git a/TC/bluetooth_TC/uts_bluetooth_authorize_device.h b/TC/bluetooth_TC/uts_bluetooth_authorize_device.h deleted file mode 100644 index 321bef3..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_authorize_device.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -//#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_authorize_device_1(void); - - void utc_bluetooth_authorize_device_2(void); - - void utc_bluetooth_authorize_device_3(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_authorize_device_1,1}, - { utc_bluetooth_authorize_device_2,2}, -// { utc_bluetooth_authorize_device_3,3}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_bond_device.c b/TC/bluetooth_TC/uts_bluetooth_bond_device.c deleted file mode 100644 index 0637a73..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_bond_device.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_bond_device.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - - g_main_loop_quit (main_loop); - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_bond_device_1(void) -{ - //Replace the below BD address with the remote device BD address - bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}}; // SGH-W240(orange) - - int return_12; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_12=bluetooth_bond_device(&device_address); - if( return_12<0) - { - tet_printf("Api failed: %d", return_12); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); - } -} - -void utc_bluetooth_bond_device_2(void) -{ - bluetooth_device_address_t* device_address; - int return_12; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - //device_address=NULL; - return_12=bluetooth_bond_device(NULL); - if( return_12>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_bond_device.h b/TC/bluetooth_TC/uts_bluetooth_bond_device.h deleted file mode 100644 index 96744ad..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_bond_device.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -//#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_bond_device_1(void); - - void utc_bluetooth_bond_device_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_bond_device_1,1}, - { utc_bluetooth_bond_device_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c b/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c deleted file mode 100644 index 9bd1ba8..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_cancel_bonding.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_cancel_bonding_1(void) -{ - int return_13; - int ret_val; - - //Replace the below BD address with the remote device BD address - bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - return_13=bluetooth_bond_device(&device_address); - - return_13=bluetooth_cancel_bonding(); - if( return_13<0) - { - tet_printf("Api failed: %d", return_13); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - -void utc_bluetooth_cancel_bonding_2(void) -{ - - int return_13; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) { - tet_printf("bluetooth_register_callback returned Success"); - } else { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - return 0; - } - - ret_val = bluetooth_check_adapter(); - - if (ret_val < BLUETOOTH_ERROR_NONE) - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - else - TC_PRT("BT state [0x%04x]", ret_val); - - return_13 = bluetooth_cancel_bonding(); - - if (return_13 < 0) { - tet_printf("Api failed: %d", return_13); - tet_result(TET_FAIL); - } else { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h b/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h deleted file mode 100644 index 055c8b0..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_cancel_bonding_1(void); - - void utc_bluetooth_cancel_bonding_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_cancel_bonding_1,1}, - { utc_bluetooth_cancel_bonding_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c b/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c deleted file mode 100644 index 7c53ba4..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_cancel_discovery.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -int thread_callback(void) -{ - int return_10; - printf("thread_callback\n"); - sleep(1); - return_10=bluetooth_cancel_discovery(); - if( return_10<0) - { - tet_printf("Api failedret_val=%d\nreturn_10=%d\n",return_10); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - g_main_loop_quit (main_loop); - return 0; - -} - - -void utc_bluetooth_cancel_discovery_1(void) -{ - unsigned max_response; - unsigned discovery_duration; - unsigned classOfDeviceMask; - int return_10; - int ret_val; - int ret = 0; - pthread_attr_t tattr;// = {0}; - pthread_t thread_id; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - // Stop discovery if BT is in discovering. - bluetooth_cancel_discovery(); - - max_response =0; - discovery_duration =0; - classOfDeviceMask =0; - ret_val=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - - ret = pthread_attr_init(&tattr); - if (ret == 0) - { - pthread_attr_setstacksize(&tattr, 131072); - ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - if(ret == 0) - { - ret = pthread_create(&thread_id, &tattr, - thread_callback, NULL); - if (ret != 0) - { - tet_printf( "Failed to create thread\n"); - } - } - - } - else - { - tet_printf( "Failed to initialize thread attribute\n"); - } - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} - -void utc_bluetooth_cancel_discovery_2(void) -{ - - int return_10; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - - return_10=bluetooth_cancel_discovery(); - if( return_10 >= 0) - { - tet_printf("Api failed: %d", return_10); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h b/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h deleted file mode 100644 index 736bf56..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_cancel_discovery_1(void); - - void utc_bluetooth_cancel_discovery_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_cancel_discovery_1,1}, - { utc_bluetooth_cancel_discovery_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c b/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c deleted file mode 100644 index b6d26b9..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_cancel_service_search.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - case BLUETOOTH_EVENT_SERVICE_SEARCHED: - { - printf("BLUETOOTH_EVENT_SERVICE_SEARCHED\n"); - break; - } - default: - { - TC_PRT("received event [0x%04x]", event); - printf("received event [0x%04x]", event); - } - break; - } -} - -int thread_callback(void) -{ - int return_10; - printf("thread_callback\n"); - - return_10=bluetooth_cancel_service_search(); - - if( return_10<0) - { - tet_printf("Api failedret_val=%d\n",return_10); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - sleep(1); - g_main_loop_quit (main_loop); - return 0; - -} - - -// Not proper case. The device is not general. -// This will be always failed. -/*How to test: pair devices . switch of BT in remote device . from native device initiate service search , as remote device is switch off native device will keep on searching for services, - then native device initiates cancel service search -*/ -#if 0 -void utc_bluetooth_cancel_service_search_1(void) -{ - //Replace the below BD address with the device address of remote. - bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - int return_19; - int ret_val; - int ret=0; - pthread_attr_t tattr;// = {0}; - pthread_t thread_id; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_19=bluetooth_search_service(&device_address); - printf("bluetooth_search_service return=%d\n",return_19); - - ret = pthread_attr_init(&tattr); - if (ret == 0) - { - pthread_attr_setstacksize(&tattr, 131072); - ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - if(ret == 0) - { - ret = pthread_create(&thread_id, &tattr, thread_callback, NULL); - if (ret != 0) - { - tet_printf( "Failed to create thread\n"); - } - } - - } - else - { - tet_printf( "Failed to initialize thread attribute\n"); - } - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); - -} -#endif - -void utc_bluetooth_cancel_service_search_1(void) -{ - - int return_19; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_19=bluetooth_cancel_service_search(); - if( return_19>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h b/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h deleted file mode 100644 index 3d13312..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_cancel_service_search_1(void); - - void utc_bluetooth_cancel_service_search_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_cancel_service_search_1,1}, -// { utc_bluetooth_cancel_service_search_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_check_adapter.c b/TC/bluetooth_TC/uts_bluetooth_check_adapter.c deleted file mode 100644 index 6d0eba2..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_check_adapter.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_check_adapter.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -pthread_t thread_t; -pthread_attr_t tattr;// = {0}; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) -// { - // g_main_loop_unref(main_loop); -// } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -int enable_thread_callback(void) -{ - int return_3; - printf("thread_callback\n"); - sleep(4); - printf("1\n"); - return_3=bluetooth_check_adapter(); - printf("2\n"); - if( return_3!=BLUETOOTH_ADAPTER_ENABLED) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - g_main_loop_quit (main_loop); - return 0; - -} - -int disable_thread_callback(void) -{ - int return_3; - printf("thread_callback\n"); - sleep(4); - printf("1\n"); - return_3=bluetooth_check_adapter(); - printf("2\n"); - if( return_3!=BLUETOOTH_ADAPTER_DISABLED) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - g_main_loop_quit (main_loop); - return 0; - -} - - -void utc_bluetooth_check_adapter_1(void) -{ - - int return_3; - int ret_val; - int ret=0; - pthread_attr_t tattr;// = {0}; - pthread_t thread_id; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - return_3=bluetooth_check_adapter(); - - printf("2\n"); - if( return_3 < BLUETOOTH_ADAPTER_DISABLED || return_3 > BLUETOOTH_ADAPTER_CHANGING_DISABLE) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - -/* - bluetooth_enable_adapter(); - - ret = pthread_attr_init(&tattr); - if (ret == 0) - { - pthread_attr_setstacksize(&tattr, 131072); - ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - if(ret == 0) - { - ret = pthread_create(&thread_id, &tattr, - enable_thread_callback, NULL); - if (ret != 0) - { - tet_printf( "Failed to create thread\n"); - } - } - - } - else - { - tet_printf( "Failed to initialize thread attribute\n"); - } - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -*/ -} - -void utc_bluetooth_check_adapter_2(void) -{ - int return_3; - int ret_val; - int ret=0; - pthread_attr_t tattr;// = {0}; - pthread_t thread_id; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - bluetooth_disable_adapter(); - - ret = pthread_attr_init(&tattr); - if (ret == 0) - { - pthread_attr_setstacksize(&tattr, 131072); - ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - if(ret == 0) - { - ret = pthread_create(&thread_id, &tattr, - disable_thread_callback, NULL); - if (ret != 0) - { - tet_printf( "Failed to create thread\n"); - } - } - - } - else - { - tet_printf( "Failed to initialize thread attribute\n"); - } - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} diff --git a/TC/bluetooth_TC/uts_bluetooth_check_adapter.h b/TC/bluetooth_TC/uts_bluetooth_check_adapter.h deleted file mode 100644 index c73fa00..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_check_adapter.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -//#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_check_adapter_1(void); - - void utc_bluetooth_check_adapter_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_check_adapter_1,1}, -// { utc_bluetooth_check_adapter_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.c b/TC/bluetooth_TC/uts_bluetooth_disable_adapter.c deleted file mode 100644 index 516787c..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_disable_adapter.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); -} - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); -// g_main_loop_quit(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - int return_2; - - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - return_2=bluetooth_disable_adapter(); - - - if (main_loop) - g_main_loop_quit(main_loop); - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - return_2=bluetooth_disable_adapter(); - if( return_2>=0) - { - tet_printf("Api Failed= %d\n",return_2); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - } - - if (main_loop) - g_main_loop_quit(main_loop); - - if (main_loop) - g_main_loop_quit(main_loop); - - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - -void bt_event_callback2(int event, bluetooth_event_param_t* param, void *user_data) -{ - int return_2; - - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - return_2=bluetooth_disable_adapter(); - if( return_2>=0) - { - tet_printf("Api Failed= %d\n",return_2); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - } - - if (main_loop) - g_main_loop_quit(main_loop); - - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - -void utc_bluetooth_disable_adapter_1(void) -{ - int return_2; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - if(bluetooth_enable_adapter()==BLUETOOTH_ERROR_NONE) - { - - } - else - bluetooth_disable_adapter(); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); - -// if(main_loop != NULL) -// { -// g_main_loop_unref(main_loop); -// } - - -// return_2=bluetooth_enable_adapter(); -/* - return_2=bluetooth_disable_adapter(); - if( return_2<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -*/ -} - -void utc_bluetooth_disable_adapter_2(void) -{ - - int return_2; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback2, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - //bluetooth_disable_adapter(); - return_2=bluetooth_disable_adapter(); - if( return_2>=0) - { - tet_printf("Api Failed= %d\n",return_2); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - -} diff --git a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.h b/TC/bluetooth_TC/uts_bluetooth_disable_adapter.h deleted file mode 100644 index 1d18b1f..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_disable_adapter_1(void); - - void utc_bluetooth_disable_adapter_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_disable_adapter_1,1}, - { utc_bluetooth_disable_adapter_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.c b/TC/bluetooth_TC/uts_bluetooth_enable_adapter.c deleted file mode 100644 index 9548932..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_enable_adapter.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - - if (param->result == BLUETOOTH_ERROR_NONE) - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - else - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - - if (main_loop) - g_main_loop_quit(main_loop); - - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_enable_adapter(); - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -void bt_event_callback2(int event, bluetooth_event_param_t* param, void *user_data) -{ - int return_1; - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - - if (param->result == BLUETOOTH_ERROR_NONE) - { - return_1=bluetooth_enable_adapter(); - if(return_1<0) - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - else - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - } - else - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - - if (main_loop) - g_main_loop_quit(main_loop); - - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - -void utc_bluetooth_enable_adapter_1(void) -{ - int return_1; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else if (ret_val == BLUETOOTH_ADAPTER_ENABLED) - { - TC_PRT("BT state [0x%04x]", ret_val); - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - return_1=bluetooth_enable_adapter(); - - if(BLUETOOTH_ERROR_NONE!=return_1) - { - bluetooth_disable_adapter(); - } - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -/* - if( return_1<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -*/ -} - -void utc_bluetooth_enable_adapter_2(void) -{ - - int return_1; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback2, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - return_1=bluetooth_enable_adapter(); - if(BLUETOOTH_ERROR_NONE!=return_1) - { - //bluetooth_disable_adapter(); - tet_printf("Api passed"); - tet_result(TET_PASS); - } - else - { - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); - } - -} diff --git a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.h b/TC/bluetooth_TC/uts_bluetooth_enable_adapter.h deleted file mode 100644 index 8ca28e3..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_enable_adapter_1(void); - - void utc_bluetooth_enable_adapter_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_enable_adapter_1,1}, - { utc_bluetooth_enable_adapter_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c b/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c deleted file mode 100644 index c5087eb..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_get_bonded_device_list.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); -} - - -void cleanup() -{ - tet_printf("bluetooth framework TC cleanup"); -} - -void utc_bluetooth_get_bonded_device_list_1(void) -{ - - int return_15; - int ret_val; - - GPtrArray *devinfo = NULL; - - devinfo = g_ptr_array_new(); - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_15=bluetooth_get_bonded_device_list(&devinfo); - if(return_15len;i++) - { - ptr = g_ptr_array_index(devinfo, i); - if(ptr != NULL) - { - TC_PRT("Name [%s]", ptr->device_name.name); - TC_PRT("Major Class [%d]", ptr->device_class.major_class); - TC_PRT("Minor Class [%d]", ptr->device_class.minor_class); - TC_PRT("Service Class [%d]", ptr->device_class.service_class); - TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]); - TC_PRT("\n"); - } - } - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - g_ptr_array_free(devinfo, TRUE); -} - -void utc_bluetooth_get_bonded_device_list_2(void) -{ - int return_15; - int ret_val; - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_15=bluetooth_get_bonded_device_list(NULL); - if(return_15==BLUETOOTH_ERROR_INVALID_PARAM) - { - tet_printf("Api failed"); - tet_result(TET_PASS); - } - else - { - tet_printf("Api passed"); - tet_result(TET_FAIL); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h b/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h deleted file mode 100644 index 05a1f73..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_get_bonded_device_list_1(void); - - void utc_bluetooth_get_bonded_device_list_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_get_bonded_device_list_1,1}, - { utc_bluetooth_get_bonded_device_list_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c b/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c deleted file mode 100644 index 2a0533a..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_get_discoverable_mode.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_get_discoverable_mode_1(void) -{ - bluetooth_discoverable_mode_t discoverable_mode_ptr; - bluetooth_discoverable_mode_t mode; - int return_7; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - mode = 3; - - return_7=bluetooth_set_discoverable_mode(mode, 60); // 60 seconds - - return_7=bluetooth_get_discoverable_mode(&discoverable_mode_ptr); - if( return_7<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_get_discoverable_mode_2(void) -{ - bluetooth_discoverable_mode_t* discoverable_mode_ptr; - int return_7; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - discoverable_mode_ptr=NULL; - return_7=bluetooth_get_discoverable_mode(discoverable_mode_ptr); - if( return_7>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h b/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h deleted file mode 100644 index e54f91f..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_get_discoverable_mode_1(void); - - void utc_bluetooth_get_discoverable_mode_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_get_discoverable_mode_1,1}, - { utc_bluetooth_get_discoverable_mode_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_address.c b/TC/bluetooth_TC/uts_bluetooth_get_local_address.c deleted file mode 100644 index 4fa4d8f..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_local_address.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_get_local_address.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_get_local_address_1(void) -{ - bluetooth_device_address_t local_address; - //Replace the below BD address with the remote device BD address - bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - int return_4; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_4=bluetooth_bond_device(&device_address); - - return_4=bluetooth_get_local_address(&local_address); - if( return_4<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_get_local_address_2(void) -{ - bluetooth_device_address_t* local_address; - int return_4; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - local_address=NULL; - return_4=bluetooth_get_local_address(local_address); - if( return_4>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_address.h b/TC/bluetooth_TC/uts_bluetooth_get_local_address.h deleted file mode 100644 index 8381438..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_local_address.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_get_local_address_1(void); - - void utc_bluetooth_get_local_address_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_get_local_address_1,1}, - { utc_bluetooth_get_local_address_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_name.c b/TC/bluetooth_TC/uts_bluetooth_get_local_name.c deleted file mode 100644 index 181b0b4..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_local_name.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_get_local_name.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_get_local_name_1(void) -{ - bluetooth_device_name_t local_name={{"local Name"}}; - - int return_5; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_5=bluetooth_set_local_name(&local_name); - - return_5=bluetooth_get_local_name(&local_name); - if( return_5<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_get_local_name_2(void) -{ - bluetooth_device_name_t* local_name; - int return_5; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_5=bluetooth_get_local_name(NULL); - if( return_5>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_name.h b/TC/bluetooth_TC/uts_bluetooth_get_local_name.h deleted file mode 100644 index 8a4e912..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_local_name.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_get_local_name_1(void); - - void utc_bluetooth_get_local_name_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_get_local_name_1,1}, - { utc_bluetooth_get_local_name_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.c b/TC/bluetooth_TC/uts_bluetooth_get_remote_device.c deleted file mode 100644 index 6a2d8fa..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_get_remote_device.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - -// Not support API -#if 0 -void utc_bluetooth_get_remote_device_1(void) -{ - bluetooth_device_address_t device_address; - int return_16; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_16=bluetooth_get_remote_device(&device_address); - if( return_16<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#endif - -void utc_bluetooth_get_remote_device_1(void) -{ - const bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - int return_16; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - //device_address=NULL; - return_16=bluetooth_get_remote_device(&device_address); - if( return_16<0) - { - tet_printf("Api failed: %d", return_16); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_get_remote_device_2(void) -{ - bluetooth_device_address_t* device_address; - int return_16; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - device_address=NULL; - return_16=bluetooth_get_remote_device(device_address); - if( return_16>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.h b/TC/bluetooth_TC/uts_bluetooth_get_remote_device.h deleted file mode 100644 index e090941..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_get_remote_device_1(void); - - void utc_bluetooth_get_remote_device_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_get_remote_device_1,1}, - { utc_bluetooth_get_remote_device_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_is_discovering.c b/TC/bluetooth_TC/uts_bluetooth_is_discovering.c deleted file mode 100644 index 695e510..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_is_discovering.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_is_discovering.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); - g_main_loop_quit(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - if (main_loop) - g_main_loop_quit(main_loop); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -int thread_callback(void) -{ - int return_11; - printf("thread_callback\n"); - sleep(1); - return_11=bluetooth_is_discovering(); - if( return_11==0) - { - tet_printf("Api failed,=%d\n",return_11); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - // let the discovery stop before quit so that when utc_bluetooth_is_discovering_2 is called discovery should be off - bluetooth_cancel_discovery(); - - g_main_loop_quit (main_loop); - return 0; - -} - - -void utc_bluetooth_is_discovering_1(void) -{ - int return_11; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_11=bluetooth_is_discovering(); - if( return_11==1) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_is_discovering_2(void) -{ - unsigned max_response; - unsigned discovery_duration; - unsigned classOfDeviceMask; - int return_11; - int ret_val; - int ret=0; - pthread_attr_t tattr;// = {0}; - pthread_t thread_id; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - max_response =0; - discovery_duration =0; - classOfDeviceMask =0; - return_11=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - - ret = pthread_attr_init(&tattr); - if (ret == 0) - { - pthread_attr_setstacksize(&tattr, 131072); - ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - if(ret == 0) - { - ret = pthread_create(&thread_id, &tattr, - thread_callback, NULL); - if (ret != 0) - { - tet_printf( "Failed to create thread\n"); - } - } - - } - else - { - tet_printf( "Failed to initialize thread attribute\n"); - } - - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} - diff --git a/TC/bluetooth_TC/uts_bluetooth_is_discovering.h b/TC/bluetooth_TC/uts_bluetooth_is_discovering.h deleted file mode 100644 index 9f4e64e..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_is_discovering.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_is_discovering_1(void); - - void utc_bluetooth_is_discovering_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_is_discovering_1,1}, - { utc_bluetooth_is_discovering_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_register_callback.c b/TC/bluetooth_TC/uts_bluetooth_register_callback.c deleted file mode 100644 index 09be1a0..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_register_callback.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_register_callback.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_register_callback_1(void) -{ - bluetooth_cb_func_ptr callback_ptr; - int return_0; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - tet_result(TET_PASS); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - tet_result(TET_FAIL); - return 0; - } -} - -void utc_bluetooth_register_callback_2(void) -{ - bluetooth_cb_func_ptr callback_ptr; - int return_0; - int ret_val; - - ret_val = bluetooth_register_callback(NULL, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - tet_result(TET_PASS); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - tet_result(TET_FAIL); - return 0; - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_register_callback.h b/TC/bluetooth_TC/uts_bluetooth_register_callback.h deleted file mode 100644 index add468b..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_register_callback.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_register_callback_1(void); - - void utc_bluetooth_register_callback_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_register_callback_1,1}, - { utc_bluetooth_register_callback_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c deleted file mode 100644 index 1247d12..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_connect.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; -int g_ret_client_fd1 = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: - { - bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data; - TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result, - con_ind->socket_fd, - con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2], - con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5], - (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT"); - //tc_result(TC_PASS, 22); - if(con_ind->device_role == RFCOMM_ROLE_CLIENT) - g_ret_client_fd1 = con_ind->socket_fd; - - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -void uts_bluetooth_rfcomm_connect_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - - //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; - //remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_connect(&remote_address, NULL); - printf("sk=%x\n",sk); - if( return_22>=0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void uts_bluetooth_rfcomm_connect_2(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - const bluetooth_device_address_t remote_address={{0}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - - //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x00; remote_address.addr[2] = 0x00; - //remote_address.addr[3]= 0x00; remote_address.addr[4] = 0x00; remote_address.addr[5]= 0x00; - - return_22= bluetooth_rfcomm_connect(NULL, rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#if 0 -void uts_bluetooth_rfcomm_connect_3(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - - return_22= bluetooth_rfcomm_connect(NULL, rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#endif -void uts_bluetooth_rfcomm_connect_4(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - //Replace the below BD address with the remote device BD address - - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - - //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0D; remote_address.addr[2] = 0x18; - //remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x24; remote_address.addr[5]= 0x47; - - return_22= bluetooth_rfcomm_connect(&remote_address, "00000000-0000-0000-0000-000000000000"); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#if 0 -void uts_bluetooth_rfcomm_connect_5(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - - return_22= bluetooth_rfcomm_connect(NULL, NULL); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#endif diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h deleted file mode 100644 index a9b2863..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - -void uts_bluetooth_rfcomm_connect_1(void); -void uts_bluetooth_rfcomm_connect_2(void); -//void uts_bluetooth_rfcomm_connect_3(void); -void uts_bluetooth_rfcomm_connect_4(void); -//void uts_bluetooth_rfcomm_connect_5(void); - - - void uts_bluetooth_rfcomm_create_sock_2(void); - - struct tet_testlist tet_testlist[] = { - { uts_bluetooth_rfcomm_connect_1,1}, - { uts_bluetooth_rfcomm_connect_2,2}, -// { uts_bluetooth_rfcomm_connect_3,3}, - { uts_bluetooth_rfcomm_connect_4,3}, -// { uts_bluetooth_rfcomm_connect_5,5}, - {NULL,0} - }; - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c deleted file mode 100644 index 228868e..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_create_socket.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void uts_bluetooth_rfcomm_create_sock_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - return_22= sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); - if( return_22<0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void uts_bluetooth_rfcomm_create_sock_2(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - return_22=bluetooth_rfcomm_create_socket(NULL); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h deleted file mode 100644 index bba8e9e..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void uts_bluetooth_rfcomm_create_sock_1(void); - - void uts_bluetooth_rfcomm_create_sock_2(void); - - struct tet_testlist tet_testlist[] = { - { uts_bluetooth_rfcomm_create_sock_1,1}, - { uts_bluetooth_rfcomm_create_sock_2,2}, - {NULL,0} - }; - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c deleted file mode 100644 index b938b49..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_disconnect.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; -int g_ret_client_fd1 = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); -// main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: - { - int return_22; - bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data; - TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result, - con_ind->socket_fd, - con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2], - con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5], - (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT"); - //tc_result(TC_PASS, 22); - tet_printf("g_ret_client_fd1=%d\nconn_ind->socket_fd %d\n",g_ret_client_fd1,con_ind->socket_fd); - tet_printf("con_ind->device_role=%d\n",con_ind->device_role); - if(con_ind->device_role == RFCOMM_ROLE_CLIENT) - g_ret_client_fd1 = con_ind->socket_fd; - - return_22=bluetooth_rfcomm_disconnect( g_ret_client_fd1); - if( return_22<0) - { - tet_printf("BLUETOOTH_EVENT_RFCOMM_CONNECTED Api failed, return_22=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - g_main_loop_quit (main_loop); -// if( main_loop!= NULL) -// { -// g_main_loop_unref(main_loop); -// } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - -#if 0 -void uts_bluetooth_rfcomm_disconnect_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - ret_val = bluetooth_register_callback(bt_event_callback); -// main_loop = g_main_loop_new(NULL, FALSE); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp); - tet_printf(" bluetooth_rfcomm_connectApi , return_22=%d\n",return_22); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} -#endif - -void uts_bluetooth_rfcomm_disconnect_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -/*Mention bd address of device to which you want to connect*/ -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - //bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp); - - return_22=bluetooth_rfcomm_disconnect( -1); - printf("sk=%x\n",sk); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h deleted file mode 100644 index 7316f19..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void uts_bluetooth_rfcomm_disconnect_1(void); - - void uts_bluetooth_rfcomm_disconnect_2(void); - - struct tet_testlist tet_testlist[] = { - { uts_bluetooth_rfcomm_disconnect_1,1}, -// { uts_bluetooth_rfcomm_disconnect_2,2}, - {NULL,0} - }; - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c deleted file mode 100644 index fe784e6..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_listen.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: - { - TC_PRT("BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED, result [0x%04x]", param->result); - bluetooth_rfcomm_received_data_t *rx_data = param->param_data; - printf("\n FD = %d \nBuffer len = %d ", rx_data->socket_fd, rx_data->buffer_size); - - printf("received data=%s\n",rx_data); - tet_printf("Api passed"); - tet_result(TET_PASS); - //tc_result(TC_PASS, 21); - - - g_main_loop_quit (main_loop); - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_rfcomm_listen_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); -// return_22=bluetooth_rfcomm_listen(sk,max_pending_connection); - return_22= bluetooth_rfcomm_listen_and_accept(sk,1); - if( return_22<0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_rfcomm_listen_2(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - sk=-1; - max_pending_connection=1000000; - - return_22= bluetooth_rfcomm_listen_and_accept(sk,max_pending_connection); - - if( return_22>=0) - { - tet_printf("Api failed result_22=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -#if 0 -void utc_bluetooth_rfcomm_listen_3(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); -// return_22=bluetooth_rfcomm_listen(sk,max_pending_connection); - return_22= bluetooth_rfcomm_listen_and_accept(sk,1); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} -#endif diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h deleted file mode 100644 index 46f2c04..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_rfcomm_listen_1(void); - - void utc_bluetooth_rfcomm_listen_2(void); - - void utc_bluetooth_rfcomm_listen_3(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_rfcomm_listen_1,1}, - { utc_bluetooth_rfcomm_listen_2,2}, -// { utc_bluetooth_rfcomm_listen_3,3}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c deleted file mode 100644 index cc729cb..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_remove_socket.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void uts_bluetooth_rfcomm_remove_socket_1(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp); - printf("sk=%x\n",sk); - return_22= bluetooth_rfcomm_remove_socket(sk, rfcomm_test_uuid_spp); - if( return_22<0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void uts_bluetooth_rfcomm_remove_socket_2(void) -{ - int sk; - int max_pending_connection; - int return_22; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - sk=-1; - printf("sk=%x\n",sk); - return_22= bluetooth_rfcomm_remove_socket(sk, rfcomm_test_uuid_spp); - if( return_22>0) - { - tet_printf("Api failed,=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h deleted file mode 100644 index 7c64130..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void uts_bluetooth_rfcomm_remove_socket_1(void); - - void uts_bluetooth_rfcomm_remove_socket_2(void); - - struct tet_testlist tet_testlist[] = { - { uts_bluetooth_rfcomm_remove_socket_1,1}, - { uts_bluetooth_rfcomm_remove_socket_2,2}, - {NULL,0} - }; - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c deleted file mode 100644 index 7579b92..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_sock_deregister_with_uuid.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void) -{ - char uuid[]="id"; - int return_21; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_21=bluetooth_rfcomm_sock_register_with_uuid(&uuid); - - return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid); - if( return_21<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void) -{ - char* uuid; - int return_21; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - uuid=NULL; - return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid); - if( return_21>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h deleted file mode 100644 index 1d8f4e5..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void); - - void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_rfcomm_sock_deregister_with_uuid_1,1}, - { utc_bluetooth_rfcomm_sock_deregister_with_uuid_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c deleted file mode 100644 index b851d95..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_sock_register_with_uuid.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void) -{ - char uuid[]="00000000-0000-1000-8000-00805F9B34FB";//"id"; - int return_20; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - //uuid =NULL;//assign value over here - return_20=bluetooth_rfcomm_sock_register_with_uuid(&uuid); - if( return_20<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void) -{ - char* uuid; - int return_20; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - uuid=NULL; - return_20=bluetooth_rfcomm_sock_register_with_uuid(uuid); - if( return_20>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h deleted file mode 100644 index f3994ac..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void); - - void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_rfcomm_sock_register_with_uuid_1,1}, - { utc_bluetooth_rfcomm_sock_register_with_uuid_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c deleted file mode 100644 index 8ced8f6..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_rfcomm_write.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; -int g_ret_client_fd1 = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); -// main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: - { - int return_22; - char *buff = "abcdefghijklmnopqrstuvwxyz"; - bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data; - TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result, - con_ind->socket_fd, - con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2], - con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5], - (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT"); - //tc_result(TC_PASS, 22); - tet_printf("g_ret_client_fd1=%d\nconn_ind->socket_fd %d\n",g_ret_client_fd1,con_ind->socket_fd); - tet_printf("con_ind->device_role=%d\n",con_ind->device_role); - - if(con_ind->device_role == RFCOMM_ROLE_CLIENT) - g_ret_client_fd1 = con_ind->socket_fd; - - TC_PRT("\n Enter the channel: "); - return_22= bluetooth_rfcomm_write(g_ret_client_fd1, buff, 26); - if( return_22<0) - { - tet_printf("BLUETOOTH_EVENT_RFCOMM_CONNECTED Api failed, return_22=%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - g_main_loop_quit (main_loop); -// if( main_loop!= NULL) -// { -// g_main_loop_unref(main_loop); -// } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - -#if 0 -void uts_bluetooth_rfcomm_write_1(void) -{ - int max_pending_connection; - int return_22; - int ret_val; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - ret_val = bluetooth_register_callback(bt_event_callback); -// main_loop = g_main_loop_new(NULL, FALSE); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp); - tet_printf(" bluetooth_rfcomm_connectApi , return_22=%d\n",return_22); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); -} -#endif - -void uts_bluetooth_rfcomm_write_1(void) -{ - int max_pending_connection; - int return_22; - int ret_val; - char *buff = "abcdefghijklmnopqrstuvwxyz"; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_write(1, buff, -1); - if( return_22>0) - { - tet_printf("Api failed =%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - -void uts_bluetooth_rfcomm_write_2(void) -{ - int max_pending_connection; - int return_22; - int ret_val; - char *buff = "abcdefghijklmnopqrstuvwxyz"; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_write(NULL, buff, 26); - if( return_22>0) - { - tet_printf("Api failed =%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void uts_bluetooth_rfcomm_write_3(void) -{ - int max_pending_connection; - int return_22; - int ret_val; - char *buff = "abcdefghijklmnopqrstuvwxyz"; - //Replace the below BD address with the remote device BD address - const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}}; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return ; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } -// remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; -// remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x82; - - return_22= bluetooth_rfcomm_write(1, NULL, 26); - if( return_22>0) - { - tet_printf("Api failed =%d\n",return_22); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h deleted file mode 100644 index eff8999..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void uts_bluetooth_rfcomm_write_1(void); - - void uts_bluetooth_rfcomm_write_2(void); - - void uts_bluetooth_rfcomm_write_3(void); - - struct tet_testlist tet_testlist[] = { - { uts_bluetooth_rfcomm_write_1,1}, - { uts_bluetooth_rfcomm_write_2,2}, - { uts_bluetooth_rfcomm_write_3,3}, - {NULL,0} - }; - diff --git a/TC/bluetooth_TC/uts_bluetooth_search_service.c b/TC/bluetooth_TC/uts_bluetooth_search_service.c deleted file mode 100644 index 8ced3cc..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_search_service.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_search_service.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_search_service_1(void) -{ - bluetooth_device_address_t device_address={{0}}; - int return_18; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_18=bluetooth_search_service(&device_address); - if( return_18<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_search_service_2(void) -{ - bluetooth_device_address_t device_address; - int return_18; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } -// device_address=NULL; - return_18=bluetooth_search_service(NULL); - if( return_18>=0) - { - tet_printf("Api failed=%d\n",return_18); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_search_service.h b/TC/bluetooth_TC/uts_bluetooth_search_service.h deleted file mode 100644 index d770f64..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_search_service.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_search_service_1(void); - - void utc_bluetooth_search_service_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_search_service_1,1}, - { utc_bluetooth_search_service_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c b/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c deleted file mode 100644 index 06c6ed1..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_set_discoverable_mode.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - -void utc_bluetooth_set_discoverable_mode_1(void) -{ - bluetooth_discoverable_mode_t discoverable_mode; - int return_8; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) { - tet_printf("bluetooth_register_callback returned Success"); - } else { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - return 0; - } - - ret_val = bluetooth_check_adapter(); - - if (ret_val < BLUETOOTH_ERROR_NONE) - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - else - TC_PRT("BT state [0x%04x]", ret_val); - - discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE; - - /* 60 seconds */ - return_8 = bluetooth_set_discoverable_mode(discoverable_mode, 60); - - if (return_8 < 0) { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } else { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_set_discoverable_mode_2(void) -{ - bluetooth_discoverable_mode_t discoverable_mode; - int return_8; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - discoverable_mode=-1; - return_8=bluetooth_set_discoverable_mode(discoverable_mode, 0); - if( return_8>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h b/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h deleted file mode 100644 index 9114aa9..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_set_discoverable_mode_1(void); - - void utc_bluetooth_set_discoverable_mode_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_set_discoverable_mode_1,1}, - { utc_bluetooth_set_discoverable_mode_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_set_local_name.c b/TC/bluetooth_TC/uts_bluetooth_set_local_name.c deleted file mode 100644 index 2cbaf07..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_set_local_name.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_set_local_name.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_set_local_name_1(void) -{ - bluetooth_device_name_t local_name={{"local Name"}}; - int return_6; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_6=bluetooth_set_local_name(&local_name); - if( return_6<0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_set_local_name_2(void) -{ - bluetooth_device_name_t* local_name; - int return_6; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - local_name=NULL; - return_6=bluetooth_set_local_name(local_name); - if( return_6>=0) - { - tet_printf("Api failed"); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_set_local_name.h b/TC/bluetooth_TC/uts_bluetooth_set_local_name.h deleted file mode 100644 index a77d571..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_set_local_name.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_set_local_name_1(void); - - void utc_bluetooth_set_local_name_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_set_local_name_1,1}, - { utc_bluetooth_set_local_name_2,2}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_start_discovery.c b/TC/bluetooth_TC/uts_bluetooth_start_discovery.c deleted file mode 100644 index 60932d1..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_start_discovery.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_start_discovery.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - //tc_result(TC_FAIL, 12); - } - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - - - -void utc_bluetooth_start_discovery_1(void) -{ - unsigned max_response; - unsigned discovery_duration; - unsigned classOfDeviceMask; - int return_9; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - bluetooth_cancel_discovery(); - - max_response =0; - discovery_duration =0; - classOfDeviceMask =0; - return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - if( return_9<0) - { - tet_printf("Api failed: %d", return_9); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - - -void utc_bluetooth_start_discovery_2(void) -{ - unsigned short max_response; - unsigned short discovery_duration; - unsigned classOfDeviceMask; - int return_9; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - max_response =0;//assign value over here - discovery_duration =0;//assign value over here - classOfDeviceMask=0x800001;//0x001000; - return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - if( return_9>=0) - { - tet_printf("Api failed=%d\n",return_9); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - - -// Not proper case!! -// The API parameter types is unsigned! -#if 0 -void utc_bluetooth_start_discovery_3(void) -{ - unsigned max_response; - unsigned discovery_duration; - unsigned classOfDeviceMask; - int return_9; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - max_response =0;//assign value over here - discovery_duration=-1; - classOfDeviceMask=0; - return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - if( return_9>=0) - { - tet_printf("Api failed=%d\n",return_9); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} - -void utc_bluetooth_start_discovery_4(void) -{ - unsigned max_response; - unsigned discovery_duration; - unsigned classOfDeviceMask; - int return_9; - int ret_val; - ret_val = bluetooth_register_callback(bt_event_callback); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - max_response=0; - discovery_duration=0; - classOfDeviceMask=-1; - return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask); - if( return_9>=0) - { - tet_printf("Api failed=%d\n",return_9); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} -#endif diff --git a/TC/bluetooth_TC/uts_bluetooth_start_discovery.h b/TC/bluetooth_TC/uts_bluetooth_start_discovery.h deleted file mode 100644 index 3dd24e9..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_start_discovery.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_start_discovery_1(void); - - void utc_bluetooth_start_discovery_2(void); - - void utc_bluetooth_start_discovery_3(void); - - void utc_bluetooth_start_discovery_4(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_start_discovery_1,1}, - { utc_bluetooth_start_discovery_2,2}, -// { utc_bluetooth_start_discovery_3,3}, -// { utc_bluetooth_start_discovery_4,4}, - {NULL,0} - }; diff --git a/TC/bluetooth_TC/uts_bluetooth_unbond_device.c b/TC/bluetooth_TC/uts_bluetooth_unbond_device.c deleted file mode 100644 index 3548bda..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_unbond_device.c +++ /dev/null @@ -1,290 +0,0 @@ - -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 "uts_bluetooth_unbond_device.h" - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define TC_FAIL 0 -#define TC_PASS 1 -#define TC_PRT tet_printf -//#define tc_result tet_result - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data); - -void startup() -{ - tet_printf("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - //main_loop = g_main_loop_new(NULL, FALSE); -} - - -void cleanup() -{ - - //g_main_loop_run(main_loop); - tet_printf("bluetooth framework TC cleanup"); - //if( main_loop!= NULL) - { - // g_main_loop_unref(main_loop); - } -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 1); - } - else - { - //tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - //tc_result(TC_PASS, 2); - } - else - { - //tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - //tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - //tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - //tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - int return_14; - bluetooth_device_info_t *device_info = NULL; - //tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - - if (device_info == NULL) - { - tet_printf("param is NULL"); - tet_result(TET_FAIL); - g_main_loop_quit (main_loop); - return; - } - - if (param->result >= BLUETOOTH_ERROR_NONE) - { - - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - - return_14=bluetooth_unbond_device(&device_info->device_address); - if( return_14<0) - { - tet_printf("Api failed: %d", return_14); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } - - g_main_loop_quit (main_loop); - break; - } - - default: - TC_PRT("received event [0x%04x]", event); - break; - } -} - - -void utc_bluetooth_unbond_device_1(void) -{ - bluetooth_device_address_t device_address={{0x00,0x02,0x78,0xDE,0x48,0x8F}}; // Samsung Stereo Headset - - int return_14; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - - return_14=bluetooth_bond_device(&device_address); - if( return_14<0) - { - tet_printf("bond failed: %d", return_14); - tet_result(TET_FAIL); - } - else - { - tet_printf("bonding is in progress"); - - main_loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(main_loop); - } -} - - -void utc_bluetooth_unbond_device_2(void) -{ - bluetooth_device_address_t* device_address; - int return_14; - int ret_val; - - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - tet_printf("bluetooth_register_callback returned Success"); - // tc_result(TC_PASS, 0); - } - else - { - tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - // tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - //tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - //tc_result(TC_PASS, 3); - } - device_address=NULL; - return_14=bluetooth_unbond_device(device_address); - if( return_14>=0) - { - tet_printf("Api failed: %d", return_14); - tet_result(TET_FAIL); - } - else - { - tet_printf("Api passed"); - tet_result(TET_PASS); - } -} diff --git a/TC/bluetooth_TC/uts_bluetooth_unbond_device.h b/TC/bluetooth_TC/uts_bluetooth_unbond_device.h deleted file mode 100644 index 5acd2c6..0000000 --- a/TC/bluetooth_TC/uts_bluetooth_unbond_device.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 -#include -#include -#include - -#include -#include - -static void startup(); - -static void cleanup(); - - -void (*tet_startup) () = startup; -void (*tet_cleanup) () = cleanup; - - void utc_bluetooth_unbond_device_1(void); - - void utc_bluetooth_unbond_device_2(void); - - struct tet_testlist tet_testlist[] = { - { utc_bluetooth_unbond_device_1,1}, - { utc_bluetooth_unbond_device_2,2}, - {NULL,0} - }; diff --git a/TC/build.sh b/TC/build.sh deleted file mode 100644 index 7a69717..0000000 --- a/TC/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -. ./_export_env.sh # setting environment variables - -echo PATH=$PATH -echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -echo TET_ROOT=$TET_ROOT -echo TET_SUITE_ROOT=$TET_SUITE_ROOT -echo ARCH=$ARCH - -RESULT_DIR=results-$ARCH -HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir $RESULT_DIR - -tcc -c -p ./ # executing tcc, with clean option (-c) -tcc -b -j $JOURNAL_RESULT -p ./ # executing tcc to build test cases (-b) -grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result diff --git a/TC/clean.sh b/TC/clean.sh deleted file mode 100644 index 27fdcf3..0000000 --- a/TC/clean.sh +++ /dev/null @@ -1,19 +0,0 @@ -. ./_export_env.sh # setting environment variables - -echo PATH=$PATH -echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -echo TET_ROOT=$TET_ROOT -echo TET_SUITE_ROOT=$TET_SUITE_ROOT -echo ARCH=$ARCH - -RESULT_DIR=results-$ARCH -HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir $RESULT_DIR - -tcc -c -p ./ # executing tcc, with clean option (-c) - -rm -rf $RESULT_DIR -rm -rf tet_tmp_dir -rm -rf results diff --git a/TC/execute.sh b/TC/execute.sh deleted file mode 100755 index e1ed207..0000000 --- a/TC/execute.sh +++ /dev/null @@ -1,17 +0,0 @@ -. ./_export_target_env.sh # setting environment variables - -echo PATH=$PATH -echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -echo TET_ROOT=$TET_ROOT -echo TET_SUITE_ROOT=$TET_SUITE_ROOT -echo ARCH=$ARCH - -RESULT_DIR=results-$ARCH -HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir $RESULT_DIR - -tcc -e -j $JOURNAL_RESULT -p ./ # executing tcc, with –e option -grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result - diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py deleted file mode 100755 index 6c5b845..0000000 --- a/TC/making_new_tet_scen.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/python - -############################################# -# tet_scen auto generator -# -# ** argv[1] = TC root -############################################# - -import sys,string,os - - -write_file = open("tet_scen", 'w') - -# -# making new tet_scen -# -def making_tet_scen (filename): - #tmp_list = filename.strip().split('/') - n_filename = filename.replace(' ', '\\ ') - #print n_filename - #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6] - new_path = "/"+n_filename[:-6] - #print new_path - file = open(filename, 'r') - lines = file.readlines() - for line in lines: - if len(line.strip()) > 1: - list = line.strip().split('/') - #print new_path + list[-1] - write_file.write("\t"+new_path+list[-1]+"\n") - -# -# usage() -# -def usage(): - print(" ") - print("./making_new_tet_scen.py tc_root") - print("Put the Test Case's root directory.") - print("Do not include '/' at the end") - print(" ") - -# -# main() -# -def main(): - if len(sys.argv) < 2: - usage() - sys.exit(0) - - os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt') - - #write_file = open("tetscen", w) - write_file.write("# auto generated tet_scen\n") - write_file.write("all\n") - write_file.write("\t\"Starting Full Test Suite\"\n") - - for file in open("tslist.txt", 'r'): - #print file.strip() - making_tet_scen(file.strip()) - - write_file.write("\t\"Completed Full Test Suite\"\n") - write_file.write("# EOF\n") - write_file.close() - print(" ") - print("==============================") - print("New tet_scen file is made~~~~") - print("==============================") - print(" ") -main() diff --git a/TC/tet_captured b/TC/tet_captured deleted file mode 100644 index 9429e64..0000000 --- a/TC/tet_captured +++ /dev/null @@ -1 +0,0 @@ -Makefile:39: *** missing separator. Stop. diff --git a/TC/tet_scen b/TC/tet_scen deleted file mode 100644 index b3da378..0000000 --- a/TC/tet_scen +++ /dev/null @@ -1,31 +0,0 @@ -# auto generated tet_scen -all - "Starting Full Test Suite" - /bluetooth_TC/uts_bluetooth_register_callback - /bluetooth_TC/uts_bluetooth_check_adapter - /bluetooth_TC/uts_bluetooth_enable_adapter - /bluetooth_TC/uts_bluetooth_authorize_device - /bluetooth_TC/uts_bluetooth_start_discovery - /bluetooth_TC/uts_bluetooth_cancel_discovery - /bluetooth_TC/uts_bluetooth_bond_device - /bluetooth_TC/uts_bluetooth_cancel_bonding - /bluetooth_TC/uts_bluetooth_unbond_device - /bluetooth_TC/uts_bluetooth_search_service - /bluetooth_TC/uts_bluetooth_cancel_service_search - /bluetooth_TC/uts_bluetooth_get_bonded_device_list - /bluetooth_TC/uts_bluetooth_get_discoverable_mode - /bluetooth_TC/uts_bluetooth_get_local_address - /bluetooth_TC/uts_bluetooth_get_local_name - /bluetooth_TC/uts_bluetooth_get_remote_device - /bluetooth_TC/uts_bluetooth_set_discoverable_mode - /bluetooth_TC/uts_bluetooth_set_local_name - /bluetooth_TC/uts_bluetooth_is_discovering - /bluetooth_TC/uts_bluetooth_rfcomm_create_socket - /bluetooth_TC/uts_bluetooth_rfcomm_remove_socket - /bluetooth_TC/uts_bluetooth_rfcomm_listen - /bluetooth_TC/uts_bluetooth_rfcomm_connect - /bluetooth_TC/uts_bluetooth_rfcomm_disconnect - /bluetooth_TC/uts_bluetooth_rfcomm_write - /bluetooth_TC/uts_bluetooth_disable_adapter - "Completed Full Test Suite" -# EOF diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg deleted file mode 100644 index f7eda55..0000000 --- a/TC/tetbuild.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option for build operation checking -TET_BUILD_TOOL=make # build with using make command -TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build -TET_API_COMPLIANT=True # use TET API in Test Case ? -TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg deleted file mode 100644 index 02d7030..0000000 --- a/TC/tetclean.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option -TET_CLEAN_TOOL= make clean # clean tool -TET_CLEAN_FILE= Makefile # file for clean -TET_API_COMPLIANT=True # TET API useage -TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg deleted file mode 100644 index ef3e452..0000000 --- a/TC/tetexec.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capturing execution or not -TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional -TET_EXEC_FILE= # ex) exectool : execution file/ Optional -TET_API_COMPLIANT=True # Test case or Tool usesTET API? -TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/TC/tslist.txt b/TC/tslist.txt deleted file mode 100644 index 053e911..0000000 --- a/TC/tslist.txt +++ /dev/null @@ -1 +0,0 @@ -bluetooth_TC/tslist diff --git a/bluetooth-frwk-agent/CMakeLists.txt b/bluetooth-frwk-agent/CMakeLists.txt index a1c29fc..2064925 100644 --- a/bluetooth-frwk-agent/CMakeLists.txt +++ b/bluetooth-frwk-agent/CMakeLists.txt @@ -15,7 +15,6 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -#pkg_check_modules(pkgs REQUIRED elementary utilX appcore-efl pmapi vconf aul syspopup-caller) pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service dbus-glib-1 msg-service email-service) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/bluetooth-frwk-agent/bluetooth-agent-cb.c b/bluetooth-frwk-agent/bluetooth-agent-cb.c index da99033..5e60a19 100644 --- a/bluetooth-frwk-agent/bluetooth-agent-cb.c +++ b/bluetooth-frwk-agent/bluetooth-agent-cb.c @@ -46,6 +46,7 @@ extern struct bt_agent_appdata *app_data; static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address); static const int __bt_agent_is_hid_keyboard(uint32_t dev_class); +static int __bt_agent_generate_passkey(char *passkey, int size); static void __bt_agent_release_memory(void) { @@ -201,7 +202,7 @@ static gboolean __pincode_request(DBusGProxy *device) } else if (__bt_agent_is_hid_keyboard(device_class)) { char str_passkey[7] = { 0 }; - bt_agent_generate_passkey(str_passkey, sizeof(str_passkey)); + __bt_agent_generate_passkey(str_passkey, sizeof(str_passkey)); if (name) _bt_agent_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, @@ -585,7 +586,7 @@ static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address) return ret; } -int bt_agent_generate_passkey(char *passkey, int size) +static int __bt_agent_generate_passkey(char *passkey, int size) { int i = 0; int random_fd = 0; diff --git a/bluetooth-frwk-agent/sc_core_agent.c b/bluetooth-frwk-agent/sc_core_agent.c index 7ea9166..89edf19 100644 --- a/bluetooth-frwk-agent/sc_core_agent.c +++ b/bluetooth-frwk-agent/sc_core_agent.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "bluetooth-agent.h" #include "sc_core_agent.h" @@ -55,6 +57,9 @@ struct _ScCoreAgentPrivate { char pairing_addr[18]; char authorize_addr[18]; + guint timeout_id; + unsigned int timeout; + SC_CORE_AGENT_FUNC_CB cb; }; @@ -85,6 +90,13 @@ static gboolean sc_core_agent_release(ScCoreAgent *agent, DBusGMethodInvocation static gboolean sc_core_agent_ignore_auto_pairing(ScCoreAgent *agent, const char *address, DBusGMethodInvocation *context); +static gboolean sc_core_agent_set_discoverable_timer(ScCoreAgent *agent, + const guint timeout, + DBusGMethodInvocation *context); + +static gboolean sc_core_agent_get_discoverable_timeout(ScCoreAgent *agent, + DBusGMethodInvocation *context); + static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *name, const char *prev, const char *new, gpointer user_data); @@ -652,6 +664,72 @@ static gboolean sc_core_agent_ignore_auto_pairing(ScCoreAgent *agent, const char return TRUE; } +static gboolean __sc_core_agent_timeout_handler(gpointer user_data) +{ + DBG("+\n"); + + ScCoreAgentPrivate *priv = (ScCoreAgentPrivate *)user_data; + + if (priv == NULL) + return FALSE; + + priv->timeout--; + + if (priv->timeout == 0) { + priv->timeout_id = 0; + return FALSE; + } + + DBG("-\n"); + return TRUE; +} + +static gboolean sc_core_agent_set_discoverable_timer(ScCoreAgent *agent, + const guint timeout, + DBusGMethodInvocation *context) +{ + DBG("+\n"); + + ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); + + if (priv == NULL) + return FALSE; + + if (priv->timeout_id) { + g_source_remove(priv->timeout_id); + priv->timeout_id = 0; + } + + priv->timeout = timeout; + + if (timeout == 0) + return TRUE; + + priv->timeout_id = g_timeout_add_seconds(1, + __sc_core_agent_timeout_handler, priv); + + DBG("-\n"); + + return TRUE; +} + +static gboolean sc_core_agent_get_discoverable_timeout(ScCoreAgent *agent, + DBusGMethodInvocation *context) +{ + DBG("+\n"); + + ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); + + if (priv == NULL) + return FALSE; + + dbus_g_method_return(context, priv->timeout); + + DBG("-\n"); + + return TRUE; +} + gboolean sc_core_agent_reply_pin_code(ScCoreAgent *agent, const guint accept, const char *pin_code, DBusGMethodInvocation *context) { @@ -981,6 +1059,13 @@ static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *n { if (g_strcmp0(name, "org.bluez") == 0 && *new == '\0') { DBG("BlueZ is terminated\n"); + + /* Update Bluetooth Status to notify other modules */ + if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0) + DBG("Set vconf failed\n"); + + if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0) + DBG("Set vconf failed\n"); } } diff --git a/bluetooth-frwk-agent/sc_core_agent.xml b/bluetooth-frwk-agent/sc_core_agent.xml index c21bde3..d26ac07 100644 --- a/bluetooth-frwk-agent/sc_core_agent.xml +++ b/bluetooth-frwk-agent/sc_core_agent.xml @@ -51,6 +51,16 @@ + + + + + + + + + + diff --git a/bluetooth-map-agent/bluetooth_map_agent.c b/bluetooth-map-agent/bluetooth_map_agent.c index 63120e5..031ebcc 100644 --- a/bluetooth-map-agent/bluetooth_map_agent.c +++ b/bluetooth-map-agent/bluetooth_map_agent.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include "vconf.h" @@ -49,15 +50,20 @@ #include "Emf_Mapi_Message.h" #include "Emf_Mapi_Network.h" #include "Emf_Mapi_Mailbox.h" +#include "Emf_Mapi_Types.h" #include -#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \ - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)) +#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", \ + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)) + +#define DBUS_STRUCT_MESSAGE_LIST (dbus_g_type_get_struct("GValueArray", \ + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)) + +static MSG_HANDLE_T g_msg_handle = NULL; + +DBusConnection *g_session_connection = NULL; -#define DBUS_STRUCT_MESSAGE_LIST (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \ - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)) -static MSG_HANDLE_T msgHandle = NULL; #define BT_MAP_STATUS_CB "sent status callback" #define BT_MAP_MSG_CB "sms message callback" #define BT_MAP_EMAIL_DEFAULTACCOUNT "db/email/defaultaccount" @@ -65,6 +71,10 @@ static MSG_HANDLE_T msgHandle = NULL; #define BT_MAP_EMAIL "_e" #define BT_MAP_MSG_INFO_MAX 256 #define BT_MAP_MSG_HANDLE_MAX 16 +#define BT_MNS_OBJECT_PATH "/org/bluez/mns" +#define BT_MNS_INTERFACE "org.bluez.mns" +#define BT_MSG_UPDATE 0 +#define BT_MSG_DELETE 1 typedef struct { GObject parent; @@ -118,6 +128,7 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, static void bluetooth_map_agent_init(BluetoothMapAgent *obj) { DBG("+\n"); + g_assert(obj != NULL); } @@ -140,59 +151,90 @@ static void bluetooth_map_agent_class_init(BluetoothMapAgentClass *klass) &dbus_glib_bluetooth_map_object_info); } -static void bluetooth_map_msg_sent_status_cb(MSG_HANDLE_T handle, - MSG_SENT_STATUS_S *pStatus, void *pUserParam) +static void __bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T handle, + msg_message_t msg, void *user_param) { - if (NULL != pStatus) { - if (pStatus->status == MSG_NETWORK_SEND_SUCCESS) - DBG("reqId : %d \n", pStatus->reqId); - else - DBG("reqId : %d , status : %d \n", - pStatus->reqId, pStatus->status); + DBusMessage *message = NULL; + char *message_type = NULL; + + DBG("+\n"); + + message = dbus_message_new_signal(BT_MNS_OBJECT_PATH, BT_MNS_INTERFACE, + "NewMessage"); + if (!message) + return; + + switch (msg_get_message_type(msg)) { + + case MSG_TYPE_SMS: + message_type = g_strdup("SMS_GSM"); + break; + case MSG_TYPE_MMS: + message_type = g_strdup("MMS"); + break; + default: + message_type = g_strdup("UNKNOWN"); + break; + } -} -static void bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T Handle, - msg_message_t msg, void *pUserParam) -{ + dbus_message_append_args(message, DBUS_TYPE_STRING, &message_type, + DBUS_TYPE_INT32, &handle, + DBUS_TYPE_INVALID); + dbus_message_set_no_reply(message, TRUE); + dbus_connection_send(g_session_connection, message, NULL); + dbus_message_unref(message); + g_free(message_type); } -static void bluetooth_map_start_service() +static gboolean __bluetooth_map_start_service() { MSG_ERROR_T err = MSG_SUCCESS; + int email_err = EMF_ERROR_NONE; + bool msg_ret = TRUE; + bool email_ret = TRUE; - err = msg_open_msg_handle(&msgHandle); + err = msg_open_msg_handle(&g_msg_handle); if (err != MSG_SUCCESS) { - DBG("msg_open_msg_handle error = %d\n", err); - } else { - err = msg_reg_sent_status_callback(msgHandle, - bluetooth_map_msg_sent_status_cb, - (void *)BT_MAP_STATUS_CB); - - if (err != MSG_SUCCESS) { - DBG("msg_reg_sent_status_callback error = %d \n", err); - } else { - err = msg_reg_sms_message_callback(msgHandle, - bluetooth_map_msg_incoming_status_cb, - 0, (void *)BT_MAP_MSG_CB); - if (err != MSG_SUCCESS) - DBG("msg_reg_sms_message_callback error = %d\n", err); - } + ERR("msg_open_msg_handle error = %d\n", err); + msg_ret = FALSE; + goto email; } - if (email_service_begin() != EMF_ERROR_NONE) - DBG("email_service_begin fail \n"); - return; + err = msg_reg_sms_message_callback(g_msg_handle, + __bluetooth_map_msg_incoming_status_cb, + 0, (void *)BT_MAP_MSG_CB); + + if (err != MSG_SUCCESS) { + ERR("msg_reg_sms_message_callback error = %d\n", err); + msg_ret = FALSE; + } + +email: + email_err = email_service_begin(); + + if (email_err != EMF_ERROR_NONE) { + ERR("email_service_begin fail \n"); + email_ret = FALSE; + } + + if (msg_ret || email_ret) + return TRUE; + else + return FALSE; } -static void bluetooth_map_stop_service() +static void __bluetooth_map_stop_service() { - if (NULL != msgHandle) - msg_close_msg_handle(&msgHandle); + if (NULL != g_msg_handle) + msg_close_msg_handle(&g_msg_handle); + + g_msg_handle = NULL; + if (EMF_ERROR_NONE != email_service_end()) - DBG("email_service_end fail \n"); + ERR("email_service_end fail \n"); return; } @@ -200,7 +242,6 @@ static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent, DBusGMethodInvocation *context) { GPtrArray *array = g_ptr_array_new(); - int folder_count = 0; MSG_FOLDER_LIST_S g_folderList; int i = 0; char name[BT_MAP_MSG_INFO_MAX] = {0,}; @@ -210,63 +251,78 @@ static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent, int mailbox_count = 0; bool flag = FALSE; int j = 0; - GValue *value; + GValue *value = NULL; + - bluetooth_map_start_service(); + if (__bluetooth_map_start_service() == FALSE) + goto done; - if (msg_get_folder_list(msgHandle, &g_folderList) == MSG_SUCCESS) { - for (i = 0; i < g_folderList.nCount; i++) { - g_strlcpy(name, g_folderList.folderInfo[i].folderName, - sizeof(name)); + if (g_msg_handle == NULL) + goto email; - value = g_new0(GValue, 1); + if (msg_get_folder_list(g_msg_handle, &g_folderList) != MSG_SUCCESS) + goto email; + + value = g_new0(GValue, 1); + + if (!value) { + g_ptr_array_free(array, TRUE); + return FALSE; + } + + for (i = 0; i < g_folderList.nCount; i++) { + g_strlcpy(name, g_folderList.folderInfo[i].folderName, + sizeof(name)); + + memset(value, 0, sizeof(GValue)); + g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_take_boxed(value, dbus_g_type_specialized_construct( + DBUS_STRUCT_STRING_STRING_UINT)); + dbus_g_type_struct_set(value, 0, name, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(value)); + } + +email: + vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id); + if (vconf_err == -1) + goto done; + + if (EMF_ERROR_NONE != email_get_mailbox_list(account_id, + EMF_MAILBOX_ALL, + &mailbox_list, + &mailbox_count)) + goto done; + + for (i = 0; i < mailbox_count; i++) { + flag = FALSE; + for (j = 0; j < g_folderList.nCount; j++) { + if (!g_ascii_strncasecmp( + mailbox_list[i].name, + g_folderList.folderInfo[j].folderName, + strlen(mailbox_list[i].name))) { + flag = TRUE; + break; + } + } + if (!flag) { + g_strlcpy(name, mailbox_list[i].name, sizeof(name)); + memset(value, 0, sizeof(GValue)); g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); g_value_take_boxed(value, dbus_g_type_specialized_construct( - DBUS_STRUCT_STRING_STRING_UINT)); + DBUS_STRUCT_STRING_STRING_UINT)); dbus_g_type_struct_set(value, 0, name, G_MAXUINT); g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); } } - vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id); - if (vconf_err != -1) { - if (EMF_ERROR_NONE == email_get_mailbox_list(account_id, - EMF_MAILBOX_ALL, - &mailbox_list, - &mailbox_count)) { - for (i = 0; i < mailbox_count; i++) { - flag = FALSE; - for (j = 0; j < g_folderList.nCount; j++) { - if (!g_ascii_strncasecmp( - mailbox_list[i].name, - g_folderList.folderInfo[j].folderName, - strlen(mailbox_list[i].name))) { - flag = TRUE; - break; - } - } - if (!flag) { - g_strlcpy(name, mailbox_list[i].name, - sizeof(name)); - value = g_new0(GValue, 1); - g_value_init(value, - DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(value, - dbus_g_type_specialized_construct( - DBUS_STRUCT_STRING_STRING_UINT)); - dbus_g_type_struct_set(value, 0, name, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); - } - } - } - } +done: + if (mailbox_list != NULL) + email_free_mailbox(&mailbox_list, mailbox_count); + g_free(value); dbus_g_method_return(context, array); g_ptr_array_free(array, TRUE); - return TRUE; } @@ -281,237 +337,276 @@ static gboolean bluetooth_map_get_message_list(BluetoothMapAgent *agent, MSG_ERROR_T err = MSG_SUCCESS; MSG_SORT_RULE_S sortRule; MSG_LIST_S msg_list; - GValue *value; + GValue *value = NULL; char msg_handle[BT_MAP_MSG_HANDLE_MAX] = {0,}; char msg_type[BT_MAP_MSG_INFO_MAX] = {0,}; - char msg_subject[BT_MAP_MSG_INFO_MAX] = {0,}; char msg_datetime[BT_MAP_MSG_INFO_MAX] = {0,}; - char s_name[BT_MAP_MSG_INFO_MAX] = {0,}; - char s_address[BT_MAP_MSG_INFO_MAX] = {0,}; - char r_2_address[BT_MAP_MSG_INFO_MAX] = {0,}; - char r_name[BT_MAP_MSG_INFO_MAX] = {0,}; - char r_address[BT_MAP_MSG_INFO_MAX] = {0,}; - char recp_status[BT_MAP_MSG_INFO_MAX] = {0,}; - int msg_size = 0; - int att_size = 0; - gboolean text; - gboolean read; - gboolean sent; - gboolean protect; - gboolean priority; - char *folder; + char *folder = NULL; int vconf_err = 0; int account_id = 0; emf_mailbox_t *mailbox_list = NULL; int mailbox_count = 0; - emf_mail_list_item_t *mail_list = NULL; int mail_count = 0; - int err_m; + int err_m = 0; emf_mailbox_t mailbox; int total = 0; int unseen = 0; + if (g_msg_handle == NULL) + goto email; + + value = g_new0(GValue, 1); + + if (!value) { + g_ptr_array_free(array, TRUE); + return FALSE; + } + folder = strrchr(folder_name, '/'); + if (NULL == folder) - folder = folder_name; - else - folder++; - - if (msg_get_folder_list(msgHandle, &g_folderList) == MSG_SUCCESS) - for (i = 0; i < g_folderList.nCount; i++) - if (!g_ascii_strncasecmp(folder, - g_folderList.folderInfo[i].folderName, - strlen(folder))) - folder_id = g_folderList.folderInfo[i].folderId; - - err = msg_get_folder_view_list(msgHandle, folder_id, + folder = folder_name; + else + folder++; + + if (msg_get_folder_list(g_msg_handle, &g_folderList) != MSG_SUCCESS) + goto email; + + for (i = 0; i < g_folderList.nCount; i++) + if (!g_ascii_strncasecmp(folder, + g_folderList.folderInfo[i].folderName, + strlen(folder))) + folder_id = g_folderList.folderInfo[i].folderId; + + err = msg_get_folder_view_list(g_msg_handle, folder_id, &sortRule, &msg_list); /*SMS and MMS*/ - if (err == MSG_SUCCESS) { - for (i = 0; i < msg_list.nCount; i++) { - value = g_new0(GValue, 1); - g_value_init(value, DBUS_STRUCT_MESSAGE_LIST); - g_value_take_boxed(value, dbus_g_type_specialized_construct( - DBUS_STRUCT_MESSAGE_LIST)); - snprintf(msg_handle, sizeof(msg_handle), "%d%s", + if (err != MSG_SUCCESS) + goto email; + + for (i = 0; i < msg_list.nCount; i++) { + time_t *time = NULL; + struct tm local_time = {0,}; + + memset(value, 0, sizeof(GValue)); + + g_value_init(value, DBUS_STRUCT_MESSAGE_LIST); + + g_value_take_boxed(value, dbus_g_type_specialized_construct( + DBUS_STRUCT_MESSAGE_LIST)); + + snprintf(msg_handle, sizeof(msg_handle), "%d%s", msg_get_message_id(msg_list.msgInfo[i]), BT_MAP_SMS); - snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d", - (int)msg_get_time(msg_list.msgInfo[i])); - DBG("date n time = %s \n ", msg_datetime); + time = msg_get_time(msg_list.msgInfo[i]); - switch (msg_get_message_type(msg_list.msgInfo[i])) { - case MSG_TYPE_SMS: - g_strlcpy(msg_type, "SMS_GSM", - sizeof(msg_type)); - break; + if (NULL != time) + localtime_r(time, &local_time); - case MSG_TYPE_MMS: - g_strlcpy(msg_type, "MMS", - sizeof(msg_type)); - break; + snprintf(msg_datetime, sizeof(msg_datetime), "%d%d%dT%d%d%d", + local_time.tm_year, local_time.tm_mon, local_time.tm_mday, + local_time.tm_hour, local_time.tm_min, local_time.tm_sec); - default: - g_strlcpy(msg_type, "UNKNOWN", - sizeof(msg_type)); - break; - } - dbus_g_type_struct_set(value, 0, msg_handle, - 1, msg_type, - 2, msg_datetime, - G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); + switch (msg_get_message_type(msg_list.msgInfo[i])) { + case MSG_TYPE_SMS: + g_strlcpy(msg_type, "SMS_GSM", sizeof(msg_type)); + break; + + case MSG_TYPE_MMS: + g_strlcpy(msg_type, "MMS", sizeof(msg_type)); + break; + + default: + g_strlcpy(msg_type, "UNKNOWN", sizeof(msg_type)); + break; } + dbus_g_type_struct_set(value, 0, msg_handle, + 1, msg_type, + 2, msg_datetime, + G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(value)); } + +email: /*Email*/ vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id); - if (vconf_err != -1) { - if (EMF_ERROR_NONE == email_get_mailbox_list(account_id, - EMF_MAILBOX_ALL, - &mailbox_list, - &mailbox_count)) - for (i = 0; i < mailbox_count; i++) - if (!g_ascii_strncasecmp(mailbox_list[i].name, folder, - strlen(mailbox_list[i].name))) - folder_id = mailbox_list[i].account_id; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - mailbox.account_id = folder_id; - mailbox.name = strdup(folder); - if (EMF_ERROR_NONE == email_count_message(&mailbox, &total, - &unseen)) { - DBG(" Total: %d, Unseen: %d \n", total, unseen); - } - - if (mailbox.name != NULL) - free(mailbox.name); - - err_m = email_get_mail_list_ex(folder_id, folder, - EMF_LIST_TYPE_NORMAL, - 0, total - 1, EMF_SORT_DATETIME_HIGH, - &mail_list, &mail_count); - if (err_m == EMF_ERROR_NONE) { - for (i = 0; i < mail_count; ++i) { - value = g_new0(GValue, 1); - g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(value, dbus_g_type_specialized_construct( - DBUS_STRUCT_STRING_STRING_UINT)); - snprintf(msg_handle, sizeof(msg_handle), "%d%s", - mail_list[i].mail_id, - BT_MAP_EMAIL); - g_strlcpy(msg_type, "EMAIL", - sizeof(msg_type)); - /*Dummy for testing purpose*/ - snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d", - 12345); - dbus_g_type_struct_set(value, 0, msg_handle, - 1, msg_type, - 2, msg_datetime, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); - } - } + if (vconf_err == -1) + goto done; + + if (EMF_ERROR_NONE != email_get_mailbox_list(account_id, + EMF_MAILBOX_ALL, + &mailbox_list, + &mailbox_count)) + goto done; + + for (i = 0; i < mailbox_count; i++) + if (!g_ascii_strncasecmp(mailbox_list[i].name, folder, + strlen(mailbox_list[i].name))) + folder_id = mailbox_list[i].account_id; + memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + mailbox.account_id = folder_id; + mailbox.name = strdup(folder); + if (EMF_ERROR_NONE != email_count_message(&mailbox, &total, &unseen)) + goto done; + + if (mailbox.name != NULL) + free(mailbox.name); + + err_m = email_get_mail_list_ex(folder_id, folder, + EMF_LIST_TYPE_NORMAL, + 0, total - 1, EMF_SORT_DATETIME_HIGH, + &mail_list, &mail_count); + if (err_m != EMF_ERROR_NONE) + goto done; + + for (i = 0; i < mail_count; ++i) { + memset(value, 0, sizeof(GValue)); + g_value_init(value, DBUS_STRUCT_MESSAGE_LIST); + + g_value_take_boxed(value, dbus_g_type_specialized_construct( + DBUS_STRUCT_MESSAGE_LIST)); + + snprintf(msg_handle, sizeof(msg_handle), "%d%s", + mail_list[i].mail_id, + BT_MAP_EMAIL); + g_strlcpy(msg_type, "EMAIL", sizeof(msg_type)); + + /*Dummy for testing purpose*/ + snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d", + 2011, 12); + dbus_g_type_struct_set(value, 0, msg_handle, + 1, msg_type, + 2, msg_datetime, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(value)); } + +done: + if (mailbox_list != NULL) + email_free_mailbox(&mailbox_list, mailbox_count); + if (mail_list != NULL) + g_free(mail_list); dbus_g_method_return(context, array); g_ptr_array_free(array, TRUE); + g_free(value); + return TRUE; } static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent, gchar *message_name, DBusGMethodInvocation *context) { + char *pch = NULL; + char *last = NULL; + int message_id = 0; + FILE *body_file = NULL; + GValue *value = NULL; + int vconf_err = 0; + int account_id = 0; GPtrArray *array = g_ptr_array_new(); - char *pch, *last; - int message_id; - GValue *value; + emf_mailbox_t mailbox; + emf_mail_body_t *body = NULL; + int nread = 0; + char *buf = NULL; + long l_size = 0; + msg_message_t msg ; + MSG_ERROR_T msg_err = MSG_SUCCESS; + MSG_SENDINGOPT_S sendOpt = { 0 }; if (message_name != NULL) { pch = strtok_r(message_name, "_", &last); if (pch == NULL) - return -1; + goto done; message_id = atoi(pch); pch = strtok_r(NULL, "_", &last); - } + } else + goto done; value = g_new0(GValue, 1); + g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); g_value_take_boxed(value, dbus_g_type_specialized_construct( DBUS_STRUCT_STRING_STRING_UINT)); if (!g_ascii_strncasecmp(pch, "s", 1)) { - msg_message_t msg ; - MSG_ERROR_T err = MSG_SUCCESS; - MSG_SENDINGOPT_S sendOpt = { 0 }; + if (g_msg_handle == NULL) + goto done; msg = msg_new_message(); - err = msg_get_message(msgHandle, (MSG_MESSAGE_ID_T)message_id, - msg, - &sendOpt); - if (err == MSG_SUCCESS) - DBG("Body =%s \n", msg_sms_get_message_body(msg)); - dbus_g_type_struct_set(value, 0, msg_sms_get_message_body(msg), + msg_err = msg_get_message(g_msg_handle, + (MSG_MESSAGE_ID_T)message_id, + msg, &sendOpt); + if (msg_err == MSG_SUCCESS) { + dbus_g_type_struct_set(value, 0, + msg_sms_get_message_body(msg), G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); - + g_ptr_array_add(array, g_value_get_boxed(value)); + } } else if (!g_ascii_strncasecmp(pch, "e", 1)) { - emf_mailbox_t mailbox; - emf_mail_t *mail = NULL; - emf_mail_body_t *body = NULL; - FILE *body_file; - int nread = 0; - char *buf; - long lSize; + vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, + &account_id); + if (vconf_err == -1) + goto done; memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - if (EMF_ERROR_NONE == email_get_mail(&mailbox, message_id, &mail)) { - if (EMF_ERROR_NONE == - email_get_body_from_mail(mail, &body)) { - body_file = fopen(body->html, "r"); - if (body_file == NULL) - body_file = fopen(body->plain, "r"); - if (body_file != NULL) { - /* obtain file size */ - fseek(body_file , 0 , SEEK_END); - lSize = ftell(body_file); - rewind(body_file); - - nread = fread(buf, 1, lSize, body_file); - if (nread != lSize) - DBG("Read error email \n"); - else { - dbus_g_type_struct_set(value, 0, - buf, - G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); - g_free(value); - } - } + mailbox.account_id = account_id; + + if (EMF_ERROR_NONE == email_get_body_info(&mailbox, message_id, + &body)) { + body_file = fopen(body->plain, "r"); + if (body_file == NULL) + body_file = fopen(body->html, "rb"); + + if (body_file != NULL) { + fseek(body_file , 0, SEEK_END); + l_size = ftell(body_file); + rewind(body_file); + + buf = (char *)malloc(sizeof(char) * l_size); + if (NULL == buf) + goto done; + + nread = fread(buf, 1, l_size, body_file); + + if (nread != l_size) + goto done; + + dbus_g_type_struct_set(value, 0, buf, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(value)); } } } + +done: dbus_g_method_return(context, array); + g_free(value); g_ptr_array_free(array, TRUE); + msg_release_message(&msg); + if (body_file != NULL) + fclose(body_file); + if (buf) + free(buf); + if (body) + email_free_body_info(&body, 1); + return TRUE; } static gboolean bluetooth_map_update_message(BluetoothMapAgent *agent, DBusGMethodInvocation *context) { - unsigned handle; - int err; - - DBG("bluetooth_map_update_message 123"); + unsigned handle = 0; + int err = EMF_ERROR_NONE; err = email_sync_header_for_all_account(&handle); if (err == EMF_ERROR_NONE) { DBG("Handle to stop download = %d \n", handle); } else { - DBG("Message Update failed \n"); + ERR("Message Update failed \n"); } dbus_g_method_return(context, err); + return (err == EMF_ERROR_NONE) ? TRUE : FALSE; } static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, @@ -519,73 +614,77 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, int indicator, int value, DBusGMethodInvocation *context) { - char *pch, *last; - int message_id; + char *pch = NULL; + char *last = NULL; + int message_id = 0; emf_mailbox_t mailbox; emf_mail_t *mail = NULL; msg_message_t msg; MSG_ERROR_T err = MSG_SUCCESS; MSG_SENDINGOPT_S sendOpt = { 0 }; - int ret; + int ret = 0; DBG("bluetooth_map_message_status"); if (message_name != NULL) { pch = strtok_r(message_name, "_", &last); if (pch == NULL) - return -1; + return FALSE; message_id = atoi(pch); pch = strtok_r(NULL, "_", &last); + } else { + return FALSE; } - DBG("Message handle = %d, i = %d, v = %d\n", message_id, indicator, value); + DBG("message_id = %d, i = %d, v = %d\n", message_id, indicator, value); if (!g_ascii_strncasecmp(pch, "s", 1)) { switch (indicator) { - case 0:{ + case BT_MSG_UPDATE:{ msg = msg_new_message(); - err = msg_get_message(msgHandle, + err = msg_get_message(g_msg_handle, (MSG_MESSAGE_ID_T)message_id, msg, &sendOpt); - if (err == MSG_SUCCESS) { - if (!msg_is_read(msg)) { - DBG(" Message is UNREAD \n"); - - ret = msg_update_read_status(msgHandle, - message_id, TRUE); - if (msg_is_mms(msg)) { - ret = msg_mms_send_read_report( - msgHandle, - message_id, - MSG_READ_REPORT_IS_READ); - } - } else { - DBG("Message is READ \n"); - ret = msg_update_read_status(msgHandle, - message_id, - FALSE); - - if (msg_is_mms(msg)) { - ret = msg_mms_send_read_report( - msgHandle, - message_id, - MSG_READ_REPORT_NONE); - } - } + if (err != MSG_SUCCESS) { msg_release_message(&msg); - } else { - DBG("Get message failed %d\n", err); + break; } + if (!msg_is_read(msg)) { + DBG(" Message is UNREAD \n"); + + ret = msg_update_read_status( + g_msg_handle, message_id, TRUE); + if (msg_is_mms(msg)) { + ret = msg_mms_send_read_report( + g_msg_handle, + message_id, + MSG_READ_REPORT_IS_READ); + } + } else { + DBG("Message is READ \n"); + ret = msg_update_read_status( + g_msg_handle, + message_id, FALSE); + + if (msg_is_mms(msg)) { + ret = msg_mms_send_read_report( + g_msg_handle, + message_id, + MSG_READ_REPORT_NONE); + } + } + msg_release_message(&msg); break; } - case 1: { - if (msg_delete_message(msgHandle, message_id) == MSG_SUCCESS) { + case BT_MSG_DELETE: { + if (msg_delete_message(g_msg_handle, message_id) == + MSG_SUCCESS) { DBG("Message delete success"); ret = TRUE; } else { - DBG("Message delete fail"); + ERR("Message delete fail"); ret = FALSE; } break; @@ -603,8 +702,9 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, newflag.answered = 0; newflag.sticky = 1; - if (email_modify_mail_flag(message_id, newflag, 1) < 0) { - DBG("email_modify_mail_flag failed \n"); + if (email_modify_mail_flag(message_id, newflag, + 1) < 0) { + ERR("email_modify_mail_flag failed \n"); ret = FALSE; } else { DBG("email_modify_mail_flag success \n"); @@ -615,14 +715,15 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, case 1: { memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); if (email_get_mail(&mailbox, message_id, &mail) < 0) { - DBG("email_get_mail failed\n"); + ERR("email_get_mail failed\n"); } else { DBG("email_get_mail success\n"); - if (email_delete_message(&mailbox, &message_id, 1, 1) >= 9) { + if (email_delete_message(&mailbox, &message_id, + 1, 1) >= 9) { DBG("\n email_delete_message success"); ret = TRUE; } else { - DBG("\n email_delete_message failed"); + ERR("\n email_delete_message failed"); ret = FALSE; } email_free_mail(&mail, 1); @@ -635,35 +736,38 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, } } dbus_g_method_return(context, ret); + return TRUE; } int main(int argc, char **argv) { BluetoothMapAgent *bluetooth_map_obj = NULL; - DBusGConnection *bus = NULL; DBusGProxy *bus_proxy = NULL; guint result = 0; GError *error = NULL; g_type_init(); - DBG("Map Agent\n"); + mainloop = g_main_loop_new(NULL, FALSE); + if (mainloop == NULL) { - DBG("Couldn't create GMainLoop\n"); + ERR("Couldn't create GMainLoop\n"); return EXIT_FAILURE; } - bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); + g_session_connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); + if (error != NULL) { - DBG("Couldn't connect to system bus[%s]\n", error->message); + ERR("Couldn't connect to system bus[%s]\n", error->message); g_error_free(error); return EXIT_FAILURE; } - bus_proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS, + bus_proxy = dbus_g_proxy_new_for_name(g_session_connection, + DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); if (bus_proxy == NULL) { - DBG("Failed to get a proxy for D-Bus\n"); + ERR("Failed to get a proxy for D-Bus\n"); goto failure; } @@ -671,14 +775,14 @@ int main(int argc, char **argv) BT_MAP_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID)) { if (error != NULL) { - DBG("RequestName RPC failed[%s]\n", error->message); + ERR("RequestName RPC failed[%s]\n", error->message); g_error_free(error); } goto failure; } DBG("result : %d %d\n", result, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER); if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - DBG("Failed to get the primary well-known name.\n"); + ERR("Failed to get the primary well-known name.\n"); goto failure; } @@ -687,24 +791,25 @@ int main(int argc, char **argv) bluetooth_map_obj = g_object_new(BLUETOOTH_MAP_TYPE_AGENT, NULL); if (bluetooth_map_obj == NULL) { - DBG("Failed to create one BluetoothMapAgent instance.\n"); + ERR("Failed to create one BluetoothMapAgent instance.\n"); goto failure; } /* Registering it on the D-Bus */ - dbus_g_connection_register_g_object(bus, BT_MAP_SERVICE_OBJECT_PATH, - G_OBJECT(bluetooth_map_obj)); + dbus_g_connection_register_g_object(g_session_connection, + BT_MAP_SERVICE_OBJECT_PATH, + G_OBJECT(bluetooth_map_obj)); g_main_loop_run(mainloop); failure: DBG("Terminate the bluetooth-map-agent\n"); - if (bus) - dbus_g_connection_unref(bus); if (bus_proxy) g_object_unref(bus_proxy); if (bluetooth_map_obj) g_object_unref(bluetooth_map_obj); + if (g_session_connection) + dbus_g_connection_unref(g_session_connection); return EXIT_FAILURE; } diff --git a/bluetooth-map-agent/bluetooth_map_agent.xml b/bluetooth-map-agent/bluetooth_map_agent.xml index 0378630..cc0832b 100644 --- a/bluetooth-map-agent/bluetooth_map_agent.xml +++ b/bluetooth-map-agent/bluetooth_map_agent.xml @@ -8,7 +8,7 @@ - + diff --git a/bluetooth-media-control/CMakeLists.txt b/bluetooth-media-control/CMakeLists.txt index bcc6d28..2dee1e8 100644 --- a/bluetooth-media-control/CMakeLists.txt +++ b/bluetooth-media-control/CMakeLists.txt @@ -1,8 +1,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-media-control C) -SET(SRCS bluetooth-media-control-api.c) -SET(HEADERS bluetooth-media-control-api.h) +SET(SRCS bluetooth-media-control.c) +SET(HEADERS bluetooth-media-control.h) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") @@ -45,6 +45,3 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkg FOREACH(hfile ${HEADERS}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-media-control) ENDFOREACH(hfile) - -ADD_SUBDIRECTORY(test) - diff --git a/bluetooth-media-control/bluetooth-media-control-api.c b/bluetooth-media-control/bluetooth-media-control-api.c deleted file mode 100644 index 4b915d1..0000000 --- a/bluetooth-media-control/bluetooth-media-control-api.c +++ /dev/null @@ -1,633 +0,0 @@ -/* - * bluetooth-media-control - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include "bluetooth-media-control-api.h" - -#define BLUEZ_SERVICE "org.bluez" -#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager" - -#define MEDIA_INTERFACE "org.bluez.Media" -#define MEDIA_PLAYER_OBJECT "/Musicplayer" - - -#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer" - - -static avrcp_dbus_info_t g_avrcp_dbus_info; -static DBusConnection *g_avrcp_connection = NULL; - -struct player_settinngs_t { - int key; - const char *property; -}; - -static struct player_settinngs_t equilizer_settings[] = { - { EQUILIZER_OFF, "off" }, - { EQUILIZER_ON, "on" }, - { EQUILIZER_INVALID, "" } -}; - -static struct player_settinngs_t repeat_settings[] = { - { REPEAT_MODE_OFF, "off" }, - { REPEAT_SINGLE_TRACK, "singletrack" }, - { REPEAT_ALL_TRACK, "alltracks" }, - { REPEAT_GROUP, "group" }, - { REPEAT_INVALID, "" } -}; - -static struct player_settinngs_t shuffle_settings[] = { - { SHUFFLE_MODE_OFF, "off" }, - { SHUFFLE_ALL_TRACK, "alltracks" }, - { SHUFFLE_GROUP, "group" }, - { SHUFFLE_INVALID, "" } -}; - -static struct player_settinngs_t scan_settings[] = { - { SCAN_MODE_OFF, "off" }, - { SCAN_ALL_TRACK, "alltracks" }, - { SCAN_GROUP, "group" }, - { SCAN_INVALID, "" } -}; - -static struct player_settinngs_t player_status[] = { - { STATUS_PLAYING, "playing" }, - { STATUS_STOPPED, "stopped" }, - { STATUS_PAUSED, "paused" }, - { STATUS_FORWARD_SEEK, "forward-seek" }, - { STATUS_REVERSE_SEEK, "reverse-seek" }, - { STATUS_ERROR, "error" }, - { STATUS_INVALID, "" } -}; - -static int __bluetooth_media_control_get_avrcp_adapter_path( - DBusGConnection *gconn, char *path) -{ - GError *err = NULL; - DBusGProxy *manager_proxy = NULL; - char *adapter_path = NULL; - int ret = 0; - - DBG("+\n"); - - manager_proxy = dbus_g_proxy_new_for_name(gconn, BLUEZ_SERVICE, "/", - BLUEZ_MANAGER_INTERFACE); - - if (manager_proxy == NULL) { - DBG("Could not create a dbus proxy\n"); - ret = BT_MEDIA_CONTROL_ERROR; - goto done; - } - - if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &err, - G_TYPE_INVALID,DBUS_TYPE_G_OBJECT_PATH, - &adapter_path,G_TYPE_INVALID)) { - DBG("Getting DefaultAdapter failed: [%s]\n", err->message); - g_error_free(err); - ret = BT_MEDIA_CONTROL_ERROR; - goto done; - } - - if (adapter_path == NULL) { - ret = BT_MEDIA_CONTROL_ERROR; - DBG("Adapter path is NULL\n"); - goto done; - } - - if (strlen(adapter_path) >= MEDIA_OBJECT_PATH_LENGTH) { - DBG("Path too long.\n"); - ret = BT_MEDIA_CONTROL_ERROR; - goto done; - } - DBG("path = %s\n", adapter_path); - g_strlcpy(path, adapter_path, MEDIA_OBJECT_PATH_LENGTH); - - done: - - if (manager_proxy != NULL) { - g_object_unref(manager_proxy); - } - if (adapter_path != NULL) { - free(adapter_path); - } - DBG("Adapter [%s]\n", path); - - DBG("-\n"); - return ret; -} - -static void __bluetooth_media_control_append_variant(DBusMessageIter *iter, - int type, void *val) -{ - DBusMessageIter value_iter; - const char *signature; - - switch (type) { - case DBUS_TYPE_BOOLEAN: - signature = DBUS_TYPE_BOOLEAN_AS_STRING; - break; - case DBUS_TYPE_STRING: - signature = DBUS_TYPE_STRING_AS_STRING; - break; - case DBUS_TYPE_BYTE: - signature = DBUS_TYPE_BYTE_AS_STRING; - break; - case DBUS_TYPE_UINT16: - signature = DBUS_TYPE_UINT16_AS_STRING; - break; - case DBUS_TYPE_UINT32: - signature = DBUS_TYPE_UINT32_AS_STRING; - break; - case DBUS_TYPE_INT16: - signature = DBUS_TYPE_INT16_AS_STRING; - break; - case DBUS_TYPE_INT32: - signature = DBUS_TYPE_INT32_AS_STRING; - break; - case DBUS_TYPE_OBJECT_PATH: - signature = DBUS_TYPE_OBJECT_PATH_AS_STRING; - break; - default: - signature = DBUS_TYPE_VARIANT_AS_STRING; - } - - dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, signature, &value_iter); - dbus_message_iter_append_basic(&value_iter, type, val); - dbus_message_iter_close_container(iter, &value_iter); -} - -static void __bluetooth_media_control_append_dict_entry(DBusMessageIter *dict, - const char *key, int type, void *property) -{ - DBusMessageIter entry; - - if (type == DBUS_TYPE_STRING) { - const char *str_ptr = *((const char **)property); - if (str_ptr == NULL) - return; - } - - dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, - NULL, &entry); - - dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); - - __bluetooth_media_control_append_variant(&entry, type, property); - - dbus_message_iter_close_container(dict, &entry); -} - -BT_EXPORT_API int bluetooth_media_control_init(void) -{ - GError *err = NULL; - char default_obj_path[MEDIA_OBJECT_PATH_LENGTH] = {0,}; - - DBG("+\n"); - - g_avrcp_dbus_info.avrcp_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); - - if (!g_avrcp_dbus_info.avrcp_conn) { - DBG("Can not get DBUS Gconnection [%s]\n",err->message); - g_error_free(err); - return BT_MEDIA_CONTROL_ERROR; - } - - g_avrcp_connection = (DBusConnection *)dbus_g_connection_get_connection( - g_avrcp_dbus_info.avrcp_conn); - - if (__bluetooth_media_control_get_avrcp_adapter_path( - g_avrcp_dbus_info.avrcp_conn, - default_obj_path) < 0) { - DBG("Could not get adapter path\n"); - goto error; - } - - if (default_obj_path != NULL) - g_strlcpy(g_avrcp_dbus_info.avrcp_obj_path, default_obj_path, - MEDIA_OBJECT_PATH_LENGTH); - else - goto error; - - DBG("-\n"); - return BT_MEDIA_CONTROL_SUCCESS; - -error: - dbus_g_connection_unref(g_avrcp_dbus_info.avrcp_conn); - g_avrcp_dbus_info.avrcp_conn = NULL; - g_avrcp_connection = NULL; - return BT_MEDIA_CONTROL_ERROR; -} - -BT_EXPORT_API int bluetooth_media_control_register_player( - media_player_settings_t player_settings, - media_metadata_attributes_t metadata ) -{ - DBusMessage *msg = NULL; - DBusMessage *reply = NULL; - DBusMessageIter iter; - DBusMessageIter property_dict; - DBusMessageIter metadata_dict; - DBusError err; - - const char *object = g_strdup(MEDIA_PLAYER_OBJECT); - - DBG("+\n"); - - msg = dbus_message_new_method_call( - BLUEZ_SERVICE, - g_avrcp_dbus_info.avrcp_obj_path, - MEDIA_INTERFACE, - "RegisterPlayer"); - if (!msg) { - DBG("dbus_message_new_method_call failed\n"); - g_free((void *)object); - return BT_MEDIA_CONTROL_ERROR; - } - - DBG("object = [%s] \n",object); - - dbus_message_iter_init_append(msg, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object); - - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &property_dict); - - if (player_settings.equilizer < EQUILIZER_INVALID) { - __bluetooth_media_control_append_dict_entry(&property_dict, - "Equalizer", - DBUS_TYPE_STRING, - &equilizer_settings[player_settings.equilizer].property); - } - - if (player_settings.repeat < REPEAT_INVALID) { - __bluetooth_media_control_append_dict_entry(&property_dict, - "Repeat", - DBUS_TYPE_STRING, - &repeat_settings[player_settings.repeat].property); - } - - if (player_settings.shuffle < SHUFFLE_INVALID) { - __bluetooth_media_control_append_dict_entry(&property_dict, - "Shuffle", - DBUS_TYPE_STRING, - &shuffle_settings[player_settings.shuffle].property); - } - - if (player_settings.scan < SCAN_INVALID) { - __bluetooth_media_control_append_dict_entry(&property_dict, - "Scan", - DBUS_TYPE_STRING, - &scan_settings[player_settings.scan].property); - } - - if (player_settings.status < STATUS_INVALID) { - __bluetooth_media_control_append_dict_entry(&property_dict, - "Status", - DBUS_TYPE_STRING, - &player_status[player_settings.status].property); - } - - if(0 != player_settings.position) - __bluetooth_media_control_append_dict_entry(&property_dict, - "Position", - DBUS_TYPE_UINT32, &player_settings.position); - - dbus_message_iter_close_container(&iter, &property_dict); - - dbus_message_iter_init_append(msg, &iter); - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &metadata_dict); - - if (NULL != metadata.title) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Title", - DBUS_TYPE_STRING, &metadata.title); - } - - if (NULL != metadata.artist) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Artist", - DBUS_TYPE_STRING, &metadata.artist); - } - - if (NULL != metadata.album) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Album", - DBUS_TYPE_STRING, &metadata.album); - } - - if ( NULL != metadata.genre ) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Genre", - DBUS_TYPE_STRING, &metadata.genre); - } - - if (0 != metadata.total_tracks) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "NumberOfTracks", - DBUS_TYPE_UINT32, &metadata.total_tracks); - - if (0 != metadata.number) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Number", - DBUS_TYPE_UINT32, &metadata.number); - - if (0 != metadata.duration) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Duration", - DBUS_TYPE_UINT32, &metadata.duration); - - dbus_message_iter_close_container(&iter, &metadata_dict); - - dbus_error_init(&err); - reply = dbus_connection_send_with_reply_and_block(g_avrcp_connection, - msg, -1, &err); - dbus_message_unref(msg); - - if (!reply) { - DBG("Error in registering the Music Player \n"); - - if (dbus_error_is_set(&err)) { - DBG("%s", err.message); - dbus_error_free(&err); - g_free((void *)object); - return BT_MEDIA_CONTROL_ERROR; - } - } - g_free((void *)object); - - DBG("-\n"); - - return BT_MEDIA_CONTROL_SUCCESS; -} - -BT_EXPORT_API int bluetooth_media_control_unregister_player(void) -{ - DBusMessage *msg = NULL; - DBusMessage *reply = NULL; - DBusError err; - const char *object = g_strdup(MEDIA_PLAYER_OBJECT); - - DBG("+\n"); - - msg = dbus_message_new_method_call(BLUEZ_SERVICE, - g_avrcp_dbus_info.avrcp_obj_path, - MEDIA_INTERFACE, - "UnregisterPlayer"); - - if (NULL == msg) { - g_free((void *)object); - return BT_MEDIA_CONTROL_ERROR; - } - - dbus_message_append_args(msg, - DBUS_TYPE_OBJECT_PATH, &object, - DBUS_TYPE_INVALID); - - dbus_error_init(&err); - reply = dbus_connection_send_with_reply_and_block(g_avrcp_connection, - msg, -1, &err); - dbus_message_unref(msg); - - if (!reply) { - DBG("Error in unregistering the Music Player \n"); - - if (dbus_error_is_set(&err)) { - DBG("%s", err.message); - dbus_error_free(&err); - g_free((void *)object); - return BT_MEDIA_CONTROL_ERROR; - } - } - g_free((void *)object); - - DBG("-\n"); - return BT_MEDIA_CONTROL_SUCCESS; -} - -static dbus_bool_t __bluetooth_media_control_emit_property_changed( - DBusConnection *conn, - const char *path, - const char *interface, - const char *name, - int type, void *value) -{ - DBusMessage *signal = NULL; - DBusMessageIter iter; - dbus_bool_t result; - - signal = dbus_message_new_signal(path, interface, "PropertyChanged"); - - if (!signal) { - DBG("Unable to allocate new %s.PropertyChanged signal", - interface); - return FALSE; - } - - dbus_message_iter_init_append(signal, &iter); - - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); - - __bluetooth_media_control_append_variant(&iter, type, value); - - result = dbus_connection_send(conn, signal, NULL); - dbus_message_unref(signal); - - return result; -} - -BT_EXPORT_API int bluetooth_media_control_player_property_changed( - media_player_settings_t player_settings) -{ - DBG("+\n"); - - if (player_settings.equilizer < EQUILIZER_INVALID) { - if (!__bluetooth_media_control_emit_property_changed( - g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Equalizer", - DBUS_TYPE_STRING, - &equilizer_settings[player_settings.equilizer].property)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - if (player_settings.repeat < REPEAT_INVALID) { - if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Repeat", - DBUS_TYPE_STRING, - &repeat_settings[player_settings.repeat].property)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - if (player_settings.shuffle < SHUFFLE_INVALID) { - if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Shuffle", - DBUS_TYPE_STRING, - &shuffle_settings[player_settings.shuffle].property)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - if (player_settings.scan < SCAN_INVALID) { - if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Scan", - DBUS_TYPE_STRING, - &scan_settings[player_settings.scan].property)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - if (player_settings.status < STATUS_INVALID) { - if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Status", - DBUS_TYPE_STRING, - &player_status[player_settings.status].property)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - if (0 != player_settings.position) { - if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection, - MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, - "Position", - DBUS_TYPE_UINT32, - &player_settings.position)) { - DBG("Error sending the PropertyChanged signal \n"); - } - } - - DBG("-\n"); - return BT_MEDIA_CONTROL_SUCCESS; -} - -BT_EXPORT_API int bluetooth_media_control_player_track_changed( - media_metadata_attributes_t metadata) -{ - DBusMessage *signal= NULL; - DBusMessageIter iter; - DBusMessageIter metadata_dict; - - DBG("+\n"); - - signal = dbus_message_new_signal(MEDIA_PLAYER_OBJECT, - MEDIA_PLAYER_INTERFACE, "TrackChanged"); - if (!signal) { - DBG("Unable to allocate TrackChanged signal\n"); - return BT_MEDIA_CONTROL_ERROR; - } - - dbus_message_iter_init_append(signal, &iter); - - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &metadata_dict); - - if (NULL != metadata.title) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Title", - DBUS_TYPE_STRING, &metadata.title); - } - - if (NULL != metadata.artist) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Artist", - DBUS_TYPE_STRING, &metadata.artist); - } - - if (NULL != metadata.album) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Album", - DBUS_TYPE_STRING, &metadata.album); - } - - if (NULL != metadata.genre) { - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Genre", - DBUS_TYPE_STRING, &metadata.genre); - } - - if (0 != metadata.total_tracks) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "NumberOfTracks", - DBUS_TYPE_UINT32, &metadata.total_tracks); - - if (0 != metadata.number) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Number", - DBUS_TYPE_UINT32, &metadata.number); - - if (0 != metadata.duration) - __bluetooth_media_control_append_dict_entry(&metadata_dict, - "Duration", - DBUS_TYPE_UINT32, &metadata.duration); - - dbus_message_iter_close_container(&iter, &metadata_dict); - - if (!dbus_connection_send(g_avrcp_connection, signal, NULL)) - DBG("Unable to send TrackChanged signal\n"); - dbus_message_unref(signal); - - DBG("-\n"); - return BT_MEDIA_CONTROL_SUCCESS; -} - -BT_EXPORT_API int bluetooth_media_control_deinit(void) -{ - DBG("+\n"); - - if (g_avrcp_dbus_info.avrcp_conn) { - dbus_g_connection_unref(g_avrcp_dbus_info.avrcp_conn); - g_avrcp_dbus_info.avrcp_conn = NULL; - } - - DBG("-\n"); - return BT_MEDIA_CONTROL_SUCCESS; -} - - diff --git a/bluetooth-media-control/bluetooth-media-control.c b/bluetooth-media-control/bluetooth-media-control.c new file mode 100644 index 0000000..8e806cc --- /dev/null +++ b/bluetooth-media-control/bluetooth-media-control.c @@ -0,0 +1,171 @@ +/* + * bluetooth-media-control + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hocheol Seo + * Girishashok Joshi + * Chanyeol Park + * + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include "bluetooth-media-control.h" + +#define MEDIA_PLAYER_OBJECT_PATH "/Samsung/Player" +#define MEDIA_PLAYER_INTERFACE "com.samsung.player" + +static int __bluetooth_media_dbus_signal_send(const char *path, + const char *interface, const char *method, int type, ...) +{ + DBusMessage *msg; + DBusConnection *conn; + va_list args; + DBG("+\n"); + + conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + if (NULL == conn) + return FALSE; + + msg = dbus_message_new_signal(path, interface, method); + if (!msg) { + DBG("Unable to allocate new D-Bus %s message", method); + dbus_connection_unref(conn); + return FALSE; + } + + va_start(args, type); + + if (!dbus_message_append_args_valist(msg, type, args)) { + dbus_message_unref(msg); + va_end(args); + dbus_connection_unref(conn); + return FALSE; + } + + va_end(args); + + if (dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_SIGNAL) + dbus_message_set_no_reply(msg, TRUE); + + if (!dbus_connection_send(conn, msg, NULL)) { + DBG("dbus_connection_send - ERROR\n"); + dbus_message_unref(msg); + dbus_connection_unref(conn); + return FALSE; + } + dbus_message_unref(msg); + dbus_connection_unref(conn); + + DBG(" -\n"); + return TRUE; +} + +BT_EXPORT_API int bluetooth_media_player_change_property( + media_player_property_type type, + unsigned int value) +{ + DBG("+\n"); + + if (type > POSITION) + return BT_MEDIA_CONTROL_ERROR; + + switch (type) { + case EQUILIZER: + if (value >= EQUILIZER_INVALID) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + case REPEAT: + if (value >= REPEAT_INVALID) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + case SHUFFLE: + if (value >= SHUFFLE_INVALID) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + case SCAN: + if (value >= SCAN_INVALID) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + case STATUS: + if (value >= STATUS_INVALID) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + case POSITION: + if (0 == value) { + return BT_MEDIA_CONTROL_ERROR; + } + break; + } + + if (!__bluetooth_media_dbus_signal_send( + MEDIA_PLAYER_OBJECT_PATH, + MEDIA_PLAYER_INTERFACE, + "PropertyChanged", + DBUS_TYPE_UINT32, &type, + DBUS_TYPE_UINT32, &value, + DBUS_TYPE_INVALID)) { + DBG("Error sending the PropertyChanged signal \n"); + return BT_MEDIA_CONTROL_ERROR; + } + + DBG("-\n"); + return BT_MEDIA_CONTROL_SUCCESS; +} + +BT_EXPORT_API int bluetooth_media_player_change_track( + media_metadata_attributes_t metadata) +{ + DBusMessage *signal = NULL; + DBusMessageIter iter; + DBusMessageIter metadata_dict; + + DBG("+\n"); + + if (!__bluetooth_media_dbus_signal_send( + MEDIA_PLAYER_OBJECT_PATH, + MEDIA_PLAYER_INTERFACE, + "TrackChanged", + DBUS_TYPE_STRING, &metadata.title, + DBUS_TYPE_STRING, &metadata.artist, + DBUS_TYPE_STRING, &metadata.album, + DBUS_TYPE_STRING, &metadata.genre, + DBUS_TYPE_UINT32, &metadata.total_tracks, + DBUS_TYPE_UINT32, &metadata.number, + DBUS_TYPE_UINT32, &metadata.duration, + DBUS_TYPE_INVALID)) { + DBG("Error sending the PropertyChanged signal \n"); + return BT_MEDIA_CONTROL_ERROR; + } + + DBG("-\n"); + return BT_MEDIA_CONTROL_SUCCESS; +} + + diff --git a/bluetooth-media-control/bluetooth-media-control-api.h b/bluetooth-media-control/bluetooth-media-control.h similarity index 58% rename from bluetooth-media-control/bluetooth-media-control-api.h rename to bluetooth-media-control/bluetooth-media-control.h index 27765b3..3156b32 100644 --- a/bluetooth-media-control/bluetooth-media-control-api.h +++ b/bluetooth-media-control/bluetooth-media-control.h @@ -25,6 +25,7 @@ #ifndef _BT_MP_CONTROL_H_ #define _BT_MP_CONTROL_H_ +#include #include #include #include @@ -49,6 +50,15 @@ extern "C" { #define BT_MEDIA_CONTROL_SUCCESS 0 typedef enum { + EQUILIZER = 0x00, + REPEAT, + SHUFFLE, + SCAN, + STATUS, + POSITION +} media_player_property_type; + +typedef enum { EQUILIZER_OFF = 0x00, EQUILIZER_ON, EQUILIZER_INVALID, @@ -93,7 +103,7 @@ typedef struct { media_player_scan_status scan; media_player_status status; unsigned int position; -}media_player_settings_t; +} media_player_settings_t; typedef struct { const char *title; @@ -103,73 +113,11 @@ typedef struct { unsigned int total_tracks; unsigned int number; unsigned int duration; -}media_metadata_attributes_t; - -typedef struct { - DBusGConnection *avrcp_conn; - char avrcp_obj_path[MEDIA_OBJECT_PATH_LENGTH]; -} avrcp_dbus_info_t; - -/** - * @fn int bluetooth_media_control_init(void) - * @brief Initializes the Media interface to media service - * - * This function is a asynchronous call. - * No event for this api.. - * - * @return 0 - Success \n - * -1 - On Failure\n - * - * @exception None - * @param[in] None. - * - * @remark None - * @see None - */ -int bluetooth_media_control_init(void); - -/** - * @fn int bluetooth_media_control_register_player(media_player_settings_t player_settings, - * media_metadata_attributes_t metadata ) - * @brief Registers the Music player with its player settings and media attributes - * - * This function is a asynchronous call. - * No event for this api.. - * - * @return 0 - Success \n - * -1 - On Failure\n - * - * @exception None - * @param[in] player_settings - Music player application settings, - * metadata -Meida attributes - * - * @remark None - * @see None - */ -int bluetooth_media_control_register_player( - media_player_settings_t player_settings, - media_metadata_attributes_t metadata ); - -/** - * @fn int bluetooth_media_control_unregister_player(void ) - * @brief Un-registers the Music player - * - * This function is a asynchronous call. - * No event for this api.. - * - * @return 0 - Success \n - * -1 - On Failure\n - * - * @exception None - * @param[in] None - * - * @remark None - * @see None - */ -int bluetooth_media_control_unregister_player(void); +} media_metadata_attributes_t; /** - * @fn int bluetooth_media_control_player_property_changed(media_player_settings_t player_settings) + * @fn int bluetooth_media_player_change_property(media_player_property_type type, + * unsigned int value); * @brief Notifies the remote bluetooth headset with change in music player settings * * This function is a asynchronous call. @@ -179,17 +127,19 @@ int bluetooth_media_control_unregister_player(void); * -1 - On Failure\n * * @exception None - * @param[in] player_settings - Music player application settings, + * @param[in] type - Type of the music player property + * value - Value of the property which is changed * * @remark None * @see None */ -int bluetooth_media_control_player_property_changed( - media_player_settings_t player_settings); +int bluetooth_media_player_change_property( + media_player_property_type type, + unsigned int value); /** - * @fn int bluetooth_media_control_player_track_changed(media_metadata_attributes_t metadata) + * @fn int bluetooth_media_player_change_track(media_metadata_attributes_t metadata) * @briefNotifies the remote bluetooth headset with change in media attributes of the track * * This function is a asynchronous call. @@ -204,27 +154,9 @@ int bluetooth_media_control_player_property_changed( * @remark None * @see None */ -int bluetooth_media_control_player_track_changed( +int bluetooth_media_player_change_track( media_metadata_attributes_t metadata); -/** - * @fn int bluetooth_media_control_deinit(void) - * @brief deinitializes the Media interface to media service - * - * This function is a asynchronous call. - * No event for this api.. - * - * @return 0 - Success \n - * -1 - On Failure\n - * - * @exception None - * @param[in] None. - * - * @remark None - * @see None - */ -int bluetooth_media_control_deinit(void); - #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/bluetooth-media-control/test/CMakeLists.txt b/bluetooth-media-control/test/CMakeLists.txt deleted file mode 100644 index f0089d1..0000000 --- a/bluetooth-media-control/test/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-media-control-test C) - -SET(SRCS bluetooth-media-control-test.c) - -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) - -INCLUDE(FindPkgConfig) -pkg_check_modules(package REQUIRED dlog dbus-glib-1 glib-2.0 gthread-2.0) - -FOREACH(flag ${package_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -FIND_PROGRAM(UNAME NAMES uname) -EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") -IF("${ARCH}" STREQUAL "arm") - ADD_DEFINITIONS("-DTARGET") - MESSAGE("add -DTARGET") -ENDIF("${ARCH}" STREQUAL "arm") - -ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") - -ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${package_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lbluetooth-media-control) - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) - diff --git a/bluetooth-media-control/test/bluetooth-media-control-test.c b/bluetooth-media-control/test/bluetooth-media-control-test.c deleted file mode 100644 index 32e6fd8..0000000 --- a/bluetooth-media-control/test/bluetooth-media-control-test.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * bluetooth-media-control - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * - * 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 -#include -#include "bluetooth-media-control-api.h" - -#include -#include -#include - -media_player_settings_t player_settings = {0x00, 0x00, 0x00,0x00, 0x01, 1111 }; -media_metadata_attributes_t metadata = {"Test Track", "Chethan", "TNC", "Tumkur", 1, 1, 14400 }; - -void static __choose_metadata_settings(void) -{ - int cmd; - media_metadata_attributes_t metadata = {0,}; - - while (1) { - printf("\nPlease choose metadata settings\n"); - printf("\t0: return to main menu\n"); - printf("\t1. Title\n"); - printf("\t2. Artist\n"); - printf("\t3. Album\n"); - printf("\t4. Genre \n"); - printf("\t5. NumberOfTracks \n"); - printf("\t6.Track Number \n"); - printf("\t7. Duration \n"); - printf("\tEnter your choice [ ]\b\b"); - - scanf("%d", &cmd); - - switch (cmd) { - case 0: - return; - case 1: /* Title */ - metadata.title = calloc(1,256); - printf("Enter the \"Track\" name\n"); - scanf("%s",(char*)metadata.title); - - break; - case 2: /*Artist */ - metadata.artist = calloc(1,256); - printf(" Enter the \"Artist\" name\n"); - scanf("%s",(char*)metadata.artist); - break; - case 3: /* Album */ - metadata.album = calloc(1,256); - printf(" Enter the \"Album\" name\n"); - scanf("%s",(char*)metadata.album); - break; - case 4: /* Genre */ - metadata.genre = calloc(1,256); - printf(" Enter the \"Genre\" \n"); - scanf("%s",(char*)metadata.genre); - break; - case 5: /* NumberOfTracks */ - printf(" Enter the \" Totol NumberOfTracks\" \n"); - scanf("%d",&metadata.total_tracks); - break; - case 6: /*Track Number */ - printf(" Enter the \" Track Number\" \n"); - scanf("%d",&metadata.number); - break; - case 7: /*Duration */ - printf(" Enter the \"Duration\" \n"); - scanf("%d",&metadata.duration); - break; - default: - break; - } - bluetooth_media_control_player_track_changed(metadata); - - if(NULL != metadata.title) { - free((void*)metadata.title); - metadata.title = NULL; - } - if(NULL != metadata.artist) { - free((void*)metadata.artist); - metadata.artist= NULL; - } - if(NULL != metadata.album) { - free((void*)metadata.album); - metadata.album= NULL; - } - if(NULL != metadata.genre) { - free((void*)metadata.genre); - metadata.genre= NULL; - } - } -} - -void static __choose_player_settings(void) -{ - int cmd; - - while (1) { - printf("\nPlease choose player settings\n"); - printf("\t0: return to main menu\n"); - printf("\t1. Equilizer\n"); - printf("\t2. Repeat\n"); - printf("\t3. Shuffle\n"); - printf("\t4. Scan \n"); - printf("\t5. Status \n"); - printf("\t6. Position \n"); - printf("\tEnter your choice [ ]\b\b"); - - scanf("%d", &cmd); - - switch (cmd) { - case 0: - return; - case 1: /* Equilizer */ - printf("Possible Values - EQUALIZER_OFF = 0x00 and EQUALIZER_ON = 0x01,\n"); - scanf("%d",&player_settings.equilizer); - break; - case 2: /*Repeat */ - printf(" Possible Values - REPEAT_MODE_OFF = 0x00, REPEAT_SINGLE_TRACK = 0x01 , \ - REPEAT_ALL_TRACK = 0x02, REPEAT_GROUP = 0x03\n"); - scanf("%d",&player_settings.repeat); - break; - case 3: /* Shuffle */ - printf(" Possible Values - SHUFFLE_MODE_OFF = 0x00, SHUFFLE_ALL_TRACK = 0x01 , \ - SHUFFLE_GROUP = 0x02\n"); - scanf("%d",&player_settings.shuffle); - break; - case 4: /* Scan */ - printf(" Possible Values - SCAN_MODE_OFF = 0x00, SCAN_ALL_TRACK = 0x01 , \ - SCAN_GROUP = 0x02\n"); - scanf("%s",&player_settings.scan); - break; - case 5: /* Status */ - printf(" Possible Values - STATUS_PLAYING = 0x00, STATUS_STOPPED = 0x01 , \ - STATUS_PAUSED = 0x02,STATUS_FORWARD_SEEK = 0x03 STATUS_REVERSE_SEEK = 0x04 \ - STATUS_ERROR = 0x05\n"); - scanf("%d",&player_settings.status); - break; - case 6: /* Position */ - printf("Enter the possible value: []"); - scanf("%d",&player_settings.position); - break; - default: - break; - } - bluetooth_media_control_player_property_changed(player_settings); - } -} - -int main() -{ - GMainLoop *agent_loop; - int cmd; - - g_type_init(); - agent_loop = g_main_loop_new(NULL, FALSE); - - printf("MP-AV test application started\n"); - while (1) { - printf("\n\n\t0. Exit\n"); - printf("\t1. bluetooth_media_control_init \n"); - printf("\t2. bluetooth_media_control_register_palyer\n"); - printf("\t3. bluetooth_media_control_player_property_changed\n"); - printf("\t4. bluetooth_media_control_player_track_changed\n"); - printf("\t5. bluetooth_media_control_unregister_palyer\n"); - printf("\tEnter your choice [ ]\b\b"); - - scanf("%d", &cmd); - - switch (cmd) { - case 0: /* exit the application */ - { - exit(0); - break; - } - case 1:/*Initialization*/ - { - bluetooth_media_control_init(); - break; - } - case 2: /*Register new Player*/ - { - bluetooth_media_control_register_player(player_settings, metadata); - break; - } - case 3: - { - __choose_player_settings(); - break; - } - case 4: - { - __choose_metadata_settings(); - break; - } - case 5: /*Unregister Player*/ - { - bluetooth_media_control_unregister_player(); - break; - } - } - } - printf("gmain loop enter\n"); - g_main_loop_run(agent_loop); - printf("gmain loop leave\n"); - return 0; -} diff --git a/bluetooth-pb-agent/CMakeLists.txt b/bluetooth-pb-agent/CMakeLists.txt index b2b18e2..c1bb0f2 100644 --- a/bluetooth-pb-agent/CMakeLists.txt +++ b/bluetooth-pb-agent/CMakeLists.txt @@ -15,8 +15,6 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -#pkg_check_modules(pkgs REQUIRED elementary utilX appcore-efl pmapi vconf aul syspopup-caller) -#pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service) pkg_check_modules(pkgs REQUIRED contacts-service vconf) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.c b/bluetooth-pb-agent/bluetooth_pb_agent.c index f27cddb..e0e81a9 100644 --- a/bluetooth-pb-agent/bluetooth_pb_agent.c +++ b/bluetooth-pb-agent/bluetooth_pb_agent.c @@ -103,6 +103,9 @@ static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, gushort max_list, gushort offset, DBusGMethodInvocation *context); +static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, + gchar *path, DBusGMethodInvocation *context); + static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent, DBusGMethodInvocation *context); static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, gchar *call_type, @@ -163,6 +166,85 @@ static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, gushort return TRUE; } +static int __bluetooth_get_calllog_type(int call_type) +{ + int val = CTS_PLOG_TYPE_NONE; + switch (call_type) { + case CTS_PLOG_TYPE_VOICE_INCOMMING: + case CTS_PLOG_TYPE_VIDEO_INCOMMING: + val = CTS_PLOG_TYPE_VOICE_INCOMMING; + break; + + case CTS_PLOG_TYPE_VOICE_OUTGOING: + case CTS_PLOG_TYPE_VIDEO_OUTGOING: + val = CTS_PLOG_TYPE_VOICE_OUTGOING; + break; + + case CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: + case CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN: + case CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN: + case CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN: + val = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; + break; + + default: + break; + } + + return val; +} + +static unsigned int __get_call_log_count(unsigned int call_log_type) +{ + CTSiter *iter = NULL; + unsigned int count = 0; + + contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); + while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue *plog = NULL; + + plog = contacts_svc_iter_get_info(iter); + if (plog) { + int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); + DBG("type: %d\n", type); + int log_type = __bluetooth_get_calllog_type(type); + + if ((call_log_type == 0xFF || call_log_type == log_type) && + (log_type != CTS_PLOG_TYPE_NONE)) { + count++; + } + } + } + return count; +} +static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, + gchar *path, DBusGMethodInvocation *context) +{ + unsigned int nr_contact = 0; + + DBG("%s() %d\n", __FUNCTION__, __LINE__); + contacts_svc_connect(); + + if ((g_strcmp0(path, "SM") == 0) || (g_strcmp0(path, "ME") == 0)) { + nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT); + } else if (g_strcmp0(path, "DC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_OUTGOING); + } else if (g_strcmp0(path, "MC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); + } else if (g_strcmp0(path, "RC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING); + } + DBG("Number of contacts is %d\n", nr_contact); + + contacts_svc_disconnect(); + + DBG("%s() %d\n", __FUNCTION__, __LINE__); + + dbus_g_method_return(context, nr_contact); + + return TRUE; +} + static void __get_vcard_from_contact(int id, int *vcard_total_len, char **vcard) { int ret; @@ -189,16 +271,10 @@ static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent, DBusGMethodInvocation *context) { int i = 0; - int ret; int nr_contact = 0; - - CTSiter *iter = NULL; - CTSstruct *contact = NULL; - - int vcard_len; int vcard_total_len = 0; - char *vcard_stream; + CTSiter *iter = NULL; static int *contact_id = NULL; static int index = 0; int last_part = 0; @@ -285,33 +361,6 @@ static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent, return TRUE; } -static int __bluetooth_get_calllog_type(int call_type) -{ - int val = CTS_PLOG_TYPE_NONE; - switch (call_type) { - case CTS_PLOG_TYPE_VOICE_INCOMMING: - case CTS_PLOG_TYPE_VIDEO_INCOMMING: - val = CTS_PLOG_TYPE_VOICE_INCOMMING; - break; - - case CTS_PLOG_TYPE_VOICE_OUTGOING: - case CTS_PLOG_TYPE_VIDEO_OUTGOING: - val = CTS_PLOG_TYPE_VOICE_OUTGOING; - break; - - case CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: - case CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN: - case CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN: - case CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN: - val = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; - break; - - default: - break; - } - - return val; -} static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list, gushort offset, gchar *call_type, DBusGMethodInvocation *context) { @@ -345,7 +394,6 @@ static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list struct tm timeinfo; char log_time_stamp[32] = {0,}; char calllog_type[10] = {0,}; - int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT); int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); DBG("type: %d\n", type); int log_type = __bluetooth_get_calllog_type(type); @@ -562,20 +610,14 @@ static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, gchar *call plog = contacts_svc_iter_get_info(iter); if (plog) { int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT); - int num_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_NUM_TYPE_INT); - int time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT); int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); - int log_type = __bluetooth_get_calllog_type(type); - int duration = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT); const char *number = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_NUMBER_STR); const char *first_name = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_FIRST_NAME_STR); const char *last_name = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_LAST_NAME_STR); - const char *display_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_DISPLAY_NAME_STR); if (!number) { DBG("number is NULL\n"); @@ -718,10 +760,6 @@ static gboolean bluetooth_pb_get_calls_entry(BluetoothPbAgent *agent, gchar *id, plog = contacts_svc_iter_get_info(iter); if (plog) { int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT); - int num_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_NUM_TYPE_INT); - int time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT); - int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); - int duration = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT); const char *number = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_NUMBER_STR); const char *first_name = contacts_svc_value_get_str(plog, @@ -838,13 +876,13 @@ static gboolean bluetooth_pb_add_contact(BluetoothPbAgent *agent, const char *fi DBG("file_path = %s\n", filename); err = contacts_svc_connect(); - DBG("contact_db_service_connect fucntion call [error] = %d \n", error); + DBG("contact_db_service_connect fucntion call [error] = %d \n", err); err = __bluetooth_pb_agent_read_file(filename, &stream); if (err != 0) { contacts_svc_disconnect(); - DBG("contacts_svc_disconnect fucntion call [error] = %d \n", error); + DBG("contacts_svc_disconnect fucntion call [error] = %d \n", err); if (NULL != stream) { free(stream); @@ -877,8 +915,8 @@ static gboolean bluetooth_pb_add_contact(BluetoothPbAgent *agent, const char *fi DBG("Fail \n"); } - error = contacts_svc_disconnect(); - DBG("contacts_svc_disconnect fucntion call [error] = %d \n", error); + err = contacts_svc_disconnect(); + DBG("contacts_svc_disconnect fucntion call [error] = %d \n", err); if (NULL != stream) { free(stream); diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.xml b/bluetooth-pb-agent/bluetooth_pb_agent.xml index 31a0100..2433b36 100644 --- a/bluetooth-pb-agent/bluetooth_pb_agent.xml +++ b/bluetooth-pb-agent/bluetooth_pb_agent.xml @@ -26,6 +26,12 @@ + + + + + + diff --git a/debian/bluetooth-frwk-test.install.in b/debian/bluetooth-frwk-test.install.in deleted file mode 100644 index 0473f37..0000000 --- a/debian/bluetooth-frwk-test.install.in +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/bluetooth-frwk-test diff --git a/debian/changelog b/debian/changelog index 3763ee7..83a2d8d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +bluetooth-frwk (0.1.48-1) unstable; urgency=low + + * Merge with lastest private git + * Git: pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.48-1 + + -- DoHyun Pyun Thu, 09 Feb 2012 14:06:25 +0900 + bluetooth-frwk (0.1.41-1) unstable; urgency=low * change "com.samsung" -> "org.tizen" diff --git a/debian/control b/debian/control index 42b6c7a..50a0d18 100644 --- a/debian/control +++ b/debian/control @@ -24,12 +24,6 @@ Description: Bluetooth framework for BlueZ This package is development files for Bluetooth framework based on BlueZ stack. This package contains API set for BT GAP, BT SDP, and BT RFCOMM. -Package: bluetooth-frwk-test -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libbluetooth-frwk-0 (= ${Source-Version}) -Description: Bluetooth framework test application - This package is a test application for bluetooth framework. - Package: bluetooth-frwk-agent Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libappcore-efl-0, libslp-utilx-0, libaul-1 diff --git a/debian/rules b/debian/rules index 9ddb186..e469be0 100755 --- a/debian/rules +++ b/debian/rules @@ -91,6 +91,9 @@ clean: rm -f bluetooth-pb-agent/bluetooth_pb_agent_glue.h rm -f bluetooth-map-agent/bluetooth_map_agent_glue.h + rm -f bluetooth-media-control/Makefile + rm -f bluetooth-media-control/bluetooth-media-control.pc + dh_clean install: build diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3d1230e..0b2702c 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,8 +1,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-api C) -SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c bluetooth-obex-server-api.c) -SET(HEADERS bluetooth-api.h SLP_BluetoothFW_PG.h) +SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c +bluetooth-obex-server-api.c bluetooth-hid-api.c) +SET(HEADERS bluetooth-api.h bluetooth-hid-api.h) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") @@ -14,7 +15,8 @@ SET(VERSION ${VERSION_MAJOR}.0.0) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf libxml-2.0) +pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf +libxml-2.0 mdm syspopup-caller) FOREACH(flag ${packages_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -55,5 +57,3 @@ FOREACH(hfile ${HEADERS}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-api) ENDFOREACH(hfile) -ADD_SUBDIRECTORY(test) - diff --git a/lib/bluetooth-api-common.c b/lib/bluetooth-api-common.c index 4054fc4..7cb8139 100644 --- a/lib/bluetooth-api-common.c +++ b/lib/bluetooth-api-common.c @@ -105,7 +105,7 @@ void bluetooth_internal_convert_uuid_num_to_string(const bluetooth_service_uuid_ DBG("-"); } -int bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path) +int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path) { GError *err = NULL; DBusGProxy *manager_proxy = NULL; @@ -353,7 +353,7 @@ DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path) return NULL; } -static void __change_uuids_to_bt_sdp_info(GValue *value, bt_sdp_info_t *sdp_data) +void _bluetooth_change_uuids_to_sdp_info(GValue *value, bt_sdp_info_t *sdp_data) { char **uuids; int i; @@ -469,7 +469,9 @@ static void __bluetooth_internal_device_property_changed(DBusGProxy *device_prox _bluetooth_internal_print_bluetooth_device_address_t(&sdp_data.device_addr); - __change_uuids_to_bt_sdp_info(value, &sdp_data); + _bluetooth_change_uuids_to_sdp_info(value, &sdp_data); + + bt_internal_info->is_service_req = FALSE; /* Report UUID list as xml_parsed_sdp_data to the upper layer. */ if (bt_internal_info->bt_cb_ptr) { @@ -689,7 +691,6 @@ static void __bluetooth_internal_adapter_property_changed(DBusGProxy *adapter, _bluetooth_internal_discovery_completed_cb(); } else { bt_info.is_discovering = TRUE; - bt_info.is_discovery_cancel = FALSE; _bluetooth_internal_discovery_started_cb(); } } else if (g_strcmp0(property, "Discoverable") == 0) { @@ -1124,12 +1125,6 @@ static void __bluetooth_internal_authorized_cb(gboolean authorized, static int __bluetooth_get_default_name(char *default_dev_name, int size) { /* Getting Phone name starts */ - FILE *fp = NULL; - char buff[BT_FILE_BUFFER_MAX+1]; - char *name = NULL; - char *token = NULL; - char *ptr = NULL; - size_t sz = 0; int ret = 0; if (default_dev_name == NULL) { @@ -1150,7 +1145,6 @@ static int __bluetooth_get_default_name(char *default_dev_name, int size) int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size) { int ret = 0; - char phone_no[BT_PHONE_NUM_LEN] = { 0 }; DBG("+"); diff --git a/lib/bluetooth-api-common.h b/lib/bluetooth-api-common.h index 5fd752e..9d63932 100644 --- a/lib/bluetooth-api-common.h +++ b/lib/bluetooth-api-common.h @@ -63,12 +63,20 @@ #define BT_MEMORY_KEY_RESTRICTION "memory/bluetooth/restriction" #define BT_SETTING_DEVICE_NAME "db/setting/device_name" +#define BT_SYSPOPUP_NAME "bt-syspopup" +#define BT_SECURITY_EVENT "bt-security" +#define BT_SECURITY_DISABLED "disabled" + +#define BLUEZ_NAME "org.bluez" +#define BLUEZ_ADAPTER_NAME "org.bluez.Adapter" + #define HCI_SCAN_ENABLE_NO_SCAN 0x00 #define HCI_SCAN_ENABLE_INQUIRY_ONLY 0x01 #define HCI_SCAN_ENABLE_PAGE_ONLY 0x02 #define HCI_SCAN_ENABLE_PAGE_AND_INQUIRY 0x03 #define BT_ADDRESS_STRING_SIZE 18 +#define BT_128_UUID_LEN 36 #define BT_ADAPTER_OBJECT_PATH_MAX 50 #define RFKILL_NODE "/dev/rfkill" @@ -165,6 +173,8 @@ typedef struct { gboolean is_headset_pin_req; /*application request bonding or not*/ bt_info_for_searching_support_service_t info_for_searching_support_service; /**< Service Seaching Session Infomation */ + + gboolean is_service_req; /**< Request to discover device services */ void *user_data; } bt_info_t; @@ -177,6 +187,8 @@ bool _bluetooth_internal_is_adapter_enabled(void); DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path); DBusGProxy *_bluetooth_internal_add_device(const char *path); +void _bluetooth_change_uuids_to_sdp_info(GValue *value, bt_sdp_info_t *sdp_data); + void _bluetooth_internal_print_bluetooth_device_address_t(const bluetooth_device_address_t *addr); void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr, const char *address); @@ -192,6 +204,9 @@ int _bluetooth_internal_set_value(bt_store_key_t key); int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size); +int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path); + + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/lib/bluetooth-api.h b/lib/bluetooth-api.h index d67a95e..8abc057 100644 --- a/lib/bluetooth-api.h +++ b/lib/bluetooth-api.h @@ -50,6 +50,7 @@ extern "C" { #define BLUETOOTH_UUID_STRING_MAX 50 +#define BLUETOOTH_OOB_DATA_LENGTH 16 /** * This is Bluetooth Connected event role */ @@ -221,6 +222,7 @@ typedef enum { BLUETOOTH_EVENT_REMOTE_DEVICE_READ, /**< Bluetooth event read remote device */ BLUETOOTH_EVENT_DEVICE_AUTHORIZED, /**< Bluetooth event authorize device */ BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED, /**< Bluetooth event unauthorize device */ + BLUETOOTH_EVENT_READ_LOCAL_OOB_DATA, /**< Bluetooth event read local oob data */ BLUETOOTH_EVENT_SERVICE_SEARCHED = BLUETOOTH_EVENT_SDP_BASE, /**< Bluetooth event serice search base id */ @@ -278,16 +280,16 @@ typedef enum { BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104), /**result != BLUETOOTH_ERROR_NONE) { + printf("BLUETOOTH_EVENT_READ_LOCAL_OOB_DATA -BLUETOOTH_ERROR "); + break; + } + + printf("BLUETOOTH_EVENT_READ_LOCAL_OOB_DATA - BLUETOOTH_ERROR_NONE"); + memcpy(&g_local_oob_data.oob_data, + (bt_oob_data_t *)param->param_data, + sizeof(bt_oob_data_t)); + + printf("hash = [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X" + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]\n", + g_local_oob_data.oob_data.hash[0], + g_local_oob_data.oob_data.hash[1], + g_local_oob_data.oob_data.hash[2], + g_local_oob_data.oob_data.hash[3], + g_local_oob_data.oob_data.hash[4], + g_local_oob_data.oob_data.hash[5], + g_local_oob_data.oob_data.hash[6], + g_local_oob_data.oob_data.hash[7], + g_local_oob_data.oob_data.hash[8], + g_local_oob_data.oob_data.hash[9], + g_local_oob_data.oob_data.hash[10], + g_local_oob_data.oob_data.hash[11], + g_local_oob_data.oob_data.hash[12], + g_local_oob_data.oob_data.hash[13], + g_local_oob_data.oob_data.hash[14], + g_local_oob_data.oob_data.hash[15]); + + printf("randomizer = [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X" + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]\n", + g_local_oob_data.oob_data.randomizer[0], + g_local_oob_data.oob_data.randomizer[1], + g_local_oob_data.oob_data.randomizer[2], + g_local_oob_data.oob_data.randomizer[3], + g_local_oob_data.oob_data.randomizer[4], + g_local_oob_data.oob_data.randomizer[5], + g_local_oob_data.oob_data.randomizer[6], + g_local_oob_data.oob_data.randomizer[7], + g_local_oob_data.oob_data.randomizer[8], + g_local_oob_data.oob_data.randomizer[9], + g_local_oob_data.oob_data.randomizer[10], + g_local_oob_data.oob_data.randomizer[11], + g_local_oob_data.oob_data.randomizer[12], + g_local_oob_data.oob_data.randomizer[13], + g_local_oob_data.oob_data.randomizer[14], + g_local_oob_data.oob_data.randomizer[15]); + } + } +} + @endcode + */ + +int bluetooth_oob_read_local_data(void); + +/** + * @fn int bluetooth_oob_add_remote_data( + * const bluetooth_device_address_t *remote_device_address, + * bt_oob_data_t *oob_data) + * @brief Add/updated the remote device Hash and Randmizer. + * + * This function is a synchronous call. + * No event for this api.. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * + * @exception None + * @param[in] remote_device_address - Remote device address + * remote_oob_data - Ponter to Hash and Randomizer oob data structure + * + * @remark None + * @see None + */ + +int bluetooth_oob_add_remote_data( + const bluetooth_device_address_t *remote_device_address, + bt_oob_data_t *remote_oob_data); + + +/** + * @fn int bluetooth_oob_remove_remote_data( + * const bluetooth_device_address_t *remote_device_address) + * @brief Delete the Hash and Randomizer w.r.t the remote device address. + * + * This function is a synchronous call. + * No event for this api.. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * + * @exception None + * @param[in] remote_device_address - Remote device address + * + * @remark None + * @see None + */ + +int bluetooth_oob_remove_remote_data( + const bluetooth_device_address_t *remote_device_address); + +/** * @} */ diff --git a/lib/bluetooth-gap-api.c b/lib/bluetooth-gap-api.c index f1f56fd..7ac32d5 100644 --- a/lib/bluetooth-gap-api.c +++ b/lib/bluetooth-gap-api.c @@ -21,6 +21,10 @@ * */ +#include +#include +#include + #include "bluetooth-gap-api.h" static bluetooth_discovery_option_t discovery_option = { 0 }; @@ -176,7 +180,6 @@ static void __bluetooth_internal_change_state_req_finish_cb(DBusGProxy *proxy, D static int __bluetooth_internal_enable_adapter(void *data) { - bluetooth_event_param_t bt_event = { 0, }; bt_info_t *bt_internal_info = NULL; bt_internal_info = _bluetooth_internal_get_information(); @@ -203,14 +206,6 @@ BT_EXPORT_API int bluetooth_enable_adapter(void) DBG("+\n"); - /* If the MDM set the allow value to FALSE, can't enable the adapter */ - if (!vconf_get_bool(BT_MEMORY_KEY_RESTRICTION, &value)) { - if (value == 1) { - DBG("Not allow to enable adapter!!"); - return BLUETOOTH_ERROR_ACCESS_DENIED; - } - } - _bluetooth_internal_session_init(); bt_internal_info = _bluetooth_internal_get_information(); @@ -236,7 +231,6 @@ BT_EXPORT_API int bluetooth_enable_adapter(void) static int __bluetooth_internal_disable_adapter(void *data) { - bluetooth_event_param_t bt_event = { 0, }; bt_info_t *bt_internal_info = NULL; bt_internal_info = _bluetooth_internal_get_information(); @@ -553,6 +547,10 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE: inq_scan = TRUE; pg_scan = TRUE; + + if (bt_internal_info->agent_proxy == NULL) + break; + break; default: return BLUETOOTH_ERROR_INVALID_PARAM; @@ -560,6 +558,12 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t } + /* Set the discoverable timeout value in agent */ + dbus_g_proxy_call_no_reply(bt_internal_info->agent_proxy, + "SetDiscoverableTimer", + G_TYPE_UINT, timeout, + G_TYPE_INVALID); + g_value_set_boolean(&connectable, pg_scan); g_value_set_boolean(&discoverable, inq_scan); g_value_set_uint(&val_timeout, timeout); @@ -1065,9 +1069,7 @@ void _bluetooth_internal_bonding_created_cb(const char *bond_address, gpointer u GValue *value = NULL; GValue *uuid_value = NULL; const gchar *name = NULL; /*Sparrow fix */ - gchar **array_ptr = NULL; - int passkey_len = 0; - gint rssi; + gint rssi = 0; DBG("+\n"); @@ -1083,9 +1085,6 @@ void _bluetooth_internal_bonding_created_cb(const char *bond_address, gpointer u value = g_hash_table_lookup(hash, "Class"); remote_class = value ? g_value_get_uint(value) : 0; - value = g_hash_table_lookup(hash, "PinLength"); - passkey_len = value ? g_value_get_uint(value) : 0; - value = g_hash_table_lookup(hash, "Trusted"); trust = value ? g_value_get_boolean(value) : FALSE; @@ -1139,7 +1138,6 @@ static void __bluetooth_internal_bonding_req_finish_cb(DBusGProxy *proxy, DBusGP int is_headset = 0; char *device_path = NULL; bt_info_t *bt_internal_info = NULL; - bluetooth_device_info_t device_info = { { { 0 } } }; GError *err = NULL; GHashTable *hash = NULL; GValue *value = NULL; @@ -1266,6 +1264,244 @@ static int __bluetooth_internal_bonding_req_timeout_cb(void *data) return 0; } +static void __bluetooth_oob_read_local_data_cb(DBusPendingCall *call, void *user_data) +{ + DBusError err; + DBusMessage *reply = NULL; + unsigned char *hash = NULL; + unsigned char *randomizer = NULL; + unsigned int hash_len; + unsigned int randomizer_len; + + bluetooth_event_param_t bt_event = {0,}; + bt_info_t *bt_internal_info = NULL; + bt_oob_data_t local_oob_data = {{0},}; + + bt_internal_info = _bluetooth_internal_get_information(); + + reply = dbus_pending_call_steal_reply(call); + + dbus_error_init(&err); + if (dbus_set_error_from_message(&err, reply)) { + DBG("ReadLocalData - error: %s, %s", + err.name, err.message); + dbus_error_free(&err); + bt_event.result = BLUETOOTH_ERROR_INTERNAL; + goto done; + } + + if (dbus_message_get_args(reply, &err, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &hash, &hash_len, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &randomizer, &randomizer_len, + DBUS_TYPE_INVALID) == FALSE) { + DBG("unable to parse get_radio_states reply: %s, %s", + err.name, err.message); + dbus_error_free(&err); + bt_event.result = BLUETOOTH_ERROR_INVALID_DATA; + goto done; + } + + if (NULL != hash && hash_len != 0) { + memcpy(&local_oob_data.hash, hash, hash_len); + local_oob_data.hash_len = hash_len; + } + + if (NULL != randomizer && randomizer_len != 0) { + memcpy(&local_oob_data.randomizer, randomizer, randomizer_len); + local_oob_data.randomizer_len = randomizer_len; + } + + bt_event.result = BLUETOOTH_ERROR_NONE; + +done: + bt_event.event = BLUETOOTH_EVENT_READ_LOCAL_OOB_DATA; + bt_event.param_data = (void *)&local_oob_data; + if (bt_internal_info->bt_cb_ptr) { + bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, + bt_internal_info->user_data); + } + dbus_message_unref(reply); +} + +BT_EXPORT_API int bluetooth_oob_read_local_data(void) +{ + DBG("+\n"); + bt_info_t *bt_internal_info = NULL; + DBusMessage *msg = NULL; + DBusPendingCall *call; + + bt_internal_info = _bluetooth_internal_get_information(); + + if (!bt_internal_info->sys_conn) { + bt_internal_info->sys_conn = + dbus_g_connection_get_connection( + bt_internal_info->conn); + } + + msg = dbus_message_new_method_call("org.bluez", + bt_internal_info->adapter_path, + "org.bluez.OutOfBand", + "ReadLocalData"); + + if(msg == NULL) + return BLUETOOTH_ERROR_INTERNAL; + + if (!dbus_connection_send_with_reply(bt_internal_info->sys_conn, msg, + &call, -1)) { + DBG("Error in ReadLocalData \n"); + dbus_message_unref(msg); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_pending_call_set_notify(call, __bluetooth_oob_read_local_data_cb, + NULL, NULL); + dbus_pending_call_unref(call); + dbus_message_unref(msg); + + DBG("-\n"); + + return BLUETOOTH_ERROR_NONE; +} + +BT_EXPORT_API int bluetooth_oob_add_remote_data( + const bluetooth_device_address_t *remote_device_address, + bt_oob_data_t *remote_oob_data) +{ + DBG("+\n"); + DBusMessage *msg = NULL; + DBusMessage *reply = NULL; + DBusError err; + const char *dev_addr = NULL; + + bt_info_t *bt_internal_info = NULL; + char address[BT_ADDRESS_STRING_SIZE] = { 0 }; + unsigned char *remote_hash = NULL; + unsigned char *remote_randomizer = NULL; + + if (NULL == remote_oob_data) { + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + bt_internal_info = _bluetooth_internal_get_information(); + + if (!bt_internal_info->sys_conn) { + bt_internal_info->sys_conn = + dbus_g_connection_get_connection( + bt_internal_info->conn); + } + + _bluetooth_internal_addr_type_to_addr_string(address, + remote_device_address); + + msg = dbus_message_new_method_call("org.bluez", + bt_internal_info->adapter_path, + "org.bluez.OutOfBand", + "AddRemoteData"); + + if (NULL == msg) { + return BLUETOOTH_ERROR_INTERNAL; + } + + DBG("remote hash len = [%d] and remote random len = [%d]\n", + remote_oob_data->hash_len, remote_oob_data->randomizer_len); + + remote_hash = remote_oob_data->hash; + remote_randomizer = remote_oob_data->randomizer; + + dev_addr = g_strdup(address); + DBG("dev_addr = [%s]\n", dev_addr); + + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &dev_addr, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &remote_hash, remote_oob_data->hash_len, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &remote_randomizer, remote_oob_data->randomizer_len, + DBUS_TYPE_INVALID); + + dbus_error_init(&err); + reply = dbus_connection_send_with_reply_and_block(bt_internal_info->sys_conn, + msg, -1, &err); + + dbus_message_unref(msg); + if (!reply) { + DBG("Error in AddRemoteData \n"); + if (dbus_error_is_set(&err)) { + DBG("%s", err.message); + dbus_error_free(&err); + g_free((void *)dev_addr); + return BLUETOOTH_ERROR_INTERNAL; + } + } + + g_free((void *)dev_addr); + dbus_message_unref(reply); + DBG("+\n"); + + return BLUETOOTH_ERROR_NONE; +} + +BT_EXPORT_API int bluetooth_oob_remove_remote_data( + const bluetooth_device_address_t *remote_device_address) +{ + DBG("+\n"); + DBusMessage *msg = NULL; + DBusMessage *reply = NULL; + DBusError err; + + bt_info_t *bt_internal_info = NULL; + char address[BT_ADDRESS_STRING_SIZE] = { 0 }; + + bt_internal_info = _bluetooth_internal_get_information(); + + if (!bt_internal_info->sys_conn) { + bt_internal_info->sys_conn = + dbus_g_connection_get_connection( + bt_internal_info->conn); + } + + _bluetooth_internal_addr_type_to_addr_string(address, remote_device_address); + + const char *dev_addr = g_strdup(address); + DBG("dev_addr = [%s]\n", dev_addr); + + msg = dbus_message_new_method_call("org.bluez", + bt_internal_info->adapter_path, + "org.bluez.OutOfBand", + "RemoveRemoteData"); + + if (NULL == msg ) { + g_free((void *)dev_addr); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_message_append_args(msg, DBUS_TYPE_STRING, + &dev_addr, DBUS_TYPE_INVALID); + + dbus_error_init(&err); + reply = dbus_connection_send_with_reply_and_block(bt_internal_info->sys_conn, + msg, -1, &err); + + dbus_message_unref(msg); + if (!reply) { + DBG("Error in AddRemoteData \n"); + if (dbus_error_is_set(&err)) { + DBG("%s", err.message); + dbus_error_free(&err); + g_free((void *)dev_addr); + return BLUETOOTH_ERROR_INTERNAL; + } + } + + g_free((void *)dev_addr); + dbus_message_unref(reply); + DBG("+\n"); + + return BLUETOOTH_ERROR_NONE; +} + static int __bluetooth_internal_bonding_req(void) { DBG("+"); diff --git a/lib/bluetooth-hdp-api.c b/lib/bluetooth-hdp-api.c index 695b7ae..62a0b07 100644 --- a/lib/bluetooth-hdp-api.c +++ b/lib/bluetooth-hdp-api.c @@ -24,6 +24,8 @@ #include "bluetooth-api-common.h" #include "bluetooth-hdp-api.h" +#define HDP_BUFFER_SIZE 1024 + /********************************************************************** * Static Functions declaration * ***********************************************************************/ @@ -53,8 +55,6 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, GIOCondition cond, gpointer data); -static void __bt_hdp_internal_handle_disconnect_cb(int sk, const char *path); - static int __bt_hdp_internal_destroy_application(const char *app_handle); static void __bt_hdp_internal_remove_filter(void); @@ -692,10 +692,9 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, GIOCondition cond, gpointer data) { DBG("+\n"); - char buff[5000] = { 0, }; + char buff[HDP_BUFFER_SIZE] = { 0, }; int sk; int act_read; - int to_read = sizeof(buff); bt_hdp_data_ind_t data_ind = { 0, }; const char *path = (const char *)data; @@ -704,16 +703,20 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { DBG("GIOCondition %d.............path = %s\n", cond, path); - goto failed; + /* We should simply return from here. Proper disconnection + * happens during ChannelDeleted signal. + */ + return FALSE; } - act_read = recv(sk, (void *)buff, to_read, 0); + act_read = recv(sk, (void *)buff, sizeof(buff), 0); + if (act_read > 0) { DBG("Received data of %d\n", act_read); } else { DBG("Read failed.....\n"); - goto failed; + return FALSE; } data_ind.channel_id = sk; @@ -726,52 +729,6 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, BLUETOOTH_ERROR_NONE, &data_ind); return TRUE; -failed: - __bt_hdp_internal_handle_disconnect_cb(sk, path); - - DBG("-\n"); - - return FALSE; -} - -static void __bt_hdp_internal_handle_disconnect_cb(int sk, const char *path) -{ - DBG("+\n"); - char address[BT_ADDRESS_STRING_SIZE] = { 0, }; - bluetooth_device_address_t device_addr = { {0} }; - bt_hdp_disconnected_t dis_ind = { 0, }; - - hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_fd(sk); - if (NULL == list) { - ERR("** Could not locate the list for fd %d****\n", sk); - return; - } - - _bluetooth_internal_device_path_to_address(path, address); - - _bluetooth_internal_convert_addr_string_to_addr_type( - &device_addr, address); - - dis_ind.channel_id = sk; - - dis_ind.device_address = device_addr; - - __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED, - BLUETOOTH_ERROR_NONE, &dis_ind); - - if (list->fd == -1) { - DBG("*** Warning! FD already deleted**\n"); - } - - list->fd = -1; - - g_free(list->obj_channel_path); - - list->obj_channel_path = NULL; - - DBG("Successfully removed fd value in the list\n"); - - close(sk); DBG("-\n"); } @@ -1062,7 +1019,7 @@ BT_EXPORT_API int bluetooth_hdp_connect(const char *app_handle, } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; @@ -1167,7 +1124,7 @@ BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id, } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; diff --git a/lib/bluetooth-hid-api.c b/lib/bluetooth-hid-api.c new file mode 100644 index 0000000..6274f93 --- /dev/null +++ b/lib/bluetooth-hid-api.c @@ -0,0 +1,446 @@ +/* + * Bluetooth-frwk + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hocheol Seo + * Girishashok Joshi + * Chanyeol Park + * + * 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-api-common.h" +#include "bluetooth-hid-api.h" + +#define BLUEZ_INPUT_NAME "org.bluez.Input" + +#define DBUS_HID_MATCH_RULE \ + "type='signal',interface='" BLUEZ_INPUT_NAME"',member='PropertyChanged'" + +typedef struct { + hid_cb_func_ptr app_cb; + DBusGConnection *conn; + DBusConnection *sys_conn; + DBusGProxy *hid_proxy; + void *user_data; +} bt_hid_info_t; + +static bt_hid_info_t bt_hid_info; + +static void __hid_connection_changed_cb(gboolean connected, + hid_device_address_t *device_addr) +{ + hid_event_param_t bt_event = { 0, }; + + DBG("+"); + + bt_event.event = connected ? BLUETOOTH_HID_CONNECTED : \ + BLUETOOTH_HID_DISCONNECTED; + bt_event.result = HID_ERROR_NONE; + bt_event.param_data = (void *)device_addr; + + if (bt_hid_info.app_cb) + bt_hid_info.app_cb(bt_event.event, &bt_event, bt_hid_info.user_data); + + DBG("-"); +} + +static DBusHandlerResult __hid_event_filter(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + const char *path = dbus_message_get_path(msg); + char *property = NULL; + gboolean property_flag = FALSE; + DBusMessageIter item_iter; + DBusMessageIter value_iter; + + if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + if (!dbus_message_is_signal(msg, BLUEZ_INPUT_NAME, "PropertyChanged")) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (path == NULL || strcmp(path, "/") == 0) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + dbus_message_iter_init(msg, &item_iter); + + if (dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_STRING) { + DBG("This is bad format dbus\n"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + dbus_message_iter_get_basic(&item_iter, &property); + DBG("Property (%s)\n", property); + + if (property == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (!strcmp(property, "Connected")) { + char address[BT_ADDRESS_STRING_SIZE] = { 0, }; + hid_device_address_t device_addr = { {0} }; + + dbus_message_iter_next(&item_iter); + dbus_message_iter_recurse(&item_iter, &value_iter); + dbus_message_iter_get_basic(&value_iter, &property_flag); + + _bluetooth_internal_device_path_to_address(path, address); + _bluetooth_internal_convert_addr_string_to_addr_type( + (bluetooth_device_address_t *)&device_addr, + address); + + __hid_connection_changed_cb(property_flag, &device_addr); + + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void __hid_connect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, + gpointer user_data) +{ + GError *g_error = NULL; + const char *dev_path = NULL; + hid_event_param_t bt_event = { 0, }; + char address[BT_ADDRESS_STRING_SIZE] = { 0, }; + hid_device_address_t device_address = { {0} }; + + DBG("+"); + + dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID); + dev_path = dbus_g_proxy_get_path(proxy); + + if (g_error != NULL) { + DBG("Hidh Connect Dbus Call Error: %s\n", g_error->message); + + g_error_free(g_error); + + _bluetooth_internal_device_path_to_address(dev_path, address); + + _bluetooth_internal_convert_addr_string_to_addr_type( + (bluetooth_device_address_t *)&device_address, + address); + + bt_event.event = BLUETOOTH_HID_CONNECTED; + bt_event.result = HID_ERROR_CONNECTION_FAILED; + bt_event.param_data = (void *)&device_address; + + if (bt_hid_info.app_cb) + bt_hid_info.app_cb(bt_event.event, &bt_event, bt_hid_info.user_data); + + } else { + DBG("Hidh Connect Dbus Call is done\n"); + } + + g_object_unref(proxy); + bt_hid_info.hid_proxy = NULL; + + DBG("-"); +} + + +static void __hid_disconnect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, + gpointer user_data) +{ + GError *g_error = NULL; + const char *dev_path = NULL; + hid_event_param_t bt_event = { 0, }; + char address[BT_ADDRESS_STRING_SIZE] = { 0, }; + hid_device_address_t device_address = { {0} }; + + DBG("+"); + + dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID); + dev_path = dbus_g_proxy_get_path(proxy); + + if (g_error != NULL) { + DBG("Hidh Connect Dbus Call Error: %s\n", g_error->message); + + g_error_free(g_error); + + _bluetooth_internal_device_path_to_address(dev_path, address); + + _bluetooth_internal_convert_addr_string_to_addr_type( + (bluetooth_device_address_t *)&device_address, + address); + + bt_event.event = BLUETOOTH_HID_DISCONNECTED; + bt_event.result = HID_ERROR_CONNECTION_FAILED; + bt_event.param_data = (void *)&device_address; + + if (bt_hid_info.app_cb) + bt_hid_info.app_cb(bt_event.event, &bt_event, bt_hid_info.user_data); + + } else { + DBG("Hidh Disconnect Dbus Call is done\n"); + } + + g_object_unref(proxy); + bt_hid_info.hid_proxy = NULL; + + DBG("-"); +} + + + +/********************************************************************** +* HID APIs * +***********************************************************************/ + +BT_EXPORT_API int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, + void *user_data) +{ + int result = HID_ERROR_NONE; + GError *err = NULL; + DBusError dbus_error; + DBusGConnection *conn = NULL; + DBusConnection *sys_conn = NULL; + + DBG("+"); + + g_type_init(); + + if (bt_hid_info.conn) { + DBG("HID is already initialized"); + return HID_ERROR_ALREADY_INITIALIZED; + } + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); + + if (err != NULL) { + DBG("ERROR: Can't get on system bus [%s]", err->message); + g_error_free(err); + return HID_ERROR_INTERNAL; + } + + sys_conn = dbus_g_connection_get_connection(conn); + + dbus_connection_add_filter(sys_conn, __hid_event_filter, NULL, NULL); + + dbus_error_init(&dbus_error); + + dbus_bus_add_match(sys_conn, DBUS_HID_MATCH_RULE, &dbus_error); + + if (dbus_error_is_set(&dbus_error)) { + DBG("Fail to add dbus filter signal: %s\n", dbus_error.message); + dbus_error_free(&dbus_error); + result = HID_ERROR_INTERNAL; + goto failed; + } + + bt_hid_info.conn = conn; + bt_hid_info.sys_conn = sys_conn; + bt_hid_info.app_cb = callback_ptr; + bt_hid_info.user_data = user_data; + + DBG("-"); + + return HID_ERROR_NONE; +failed: + if (conn) + dbus_g_connection_unref(conn); + + return result; +} + +BT_EXPORT_API int bluetooth_hid_deinit(void) +{ + DBG("+\n"); + + if (bt_hid_info.conn == NULL) { + DBG("HID is not initialized"); + return HID_ERROR_NOT_INITIALIZED; + } + + if (bt_hid_info.sys_conn) { + dbus_connection_remove_filter(bt_hid_info.sys_conn, + __hid_event_filter, + NULL); + + dbus_bus_remove_match(bt_hid_info.sys_conn, + DBUS_HID_MATCH_RULE, NULL); + } + + if (bt_hid_info.hid_proxy) + g_object_unref(bt_hid_info.hid_proxy); + + dbus_g_connection_unref(bt_hid_info.conn); + + bt_hid_info.conn = NULL; + bt_hid_info.sys_conn = NULL; + bt_hid_info.hid_proxy = NULL; + bt_hid_info.app_cb = NULL; + bt_hid_info.user_data = NULL; + + DBG("-\n"); + + return HID_ERROR_NONE; +} + +BT_EXPORT_API int bluetooth_hid_connect(hid_device_address_t *device_address) +{ + GError *g_error = NULL; + DBusGProxy *hid_proxy = NULL; + DBusGProxy *adapter_proxy = NULL; + char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 }; + char address[BT_ADDRESS_STRING_SIZE] = { 0 }; + const char *hid_dev_path = NULL; + + DBG("+\n"); + + if (device_address == NULL) + return HID_ERROR_INVALID_PARAM; + + if (bt_hid_info.conn == NULL) { + DBG("HID is not initialized"); + return HID_ERROR_NOT_INITIALIZED; + } + + /* If the adapter path is wrong, we can think the BT is not enabled. */ + if (_bluetooth_internal_get_adapter_path(bt_hid_info.conn, adapter_path) < 0) { + DBG("Could not get adapter path\n"); + return HID_ERROR_NOT_ENABLED; + } + + adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + adapter_path, BLUEZ_ADAPTER_NAME); + + if (adapter_proxy == NULL) { + DBG("dbus_g_proxy_new_for_name() failed\n"); + return HID_ERROR_INTERNAL; + } + + _bluetooth_internal_addr_type_to_addr_string(address, + (const bluetooth_device_address_t *)device_address); + + dbus_g_proxy_call(adapter_proxy, "FindDevice", + &g_error, G_TYPE_STRING, address, + G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, + &hid_dev_path, G_TYPE_INVALID); + + if (g_error != NULL) { + DBG("Failed to Find device: %s\n", g_error->message); + g_error_free(g_error); + g_object_unref(adapter_proxy); + return HID_ERROR_NOT_PAIRED; + } + + hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + hid_dev_path, BLUEZ_INPUT_NAME); + + if (hid_proxy == NULL) { + DBG("Failed to get hidh proxy\n"); + g_object_unref(adapter_proxy); + return HID_ERROR_NOT_PAIRED; + } + + bt_hid_info.hid_proxy = hid_proxy; + + if (!dbus_g_proxy_begin_call(hid_proxy, "Connect", + (DBusGProxyCallNotify)__hid_connect_request_cb, + NULL, + NULL, G_TYPE_INVALID)) { + DBG("Hidh connect Dbus Call Error"); + g_object_unref(hid_proxy); + g_object_unref(adapter_proxy); + bt_hid_info.hid_proxy = NULL; + return HID_ERROR_CONNECTION_FAILED; + } + + g_object_unref(adapter_proxy); + + DBG("-\n"); + + return HID_ERROR_NONE; +} + +BT_EXPORT_API int bluetooth_hid_disconnect(hid_device_address_t *device_address) +{ + GError *g_error = NULL; + DBusGProxy *hid_proxy = NULL; + DBusGProxy *adapter_proxy = NULL; + char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 }; + char address[BT_ADDRESS_STRING_SIZE] = { 0 }; + const char *hid_dev_path = NULL; + + DBG("+\n"); + + if (device_address == NULL) + return HID_ERROR_INVALID_PARAM; + + if (bt_hid_info.conn == NULL) { + DBG("HID is not initialized"); + return HID_ERROR_NOT_INITIALIZED; + } + + /* If the adapter path is wrong, we can think the BT is not enabled. */ + if (_bluetooth_internal_get_adapter_path(bt_hid_info.conn, adapter_path) < 0) { + DBG("Could not get adapter path\n"); + return HID_ERROR_NOT_ENABLED; + } + + adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + adapter_path, BLUEZ_ADAPTER_NAME); + + if (adapter_proxy == NULL) { + DBG("dbus_g_proxy_new_for_name() failed\n"); + return HID_ERROR_INTERNAL; + } + + _bluetooth_internal_addr_type_to_addr_string(address, + (const bluetooth_device_address_t *)device_address); + + dbus_g_proxy_call(adapter_proxy, "FindDevice", + &g_error, G_TYPE_STRING, address, + G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, + &hid_dev_path, G_TYPE_INVALID); + + if (g_error != NULL) { + DBG("Failed to Find device: %s\n", g_error->message); + g_error_free(g_error); + g_object_unref(adapter_proxy); + return HID_ERROR_NOT_PAIRED; + } + + hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + hid_dev_path, BLUEZ_INPUT_NAME); + + if (hid_proxy == NULL) { + DBG("Failed to get hidh proxy\n"); + g_object_unref(adapter_proxy); + return HID_ERROR_NOT_PAIRED; + } + + bt_hid_info.hid_proxy = hid_proxy; + + if (!dbus_g_proxy_begin_call(hid_proxy, "Disconnect", + (DBusGProxyCallNotify)__hid_disconnect_request_cb, + NULL, + NULL, G_TYPE_INVALID)) { + DBG("Hidh disconnect Dbus Call Error"); + g_object_unref(adapter_proxy); + g_object_unref(hid_proxy); + bt_hid_info.hid_proxy = NULL; + return HID_ERROR_CONNECTION_FAILED; + } + + g_object_unref(adapter_proxy); + + DBG("-\n"); + + return HID_ERROR_NONE; +} diff --git a/lib/bluetooth-hid-api.h b/lib/bluetooth-hid-api.h new file mode 100644 index 0000000..e6d924b --- /dev/null +++ b/lib/bluetooth-hid-api.h @@ -0,0 +1,148 @@ +/* + * Bluetooth-frwk + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hocheol Seo + * Girishashok Joshi + * Chanyeol Park + * + * 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 __BLUETOOTH_HID_API_H +#define __BLUETOOTH_HID_API_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define HID_ADDRESS_LENGTH 6 + +#define HID_ERROR_NONE ((int)0) + +#define HID_ERROR_BASE ((int)0) +#define HID_ERROR_ALREADY_INITIALIZED ((int)HID_ERROR_BASE - 0x01) +#define HID_ERROR_NOT_INITIALIZED ((int)HID_ERROR_BASE - 0x01) +#define HID_ERROR_NOT_PAIRED ((int)HID_ERROR_BASE - 0x02) +#define HID_ERROR_INTERNAL ((int)HID_ERROR_BASE - 0x03) +#define HID_ERROR_INVALID_PARAM ((int)HID_ERROR_BASE - 0x04) +#define HID_ERROR_NOT_ENABLED ((int)HID_ERROR_BASE - 0x05) +#define HID_ERROR_CONNECTION_FAILED ((int)HID_ERROR_BASE - 0x06) + +/** + * Bluetooth event type + */ +typedef enum { + BLUETOOTH_HID_CONNECTED, + BLUETOOTH_HID_DISCONNECTED +} hid_event_t; + +typedef struct { + int event; + int result; + void *param_data; + void *user_data; +} hid_event_param_t; + +typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *); + +typedef struct { + unsigned char addr[HID_ADDRESS_LENGTH]; +} hid_device_address_t; + + +/** + * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data) + * @brief Initialize HID service and register the callback + * + * This function is a synchronous call. + * + * @return HID_ERROR_NONE - Success \n + * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n + * HID_ERROR_INTERNAL - Internal Error \n + * HID_ERROR_NOT_ENABLED - Not enabled \n + * + * @remark None + * + */ +int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data); + +/** + * @fn int bluetooth_hid_deinit(void) + * @brief Initialize HID service and register the callback + * + * This function is a synchronous call. + * + * @return HID_ERROR_NONE - Success \n + * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n + * + * @remark None + * + */ +int bluetooth_hid_deinit(void); + + +/** + * @fn int bluetooth_hid_connect(hid_device_address_t *device_address) + * + * @brief Connect the HID device in the peer + * + * This function is a asynchronous call. + * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event. + * + * @return HID_ERROR_NONE - Success \n + * HID_ERROR_INVALID_PARAM - Invalid parameter \n + * HID_ERROR_NOT_INITIALIZED - Internal Error \n + * HID_ERROR_NOT_ENABLED - Not enabled \n + * HID_ERROR_INTERNAL - Not enabled \n + * HID_ERROR_NOT_PAIRED - Not enabled \n + * HID_ERROR_CONNECTION_FAILED - Connection Fail \n + * + * @exception None + * @param[in] device_address This indicates an address of the device with which the pairing + * should be initiated + * @remark None + */ +int bluetooth_hid_connect(hid_device_address_t *device_address); + +/** + * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address) + * + * @brief Disconnect the HID device in the peer + * + * This function is a asynchronous call. + * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event. + * + * @return HID_ERROR_NONE - Success \n + * HID_ERROR_INVALID_PARAM - Invalid parameter \n + * HID_ERROR_NOT_INITIALIZED - Internal Error \n + * HID_ERROR_NOT_ENABLED - Not enabled \n + * HID_ERROR_INTERNAL - Not enabled \n + * HID_ERROR_NOT_PAIRED - Not enabled \n + * HID_ERROR_CONNECTION_FAILED - Connection Fail \n + * + * @exception None + * @param[in] device_address This indicates an address of the device with which the pairing + * should be initiated + * @remark None + */ +int bluetooth_hid_disconnect(hid_device_address_t *device_address); + + +#ifdef __cplusplus +} +#endif +#endif /* __BLUETOOTH_HID_API_H */ diff --git a/lib/bluetooth-network-api.c b/lib/bluetooth-network-api.c index 816c338..021d18f 100644 --- a/lib/bluetooth-network-api.c +++ b/lib/bluetooth-network-api.c @@ -67,7 +67,7 @@ BT_EXPORT_API int bluetooth_network_activate_server(void) } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; @@ -120,7 +120,7 @@ BT_EXPORT_API int bluetooth_network_deactivate_server(void) } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; @@ -221,7 +221,6 @@ void _bluetooth_network_server_add_signal(void) DBG("+\n"); bt_info_t *bt_internal_info = NULL; - DBusError dbus_error; bt_internal_info = _bluetooth_internal_get_information(); @@ -289,9 +288,8 @@ static void __bluetooth_network_server_connected(DBusGProxy *proxy, gpointer user_data) { bluetooth_event_param_t bt_event = { 0, }; - bluetooth_network_device_info_t device_info = { 0 }; + bluetooth_network_device_info_t device_info = {{{0}}}; bt_info_t *bt_internal_info = NULL; - DBG("+"); if (device == NULL || address == NULL) @@ -320,7 +318,7 @@ static void __bluetooth_network_server_disconnected(DBusGProxy *proxy, gpointer user_data) { bluetooth_event_param_t bt_event = { 0, }; - bluetooth_network_device_info_t device_info = { 0 }; + bluetooth_network_device_info_t device_info = {{{0}}}; bt_info_t *bt_internal_info = NULL; DBG("+"); @@ -377,7 +375,7 @@ BT_EXPORT_API int bluetooth_network_connect(const bluetooth_device_address_t *de } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; @@ -470,7 +468,7 @@ BT_EXPORT_API int bluetooth_network_disconnect(const bluetooth_device_address_t } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; @@ -672,7 +670,6 @@ static DBusHandlerResult __bluetooth_network_event_filter(DBusConnection *sys_co const char *path = dbus_message_get_path(msg); DBusMessageIter item_iter, value_iter; const char *property; - char *state; if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; diff --git a/lib/bluetooth-obex-server-api.c b/lib/bluetooth-obex-server-api.c index 2bcb390..64c60c8 100644 --- a/lib/bluetooth-obex-server-api.c +++ b/lib/bluetooth-obex-server-api.c @@ -215,6 +215,22 @@ static transfer_info_t *_bt_find_transfer(const char *transfer_path) return NULL; } +static transfer_info_t *_bt_find_transfer_by_id(int transfer_id) +{ + GSList *l; + + for (l = transfers; l != NULL; l = l->next) { + transfer_info_t *transfer = l->data; + + if (transfer) { + if (transfer->transfer_id == transfer_id) + return transfer; + } + } + + return NULL; +} + static void __bt_obex_server_transfer_free(transfer_info_t *transfer_info) { DBG("+"); @@ -234,9 +250,9 @@ static void __bt_obex_server_transfer_free(transfer_info_t *transfer_info) g_free(transfer_info->path); g_free(transfer_info->filename); - g_free(transfer_info->device_name); g_free(transfer_info->type); - g_free(transfer_info); + g_free(transfer_info->device_name); + g_free(transfer_info); DBG("-"); } @@ -249,20 +265,23 @@ static int __bt_obex_server_reply_authorize(const guint accept, if (obex_server_info) { if (accept == BT_OBEX_AGENT_ACCEPT) { - dbus_g_method_return(obex_server_info->reply_context, filepath); + dbus_g_method_return(obex_server_info->reply_context, + filepath); } else { GError *error = NULL; error = __bt_obex_agent_error(BT_OBEX_AGENT_ERROR_CANCEL, "CanceledbyUser"); - dbus_g_method_return_error(obex_server_info->reply_context, error); + dbus_g_method_return_error(obex_server_info->reply_context, + error); g_error_free(error); + g_free(obex_server_info->filename); obex_server_info->filename = NULL; + g_free(obex_server_info->transfer_path); + obex_server_info->transfer_path = NULL; g_free(obex_server_info->device_name); obex_server_info->device_name = NULL; - g_free(obex_server_info->type); - obex_server_info->type = NULL; - } + } } DBG("-\n"); @@ -404,72 +423,88 @@ BT_EXPORT_API int bluetooth_obex_server_set_root(char *root) return BLUETOOTH_ERROR_NONE; } -static char *__bt_get_remote_device_name(DBusGConnection *bus, - const char *bdaddress) +BT_EXPORT_API int bluetooth_obex_server_cancel_transfer(int transfer_id) +{ + obex_server_info_t *obex_server_info = &g_obex_server_info; + transfer_info_t *transfer = NULL; + + DBG("+\n"); + + _bluetooth_internal_session_init(); + + if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + DBG("Adapter not enabled"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + if (NULL == obex_server_info->obex_server_agent) { + DBG("Agent not registered"); + return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST; + } + + if (obex_server_info->obex_proxy == NULL) { + DBG("obex_proxy is NULL \n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + transfer = _bt_find_transfer_by_id(transfer_id); + + if (transfer == NULL) { + DBG("No transfer information"); + return BLUETOOTH_ERROR_NOT_FOUND; + } + + dbus_g_proxy_call_no_reply(transfer->transfer_proxy, "Cancel", + G_TYPE_INVALID, G_TYPE_INVALID); + + DBG("+\n"); + + return BLUETOOTH_ERROR_NONE; +} + +static char *__bt_get_remote_device_name(const char *bdaddress) { - DBusGProxy *manager_proxy = NULL; - DBusGProxy *adapter_proxy = NULL; GError *error = NULL; - const char *adapter_path = NULL; char *device_path = NULL; + char *name = NULL; DBusGProxy *device = NULL; GHashTable *hash = NULL; GValue *value; - gchar *name = NULL; + DBusGProxy *device_proxy = NULL; + bt_info_t *bt_internal_info = NULL; + DBG("+\n"); - if ((NULL == bus) || (NULL == bdaddress)) { + if (NULL == bdaddress) return NULL; - } - manager_proxy = dbus_g_proxy_new_for_name(bus, - "org.bluez", "/", - "org.bluez.Manager"); + bt_internal_info = _bluetooth_internal_get_information(); - if (NULL == manager_proxy) { - ERR("ERROR: Can't make dbus proxy"); - goto done; - } + if (bt_internal_info->adapter_proxy == NULL) + return NULL; + + dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", &error, + G_TYPE_STRING, bdaddress, G_TYPE_INVALID, + DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID); - if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &error, - G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &adapter_path, - G_TYPE_INVALID)) { - DBG("Getting DefaultAdapter failed: [%s]", error->message); + if (error != NULL) { + DBG("Error occured in FindDevice Proxy call [%s]\n", error->message); g_error_free(error); - error = NULL; - goto done; + return NULL; } - adapter_proxy = dbus_g_proxy_new_for_name(bus, "org.bluez", - adapter_path, - "org.bluez.Adapter"); - - if (NULL == adapter_proxy) - goto done; + device_proxy = _bluetooth_internal_find_device_by_path(device_path); - if (!dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL, - G_TYPE_STRING, bdaddress, G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &device_path, - G_TYPE_INVALID)) { - goto done; - } - - device = dbus_g_proxy_new_from_proxy(adapter_proxy, - "org.bluez.Device", - device_path); - if (NULL == device) - goto done; + if (!device_proxy) + return NULL; - if (!dbus_g_proxy_call(device, "GetProperties", &error, - G_TYPE_INVALID, - dbus_g_type_get_map("GHashTable", G_TYPE_STRING, - G_TYPE_VALUE), &hash, - G_TYPE_INVALID)) { - DBG("error in GetBasicProperties [%s]\n", error->message); + if (!dbus_g_proxy_call(device_proxy, "GetProperties", &error, + G_TYPE_INVALID, + dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &hash, G_TYPE_INVALID)) { + DBG( "error in GetBasicProperties [%s]\n", error->message); g_error_free(error); - error = NULL; - goto done; + return NULL; } if (hash != NULL) { @@ -477,18 +512,8 @@ static char *__bt_get_remote_device_name(DBusGConnection *bus, name = value ? g_value_dup_string(value) : NULL; } - done: - if (device) - g_object_unref(device); - - if (adapter_proxy) - g_object_unref(adapter_proxy); - - if (manager_proxy) - g_object_unref(manager_proxy); - - DBG("-"); - return name; + DBG("-"); + return name; } static gboolean __bt_authorize_callback(DBusGMethodInvocation *context, @@ -500,33 +525,27 @@ static gboolean __bt_authorize_callback(DBusGMethodInvocation *context, gint time, gpointer user_data) { - char *device_path = NULL; - DBusGProxy *device = NULL; - bt_obex_server_authorize_into_t auth_info; - const gchar *device_name = NULL; - obex_server_info_t *obex_server_info = user_data; + bt_obex_server_authorize_into_t auth_info; + obex_server_info_t *obex_server_info = user_data; + char *device_name = NULL; DBG("+\n"); DBG(" File name [%s] Address [%s] Type [%s] length [%d] path [%s] \n", name, bdaddress, type, length, path); - obex_server_info->reply_context = context; - /* We have to free filename to handle the case - - * authorize reply is sent but transfer started did not come. */ - g_free(obex_server_info->filename); - g_free(obex_server_info->device_name); - g_free(obex_server_info->type); - obex_server_info->filename = g_strdup(name); - auth_info.type = g_strdup(type); - obex_server_info->type = auth_info.type; - auth_info.filename = obex_server_info->filename; - auth_info.length = length; + obex_server_info->reply_context = context; + obex_server_info->filename = g_strdup(name); obex_server_info->file_size = length; - obex_server_info->device_name = __bt_get_remote_device_name(obex_server_info->bus, - bdaddress); - if (NULL == obex_server_info->device_name) - obex_server_info->device_name = g_strdup(bdaddress); + obex_server_info->transfer_path = g_strdup(path); + + device_name = __bt_get_remote_device_name(bdaddress); - auth_info.device_name = obex_server_info->device_name; + if (!device_name) + device_name = g_strdup(bdaddress); + + obex_server_info->device_name = device_name; + + auth_info.filename = obex_server_info->filename; + auth_info.length = length; __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, BLUETOOTH_ERROR_NONE, &auth_info); @@ -556,14 +575,13 @@ static void __bt_transfer_progress_cb(DBusGProxy *object, if (transfer_info) { DBG("File [%s] path [%s]\n", transfer_info->filename, transfer_info->path); - info.filename = transfer_info->filename; - percentage_progress = (gdouble) transferred / (gdouble) total * 100; + + info.filename = transfer_info->filename; info.percentage = percentage_progress; - info.transfer_id = __bt_get_transfer_id(transfer_info->path); + info.transfer_id = transfer_info->transfer_id; + info.file_size = transfer_info->file_size; info.type = transfer_info->type; - info.device_name = transfer_info->device_name; - info.file_size = transfer_info->file_size; DBG("Transfer ID : %d Percentage : %d \n", info.transfer_id, (int)percentage_progress); @@ -573,75 +591,127 @@ static void __bt_transfer_progress_cb(DBusGProxy *object, } } -static void __bt_session_created_cb(DBusGProxy *object, - const char *session_path, - gpointer user_data) +static transfer_info_t *__bt_create_transfer(DBusGConnection *conn, + const char *transfer_path) { - DBG("%s\n", session_path); + transfer_info_t *transfer_info = g_new0(transfer_info_t, 1); + + transfer_info->transfer_proxy = dbus_g_proxy_new_for_name(conn, + "org.openobex", + transfer_path, + "org.openobex.Transfer"); + if (NULL == transfer_info->transfer_proxy) { + DBG("proxy faliled"); + g_free(transfer_info); + return NULL; + } + + dbus_g_proxy_add_signal(transfer_info->transfer_proxy, + "Progress", G_TYPE_INT, + G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(transfer_info->transfer_proxy, + "Progress", + G_CALLBACK(__bt_transfer_progress_cb), + transfer_info, NULL); + + transfer_info->transfer_id = __bt_get_transfer_id(transfer_path); + DBG("Transfer ID : %d \n", transfer_info->transfer_id); + + return transfer_info; } -static void __bt_session_removed_cb(DBusGProxy *object, - const char *session_path, - gpointer user_data) +static int __bt_transfer_get_properties(transfer_info_t *transfer_info) { - DBG("%s\n", session_path); -} + GHashTable *hash = NULL; + GValue *value; + dbus_g_proxy_call(transfer_info->transfer_proxy, "GetProperties", NULL, + G_TYPE_INVALID, + dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &hash, G_TYPE_INVALID); + if (NULL == hash) { + DBG("hash faliled"); + return -1; + } + + value = g_hash_table_lookup(hash, "Operation"); + transfer_info->type = value ? g_strdup(g_value_get_string(value)) : NULL; + if (transfer_info->type == NULL) { + g_hash_table_destroy(hash); + DBG("Operation faliled"); + return -1; + } + + value = g_hash_table_lookup(hash, "Filename"); + transfer_info->filename = value ? g_strdup(g_value_get_string(value)) : NULL; + if (transfer_info->filename == NULL) { + g_hash_table_destroy(hash); + return -1; + } + + value = g_hash_table_lookup(hash, "Size"); + transfer_info->file_size = value ? g_value_get_uint64(value) : 0; + + g_hash_table_destroy(hash); + + DBG("Operation %s :",transfer_info->type); + DBG("FileName %s :", transfer_info->filename); + DBG("Size %d :", transfer_info->file_size); + + return 0; +} static void __bt_transfer_started_cb(DBusGProxy *object, const char *transfer_path, gpointer user_data) { obex_server_info_t *obex_server_info = user_data; bt_obex_server_transfer_info_t app_transfer_info; + transfer_info_t *transfer_info; DBG("%s\n", transfer_path); - transfer_info_t *transfer_info = g_new0(transfer_info_t, 1); - if (transfer_info) { - transfer_info->transfer_proxy = dbus_g_proxy_new_for_name(obex_server_info->bus, - "org.openobex", transfer_path, - "org.openobex.Transfer"); - if (transfer_info->transfer_proxy) { - dbus_g_proxy_add_signal(transfer_info->transfer_proxy, - "Progress", G_TYPE_INT, - G_TYPE_INT, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(transfer_info->transfer_proxy, - "Progress", - G_CALLBACK(__bt_transfer_progress_cb), - transfer_info, NULL); - } - transfer_info->path = g_strdup(transfer_path); + transfer_info = __bt_create_transfer(obex_server_info->bus, transfer_path); + if (NULL == transfer_info) + return; + + if (0 == g_strcmp0(transfer_path, obex_server_info->transfer_path)) { + DBG("OPP transfer"); transfer_info->filename = obex_server_info->filename; - obex_server_info->filename = NULL; + transfer_info->file_size = obex_server_info->file_size; + transfer_info->type = g_strdup(TRANSFER_PUT); + transfer_info->path = obex_server_info->transfer_path; transfer_info->device_name = obex_server_info->device_name; - transfer_info->transfer_id = __bt_get_transfer_id(transfer_info->path); - DBG("Transfer ID : %d \n", transfer_info->transfer_id); + + obex_server_info->filename = NULL; + obex_server_info->transfer_path = NULL; obex_server_info->device_name = NULL; - transfer_info->type = obex_server_info->type; - transfer_info->file_size = obex_server_info->file_size; - obex_server_info->type = NULL; + } else { + if (__bt_transfer_get_properties(transfer_info) < 0) { + DBG("Get Properties failed"); + __bt_obex_server_transfer_free(transfer_info); + return; + } - transfers = g_slist_append(transfers, transfer_info); + transfer_info->path = g_strdup(transfer_path); + } - app_transfer_info.filename = transfer_info->filename; - app_transfer_info.device_name = transfer_info->device_name; - app_transfer_info.transfer_id = transfer_info->transfer_id; - app_transfer_info.type = transfer_info->type; - app_transfer_info.file_size = transfer_info->file_size; + transfers = g_slist_append(transfers, transfer_info); - DBG("Transfer id %d\n", app_transfer_info.transfer_id); + app_transfer_info.filename = transfer_info->filename; + app_transfer_info.transfer_id = transfer_info->transfer_id; + app_transfer_info.type = transfer_info->type; - __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, - BLUETOOTH_ERROR_NONE, &app_transfer_info); - } -} + DBG("Transfer id %d\n", app_transfer_info.transfer_id); + + __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, + BLUETOOTH_ERROR_NONE, &app_transfer_info); + } static void __bt_transfer_completed_cb(DBusGProxy *object, const char *transfer_path, gboolean success, gpointer user_data) { - obex_server_info_t *obex_server_info = user_data; transfer_info_t *transfer_info; int result; DBG("Transfer [%s] Success [%d] \n", transfer_path, success); @@ -655,10 +725,10 @@ static void __bt_transfer_completed_cb(DBusGProxy *object, bt_obex_server_transfer_info_t transfer_complete_info; transfers = g_slist_remove(transfers, transfer_info); transfer_complete_info.filename = transfer_info->filename; - transfer_complete_info.device_name = transfer_info->device_name; - transfer_complete_info.transfer_id = __bt_get_transfer_id(transfer_path); + transfer_complete_info.transfer_id = transfer_info->transfer_id; + transfer_complete_info.file_size = transfer_info->file_size; transfer_complete_info.type = transfer_info->type; - transfer_complete_info.file_size - transfer_info->file_size; + transfer_complete_info.device_name = transfer_info->device_name; __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED, result, &transfer_complete_info); @@ -734,22 +804,6 @@ static int __bt_obex_agent_register(obex_server_info_t *obex_server_info, G_CALLBACK(__bt_transfer_completed_cb), obex_server_info, NULL); - dbus_g_proxy_add_signal(obex_server_info->obex_proxy, "SessionCreated", - DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(obex_server_info->obex_proxy, - "SessionCreated", - G_CALLBACK(__bt_session_created_cb), - obex_server_info, NULL); - - dbus_g_proxy_add_signal(obex_server_info->obex_proxy, "SessionRemoved", - DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(obex_server_info->obex_proxy, - "SessionRemoved", - G_CALLBACK(__bt_session_removed_cb), - obex_server_info, NULL); - return BLUETOOTH_ERROR_NONE; } @@ -776,16 +830,6 @@ static void __bt_obex_agent_unregister(obex_server_info_t *obex_server_info) G_CALLBACK(__bt_transfer_completed_cb), obex_server_info); - dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy, - "SessionCreated", - G_CALLBACK(__bt_session_created_cb), - obex_server_info); - - dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy, - "SessionRemoved", - G_CALLBACK(__bt_session_removed_cb), - obex_server_info); - obex_server_info->bus = NULL; g_object_unref(obex_server_info->obex_proxy); diff --git a/lib/bluetooth-obex-server-api.h b/lib/bluetooth-obex-server-api.h index 30bf834..04a2c31 100644 --- a/lib/bluetooth-obex-server-api.h +++ b/lib/bluetooth-obex-server-api.h @@ -51,9 +51,9 @@ typedef struct { DBusGProxy *obex_proxy; DBusGMethodInvocation *reply_context; char *filename; + char *transfer_path; char *device_name; - char *type; - int file_size; + int file_size; } obex_server_info_t; typedef enum { @@ -65,11 +65,11 @@ typedef enum { typedef struct { DBusGProxy *transfer_proxy; - char *path; char *filename; - char *device_name; + char *path; char *type; - int transfer_id; + char *device_name; + int transfer_id; int file_size; } transfer_info_t; diff --git a/lib/bluetooth-opc-api.c b/lib/bluetooth-opc-api.c index f820a26..b9179d6 100644 --- a/lib/bluetooth-opc-api.c +++ b/lib/bluetooth-opc-api.c @@ -154,7 +154,6 @@ BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_ad GHashTable *hash; GValue *value; char address[BT_BD_ADDR_MAX_LEN] = { 0 }; - GError *error = NULL; char agent_path[100] = {0}; if (remote_address == NULL || file_name_array == NULL) @@ -248,7 +247,7 @@ BT_EXPORT_API int bluetooth_opc_cancel_push(void) return BLUETOOTH_ERROR_NONE; } -BT_EXPORT_API gboolean bluetooth_opc_sessioin_is_exist(void) +BT_EXPORT_API gboolean bluetooth_opc_session_is_exist(void) { DBG("+"); @@ -548,7 +547,6 @@ static gboolean __bt_error_callback(DBusGMethodInvocation *context, static int __bt_obex_client_agent_init(char *agent_path) { - int random_num = 0; opc_obex_agent = obex_agent_new(); if(NULL == opc_obex_agent) diff --git a/lib/bluetooth-rfcomm-api.c b/lib/bluetooth-rfcomm-api.c index 52ecfa9..6049e64 100644 --- a/lib/bluetooth-rfcomm-api.c +++ b/lib/bluetooth-rfcomm-api.c @@ -39,6 +39,7 @@ #include #include "bluetooth-rfcomm-api.h" +#include #define BLUEZ_SERVICE_NAME "org.bluez" #define BLUEZ_SERIAL_CLINET_INTERFACE "org.bluez.Serial" @@ -80,7 +81,9 @@ static int __bluetooth_rfcomm_internal_client_get_index_from_socket(int fd); static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data); -static int __bluetooth_internal_set_nonblocking(int sk); +static int __bluetooth_internal_set_non_blocking(int sk); + +static int __bluetooth_internal_set_non_blocking_tty(int sk); /*Get the free index channel for server */ static int __bluetooth_rfcomm_internal_server_get_free_index(void) @@ -290,7 +293,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond int fd = g_io_channel_unix_get_fd(chan); int index = __bluetooth_rfcomm_internal_server_get_index_from_socket(fd); if (index < 0) { - DBG("Invalid index %d", index); + ERR("Invalid index %d", index); return BLUETOOTH_ERROR_INVALID_PARAM; } int server_sock, client_sock; @@ -314,7 +317,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond (struct sockaddr *)&client_sock_addr, (socklen_t *)&client_addr_len); if (client_sock < 0) { - perror("Server Accept Error"); + ERR("Server Accept Error"); return TRUE; } else { @@ -322,21 +325,11 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond } - long arg; - - arg = fcntl(client_sock, F_GETFL); - - if (arg < 0) - return -errno; - - if (arg & O_NONBLOCK) { - DBG("Already blocking \n"); - arg ^= O_NONBLOCK; + if(__bluetooth_internal_set_non_blocking_tty(client_sock) < 0) { + /* Even if setting the tty fails we will continue */ + DBG("Warning!!Setting the tty properties failed(%d)\n", client_sock); } - if (fcntl(client_sock, F_SETFL, arg) < 0) - return -errno; - rfcomm_server[index].client_sock_fd = client_sock; rfcomm_server[index].client_io_channel = g_io_channel_unix_new(client_sock); @@ -366,7 +359,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond if (!reply) { DBG("\nCan't Call GetInfo Proxy\n"); if (dbus_error_is_set(&error)) { - DBG("%s\n", error.message); + ERR("%s\n", error.message); dbus_error_free(&error); } return -1; @@ -375,7 +368,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond dbus_message_iter_init(reply, &reply_iter); if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { - DBG("Can't get reply arguments - DBUS_TYPE_ARRAY\n"); + ERR("Can't get reply arguments - DBUS_TYPE_ARRAY\n"); dbus_message_unref(reply); return -1; } @@ -694,6 +687,105 @@ static int __get_rfcomm_proxy_list(char ***proxy_list, int *len) return 0; } + +static gboolean __get_rfcomm_is_match_uuid(char *proxy, const char *uuid) +{ + DBusMessage *msg = NULL; + DBusMessage *reply = NULL; + DBusError error; + DBusMessageIter reply_iter; + DBusMessageIter reply_iter_entry; + const char *property; + DBusConnection *conn = NULL; + + conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + + if (proxy == NULL || uuid == NULL) + return FALSE; + + /* GetInfo Proxy Part */ + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, + proxy, + BLUEZ_SERIAL_PROXY_INTERFACE, "GetInfo"); + + conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) + return FALSE; + + dbus_error_init(&error); + + reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &error); + dbus_message_unref(msg); + + if (!reply) { + DBG("\nCan't Call GetInfo Proxy\n"); + if (dbus_error_is_set(&error)) { + ERR("%s\n", error.message); + dbus_error_free(&error); + } + dbus_connection_unref(conn); + return FALSE; + } + + dbus_message_iter_init(reply, &reply_iter); + + if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { + ERR("Can't get reply arguments - DBUS_TYPE_ARRAY\n"); + dbus_message_unref(reply); + dbus_connection_unref(conn); + return FALSE; + } + + dbus_message_iter_recurse(&reply_iter, &reply_iter_entry); + + /*Parse the dict */ + while (dbus_message_iter_get_arg_type(&reply_iter_entry) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter dict_entry; + DBusMessageIter dict_entry_val; + + dbus_message_iter_recurse(&reply_iter_entry, &dict_entry); + + dbus_message_iter_get_basic(&dict_entry, &property); /*get key value*/ + DBG("property = %s\n", property); + + if (g_strcmp0("uuid", property) == 0) { + const char *value; + + if (!dbus_message_iter_next(&dict_entry)) + DBG("Fail\n"); + + if (dbus_message_iter_get_arg_type(&dict_entry) != DBUS_TYPE_VARIANT) + DBG("Fail\n"); + + /*Getting the value of the varient*/ + dbus_message_iter_recurse(&dict_entry, &dict_entry_val); + + if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_STRING) + DBG("Fail\n"); + + dbus_message_iter_get_basic(&dict_entry_val, &value); + + DBG("uuid = %s", value); + + if (g_strcasecmp(uuid, value) == 0) { + dbus_message_unref(reply); + dbus_connection_unref(conn); + return TRUE; + } + + } + + dbus_message_iter_next(&reply_iter_entry); + } + + dbus_message_unref(reply); + dbus_connection_unref(conn); + + return FALSE; +} + + /*Server Part */ /* * SLP 2.0 Bluetooth RFCOMM API @@ -815,6 +907,8 @@ BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid) } dbus_message_unref(reply); + DBG("uds_proxy = %s, %s", uds_proxy, rfcomm_server[index].uds_name); + /* Make Unix Socket */ int sk; struct sockaddr_un server_addr; @@ -841,15 +935,19 @@ BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid) if (bind(sk, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { perror("\nCan't Bind Sock\n"); + close(sk); return BLUETOOTH_ERROR_INTERNAL; } DBG("Return fd = %d\n", sk); - DBG("-\n"); - ret = __bluetooth_internal_set_nonblocking(sk); - if (ret != 0) - return ret; + ret = __bluetooth_internal_set_non_blocking(sk); + DBG("-\n"); + if (ret != 0) { + DBG("Cannot set the tty%d\n", sk); + close(sk); + return BLUETOOTH_ERROR_INTERNAL; + } else return sk; } @@ -1090,6 +1188,12 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call DBG("\n/dev/rfcomm fd = %d\n", dev_node_fd); + if(__bluetooth_internal_set_non_blocking_tty(dev_node_fd) < 0) { + DBG("\nWarning! Unable to set the tty /dev/rfcomm fd = %d\n", + dev_node_fd); + /* Even if setting the tty fails we will continue */ + } + rfcomm_client[index].id = index; rfcomm_client[index].sock_fd = dev_node_fd; rfcomm_client[index].dev_node_name = dev_node; @@ -1352,9 +1456,9 @@ BT_EXPORT_API int bluetooth_rfcomm_write(int fd, const char *buf, int length) DBG("-\n"); } -static int __bluetooth_internal_set_nonblocking(int sk) +static int __bluetooth_internal_set_non_blocking(int sk) { -/* Set Nonblocking */ + /* Set Nonblocking */ long arg; arg = fcntl(sk, F_GETFL); @@ -1370,5 +1474,31 @@ static int __bluetooth_internal_set_nonblocking(int sk) if (fcntl(sk, F_SETFL, arg) < 0) return -errno; + return 0; } + +static int __bluetooth_internal_set_non_blocking_tty(int sk) +{ + struct termios ti = {0,}; + int err = 0; + + err = __bluetooth_internal_set_non_blocking(sk); + + if (err < 0) { + ERR("Error in set non blocking!\n"); + return err; + } + + /*Setting tty line disipline*/ + DBG("\nsetting raw\n"); + + tcflush(sk, TCIOFLUSH); + + /* Switch tty to RAW mode */ + cfmakeraw(&ti); + tcsetattr(sk, TCSANOW, &ti); + + return 0; +} + diff --git a/lib/bluetooth-sdp-api.c b/lib/bluetooth-sdp-api.c index 85d498a..d8ae518 100644 --- a/lib/bluetooth-sdp-api.c +++ b/lib/bluetooth-sdp-api.c @@ -231,7 +231,9 @@ static gboolean __bluetooth_internal_get_service_class_id_list_from_node(xmlNode if (sdp_info->service_index < BLUETOOTH_MAX_SERVICES_FOR_DEVICE) { DBG("sdp_info->service_index %d", sdp_info->service_index); - g_strlcpy(sdp_info->uuids[sdp_info->service_index], uuid_attr->children->content, BLUETOOTH_UUID_STRING_MAX); + g_strlcpy(sdp_info->uuids[sdp_info->service_index], + (const gchar *)uuid_attr->children->content, + BLUETOOTH_UUID_STRING_MAX); sdp_info->service_list_array[sdp_info->service_index] = strtol((char *)uuid_attr->children->content, @@ -403,140 +405,93 @@ static void __bluetooth_internal_discover_services_cb(DBusGProxy *proxy, DBusGPr { GError *err = NULL; GHashTable *hash; - static bt_sdp_info_t xml_parsed_sdp_data; + GHashTable *property_hash; + GValue *value; + const char *dev_path = NULL; + static bt_sdp_info_t sdp_data; bt_info_t *bt_internal_info = NULL; bluetooth_event_param_t bt_event = { 0, }; bt_info_for_searching_support_service_t *bt_info_for_searching_support_service = (bt_info_for_searching_support_service_t *) user_data; - /* if service_info is NULL, it means search discover Browse group - Otherwise, it means search known UUIDs. - */ - - match_entries_t *service_info = bt_info_for_searching_support_service->search_match_ptr; - char *xml_record = NULL; - - DBG("+\n"); - dbus_g_proxy_end_call(proxy, call, &err, dbus_g_type_get_map("GHashTable", G_TYPE_UINT, G_TYPE_STRING), &hash, G_TYPE_INVALID); - _bluetooth_internal_print_bluetooth_device_address_t(&bt_info_for_searching_support_service->remote_device_addr); - memcpy(&xml_parsed_sdp_data.device_addr, - &bt_info_for_searching_support_service->remote_device_addr, - sizeof(bluetooth_device_address_t)); + bt_internal_info = _bluetooth_internal_get_information(); if (err != NULL) { DBG("Error occured in Proxy call [%s]\n", err->message); - xml_parsed_sdp_data.service_index = 0; + sdp_data.service_index = 0; if (!strcmp("Operation canceled", err->message)) { - __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data, + __bluetooth_internal_sdp_fail_cb(&sdp_data, BLUETOOTH_ERROR_CANCEL_BY_USER); } else if (!strcmp("In Progress", err->message)) { - __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data, + __bluetooth_internal_sdp_fail_cb(&sdp_data, BLUETOOTH_ERROR_IN_PROGRESS); } else if (!strcmp("Host is down", err->message)) { - __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data, + __bluetooth_internal_sdp_fail_cb(&sdp_data, BLUETOOTH_ERROR_HOST_DOWN); } else { - __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data, + __bluetooth_internal_sdp_fail_cb(&sdp_data, BLUETOOTH_ERROR_CONNECTION_ERROR); } + bt_internal_info->is_service_req = FALSE; + g_error_free(err); return; } - bt_internal_info = _bluetooth_internal_get_information(); - - if (service_info == NULL) { - xml_parsed_sdp_data.service_index = 0; - bt_info_for_searching_support_service->success_search_index = 0; - memcpy(&xml_parsed_sdp_data.device_addr, - &bt_info_for_searching_support_service->remote_device_addr, - sizeof(bluetooth_device_address_t)); -/* Read SDP XML record direclty and Call back to the upper layer. */ - - if (hash != NULL) { - GList *list = g_hash_table_get_values(hash); - GList *ptr = NULL; - for (ptr = list; ptr; ptr = ptr->next) { - xml_record = ptr->data; - __bluetooth_internal_parse_sdp_xml(xml_record, - g_utf8_strlen(xml_record, -1), - &xml_parsed_sdp_data); - } - } - - if (bt_internal_info->bt_cb_ptr) { - bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED; - DBG("service_index %d\n", xml_parsed_sdp_data.service_index); - if (xml_parsed_sdp_data.service_index < 0) { - bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR; - xml_parsed_sdp_data.service_index = 0; - } else if (xml_parsed_sdp_data.service_index == 0) { - /*This is for some carkit, printer.*/ - __bluetooth_internal_request_search_supported_services( - &bt_info_for_searching_support_service->remote_device_addr); - return; - } else { - bt_event.result = BLUETOOTH_ERROR_NONE; - bt_event.param_data = &xml_parsed_sdp_data; - } - - bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data); - } + if (bt_internal_info->is_service_req == FALSE) { + /* This flag is unset in __bluetooth_internal_device_property_changed function. + If the UUIDs was updated, __bluetooth_internal_device_property_changed func + was called first. So we don't need to send the callback event. + */ + DBG("Searched event is already sent"); return; } - xml_parsed_sdp_data.service_index = service_info - supported_service_info; - DBG("service_index %d\n", xml_parsed_sdp_data.service_index); - - DBG("Search Service[%s]\n", service_info->match_name); - if (hash != NULL) { - GList *list = g_hash_table_get_values(hash); - if (list != NULL && g_list_length(list) > 0) { - xml_record = (char *)g_list_nth_data(list, 0); - __bluetooth_internal_parse_sdp_xml(xml_record, g_utf8_strlen(xml_record, -1), - &xml_parsed_sdp_data); - } - } - - if (xml_record == NULL) { - DBG("No Record [%s]\n", service_info->match_name); + bt_internal_info->is_service_req = FALSE; - } + /* If there is no changes in device's UUIDs, device_property_changed func is not called. + In this case, we use the UUIDs value in device's property. */ - bt_info_for_searching_support_service->search_match_ptr++; - service_info = bt_info_for_searching_support_service->search_match_ptr; + dev_path = dbus_g_proxy_get_path(proxy); - DBG("Search Service[%s]\n", service_info->match_name); + memcpy(&sdp_data.device_addr, + &bt_info_for_searching_support_service->remote_device_addr, + sizeof(bluetooth_device_address_t)); - if (service_info->match) { - __bluetooth_internal_get_remote_service_handle(proxy, - bt_info_for_searching_support_service); - } else { - DBG("Search Ending\n"); - /* Report UUID list as xml_parsed_sdp_data to the upper layer. */ - if (bt_internal_info->bt_cb_ptr) { - bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED; - if (xml_parsed_sdp_data.service_index <= 0 - || xml_parsed_sdp_data.service_index >= - BLUETOOTH_MAX_SERVICES_FOR_DEVICE) { - bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR; - xml_parsed_sdp_data.service_index = 0; - } else { - bt_event.result = BLUETOOTH_ERROR_NONE; - bt_event.param_data = &xml_parsed_sdp_data; - } + dbus_g_proxy_call(proxy, "GetProperties", NULL, + G_TYPE_INVALID, + dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &property_hash, G_TYPE_INVALID); - bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, - bt_internal_info->user_data); + if (property_hash != NULL) { + value = g_hash_table_lookup(property_hash, "UUIDs"); + _bluetooth_change_uuids_to_sdp_info(value, &sdp_data); + } + if (bt_internal_info->bt_cb_ptr) { + bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED; + DBG("service_index %d\n", sdp_data.service_index); + if (sdp_data.service_index < 0) { + bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR; + sdp_data.service_index = 0; + } else if (sdp_data.service_index == 0) { + /*This is for some carkit, printer.*/ + __bluetooth_internal_request_search_supported_services( + &bt_info_for_searching_support_service->remote_device_addr); + return; + } else { + bt_event.result = BLUETOOTH_ERROR_NONE; + bt_event.param_data = &sdp_data; } + + bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data); } DBG("-\n"); @@ -628,6 +583,8 @@ BT_EXPORT_API int bluetooth_search_service(const bluetooth_device_address_t *dev return BLUETOOTH_ERROR_NONE; } + bt_internal_info->is_service_req = TRUE; + } return BLUETOOTH_ERROR_NONE; diff --git a/lib/obex-agent.c b/lib/obex-agent.c index 65d7aeb..f450986 100644 --- a/lib/obex-agent.c +++ b/lib/obex-agent.c @@ -119,7 +119,7 @@ static gboolean obex_agent_authorize(ObexAgent *agent, const char *path, const c ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent); gboolean result = FALSE; - DBG("agent %p sender %s", agent); + DBG("agent %p", agent); if (priv->authorize_func) { result = priv->authorize_func(context, path, bdaddress, name, type, length, time, diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt deleted file mode 100644 index 03bdba8..0000000 --- a/lib/test/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-frwk-test C) - -SET(SRCS bluetooth-frwk-test.c) - -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) - -INCLUDE(FindPkgConfig) -pkg_check_modules(package REQUIRED dlog dbus-glib-1 glib-2.0 gthread-2.0) - -FOREACH(flag ${package_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -FIND_PROGRAM(UNAME NAMES uname) -EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") -IF("${ARCH}" STREQUAL "arm") - ADD_DEFINITIONS("-DTARGET") - MESSAGE("add -DTARGET") -ENDIF("${ARCH}" STREQUAL "arm") - -ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") - -ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${package_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lbluetooth-api) - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) - diff --git a/lib/test/bluetooth-frwk-test.c b/lib/test/bluetooth-frwk-test.c deleted file mode 100644 index 7f2f2f8..0000000 --- a/lib/test/bluetooth-frwk-test.c +++ /dev/null @@ -1,1356 +0,0 @@ -/* - * Bluetooth-frwk - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hocheol Seo - * Girishashok Joshi - * Chanyeol Park - * - * 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 bluetooth-frwk-test.c - * @brief This is the source file for bluetooth framework test suite. - */ - -#include -#include -#include -#include -#include - -#include "bluetooth-api.h" - - -bluetooth_device_address_t searched_device = {{0}}; - -#define TC_TIMEOUT 30000 - -#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET" -#define DISCOVER_TIMEOUT 20 -#define DISCOVER_CANCEL_INTERVAL 3 - -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define TC_PRT(format, args...) PRT(format"\n", ##args) - -#define TC_PASS 1 -#define TC_FAIL 0 -int g_tmp = 0; -int g_ret_client_fd1 = -1, g_ret_client_fd2 = -1; -const char *g_hdp_app_handle1 = NULL; -const char *g_hdp_app_handle2 = NULL; -int selection; -int hdp_manual_mode = 1; -const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB"; -const char * rfcomm_test_uuid_dun = "00001103-0000-1000-8000-00805F9B34FB"; - -GMainLoop *main_loop = NULL; -static int timeout_status = 0; - -typedef struct -{ - const char *tc_name; - int tc_code; -} tc_table_t; - -tc_table_t tc_table[] = -{ - {"bluetooth_register_callback" , 0x0001}, - {"bluetooth_enable_adapter" , 0x0002}, - {"bluetooth_disable_adapter" , 0x0003}, - {"bluetooth_check_adapter" , 0x0004}, - {"bluetooth_get_local_address" , 0x0005}, - {"bluetooth_get_local_name" , 0x0006}, - {"bluetooth_set_local_name" , 0x0007}, - {"bluetooth_get_discoverable_mode" , 0x0008}, - {"bluetooth_set_discoverable_mode" , 0x0009}, - {"bluetooth_start_discovery" , 0x000a}, - {"bluetooth_cancel_discovery" , 0x000b}, - {"bluetooth_is_discovering" , 0x000c}, - {"bluetooth_bond_device" , 0x000d}, - {"bluetooth_cancel_bonding" , 0x000e}, - {"bluetooth_unbond_device" , 0x000f}, - {"bluetooth_get_bonded_device_list" , 0x0010}, - {"bluetooth_get_remote_device" , 0x0011}, - {"bluetooth_authorize_device" , 0x0012}, - {"bluetooth_search_service" , 0x0013}, - {"bluetooth_set_alias" , 0x0014}, - /*Rfcomm related*/ - {"bluetooth_rfcomm_create_socket" , 0x0020}, - {"bluetooth_rfcomm_listen_and_accept" , 0x0021}, - {"bluetooth_rfcomm_remove_socket" , 0x0022}, - - {"bluetooth_rfcomm_connect" , 0x0023}, - {"bluetooth_rfcomm_disconnect" , 0x0024}, - {"bluetooth_rfcomm_write" , 0x0025}, - {"bluetooth_network_activate_server" , 0x0026}, - {"bluetooth_network_deactivate_server" , 0x0027}, - {"bluetooth_network_connect" , 0x0028}, - {"bluetooth_network_disconnect" , 0x0029}, - - {"bluetooth_hdp_activate" , 0x0030}, - {"bluetooth_hdp_deactivate" , 0x0031}, - {"bluetooth_hdp_connect" , 0x0032}, - {"bluetooth_hdp_disconnect" , 0x0033}, - {"bluetooth_hdp_send_data" , 0x0034}, - - {"bluetooth_opc_init" , 0x0035}, - {"bluetooth_opc_push_file" , 0x0036}, - {"bluetooth_opc_cancel_push" , 0x0037}, - {"bluetooth_opc_deinit" , 0x0038}, - /* -----------------------------------------*/ - {"Finish" , 0x00ff}, - {NULL , 0x0000}, - -}; - -#define tc_result(success, tc_index) \ - TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS)?"Success":"Failed")); - -bluetooth_device_info_t bond_dev; -int is_bond_device = FALSE; - -void tc_usage_print(void) -{ - int i = 0; - - while (tc_table[i].tc_name && tc_table[i].tc_code) - { - if (tc_table[i].tc_code != 0x00ff) - { - TC_PRT("Key %d : usage %s", i, tc_table[i].tc_name); - } - else - { - TC_PRT("Key %d : usage %s\n\n", 0x00ff, tc_table[i].tc_name); - } - - i++; - } - -} - -int test_input_callback(void *data) -{ - int ret = 0; - int test_id = (int)data; - - switch (test_id) - { - case 0x00ff: - TC_PRT("Finished"); - g_main_loop_quit(main_loop); - break; - - case 1: - TC_PRT("TC : %s", tc_table[1].tc_name); - ret = bluetooth_enable_adapter(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[1].tc_name, ret); - tc_result(TC_FAIL, 1); - } - break; - - case 2: - TC_PRT("TC : %s", tc_table[2].tc_name); - ret = bluetooth_disable_adapter(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[2].tc_name, ret); - tc_result(TC_FAIL, 2); - } - break; - - case 3: - TC_PRT("TC : %s", tc_table[3].tc_name); - ret = bluetooth_check_adapter(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[3].tc_name, ret); - tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret); - tc_result(TC_PASS, 3); - } - break; - - case 4: - { - bluetooth_device_address_t local_address = {{0}}; - - TC_PRT("TC : %s", tc_table[4].tc_name); - ret = bluetooth_get_local_address(&local_address); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[4].tc_name, ret); - tc_result(TC_FAIL, 4); - } - else - { - TC_PRT("BT local address[%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - local_address.addr[0], local_address.addr[1], local_address.addr[2], \ - local_address.addr[3], local_address.addr[4], local_address.addr[5]); - tc_result(TC_PASS, 4); - } - break; - } - - case 5: - { - bluetooth_device_name_t local_name = {{0}}; - - TC_PRT("TC : %s", tc_table[5].tc_name); - ret = bluetooth_get_local_name(&local_name); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[5].tc_name, ret); - tc_result(TC_FAIL, 5); - } - else - { - TC_PRT("BT local name [%s]", \ - local_name.name); - tc_result(TC_PASS, 5); - } - break; - } - - case 6: - { - bluetooth_device_name_t local_name = {{0}}; - snprintf(local_name.name, sizeof(local_name.name), - "bt-frwk-pid-%d", getpid()); - - TC_PRT("TC : %s", tc_table[6].tc_name); - ret = bluetooth_set_local_name(&local_name); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[6].tc_name, ret); - tc_result(TC_FAIL, 6); - } - break; - } - - case 7: - { - bluetooth_discoverable_mode_t mode; - TC_PRT("TC : %s", tc_table[7].tc_name); - ret = bluetooth_get_discoverable_mode(&mode); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[7].tc_name, ret); - tc_result(TC_FAIL, 7); - } - else - { - TC_PRT("BT Get Discoverable mode [%d]", \ - mode); - tc_result(TC_PASS, 7); - } - break; - } - - case 8: - { - bluetooth_discoverable_mode_t mode = 3; - TC_PRT("TC : %s", tc_table[8].tc_name); - ret = bluetooth_set_discoverable_mode(mode, 180); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[8].tc_name, ret); - tc_result(TC_FAIL, 8); - } - else - { - TC_PRT("BT Set Discoverable mode [%d]", \ - mode); - tc_result(TC_PASS, 8); - } - break; - } - - case 9: - TC_PRT("TC : %s", tc_table[9].tc_name); - ret = bluetooth_start_discovery(0,0,0); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[9].tc_name, ret); - tc_result(TC_FAIL, 9); - } - break; - - case 10: - TC_PRT("TC : %s", tc_table[10].tc_name); - ret = bluetooth_cancel_discovery(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[10].tc_name, ret); - tc_result(TC_FAIL, 10); - } - break; - - case 11: - { - TC_PRT("TC : %s", tc_table[11].tc_name); - ret = bluetooth_is_discovering(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[11].tc_name, ret); - tc_result(TC_FAIL, 11); - } - else - { - TC_PRT("Discovering [%d]", ret); - tc_result(TC_PASS, 11); - } - break; - } - - case 12: - { - if (searched_device.addr[0] || searched_device.addr[1] || searched_device.addr[2] \ - || searched_device.addr[3] || searched_device.addr[4] || searched_device.addr[5]) - { - TC_PRT("TC : %s", tc_table[12].tc_name); - - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - searched_device.addr[0], searched_device.addr[1], searched_device.addr[2], \ - searched_device.addr[3], searched_device.addr[4], searched_device.addr[5]); - - ret = bluetooth_bond_device(&searched_device); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[12].tc_name, ret); - tc_result(TC_FAIL, 12); - } - } - else - { - TC_PRT("Do search first"); - } - break; - } - - case 13: /*Cancel bonding */ - { - - TC_PRT("TC : %s", tc_table[13].tc_name); - ret = bluetooth_cancel_bonding(); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[13].tc_name, ret); - tc_result(TC_FAIL, 13); - } - - break; - } - - case 14: /*Get paired device */ - { - bluetooth_device_info_t devinfo = {0}; - bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}}; - - ret = bluetooth_get_bonded_device(&device_address, &devinfo); - if (ret != BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_get_bonded_device failed with [%d]",ret); - } - else - { - TC_PRT("Name [%s]", devinfo.device_name.name); - TC_PRT("Major Class [%d]", devinfo.device_class.major_class); - TC_PRT("Minor Class [%d]", devinfo.device_class.minor_class); - TC_PRT("Service Class [%d]", devinfo.device_class.service_class); - TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", devinfo.device_address.addr[0], devinfo.device_address.addr[1], devinfo.device_address.addr[2], devinfo.device_address.addr[3], devinfo.device_address.addr[4], devinfo.device_address.addr[5]); - } - - break; - } - - case 15: /*Get paired device list */ - { - - TC_PRT("TC : %s", tc_table[15].tc_name); -// bluetooth_device_address_t remote_address = {{0}}; - - GPtrArray *devinfo = NULL; - devinfo = g_ptr_array_new(); - TC_PRT("g pointer arrary count : [%d]", devinfo->len); - - ret = bluetooth_get_bonded_device_list(&devinfo); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret); - tc_result(TC_FAIL, 15); - } - else - { - int i; - bluetooth_device_info_t *ptr; - TC_PRT("g pointer arrary count : [%d]", devinfo->len); - - if(devinfo->len >=1) - { - ptr = g_ptr_array_index(devinfo, 0); - memcpy(&bond_dev, ptr, sizeof(bluetooth_device_info_t)); - is_bond_device = TRUE; - } - else - is_bond_device = FALSE; - - for(i=0; ilen;i++) - { - ptr = g_ptr_array_index(devinfo, i); - if(ptr != NULL) - { - TC_PRT("Name [%s]", ptr->device_name.name); - TC_PRT("Major Class [%d]", ptr->device_class.major_class); - TC_PRT("Minor Class [%d]", ptr->device_class.minor_class); - TC_PRT("Service Class [%d]", ptr->device_class.service_class); - TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]); - TC_PRT("\n"); - } - } - tc_result(TC_PASS, 15); - } - g_ptr_array_free(devinfo, TRUE); - - break; - } - case 18: /*service search */ - { - - TC_PRT("TC : %s", tc_table[18].tc_name); - bluetooth_device_address_t remote_address = {{0}}; - - TC_PRT("Selected Choi Dongle\n"); - /*Syam PC Dongle choi*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x03; remote_address.addr[2] = 0x7A; - remote_address.addr[3]= 0x2D; remote_address.addr[4] = 0xC9; remote_address.addr[5]= 0x9D; - - ret = bluetooth_search_service(&remote_address); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[18].tc_name, ret); - tc_result(TC_FAIL, 18); - } - - - break; - } - case 19: /*set alias for bonded device */ - { - char buff[100] = {0,}; - TC_PRT("TC : %s", tc_table[19].tc_name); - - TC_PRT("TC : Input the alias = "); - scanf("%s", buff); - - if(!strcmp(buff, "NULL")) - { - memset(buff, 0, 100); - TC_PRT("There is no alias"); - } - else - TC_PRT("ALIAS is %s", buff); - - if(is_bond_device) - { - ret = bluetooth_set_alias(&bond_dev.device_address, buff); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret); - tc_result(TC_FAIL, 19); - } - else - { - tc_result(TC_PASS, 19); - } - } - else - { - TC_PRT("Please get bonded device list calling bluetooth_get_bonded_device_list"); - } - break; - } - - /*Rfcomm */ - case 20: /*Create server socket */ - { - TC_PRT("TC : %s", tc_table[20].tc_name); - ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[20].tc_name, ret); - tc_result(TC_FAIL, 20); - } - TC_PRT("\nReturned FD = %d\n", ret); - g_tmp = ret; - break; - } - case 21: /*Listen and accept */ - { - - TC_PRT("TC : %s", tc_table[21].tc_name); - ret = bluetooth_rfcomm_listen_and_accept(g_tmp,1); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[21].tc_name, ret); - tc_result(TC_FAIL, 21); - } - TC_PRT("\nListining status(True/False) = %d\n", ret); - break; - } - case 22: /*Server remove */ - { - - TC_PRT("TC : %s", tc_table[22].tc_name); - ret = bluetooth_rfcomm_remove_socket(g_tmp, rfcomm_test_uuid_spp); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[22].tc_name, ret); - tc_result(TC_FAIL, 22); - } - - break; - } - case 23: /*connect */ - { - bluetooth_device_address_t remote_address = {{0}}; - TC_PRT("Enter connect device 1 or 2:"); - scanf("%d", &selection); - if(selection == 1) - { -#if 1 - TC_PRT("Selected Choi Dongle\n"); - /*Syam PC Dongle choi*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A; - remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19; remote_address.addr[5]= 0x36; -#else - TC_PRT("Selected Grey Dongle\n"); - /*Syam PC Dongle Grey BT*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0D; remote_address.addr[2] = 0x18; - remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x24; remote_address.addr[5]= 0x47; -#endif - } - else - { - /*Syam Mob 00:21:D1:0B:45:22*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x21; remote_address.addr[2] = 0xD1; - remote_address.addr[3]= 0x0B; remote_address.addr[4] = 0x45; remote_address.addr[5]= 0x22; - - } - - TC_PRT("TC : %s", tc_table[23].tc_name); - - ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret); - tc_result(TC_FAIL, 23); - } - else - { - TC_PRT("\n Returned value = %d\n", ret); - } - break; - } - - case 24: /*disconnect */ - { -// bluetooth_device_address_t remote_address = {{0}}; - int no, fd_dis; - TC_PRT("Enter Disconnect device 1 or 2:"); - scanf("%d", &no); - - if(no == 1) - { - fd_dis = g_ret_client_fd1; - } - else - { - fd_dis = g_ret_client_fd2; - } - - TC_PRT("TC : %s", tc_table[24].tc_name); - - ret = bluetooth_rfcomm_disconnect(fd_dis); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret); - tc_result(TC_FAIL, 24); - } - TC_PRT("\n Disconnect result for fd %d is = %d\n", fd_dis, ret); - break; - } - - case 25: /*write */ - { -// bluetooth_device_address_t remote_address = {{0}}; - char *buff = "abcdefghijklmnopqrstuvwxyz"; - int fd_channel; - TC_PRT("TC : %s", tc_table[25].tc_name); - TC_PRT("\n Enter the channel: "); - scanf("%d", &fd_channel); - ret = bluetooth_rfcomm_write(fd_channel, buff, 26); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[25].tc_name, ret); - tc_result(TC_FAIL, 25); - } - break; - } - - case 26: /*bluetooth_network_activate_server */ - { - bluetooth_network_activate_server(); - break; - } - - case 27: /*bluetooth_network_deactivate_server */ - { - bluetooth_network_deactivate_server(); - break; - } - - case 28: /*bluetooth_network_connect */ - { - bluetooth_device_address_t device_address={{0x00,0x02,0x10,0x54,0x90,0x27}}; - bluetooth_network_connect(&device_address, BLUETOOTH_NETWORK_NAP_ROLE, NULL); - break; - } - - case 29: /*bluetooth_network_disconnect */ - { - bluetooth_device_address_t device_address={{0x00,0x02,0x10,0x54,0x90,0x27}}; - bluetooth_network_disconnect(&device_address); - break; - } - - - case 30: /*HDP Activate*/ - { - if(hdp_manual_mode == 1) - { - int d_type; - TC_PRT("Enter the device type value\n"); - TC_PRT("eg: 4100(pulse), 4103(Blood pressure), 4104(thermometer), 4111(weight), 4113(Glucose)\n"); - scanf("%d", &d_type); - ret = bluetooth_hdp_activate(d_type, HDP_ROLE_SINK, HDP_QOS_ANY); - TC_PRT("Act Done\n"); - break; - } - - ret = bluetooth_hdp_activate(4100, HDP_ROLE_SINK, HDP_QOS_ANY); - - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[30].tc_name, ret); - tc_result(TC_FAIL, 30); - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - case 31: /*HDP DeActivate*/ - { - - if(hdp_manual_mode == 1) - { - if(NULL == g_hdp_app_handle2) - { - ret = bluetooth_hdp_deactivate(g_hdp_app_handle1); - g_hdp_app_handle1 = NULL; - } - else - { - ret = bluetooth_hdp_deactivate(g_hdp_app_handle2); - g_hdp_app_handle2 = NULL; - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - ret = bluetooth_hdp_deactivate(g_hdp_app_handle1); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[31].tc_name, ret); - tc_result(TC_FAIL, 31); - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - case 32: /*HDP Connect*/ - { - bluetooth_device_address_t remote_address = {{0}}; - TC_PRT("Warning!!! Make sure that you have changed the BD address \n"); - /*PTS Dongle 1*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; - remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x07; - if(hdp_manual_mode) - { - if(g_hdp_app_handle2 != NULL) /**/ - { - ret = bluetooth_hdp_connect(g_hdp_app_handle2, HDP_QOS_ANY, &remote_address); - g_hdp_app_handle2 = NULL; - } - else - { - ret = bluetooth_hdp_connect(g_hdp_app_handle1, HDP_QOS_ANY, &remote_address); - g_hdp_app_handle1 = NULL; - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - - - ret = bluetooth_hdp_connect(g_hdp_app_handle1, HDP_QOS_ANY, &remote_address); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[32].tc_name, ret); - tc_result(TC_FAIL, 32); - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - - case 33: /*HDP Disconnect*/ - { - bluetooth_device_address_t remote_address = {{0}}; - TC_PRT("Warning!!! Make sure that you have changed the BD address \n"); - /*PTS Dongle 1*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; - remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x07; - if(hdp_manual_mode) - { - int d_type; - TC_PRT("Enter the channel id (fd):\n"); - scanf("%d", &d_type); - ret = bluetooth_hdp_disconnect(d_type, &remote_address); - TC_PRT("Done, Res = %d\n", ret); - break; - } - ret = bluetooth_hdp_disconnect(g_ret_client_fd1, &remote_address); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[33].tc_name, ret); - tc_result(TC_FAIL, 33); - } - close(g_ret_client_fd1); - TC_PRT("Done..\n"); - break; - } - - - case 34: /*HDP Send Data*/ - { - char *buff = "abcdefghijklmnopqrstuvwxyz"; - - ret = bluetooth_hdp_send_data(g_ret_client_fd1, buff, 26); - if (ret < 0) - { - TC_PRT("%s failed with [0x%04x]", tc_table[34].tc_name, ret); - tc_result(TC_FAIL, 34); - } - TC_PRT("Done, Res = %d\n", ret); - break; - } - - case 35: - { - bluetooth_opc_init(); - break; - } - - case 36: - { - bluetooth_device_address_t remote_address = {{0}}; - TC_PRT("Warning!!! Make sure that you have changed the BD address \n"); -#if 0 - /*PTS Dongle 1*/ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98; - remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34; remote_address.addr[5]= 0x07; -#endif - /* Grey dongle */ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x19; remote_address.addr[2] = 0x0E; - remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x61; remote_address.addr[5]= 0x17; - char *files[5] = {NULL}; - files[0] = "/opt/media/photo1.jpg"; - files[1] = "/opt/media/photo2.jpg"; - files[2] = "/opt/media/photo3.jpg"; -// files[3] = "/opt/media/Downloads/4_photo_41.jpg"; - bluetooth_opc_push_files(&remote_address,files); - break; - } - - case 37: - { - bluetooth_device_address_t remote_address = {{0}}; - /* Grey dongle */ - remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x03; remote_address.addr[2] = 0x7A; - remote_address.addr[3]= 0x2D; remote_address.addr[4] = 0xC9; remote_address.addr[5]= 0x9D; - - char *files[5] = {NULL}; - files[0] = "/opt/media/photo1.jpg"; - files[1] = "/opt/media/photo2.jpg"; - files[2] = "/opt/media/photo3.jpg"; - bluetooth_opc_push_files(&remote_address,files); - break; - } - - case 38: - { - bluetooth_opc_deinit(); - break; - } - - case 39: - { - bluetooth_obex_server_init("/opt/media/Downloads"); - break; - } - - case 40: - { - bluetooth_obex_server_deinit(); - break; - } - - case 41: - { - bluetooth_obex_server_accept_authorize("abc"); - break; - } - - case 42: - { - bluetooth_obex_server_reject_authorize(); - break; - } - - case 43: - { - bluetooth_is_supported(); - break; - } - - case 44: - { - bluetooth_allow_service(TRUE); - break; - } - - case 45: - { - bluetooth_allow_service(FALSE); - break; - } - - case 46: - { - bluetooth_opc_sessioin_is_exist(); - break; - } - - case 47: - { - bluetooth_obex_server_is_activated(); - break; - } - - default: - break; - } - - return 0; -} - -void startup() -{ - TC_PRT("bluetooth framework TC startup"); - - if(!g_thread_supported()) - { - g_thread_init(NULL); - } - - dbus_g_thread_init(); - - g_type_init(); - main_loop = g_main_loop_new(NULL, FALSE); -} - -void cleanup() -{ - TC_PRT("bluetooth framework TC cleanup"); - if( main_loop!= NULL) - { - g_main_loop_unref(main_loop); - } -} - -int timeout_callback(void *data) -{ - TC_PRT("timeout callback"); - timeout_status = -1; - - g_main_loop_quit(main_loop); - - return FALSE; -} - -void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data) -{ - TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - TC_PRT("bt event callback 0x%04x", event); - switch(event) - { - case BLUETOOTH_EVENT_ENABLED: - TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - tc_result(TC_PASS, 1); - } - else - { - tc_result(TC_FAIL, 1); - } - break; - - case BLUETOOTH_EVENT_DISABLED: - TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - tc_result(TC_PASS, 2); - } - else - { - tc_result(TC_FAIL, 2); - } - break; - - case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: - TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result); - if (param->result == BLUETOOTH_ERROR_NONE) - { - bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data; - tc_result(TC_PASS, 6); - TC_PRT("Changed Name : [%s]", local_name->name); - } - else - { - tc_result(TC_FAIL, 6); - } - break; - - - case BLUETOOTH_EVENT_DISCOVERY_STARTED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result); - break; - - case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: - { - bluetooth_device_info_t *device_info = NULL; - TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result); - device_info = (bluetooth_device_info_t *)param->param_data; - memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t)); - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result); - tc_result(TC_PASS, 9); - break; - - - case BLUETOOTH_EVENT_BONDING_FINISHED: - { - TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - bluetooth_device_info_t *device_info = NULL; - tc_result(TC_PASS, 12); - device_info = (bluetooth_device_info_t *)param->param_data; - TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \ - device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \ - device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \ - device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class); - } - else - { - tc_result(TC_FAIL, 12); - } - break; - } - - case BLUETOOTH_EVENT_BONDED_DEVICE_FOUND: - { - // bluetooth_get_bonded_device_list is changed as synchronous API. This event is not used any more. - // 2011.01.06 -#if 0 -// int i = 0; - TC_PRT("BLUETOOTH_EVENT_BONDED_DEVICE_FOUND, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - ///tc_result(TC_PASS, 15); - bluetooth_device_info_t * bt_dev_info= (bluetooth_device_info_t*)param->param_data; - - TC_PRT("Dev Name = %s, Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X, COD (major,minor,service)= 0x%x:%x:%x\n", bt_dev_info->device_name.name, - bt_dev_info->device_address.addr[0], bt_dev_info->device_address.addr[1], bt_dev_info->device_address.addr[2], \ - bt_dev_info->device_address.addr[3], bt_dev_info->device_address.addr[4], bt_dev_info->device_address.addr[5], \ - bt_dev_info->device_class.major_class, bt_dev_info->device_class.minor_class, bt_dev_info->device_class.service_class); - - } - else - if(param->result == BLUETOOTH_ERROR_END_OF_DEVICE_LIST) /*End of the Device found indication*/ - { - tc_result(TC_PASS, 15); - TC_PRT("*****<>***** "); - } - else - { - tc_result(TC_FAIL, 15); - TC_PRT("*****API failed ***** "); - } - break; -#endif - } - case BLUETOOTH_EVENT_SERVICE_SEARCHED: - { - int i = 0; - TC_PRT("BLUETOOTH_EVENT_SERVICE_SEARCHED, result [0x%04x]", param->result); - if (param->result >= BLUETOOTH_ERROR_NONE) - { - tc_result(TC_PASS, 18); - bt_sdp_info_t * bt_sdp_info=param->param_data; - - TC_PRT("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - bt_sdp_info->device_addr.addr[0], bt_sdp_info->device_addr.addr[1], bt_sdp_info->device_addr.addr[2], \ - bt_sdp_info->device_addr.addr[3], bt_sdp_info->device_addr.addr[4], bt_sdp_info->device_addr.addr[5]); - - TC_PRT("Supported service list:\n"); - for(i=0; iservice_index; i++) - TC_PRT("[%#x]\n", bt_sdp_info->service_list_array[i]); - - } - else - { - tc_result(TC_FAIL, 18); - } - break; - } - case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: - { - TC_PRT("BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED, result [0x%04x]", param->result); - bluetooth_rfcomm_received_data_t *rx_data = param->param_data; - printf("\n FD = %d \nBuffer len = %d ", rx_data->socket_fd, rx_data->buffer_size); - //tc_result(TC_PASS, 21); - break; - } - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: - { - bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data; - TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result, - con_ind->socket_fd, - con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2], - con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5], - (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT"); - //tc_result(TC_PASS, 22); - if((con_ind->device_role == RFCOMM_ROLE_CLIENT) && (con_ind->socket_fd > 0)) - { - if(selection == 1) - g_ret_client_fd1 = con_ind->socket_fd; - else - g_ret_client_fd2 = con_ind->socket_fd; - } - - break; - } - case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: - { - bluetooth_rfcomm_disconnection_t *disconnection_ind = (bluetooth_rfcomm_disconnection_t *)param->param_data;; - TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x] Fd = %d, device add = 0x%X:%X:%X:%X:%X:%X\n", param->result, disconnection_ind->socket_fd, - disconnection_ind->device_addr.addr[0], disconnection_ind->device_addr.addr[1], disconnection_ind->device_addr.addr[2], - disconnection_ind->device_addr.addr[3], disconnection_ind->device_addr.addr[4], disconnection_ind->device_addr.addr[5] ); - //tc_result(TC_PASS, 22); - break; - } - case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED: - { - bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data; - - TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result); - TC_PRT("interface name: %s", dev_info->interface_name); - - TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2], - dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5] ); - break; - } - case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED: - { - bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data; - - TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result); - TC_PRT("interface name: %s", dev_info->interface_name); - - TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2], - dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5] ); - break; - } - - - case BLUETOOTH_EVENT_HDP_ACTIVATED: - { - - TC_PRT("BLUETOOTH_EVENT_HDP_ACTIVATED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX"); - bt_hdp_activate_t *act_cfm = (bt_hdp_activate_t *)param->param_data; - TC_PRT("App handler = %s\n", act_cfm->app_handle); - if(hdp_manual_mode == 1) - { - if(NULL == g_hdp_app_handle1) - g_hdp_app_handle1 = act_cfm->app_handle; /*1st time */ - else - g_hdp_app_handle2 = act_cfm->app_handle; /*2nd time */ - - break; - } - g_hdp_app_handle1 = act_cfm->app_handle; - break; - } - - case BLUETOOTH_EVENT_HDP_DEACTIVATED: - { - - TC_PRT("BLUETOOTH_EVENT_HDP_DEACTIVATED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX"); - bt_hdp_deactivate_t *deact_cfm = (bt_hdp_deactivate_t *)param->param_data; - TC_PRT("App handler = %s\n", deact_cfm->app_handle); - break; - } - - case BLUETOOTH_EVENT_HDP_CONNECTED: - { - bt_hdp_connected_t *conn_ind = (bt_hdp_connected_t *)param->param_data; - - TC_PRT("BLUETOOTH_EVENT_HDP_CONNECTED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX"); - TC_PRT("App handler = %s, channel id = %d, type = %s", conn_ind->app_handle, conn_ind->channel_id, (conn_ind->type == HDP_QOS_RELIABLE)? "Reliable":"Streaming"); - TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - conn_ind->device_address.addr[0], conn_ind->device_address.addr[1], conn_ind->device_address.addr[2], - conn_ind->device_address.addr[3], conn_ind->device_address.addr[4], conn_ind->device_address.addr[5] ); - - g_ret_client_fd1 = conn_ind->channel_id; - break; - } - - case BLUETOOTH_EVENT_HDP_DISCONNECTED: - { - bt_hdp_disconnected_t *dis_ind = (bt_hdp_disconnected_t *)param->param_data; - - TC_PRT("BLUETOOTH_EVENT_HDP_DISCONNECTED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX"); - TC_PRT("Channel = %d, Add = device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", dis_ind->channel_id, - dis_ind->device_address.addr[0], dis_ind->device_address.addr[1], dis_ind->device_address.addr[2], - dis_ind->device_address.addr[3], dis_ind->device_address.addr[4], dis_ind->device_address.addr[5]); - break; - } - - case BLUETOOTH_EVENT_HDP_DATA_RECEIVED: - { - bt_hdp_data_ind_t *data_ind = (bt_hdp_data_ind_t *)param->param_data; - - TC_PRT("BLUETOOTH_EVENT_HDP_DATA_RECEIVED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX"); - TC_PRT("Data received from channel id = %d and size =%d, buff =[%s]\n", data_ind->channel_id, data_ind->size, data_ind->buffer); - - break; - } - - case BLUETOOTH_EVENT_OPC_CONNECTED: - TC_PRT("BLUETOOTH_EVENT_OPC_CONNECTED"); - break; - - case BLUETOOTH_EVENT_OPC_DISCONNECTED: - TC_PRT("BLUETOOTH_EVENT_OPC_DISCONNECTED"); - break; - case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: - { - TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED"); - if (param->param_data) { - bt_opc_transfer_info_t *info = param->param_data; - TC_PRT("file %s", info->filename); - TC_PRT("size %d", info->size); - } - break; - } - case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: - { - TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS"); - break; - } - case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: - { - TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE"); - bt_opc_transfer_info_t *info = param->param_data; - TC_PRT("file %s", info->filename); - TC_PRT("size %d", info->size); - break; - } - - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: - TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE"); - break; - - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: - TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED"); - break; - - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: - TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS"); - break; - - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: - TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED"); - break; - - default: - TC_PRT("received event [0x%04x]", event); - break; - } - TC_PRT("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); -} - -#ifdef __THREAD__ -static void* input_thread( void* arg ) -{ - char test_code[8000]; - int test_id; - - while (1==1) - { - - tc_usage_print(); - printf("Input test ID : "); - gets(test_code); - test_id = atoi(test_code); - if (test_id) - g_idle_add(test_input_callback, (void*)test_id); - } - - return NULL; -} -#endif - -static gboolean key_event_cb(GIOChannel * chan, GIOCondition cond , gpointer data) -{ - char buf[10] = {0}; - - unsigned int len=0; - int test_id; - memset(buf, 0, sizeof(buf)); - - if(g_io_channel_read(chan, buf, sizeof(buf), &len) !=G_IO_ERROR_NONE) { - - printf("IO Channel read error"); - return FALSE; - - } - printf("%s\n",buf); - tc_usage_print(); - - test_id=atoi(buf); - - if(test_id) - g_idle_add(test_input_callback, (void*)test_id); - - return TRUE; -} - -int main() -{ - int ret_val; - - startup(); - - // Register callback function - TC_PRT("TC : %s", tc_table[0].tc_name); - ret_val = bluetooth_register_callback(bt_event_callback, NULL); - if (ret_val >= BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_register_callback returned Success"); - tc_result(TC_PASS, 0); - } - else - { - TC_PRT("bluetooth_register_callback returned failiure [0x%04x]", ret_val); - tc_result(TC_FAIL, 0); - return 0; - } - - ret_val = bluetooth_check_adapter(); - if (ret_val < BLUETOOTH_ERROR_NONE) - { - TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val); - tc_result(TC_FAIL, 3); - } - else - { - TC_PRT("BT state [0x%04x]", ret_val); - tc_result(TC_PASS, 3); - } - -#ifdef __THREAD__ - { - pthread_t thread; - pthread_attr_t tattr = {{0}}; - - ret_val = pthread_attr_init(&tattr); - ret_val = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize(&tattr, 128*1024); - ret_val = pthread_create(&thread, &tattr, input_thread, NULL); - pthread_attr_destroy(&tattr); - } -#else - { - GIOChannel *key_io; - key_io=g_io_channel_unix_new(fileno(stdin)); - - g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - key_event_cb, NULL); - g_io_channel_unref(key_io); - } -#endif - - g_main_loop_run(main_loop); - - cleanup(); - return 0; -} - diff --git a/packaging/bluetooth-frwk.spec b/packaging/bluetooth-frwk.spec index b12a1c8..bf88f61 100644 --- a/packaging/bluetooth-frwk.spec +++ b/packaging/bluetooth-frwk.spec @@ -16,7 +16,6 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(bluez) BuildRequires: pkgconfig(dbus-1) -BuildRequires: pkgconfig(utilX) BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(openobex) BuildRequires: cmake @@ -39,15 +38,6 @@ This package is development files for Bluetooth framework based on BlueZ stack. This package contains API set for BT GAP, BT SDP, and BT RFCOMM. -%package test -Summary: Bluetooth framework test application -Group: TO_BE/FILLED -Requires: %{name} = %{version}-%{release} - -%description test -This package is a test application for bluetooth framework. - - %package agent Summary: Bluetooth Agent for pairing and authorization Group: TO_BE/FILLED @@ -84,9 +74,6 @@ rm -rf %{buildroot} /usr/include/* /usr/lib/pkgconfig/* -%files test -/usr/bin/bluetooth-frwk-test - %files agent /usr/bin/bluetooth-agent /usr/bin/bluetooth-pb-agent -- 2.7.4