# API library
ADD_SUBDIRECTORY(lib)
+# API library
+ADD_SUBDIRECTORY(bluetooth-media-control)
+
# Bluetooth FW Agent
ADD_SUBDIRECTORY(bluetooth-frwk-agent)
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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 *~
+++ /dev/null
-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
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-//#include <dbus/dbus-glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_authorize_device_1(void);\r
-\r
- void utc_bluetooth_authorize_device_2(void);\r
-\r
- void utc_bluetooth_authorize_device_3(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_authorize_device_1,1},\r
- { utc_bluetooth_authorize_device_2,2},\r
-// { utc_bluetooth_authorize_device_3,3},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-//#include <dbus/dbus-glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_bond_device_1(void);\r
-\r
- void utc_bluetooth_bond_device_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_bond_device_1,1},\r
- { utc_bluetooth_bond_device_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_cancel_bonding_1(void);\r
-\r
- void utc_bluetooth_cancel_bonding_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_cancel_bonding_1,1},\r
- { utc_bluetooth_cancel_bonding_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_cancel_discovery.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-int thread_callback(void)\r
-{\r
- int return_10;\r
- printf("thread_callback\n");\r
- sleep(1);\r
- return_10=bluetooth_cancel_discovery();\r
- if( return_10<0)\r
- {\r
- tet_printf("Api failedret_val=%d\nreturn_10=%d\n",return_10);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- g_main_loop_quit (main_loop);\r
- return 0;\r
-\r
-}\r
-\r
-\r
-void utc_bluetooth_cancel_discovery_1(void)\r
-{\r
- unsigned max_response;\r
- unsigned discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_10;\r
- int ret_val;\r
- int ret = 0;\r
- pthread_attr_t tattr;// = {0};\r
- pthread_t thread_id;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- // Stop discovery if BT is in discovering.\r
- bluetooth_cancel_discovery();\r
-\r
- max_response =0;\r
- discovery_duration =0;\r
- classOfDeviceMask =0;\r
- ret_val=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
-\r
- ret = pthread_attr_init(&tattr);\r
- if (ret == 0)
- {
- pthread_attr_setstacksize(&tattr, 131072);\r
- ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- if(ret == 0)
- {
- ret = pthread_create(&thread_id, &tattr,\r
- thread_callback, NULL);\r
- if (ret != 0)
- {
- tet_printf( "Failed to create thread\n");\r
- }\r
- }\r
-\r
- }
- else
- {
- tet_printf( "Failed to initialize thread attribute\n");\r
- }\r
-\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
-}\r
-\r
-void utc_bluetooth_cancel_discovery_2(void)\r
-{\r
-\r
- int return_10;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
-\r
- return_10=bluetooth_cancel_discovery();\r
- if( return_10 >= 0)\r
- {\r
- tet_printf("Api failed: %d", return_10);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_cancel_discovery_1(void);\r
-\r
- void utc_bluetooth_cancel_discovery_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_cancel_discovery_1,1},\r
- { utc_bluetooth_cancel_discovery_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_cancel_service_search_1(void);\r
-\r
- void utc_bluetooth_cancel_service_search_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_cancel_service_search_1,1},\r
-// { utc_bluetooth_cancel_service_search_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_check_adapter.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-pthread_t thread_t;\r
-pthread_attr_t tattr;// = {0};\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
-// {\r
- // g_main_loop_unref(main_loop);\r
-// }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-int enable_thread_callback(void)\r
-{\r
- int return_3;\r
- printf("thread_callback\n");\r
- sleep(4);\r
- printf("1\n");\r
- return_3=bluetooth_check_adapter();\r
- printf("2\n");\r
- if( return_3!=BLUETOOTH_ADAPTER_ENABLED)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- g_main_loop_quit (main_loop);\r
- return 0;\r
-\r
-}\r
-\r
-int disable_thread_callback(void)\r
-{\r
- int return_3;\r
- printf("thread_callback\n");\r
- sleep(4);\r
- printf("1\n");\r
- return_3=bluetooth_check_adapter();\r
- printf("2\n");\r
- if( return_3!=BLUETOOTH_ADAPTER_DISABLED)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- g_main_loop_quit (main_loop);\r
- return 0;\r
-\r
-}\r
-\r
-\r
-void utc_bluetooth_check_adapter_1(void)\r
-{\r
-\r
- int return_3;\r
- int ret_val;\r
- int ret=0;\r
- pthread_attr_t tattr;// = {0};\r
- pthread_t thread_id;\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- return_3=bluetooth_check_adapter();\r
-\r
- printf("2\n");\r
- if( return_3 < BLUETOOTH_ADAPTER_DISABLED || return_3 > BLUETOOTH_ADAPTER_CHANGING_DISABLE)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-\r
-/*\r
- bluetooth_enable_adapter();\r
-\r
- ret = pthread_attr_init(&tattr);\r
- if (ret == 0)
- {
- pthread_attr_setstacksize(&tattr, 131072);\r
- ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- if(ret == 0)
- {
- ret = pthread_create(&thread_id, &tattr,\r
- enable_thread_callback, NULL);\r
- if (ret != 0)
- {
- tet_printf( "Failed to create thread\n");\r
- }\r
- }\r
-\r
- }
- else
- {
- tet_printf( "Failed to initialize thread attribute\n");\r
- }\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
-*/\r
-}\r
-\r
-void utc_bluetooth_check_adapter_2(void)\r
-{\r
- int return_3;\r
- int ret_val;\r
- int ret=0;\r
- pthread_attr_t tattr;// = {0};\r
- pthread_t thread_id;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- bluetooth_disable_adapter();\r
-\r
- ret = pthread_attr_init(&tattr);\r
- if (ret == 0)
- {
- pthread_attr_setstacksize(&tattr, 131072);\r
- ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- if(ret == 0)
- {
- ret = pthread_create(&thread_id, &tattr,\r
- disable_thread_callback, NULL);\r
- if (ret != 0)
- {
- tet_printf( "Failed to create thread\n");\r
- }\r
- }\r
-\r
- }
- else
- {
- tet_printf( "Failed to initialize thread attribute\n");\r
- }\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-//#include <dbus/dbus-glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_check_adapter_1(void);\r
-\r
- void utc_bluetooth_check_adapter_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_check_adapter_1,1},\r
-// { utc_bluetooth_check_adapter_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_disable_adapter_1(void);\r
-\r
- void utc_bluetooth_disable_adapter_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_disable_adapter_1,1},\r
- { utc_bluetooth_disable_adapter_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_enable_adapter.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
-\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- else\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
-\r
- if (main_loop)\r
- g_main_loop_quit(main_loop);\r
-\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_enable_adapter();\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-void bt_event_callback2(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- int return_1;\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
-\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- return_1=bluetooth_enable_adapter();\r
- if(return_1<0)\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- else\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- }\r
- else\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
-\r
- if (main_loop)\r
- g_main_loop_quit(main_loop);\r
-\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
-\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-void utc_bluetooth_enable_adapter_1(void)\r
-{\r
- int return_1;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else if (ret_val == BLUETOOTH_ADAPTER_ENABLED)\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-\r
- return_1=bluetooth_enable_adapter();\r
-\r
- if(BLUETOOTH_ERROR_NONE!=return_1)\r
- {\r
- bluetooth_disable_adapter();\r
- }\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
-/*\r
- if( return_1<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-*/\r
-}\r
-\r
-void utc_bluetooth_enable_adapter_2(void)\r
-{\r
-\r
- int return_1;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback2, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- return_1=bluetooth_enable_adapter();\r
- if(BLUETOOTH_ERROR_NONE!=return_1)\r
- {\r
- //bluetooth_disable_adapter();\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
- else\r
- {\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_enable_adapter_1(void);\r
-\r
- void utc_bluetooth_enable_adapter_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_enable_adapter_1,1},\r
- { utc_bluetooth_enable_adapter_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_get_bonded_device_list.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
- tet_printf("bluetooth framework TC cleanup");\r
-}\r
-\r
-void utc_bluetooth_get_bonded_device_list_1(void)\r
-{\r
-\r
- int return_15;\r
- int ret_val;\r
-\r
- GPtrArray *devinfo = NULL;\r
-\r
- devinfo = g_ptr_array_new();\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_15=bluetooth_get_bonded_device_list(&devinfo);\r
- if(return_15<BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- int i;\r
- bluetooth_paired_device_info_t *ptr;\r
- for(i=0; i<devinfo->len;i++)\r
- {\r
- ptr = g_ptr_array_index(devinfo, i);\r
- if(ptr != NULL)\r
- {\r
- TC_PRT("Name [%s]", ptr->device_name.name);\r
- TC_PRT("Major Class [%d]", ptr->device_class.major_class);\r
- TC_PRT("Minor Class [%d]", ptr->device_class.minor_class);\r
- TC_PRT("Service Class [%d]", ptr->device_class.service_class);\r
- 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]);\r
- TC_PRT("\n");\r
- }\r
- }\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-\r
- g_ptr_array_free(devinfo, TRUE);\r
-}\r
-\r
-void utc_bluetooth_get_bonded_device_list_2(void)\r
-{\r
- int return_15;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_15=bluetooth_get_bonded_device_list(NULL);\r
- if(return_15==BLUETOOTH_ERROR_INVALID_PARAM)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_PASS);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_FAIL);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <dbus/dbus-glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_get_bonded_device_list_1(void);\r
-\r
- void utc_bluetooth_get_bonded_device_list_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_get_bonded_device_list_1,1},\r
- { utc_bluetooth_get_bonded_device_list_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_get_discoverable_mode.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_get_discoverable_mode_1(void)\r
-{\r
- bluetooth_discoverable_mode_t discoverable_mode_ptr;\r
- bluetooth_discoverable_mode_t mode;\r
- int return_7;\r
- int ret_val;\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- mode = 3;\r
-\r
- return_7=bluetooth_set_discoverable_mode(mode, 60); // 60 seconds\r
-\r
- return_7=bluetooth_get_discoverable_mode(&discoverable_mode_ptr);\r
- if( return_7<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_get_discoverable_mode_2(void)\r
-{\r
- bluetooth_discoverable_mode_t* discoverable_mode_ptr;\r
- int return_7;\r
- int ret_val;\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- discoverable_mode_ptr=NULL;\r
- return_7=bluetooth_get_discoverable_mode(discoverable_mode_ptr);\r
- if( return_7>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_get_discoverable_mode_1(void);\r
-\r
- void utc_bluetooth_get_discoverable_mode_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_get_discoverable_mode_1,1},\r
- { utc_bluetooth_get_discoverable_mode_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_get_local_address_1(void);\r
-\r
- void utc_bluetooth_get_local_address_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_get_local_address_1,1},\r
- { utc_bluetooth_get_local_address_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_get_local_name.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_get_local_name_1(void)\r
-{\r
- bluetooth_device_name_t local_name={{"local Name"}};\r
-\r
- int return_5;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_5=bluetooth_set_local_name(&local_name);\r
-\r
- return_5=bluetooth_get_local_name(&local_name);\r
- if( return_5<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_get_local_name_2(void)\r
-{\r
- bluetooth_device_name_t* local_name;\r
- int return_5;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_5=bluetooth_get_local_name(NULL);\r
- if( return_5>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_get_local_name_1(void);\r
-\r
- void utc_bluetooth_get_local_name_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_get_local_name_1,1},\r
- { utc_bluetooth_get_local_name_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_get_remote_device.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-// Not support API\r
-#if 0\r
-void utc_bluetooth_get_remote_device_1(void)\r
-{\r
- bluetooth_device_address_t device_address;\r
- int return_16;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_16=bluetooth_get_remote_device(&device_address);\r
- if( return_16<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-#endif\r
-\r
-void utc_bluetooth_get_remote_device_1(void)\r
-{\r
- const bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};\r
- int return_16;\r
- int ret_val;\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- //device_address=NULL;\r
- return_16=bluetooth_get_remote_device(&device_address);\r
- if( return_16<0)\r
- {\r
- tet_printf("Api failed: %d", return_16);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_get_remote_device_2(void)\r
-{\r
- bluetooth_device_address_t* device_address;\r
- int return_16;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- device_address=NULL;\r
- return_16=bluetooth_get_remote_device(device_address);\r
- if( return_16>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <dbus/dbus-glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_get_remote_device_1(void);\r
-\r
- void utc_bluetooth_get_remote_device_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_get_remote_device_1,1},\r
- { utc_bluetooth_get_remote_device_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_is_discovering.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
-\r
- if( main_loop!= NULL)\r
- {\r
- g_main_loop_unref(main_loop);\r
- g_main_loop_quit(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- if (main_loop)\r
- g_main_loop_quit(main_loop);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-int thread_callback(void)\r
-{\r
- int return_11;\r
- printf("thread_callback\n");\r
- sleep(1);\r
- return_11=bluetooth_is_discovering();\r
- if( return_11==0)\r
- {\r
- tet_printf("Api failed,=%d\n",return_11);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-\r
- // let the discovery stop before quit so that when utc_bluetooth_is_discovering_2 is called discovery should be off\r
- bluetooth_cancel_discovery();\r
-\r
- g_main_loop_quit (main_loop);\r
- return 0;\r
-\r
-}\r
-\r
-\r
-void utc_bluetooth_is_discovering_1(void)\r
-{\r
- int return_11;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_11=bluetooth_is_discovering();\r
- if( return_11==1)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_is_discovering_2(void)\r
-{\r
- unsigned max_response;\r
- unsigned discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_11;\r
- int ret_val;\r
- int ret=0;\r
- pthread_attr_t tattr;// = {0};\r
- pthread_t thread_id;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- max_response =0;\r
- discovery_duration =0;\r
- classOfDeviceMask =0;\r
- return_11=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
-\r
- ret = pthread_attr_init(&tattr);\r
- if (ret == 0)
- {
- pthread_attr_setstacksize(&tattr, 131072);\r
- ret = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- if(ret == 0)
- {
- ret = pthread_create(&thread_id, &tattr,\r
- thread_callback, NULL);\r
- if (ret != 0)
- {
- tet_printf( "Failed to create thread\n");\r
- }\r
- }\r
-\r
- }
- else
- {
- tet_printf( "Failed to initialize thread attribute\n");\r
- }\r
-\r
-\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
-}\r
-\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_is_discovering_1(void);\r
-\r
- void utc_bluetooth_is_discovering_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_is_discovering_1,1},\r
- { utc_bluetooth_is_discovering_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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;
- }
-}
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_register_callback_1(void);\r
-\r
- void utc_bluetooth_register_callback_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_register_callback_1,1},\r
- { utc_bluetooth_register_callback_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include <bluetooth-api.h>
-#include <tet_api.h>
-
-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}
- };
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include <bluetooth-api.h>
-#include <tet_api.h>
-
-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}
- };
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
-
-
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include <bluetooth-api.h>
-#include <tet_api.h>
-
-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}
- };
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_rfcomm_listen_1(void);\r
-\r
- void utc_bluetooth_rfcomm_listen_2(void);\r
-\r
- void utc_bluetooth_rfcomm_listen_3(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_rfcomm_listen_1,1},\r
- { utc_bluetooth_rfcomm_listen_2,2},\r
-// { utc_bluetooth_rfcomm_listen_3,3},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
-
-
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include <bluetooth-api.h>
-#include <tet_api.h>
-
-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}
- };
-
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_rfcomm_sock_deregister_with_uuid.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void)\r
-{\r
- char uuid[]="id";\r
- int return_21;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_21=bluetooth_rfcomm_sock_register_with_uuid(&uuid);\r
-\r
- return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid);\r
- if( return_21<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void)\r
-{\r
- char* uuid;\r
- int return_21;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- uuid=NULL;\r
- return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid);\r
- if( return_21>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void);\r
-\r
- void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_rfcomm_sock_deregister_with_uuid_1,1},\r
- { utc_bluetooth_rfcomm_sock_deregister_with_uuid_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_rfcomm_sock_register_with_uuid.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void)\r
-{\r
- char uuid[]="00000000-0000-1000-8000-00805F9B34FB";//"id";\r
- int return_20;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- //uuid =NULL;//assign value over here\r
- return_20=bluetooth_rfcomm_sock_register_with_uuid(&uuid);\r
- if( return_20<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void)\r
-{\r
- char* uuid;\r
- int return_20;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- uuid=NULL;\r
- return_20=bluetooth_rfcomm_sock_register_with_uuid(uuid);\r
- if( return_20>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void);\r
-\r
- void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_rfcomm_sock_register_with_uuid_1,1},\r
- { utc_bluetooth_rfcomm_sock_register_with_uuid_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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);
- }
-}
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include <bluetooth-api.h>
-#include <tet_api.h>
-
-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}
- };
-
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_search_service.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_search_service_1(void)\r
-{\r
- bluetooth_device_address_t device_address={{0}};\r
- int return_18;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_18=bluetooth_search_service(&device_address);\r
- if( return_18<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_search_service_2(void)\r
-{\r
- bluetooth_device_address_t device_address;\r
- int return_18;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-// device_address=NULL;\r
- return_18=bluetooth_search_service(NULL);\r
- if( return_18>=0)\r
- {\r
- tet_printf("Api failed=%d\n",return_18);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_search_service_1(void);\r
-\r
- void utc_bluetooth_search_service_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_search_service_1,1},\r
- { utc_bluetooth_search_service_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_set_discoverable_mode.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-void utc_bluetooth_set_discoverable_mode_1(void)\r
-{\r
- bluetooth_discoverable_mode_t discoverable_mode;\r
- int return_8;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE) {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- } else {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
-\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- else\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
-\r
- discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;\r
-\r
- /* 60 seconds */\r
- return_8 = bluetooth_set_discoverable_mode(discoverable_mode, 60);\r
-\r
- if (return_8 < 0) {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- } else {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_set_discoverable_mode_2(void)\r
-{\r
- bluetooth_discoverable_mode_t discoverable_mode;\r
- int return_8;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- discoverable_mode=-1;\r
- return_8=bluetooth_set_discoverable_mode(discoverable_mode, 0);\r
- if( return_8>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_set_discoverable_mode_1(void);\r
-\r
- void utc_bluetooth_set_discoverable_mode_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_set_discoverable_mode_1,1},\r
- { utc_bluetooth_set_discoverable_mode_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_set_local_name.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_set_local_name_1(void)\r
-{\r
- bluetooth_device_name_t local_name={{"local Name"}};\r
- int return_6;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_6=bluetooth_set_local_name(&local_name);\r
- if( return_6<0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_set_local_name_2(void)\r
-{\r
- bluetooth_device_name_t* local_name;\r
- int return_6;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- local_name=NULL;\r
- return_6=bluetooth_set_local_name(local_name);\r
- if( return_6>=0)\r
- {\r
- tet_printf("Api failed");\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_set_local_name_1(void);\r
-\r
- void utc_bluetooth_set_local_name_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_set_local_name_1,1},\r
- { utc_bluetooth_set_local_name_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_start_discovery.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 12);\r
- }\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-void utc_bluetooth_start_discovery_1(void)\r
-{\r
- unsigned max_response;\r
- unsigned discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_9;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- bluetooth_cancel_discovery();\r
-\r
- max_response =0;\r
- discovery_duration =0;\r
- classOfDeviceMask =0;\r
- return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
- if( return_9<0)\r
- {\r
- tet_printf("Api failed: %d", return_9);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-\r
-\r
-void utc_bluetooth_start_discovery_2(void)\r
-{\r
- unsigned short max_response;\r
- unsigned short discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_9;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- max_response =0;//assign value over here\r
- discovery_duration =0;//assign value over here\r
- classOfDeviceMask=0x800001;//0x001000;\r
- return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
- if( return_9>=0)\r
- {\r
- tet_printf("Api failed=%d\n",return_9);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-\r
-// Not proper case!!\r
-// The API parameter types is unsigned!\r
-#if 0\r
-void utc_bluetooth_start_discovery_3(void)\r
-{\r
- unsigned max_response;\r
- unsigned discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_9;\r
- int ret_val;\r
- ret_val = bluetooth_register_callback(bt_event_callback);\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- max_response =0;//assign value over here\r
- discovery_duration=-1;\r
- classOfDeviceMask=0;\r
- return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
- if( return_9>=0)\r
- {\r
- tet_printf("Api failed=%d\n",return_9);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-\r
-void utc_bluetooth_start_discovery_4(void)\r
-{\r
- unsigned max_response;\r
- unsigned discovery_duration;\r
- unsigned classOfDeviceMask;\r
- int return_9;\r
- int ret_val;\r
- ret_val = bluetooth_register_callback(bt_event_callback);\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- max_response=0;\r
- discovery_duration=0;\r
- classOfDeviceMask=-1;\r
- return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
- if( return_9>=0)\r
- {\r
- tet_printf("Api failed=%d\n",return_9);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
-#endif\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_start_discovery_1(void);\r
-\r
- void utc_bluetooth_start_discovery_2(void);\r
-\r
- void utc_bluetooth_start_discovery_3(void);\r
-\r
- void utc_bluetooth_start_discovery_4(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_start_discovery_1,1},\r
- { utc_bluetooth_start_discovery_2,2},\r
-// { utc_bluetooth_start_discovery_3,3},\r
-// { utc_bluetooth_start_discovery_4,4},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-\r
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include "uts_bluetooth_unbond_device.h"\r
-\r
-bluetooth_device_address_t searched_device = {{0}};\r
-\r
-#define TC_TIMEOUT 30000\r
-\r
-#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
-#define DISCOVER_TIMEOUT 20\r
-#define DISCOVER_CANCEL_INTERVAL 3\r
-\r
-#define TC_FAIL 0\r
-#define TC_PASS 1\r
-#define TC_PRT tet_printf\r
-//#define tc_result tet_result\r
-\r
-GMainLoop *main_loop = NULL;\r
-static int timeout_status = 0;\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
-\r
-void startup()\r
-{\r
- tet_printf("bluetooth framework TC startup");\r
-\r
- if(!g_thread_supported())\r
- {\r
- g_thread_init(NULL);\r
- }\r
-\r
- dbus_g_thread_init();\r
-\r
- g_type_init();\r
- //main_loop = g_main_loop_new(NULL, FALSE);\r
-}\r
-\r
-\r
-void cleanup()\r
-{\r
-\r
- //g_main_loop_run(main_loop);\r
- tet_printf("bluetooth framework TC cleanup");\r
- //if( main_loop!= NULL)\r
- {\r
- // g_main_loop_unref(main_loop);\r
- }\r
-}\r
-\r
-void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
-{\r
- TC_PRT("bt event callback 0x%04x", event);\r
- switch(event)\r
- {\r
- case BLUETOOTH_EVENT_ENABLED:\r
- TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 1);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 1);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_DISABLED:\r
- TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- //tc_result(TC_PASS, 2);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 2);\r
- }\r
- break;\r
-\r
- case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
- TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
- if (param->result == BLUETOOTH_ERROR_NONE)\r
- {\r
- bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
- //tc_result(TC_PASS, 6);\r
- TC_PRT("Changed Name : [%s]", local_name->name);\r
- }\r
- else\r
- {\r
- //tc_result(TC_FAIL, 6);\r
- }\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
- break;\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
- {\r
- bluetooth_device_info_t *device_info = NULL;\r
- TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
- memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
- TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
- break;\r
- }\r
-\r
- case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
- TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
- //tc_result(TC_PASS, 9);\r
- break;\r
-\r
-\r
- case BLUETOOTH_EVENT_BONDING_FINISHED:\r
- {\r
- TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
- int return_14;\r
- bluetooth_device_info_t *device_info = NULL;\r
- //tc_result(TC_PASS, 12);\r
- device_info = (bluetooth_device_info_t *)param->param_data;\r
-\r
- if (device_info == NULL)\r
- {\r
- tet_printf("param is NULL");\r
- tet_result(TET_FAIL);\r
- g_main_loop_quit (main_loop);\r
- return;\r
- }\r
-\r
- if (param->result >= BLUETOOTH_ERROR_NONE)\r
- {\r
-\r
- 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, \\r
- device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
- device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
- device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
- }\r
-\r
- return_14=bluetooth_unbond_device(&device_info->device_address);\r
- if( return_14<0)\r
- {\r
- tet_printf("Api failed: %d", return_14);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-\r
- g_main_loop_quit (main_loop);\r
- break;\r
- }\r
-\r
- default:\r
- TC_PRT("received event [0x%04x]", event);\r
- break;\r
- }\r
-}\r
-\r
-\r
-void utc_bluetooth_unbond_device_1(void)\r
-{\r
- bluetooth_device_address_t device_address={{0x00,0x02,0x78,0xDE,0x48,0x8F}}; // Samsung Stereo Headset\r
-\r
- int return_14;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
-\r
- return_14=bluetooth_bond_device(&device_address);\r
- if( return_14<0)\r
- {
- tet_printf("bond failed: %d", return_14);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("bonding is in progress");\r
-\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
- g_main_loop_run(main_loop);\r
- }\r
-}\r
-\r
-\r
-void utc_bluetooth_unbond_device_2(void)\r
-{\r
- bluetooth_device_address_t* device_address;\r
- int return_14;\r
- int ret_val;\r
-\r
- ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
-\r
- if (ret_val >= BLUETOOTH_ERROR_NONE)\r
- {\r
- tet_printf("bluetooth_register_callback returned Success");\r
- // tc_result(TC_PASS, 0);\r
- }\r
- else\r
- {\r
- tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
- // tc_result(TC_FAIL, 0);\r
- return 0;\r
- }\r
-\r
- ret_val = bluetooth_check_adapter();\r
- if (ret_val < BLUETOOTH_ERROR_NONE)\r
- {\r
- TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
- //tc_result(TC_FAIL, 3);\r
- }\r
- else\r
- {\r
- TC_PRT("BT state [0x%04x]", ret_val);\r
- //tc_result(TC_PASS, 3);\r
- }\r
- device_address=NULL;\r
- return_14=bluetooth_unbond_device(device_address);\r
- if( return_14>=0)\r
- {\r
- tet_printf("Api failed: %d", return_14);\r
- tet_result(TET_FAIL);\r
- }\r
- else\r
- {\r
- tet_printf("Api passed");\r
- tet_result(TET_PASS);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Bluetooth-frwk\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>\r
- * Girishashok Joshi <girish.joshi@samsung.com>\r
- * Chanyeol Park <chanyeol.park@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <glib.h>\r
-#include <pthread.h>\r
-\r
-#include <bluetooth-api.h>\r
-#include <tet_api.h>\r
-\r
-static void startup();\r
-\r
-static void cleanup();\r
-\r
-\r
-void (*tet_startup) () = startup;\r
-void (*tet_cleanup) () = cleanup;\r
-\r
- void utc_bluetooth_unbond_device_1(void);\r
-\r
- void utc_bluetooth_unbond_device_2(void);\r
-\r
- struct tet_testlist tet_testlist[] = {\r
- { utc_bluetooth_unbond_device_1,1},\r
- { utc_bluetooth_unbond_device_2,2},\r
- {NULL,0}\r
- };\r
+++ /dev/null
-. ./_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
+++ /dev/null
-. ./_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
+++ /dev/null
-. ./_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 \96e option
-grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
-
+++ /dev/null
-#!/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()
+++ /dev/null
-Makefile:39: *** missing separator. Stop.
+++ /dev/null
-# 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
+++ /dev/null
-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?
+++ /dev/null
-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
+++ /dev/null
-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 ?
+++ /dev/null
-bluetooth_TC/tslist
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})
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)
{
} 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,
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;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <vconf.h>
+#include <vconf-keys.h>
#include "bluetooth-agent.h"
#include "sc_core_agent.h"
char pairing_addr[18];
char authorize_addr[18];
+ guint timeout_id;
+ unsigned int timeout;
+
SC_CORE_AGENT_FUNC_CB cb;
};
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);
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)
{
{
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");
}
}
<arg type="s" name="address"/>
</method>
+ <method name="SetDiscoverableTimer">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="timeout"/>
+ </method>
+
+ <method name="GetDiscoverableTimeout">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="timeout" direction="out"/>
+ </method>
+
<method name="ReplyPinCode">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="u" name="accept"/>
#include <unistd.h>
#include <glib.h>
#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
#include <time.h>
#include <errno.h>
#include "vconf.h"
#include "Emf_Mapi_Message.h"
#include "Emf_Mapi_Network.h"
#include "Emf_Mapi_Mailbox.h"
+#include "Emf_Mapi_Types.h"
#include <bluetooth_map_agent.h>
-#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"
#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;
static void bluetooth_map_agent_init(BluetoothMapAgent *obj)
{
DBG("+\n");
+
g_assert(obj != NULL);
}
&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;
}
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,};
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;
}
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,
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;
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");
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);
}
}
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;
}
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;
}
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;
}
<method name="GetMessageList">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="folder_name"/>
- <arg type="a(ss)" name="msg_list" direction="out"/>
+ <arg type="a(sss)" name="msg_list" direction="out"/>
</method>
<method name="GetMessage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
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}")
FOREACH(hfile ${HEADERS})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-media-control)
ENDFOREACH(hfile)
-
-ADD_SUBDIRECTORY(test)
-
+++ /dev/null
-/*
- * bluetooth-media-control
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
-#include <glib.h>
-#include <string.h>
-
-#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;
-}
-
-
+++ /dev/null
-/*
- * bluetooth-media-control
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- *
- * 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 _BT_MP_CONTROL_H_
-#define _BT_MP_CONTROL_H_
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-#include <dlog.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /*__cplusplus*/
-
-#ifndef BT_EXPORT_API
-#define BT_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#define BT_MEDIA_CONTROL "BT_MEDIA_CONTROL"
-#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
-#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
-
-/* defines*/
-#define MEDIA_OBJECT_PATH_LENGTH 50
-
-#define BT_MEDIA_CONTROL_ERROR -1
-#define BT_MEDIA_CONTROL_SUCCESS 0
-
-typedef enum {
- EQUILIZER_OFF = 0x00,
- EQUILIZER_ON,
- EQUILIZER_INVALID,
-} media_player_equilizer_status;
-
-typedef enum {
- REPEAT_MODE_OFF = 0x00,
- REPEAT_SINGLE_TRACK,
- REPEAT_ALL_TRACK,
- REPEAT_GROUP,
- REPEAT_INVALID,
-} media_player_repeat_status;
-
-typedef enum {
- SHUFFLE_MODE_OFF = 0x00,
- SHUFFLE_ALL_TRACK,
- SHUFFLE_GROUP,
- SHUFFLE_INVALID,
-} media_player_shuffle_status;
-
-typedef enum {
- SCAN_MODE_OFF = 0x00,
- SCAN_ALL_TRACK,
- SCAN_GROUP,
- SCAN_INVALID,
-} media_player_scan_status;
-
-typedef enum {
- STATUS_PLAYING = 0x00,
- STATUS_STOPPED,
- STATUS_PAUSED,
- STATUS_FORWARD_SEEK,
- STATUS_REVERSE_SEEK,
- STATUS_ERROR,
- STATUS_INVALID
-} media_player_status;
-
-typedef struct {
- media_player_equilizer_status equilizer;
- media_player_repeat_status repeat;
- media_player_shuffle_status shuffle;
- media_player_scan_status scan;
- media_player_status status;
- unsigned int position;
-}media_player_settings_t;
-
-typedef struct {
- const char *title;
- const char *artist;
- const char *album;
- const char *genre;
- 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);
-
-/**
- * @fn int bluetooth_media_control_player_property_changed(media_player_settings_t player_settings)
- * @brief Notifies the remote bluetooth headset with change in music player settings
- *
- * 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,
- *
- * @remark None
- * @see None
- */
-int bluetooth_media_control_player_property_changed(
- media_player_settings_t player_settings);
-
-
-/**
- * @fn int bluetooth_media_control_player_track_changed(media_metadata_attributes_t metadata)
- * @briefNotifies the remote bluetooth headset with change in media attributes of the track
- *
- * This function is a asynchronous call.
- * No event for this api..
- *
- * @return 0 - Success \n
- * -1 - On Failure\n
- *
- * @exception None
- * @param[in] metadata -Meida attributes
- *
- * @remark None
- * @see None
- */
-int bluetooth_media_control_player_track_changed(
- 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*/
-
-#endif /*_BT_MP_CONTROL_H_*/
--- /dev/null
+/*
+ * bluetooth-media-control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hocheol Seo <hocheol.seo@samsung.com>
+ * Girishashok Joshi <girish.joshi@samsung.com>
+ * Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <string.h>
+
+#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;
+}
+
+
--- /dev/null
+/*
+ * bluetooth-media-control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hocheol Seo <hocheol.seo@samsung.com>
+ * Girishashok Joshi <girish.joshi@samsung.com>
+ * Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ *
+ * 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 _BT_MP_CONTROL_H_
+#define _BT_MP_CONTROL_H_
+
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /*__cplusplus*/
+
+#ifndef BT_EXPORT_API
+#define BT_EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#define BT_MEDIA_CONTROL "BT_MEDIA_CONTROL"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+/* defines*/
+#define MEDIA_OBJECT_PATH_LENGTH 50
+
+#define BT_MEDIA_CONTROL_ERROR -1
+#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,
+} media_player_equilizer_status;
+
+typedef enum {
+ REPEAT_MODE_OFF = 0x00,
+ REPEAT_SINGLE_TRACK,
+ REPEAT_ALL_TRACK,
+ REPEAT_GROUP,
+ REPEAT_INVALID,
+} media_player_repeat_status;
+
+typedef enum {
+ SHUFFLE_MODE_OFF = 0x00,
+ SHUFFLE_ALL_TRACK,
+ SHUFFLE_GROUP,
+ SHUFFLE_INVALID,
+} media_player_shuffle_status;
+
+typedef enum {
+ SCAN_MODE_OFF = 0x00,
+ SCAN_ALL_TRACK,
+ SCAN_GROUP,
+ SCAN_INVALID,
+} media_player_scan_status;
+
+typedef enum {
+ STATUS_PLAYING = 0x00,
+ STATUS_STOPPED,
+ STATUS_PAUSED,
+ STATUS_FORWARD_SEEK,
+ STATUS_REVERSE_SEEK,
+ STATUS_ERROR,
+ STATUS_INVALID
+} media_player_status;
+
+typedef struct {
+ media_player_equilizer_status equilizer;
+ media_player_repeat_status repeat;
+ media_player_shuffle_status shuffle;
+ media_player_scan_status scan;
+ media_player_status status;
+ unsigned int position;
+} media_player_settings_t;
+
+typedef struct {
+ const char *title;
+ const char *artist;
+ const char *album;
+ const char *genre;
+ unsigned int total_tracks;
+ unsigned int number;
+ unsigned int duration;
+} media_metadata_attributes_t;
+
+/**
+ * @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.
+ * No event for this api..
+ *
+ * @return 0 - Success \n
+ * -1 - On Failure\n
+ *
+ * @exception None
+ * @param[in] type - Type of the music player property
+ * value - Value of the property which is changed
+ *
+ * @remark None
+ * @see None
+ */
+int bluetooth_media_player_change_property(
+ media_player_property_type type,
+ unsigned int value);
+
+
+/**
+ * @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.
+ * No event for this api..
+ *
+ * @return 0 - Success \n
+ * -1 - On Failure\n
+ *
+ * @exception None
+ * @param[in] metadata -Meida attributes
+ *
+ * @remark None
+ * @see None
+ */
+int bluetooth_media_player_change_track(
+ media_metadata_attributes_t metadata);
+
+#ifdef __cplusplus
+}
+#endif /*__cplusplus*/
+
+#endif /*_BT_MP_CONTROL_H_*/
+++ /dev/null
-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)
-
+++ /dev/null
-/*
- * bluetooth-media-control
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "bluetooth-media-control-api.h"
-
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-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;
-}
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})
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,
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;
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;
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)
{
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);
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");
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,
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);
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);
<arg type="u" name="phonebook_size" direction="out"/>
</method>
+ <method name="GetTotalObjectCount">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="path"/>
+ <arg type="u" name="phonebook_size" direction="out"/>
+ </method>
+
<method name="GetPhonebookList">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="a(ssu)" name="phonebook_list" direction="out"/>
+++ /dev/null
-/usr/bin/bluetooth-frwk-test
+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 <dh79.pyun@samsung.com> Thu, 09 Feb 2012 14:06:25 +0900
+
bluetooth-frwk (0.1.41-1) unstable; urgency=low
* change "com.samsung" -> "org.tizen"
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
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
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}")
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}")
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-api)
ENDFOREACH(hfile)
-ADD_SUBDIRECTORY(test)
-
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;
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;
_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) {
_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) {
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) {
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("+");
#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"
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;
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);
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 */
#define BLUETOOTH_UUID_STRING_MAX 50
+#define BLUETOOTH_OOB_DATA_LENGTH 16
/**
* This is Bluetooth Connected event role
*/
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 */
BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104), /**<OBEX IR MC SYNC*/
BLUETOOTH_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105), /**<OPP*/
BLUETOOTH_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106), /**<FTP*/
+ BLUETOOTH_IRMC_SYNC_COMMAND_UUID = ((unsigned short)0x1107), /**<IRMC SYNC COMMAND*/
BLUETOOTH_HS_PROFILE_UUID = ((unsigned short)0x1108), /**<HS*/
BLUETOOTH_CTP_PROFILE_UUID = ((unsigned short)0x1109), /**<CTP*/
BLUETOOTH_AUDIO_SOURCE_UUID = ((unsigned short)0x110A), /**<AUDIO SOURCE*/
BLUETOOTH_AUDIO_SINK_UUID = ((unsigned short)0x110B), /**<AUDIO SINK*/
- BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303), /**<VEDIO SOURCE*/
- BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304), /**<VEDIO SINK*/
BLUETOOTH_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C), /**<AV REMOTE CONTROL
TARGET*/
BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
BLUETOOTH_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E), /**<AV REMOTE CONTROL UUID*/
+ BLUETOOTH_AV_REMOTE_CONTROL_CONTROLLER_UUID = ((unsigned short)0x110F), /**<AV REMOTE CONTROLLER UUID*/
BLUETOOTH_ICP_PROFILE_UUID = ((unsigned short)0x1110), /**<ICP*/
BLUETOOTH_FAX_PROFILE_UUID = ((unsigned short)0x1111), /**<FAX*/
BLUETOOTH_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112), /**<HS AG */
BLUETOOTH_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116), /**<PAN*/
BLUETOOTH_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117), /**<PAN*/
BLUETOOTH_DIRECT_PRINTING = ((unsigned short)0x1118),
+ BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118), /**<OBEX BPPS*/ /* Will be removed */
BLUETOOTH_REFERENCE_PRINTING = ((unsigned short)0x1119),
BLUETOOTH_OBEX_IMAGING_UUID = ((unsigned short)0x111A), /**<OBEX_IMAGING*/
BLUETOOTH_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B), /**<OBEX_IMAGING
RESPONDER*/
+ BLUETOOTH_IMAGING_AUTOMATIC_ARCHIVE_UUID = ((unsigned short)0x111C), /**<IMAGING AUTOMATIC ARCHIVE*/
+ BLUETOOTH_IMAGING_REFERENCED_OBJECTS_UUID = ((unsigned short)0x111D), /**<IMAGING REFERENCED OBJECTS*/
BLUETOOTH_HF_PROFILE_UUID = ((unsigned short)0x111E), /**<HF*/
BLUETOOTH_HFG_PROFILE_UUID = ((unsigned short)0x111F), /**<HFG*/
BLUETOOTH_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
/**<DIRECT PRINTING*/
+ BLUETOOTH_REFLECTED_UI = ((unsigned short)0x1121), /**<REFLECTED UI*/
BLUETOOTH_BASIC_PRINTING = ((unsigned short)0x1122), /**<BASIC PRINTING*/
BLUETOOTH_PRINTING_STATUS = ((unsigned short)0x1123), /**<PRINTING STATUS*/
+ BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/ /* Will be removed */
BLUETOOTH_HID_PROFILE_UUID = ((unsigned short)0x1124), /**<HID*/
+ BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125), /**<HCRP*/
+ BLUETOOTH_HCR_PRINT_UUID = ((unsigned short)0x1126), /**<HCR PRINT*/
+ BLUETOOTH_HCR_SCAN_UUID = ((unsigned short)0x1127), /**<HCR SCAN*/
BLUETOOTH_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D), /**<SIM ACCESS PROFILE*/
- BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/
+ BLUETOOTH_PBAP_PCE_UUID = ((unsigned short)0x112E), /**<PBAP - PCE*/
+ BLUETOOTH_PBAP_PSE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/
+ BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/ /* Will be removed */
BLUETOOTH_OBEX_PBAP_UUID = ((unsigned short)0x1130), /**<OBEX PBA*/
- BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118), /**<OBEX BPPS*/
+ BLUETOOTH_HEADSET_HS_UUID = ((unsigned short)0x1131), /**<HEADSET HS*/
+ BLUETOOTH_MESSAGE_ACCESS_SERVER_UUID = ((unsigned short)0x1132),/**<MESSAGE ACCESS SERVER*/
+ BLUETOOTH_MESSAGE_NOTIFICATION_SERVER_UUID = ((unsigned short)0x1133),/**<MESSAGE NOTIFICATION SERVER*/
+ BLUETOOTH_MESSAGE_ACCESS_PROFILE_UUID = ((unsigned short)0x1134),/**<MESSAGE ACCESS PROFILE*/
BLUETOOTH_PNP_INFORMATION_UUID = ((unsigned short)0x1200), /**<PNP*/
- BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/
- BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125), /**<HCRP*/
- BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/
+ BLUETOOTH_GENERIC_NETWORKING_UUID = ((unsigned short)0x1201), /**<GENERIC NETWORKING*/
+ BLUETOOTH_GENERIC_FILE_TRANSFER_UUID = ((unsigned short)0x1202),/**<GENERIC FILE TRANSFER*/
+ BLUETOOTH_GENERIC_AUDIO_UUID = ((unsigned short)0x1203), /**<GENERIC AUDIO*/
+ BLUETOOTH_GENERIC_TELEPHONY_UUID = ((unsigned short)0x1204), /**<GENERIC TELEPHONY*/
+ BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303), /**<VEDIO SOURCE*/
+ BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304), /**<VEDIO SINK*/
+ BLUETOOTH_VIDEO_DISTRIBUTION_UUID = ((unsigned short)0x1305), /**<VEDIO DISTRIBUTION*/
+ BLUETOOTH_HDP_UUID = ((unsigned short)0x1400), /**<HDP*/
+ BLUETOOTH_HDP_SOURCE_UUID = ((unsigned short)0x1401), /**<HDP SOURCE*/
+ BLUETOOTH_HDP_SINK_UUID = ((unsigned short)0x1402), /**<HDP SINK*/
+ BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/ /* Will be removed */
} bluetooth_service_uuid_list_t;
/**
int size;
}bt_opc_transfer_info_t;
+/* Obex Server transfer type */
+#define TRANSFER_PUT "PUT"
+#define TRANSFER_GET "GET"
/**
* Stucture to OPP/FTP Server authorize information
*/
typedef struct {
char *filename;
- char *device_name;
- char *type;
int length;
} bt_obex_server_authorize_into_t;
int percentage;
} bt_obex_server_transfer_info_t;
-/* This is for distingushing the FTP server operation type */
-#define FTS_TYPE_PUT "x-obex/ftp-put"
-#define FTS_TYPE_GET "x-obex/ftp-get"
-#define FTS_TYPE_DEL "x-obex/ftp-delete"
+/**
+ * Stucture to OOB data
+ */
+typedef struct {
+ unsigned char hash[BLUETOOTH_OOB_DATA_LENGTH];
+ unsigned char randomizer[BLUETOOTH_OOB_DATA_LENGTH];
+ unsigned int hash_len;
+ unsigned int randomizer_len;
+} bt_oob_data_t;
/**
* Callback pointer type
int bluetooth_opc_cancel_push(void);
/**
- * @fn gboolean bluetooth_opc_sessioin_is_exist(void)
+ * @fn gboolean bluetooth_opc_session_is_exist(void)
* @brief Informs whether opc session exists or not.
*
* This function is a synchronous call.
* @see None
*/
-gboolean bluetooth_opc_sessioin_is_exist(void);
+gboolean bluetooth_opc_session_is_exist(void);
/**
int bluetooth_obex_server_set_root(char *root);
+/**
+ * @fn int bluetooth_obex_server_cancel_transfer(int transfer_id)
+ * @brief Cancel the transfer on server
+ *
+ * This function is a asynchronous call.
+ * If the call is success to cancel transfering then the application will receive
+ * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
+ * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
+ * the error code will be BLUETOOTH_ERROR_NONE
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
+ * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
+ * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
+ *
+ * @exception None
+ * @param[in] transfer_id transfer ID
+
+ * @remark None
+ * @see None
+ */
+
+int bluetooth_obex_server_cancel_transfer(int transfer_id);
+
+
+/**
+ * @fn int bluetooth_oob_read_local_data(void)
+ * @brief Read the local Hash and Randmizer.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *
+ * @exception None
+ * @param[in] None.
+ * @param[out]
+ *
+ * @remark None
+ * @see None
+ @code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+ switch(event)
+ {
+ case BLUETOOTH_EVENT_READ_LOCAL_OOB_DATA:
+ {
+ if (param->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);
+
/**
* @}
*/
*
*/
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <syspopup_caller.h>
+
#include "bluetooth-gap-api.h"
static bluetooth_discovery_option_t discovery_option = { 0 };
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();
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();
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();
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;
}
+ /* 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);
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");
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;
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;
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("+");
#include "bluetooth-api-common.h"
#include "bluetooth-hdp-api.h"
+#define HDP_BUFFER_SIZE 1024
+
/**********************************************************************
* Static Functions declaration *
***********************************************************************/
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);
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;
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;
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");
}
}
/* 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;
}
/* 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;
--- /dev/null
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hocheol Seo <hocheol.seo@samsung.com>
+ * Girishashok Joshi <girish.joshi@samsung.com>
+ * Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * 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;
+}
--- /dev/null
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hocheol Seo <hocheol.seo@samsung.com>
+ * Girishashok Joshi <girish.joshi@samsung.com>
+ * Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * 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 */
}
/* 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;
}
/* 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;
DBG("+\n");
bt_info_t *bt_internal_info = NULL;
- DBusError dbus_error;
bt_internal_info = _bluetooth_internal_get_information();
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)
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 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;
}
/* 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;
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;
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("+");
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("-");
}
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");
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) {
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,
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);
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);
}
}
-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);
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);
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;
}
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);
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 {
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;
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)
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("+");
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)
#include <sys/stat.h>
#include "bluetooth-rfcomm-api.h"
+#include <termios.h>
#define BLUEZ_SERVICE_NAME "org.bluez"
#define BLUEZ_SERIAL_CLINET_INTERFACE "org.bluez.Serial"
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)
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;
(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 {
}
- 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);
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;
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;
}
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
}
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;
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;
}
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;
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);
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;
+}
+
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,
{
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");
return BLUETOOTH_ERROR_NONE;
}
+ bt_internal_info->is_service_req = TRUE;
+
}
return BLUETOOTH_ERROR_NONE;
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,
+++ /dev/null
-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)
-
+++ /dev/null
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
- *
- * 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 <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <pthread.h>
-
-#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; i<devinfo->len;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("*****<<No more BLUETOOTH_EVENT_BONDED_DEVICE_FOUND indication>>***** ");
- }
- 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; i<bt_sdp_info->service_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;
-}
-
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(bluez)
BuildRequires: pkgconfig(dbus-1)
-BuildRequires: pkgconfig(utilX)
BuildRequires: pkgconfig(appcore-efl)
BuildRequires: pkgconfig(openobex)
BuildRequires: cmake
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
/usr/include/*
/usr/lib/pkgconfig/*
-%files test
-/usr/bin/bluetooth-frwk-test
-
%files agent
/usr/bin/bluetooth-agent
/usr/bin/bluetooth-pb-agent