From: Wootak Jung Date: Tue, 16 Jun 2020 08:09:14 +0000 (+0900) Subject: Add unittest for auto coverage X-Git-Tag: submit/tizen/20200724.011437^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F236326%2F12;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add unittest for auto coverage Make tests folder and include test and unittest folder Change-Id: I7f9a9dc72a5d8b4710bf24e55fe0fc11fb197a99 Signed-off-by: Wootak Jung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f17c7..cf95802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,16 +88,17 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(tests/test) +ADD_SUBDIRECTORY(tests/unittest) IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean + DEPENDS clean COMMENT "distribution clean" COMMAND find - ARGS . + ARGS . -not -name config.cmake -and \( -name tester.c -or -name Testing -or diff --git a/packaging/capi-network-bluetooth.spec b/packaging/capi-network-bluetooth.spec index b90b392..df1d5ef 100644 --- a/packaging/capi-network-bluetooth.spec +++ b/packaging/capi-network-bluetooth.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(capi-appfw-app-control) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) BuildRequires: cmake +BuildRequires: gtest-devel %if 0%{?gcov:1} BuildRequires: lcov %endif @@ -88,26 +89,29 @@ export FFLAGS+=" -DARCH64" %cmake MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} +%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -exec cp '{}' gcov-obj ';' -%endif - %install rm -rf %{buildroot} %make_install %if 0%{?gcov:1} -mkdir -p %{buildroot}%{_datadir}/gcov/obj -install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - +install -d -m 755 %{buildroot}%{_datadir}/gcov/obj +tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj +%endif + +%check +LD_LIBRARY_PATH=. LD_PRELOAD=tests/unittest/libbluetooth-mock.so tests/unittest/tct-bluetooth-core +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info --exclude "*/unittest/*" +genhtml %{name}.info -o out --legend --show-details %endif mkdir -p %{buildroot}%{_unitdir} -install -m 0644 test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}/bt_infinite_spp_test_server.service +install -m 0644 tests/test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}/bt_infinite_spp_test_server.service %post -p /sbin/ldconfig diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 889696d..a2f45d9 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -495,7 +495,6 @@ int _bt_get_error_code(int origin_error) return BT_ERROR_OPERATION_FAILED; /* LCOV_EXCL_LINE */ } -/* LCOV_EXCL_START */ int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev) { int i = 0; @@ -582,6 +581,7 @@ void _bt_free_bt_device_info_s(bt_device_info_s *device_info) device_info = NULL; } +/* LCOV_EXCL_START */ int _bt_get_ad_data_by_type(char *in_data, int in_len, char in_type, char **data, int *data_len) { @@ -688,6 +688,7 @@ char *_bt_convert_error_to_string(int error) return "UNKNOWN"; /* LCOV_EXCL_LINE */ } +/* LCOV_EXCL_START */ bool _bt_get_random_bytes(void *buf, size_t num_bytes) { ssize_t len; @@ -706,6 +707,7 @@ bool _bt_get_random_bytes(void *buf, size_t num_bytes) return true; } +/* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ char *_bt_convert_uuid_to_uuid128(const char *uuid) @@ -1488,7 +1490,6 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) (_bt_get_error_code(param->result), BT_ADAPTER_ENABLED, bt_event_slot_container[event_index].user_data); break; -/* LCOV_EXCL_START */ case BLUETOOTH_EVENT_DISABLED: BT_INFO("bt_adapter_state_changed_cb() will be called with BT_ADAPTER_DISABLED"); ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) @@ -1503,6 +1504,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us ((bt_adapter_name_changed_cb)bt_event_slot_container[event_index].callback) ((char *)(param->param_data), bt_event_slot_container[event_index].user_data); break; +/* LCOV_EXCL_START */ case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: BT_INFO("bt_adapter_visibility_mode_changed_cb() will be called"); ((bt_adapter_visibility_mode_changed_cb)bt_event_slot_container[event_index].callback) @@ -4097,7 +4099,7 @@ static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void ((bt_adapter_le_state_changed_cb) bt_event_slot_container[event_index].callback) /* LCOV_EXCL_LINE */ (_bt_get_error_code(param->result), BT_ADAPTER_LE_DISABLED, bt_event_slot_container[event_index].user_data); break; - case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: /* LCOV_EXCL_START */ + case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: event_index = BT_EVENT_LE_SCAN_RESULT_UPDATED; if (bt_event_slot_container[event_index].callback != NULL) { if (__bt_get_bt_adapter_le_device_scan_info_s(&scan_info, (bluetooth_le_device_info_t *)(param->param_data)) == BT_ERROR_NONE) { @@ -4146,7 +4148,6 @@ static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void break; } } -/* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info) diff --git a/src/bluetooth-hrp.c b/src/bluetooth-hrp.c index 59e9448..cf95587 100644 --- a/src/bluetooth-hrp.c +++ b/src/bluetooth-hrp.c @@ -112,6 +112,7 @@ static bt_hrp_collector_s *_bt_hrp_collector_find(const char *remote_address); Heart Rate Server - Utility ========================================================================================================*/ +/* LCOV_EXCL_START */ /*Internal Functions*/ static void __bt_hrp_sensor_read_value_requested_cb( const char *remote_address, int request_id, @@ -1178,4 +1179,4 @@ int bt_hrp_collector_get_body_sensor_location(bt_hrp_collector_h collector, return error_code; } - +/* LCOV_EXCL_STOP */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 0d6a867..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -SET(fw_test "${fw_name}-test") - -INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED glib-2.0 capi-appfw-app-control) -FOREACH(flag ${${fw_test}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -aux_source_directory(. sources) -FOREACH(src ${sources}) - GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) - MESSAGE("${src_name}") - ADD_EXECUTABLE(${src_name} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) -ENDFOREACH() - -INSTALL(TARGETS bt_unit_test DESTINATION bin) -INSTALL(TARGETS bt_mesh_unit_test DESTINATION bin) -INSTALL(TARGETS bt_onoff DESTINATION bin) -INSTALL(TARGETS ble_mouse DESTINATION bin) -INSTALL(TARGETS hid_keyboard DESTINATION bin) -INSTALL(TARGETS bt_infinite_spp_test DESTINATION bin) diff --git a/test/ble_mouse.c b/test/ble_mouse.c deleted file mode 100644 index 31305db..0000000 --- a/test/ble_mouse.c +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "BLE_MOUSE" - -/** - * Variables - **/ -static GMainLoop *g_mainloop = NULL; -static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; -static bt_gatt_server_h server = NULL; -static bt_advertiser_h advertiser = NULL; - -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define BLE_PRT(format, args...) PRT(format"\n", ##args) - -static const char *__bt_get_error_message(bt_error_e err) -{ - const char *err_str = NULL; - - switch (err) { - case BT_ERROR_NONE: - err_str = "BT_ERROR_NONE"; - break; - case BT_ERROR_CANCELLED: - err_str = "BT_ERROR_CANCELLED"; - break; - case BT_ERROR_INVALID_PARAMETER: - err_str = "BT_ERROR_INVALID_PARAMETER"; - break; - case BT_ERROR_OUT_OF_MEMORY: - err_str = "BT_ERROR_OUT_OF_MEMORY"; - break; - case BT_ERROR_RESOURCE_BUSY: - err_str = "BT_ERROR_RESOURCE_BUSY"; - break; - case BT_ERROR_TIMED_OUT: - err_str = "BT_ERROR_TIMED_OUT"; - break; - case BT_ERROR_NOW_IN_PROGRESS: - err_str = "BT_ERROR_NOW_IN_PROGRESS"; - break; - case BT_ERROR_NOT_INITIALIZED: - err_str = "BT_ERROR_NOT_INITIALIZED"; - break; - case BT_ERROR_NOT_ENABLED: - err_str = "BT_ERROR_NOT_ENABLED"; - break; - case BT_ERROR_ALREADY_DONE: - err_str = "BT_ERROR_ALREADY_DONE"; - break; - case BT_ERROR_OPERATION_FAILED: - err_str = "BT_ERROR_OPERATION_FAILED"; - break; - case BT_ERROR_NOT_IN_PROGRESS: - err_str = "BT_ERROR_NOT_IN_PROGRESS"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; - break; - case BT_ERROR_AUTH_REJECTED: - err_str = "BT_ERROR_AUTH_REJECTED"; - break; - case BT_ERROR_AUTH_FAILED: - err_str = "BT_ERROR_AUTH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; - break; - case BT_ERROR_SERVICE_SEARCH_FAILED: - err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; - break; - case BT_ERROR_PERMISSION_DENIED: - err_str = "BT_ERROR_PERMISSION_DENIED"; - break; - case BT_ERROR_SERVICE_NOT_FOUND: - err_str = "BT_ERROR_SERVICE_NOT_FOUND"; - break; - case BT_ERROR_NO_DATA: - err_str = "BT_ERROR_NO_DATA"; - break; - case BT_ERROR_NOT_SUPPORTED: - err_str = "BT_ERROR_NOT_SUPPORTED"; - break; - case BT_ERROR_DEVICE_POLICY_RESTRICTION: - err_str = "DEVICE_POLICY_RESTRICTION"; - break; - default: - err_str = "NOT Defined"; - break; - } - - return err_str; -} - -/** - * Callback functions - **/ -static gboolean __timeout_func(gpointer data) -{ - BLE_PRT("Timeout."); - if (g_mainloop) - g_main_loop_quit((GMainLoop *)data); - - return FALSE; -} - -static void __bt_state_changed_impl(int result, - bt_adapter_state_e adapter_state, - void *user_data) -{ - if (adapter_state == BT_ADAPTER_ENABLED) { - if (result == BT_ERROR_NONE) { - BLE_PRT("Callback: BT was enabled successfully."); - bt_state = BT_ADAPTER_ENABLED; - } else { - BLE_PRT("Callback: Failed to enable BT."); - } - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -static void __bt_gatt_read_value1_req_cb( - const char *remote_address, int request_id, - bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data) -{ - char char_value[4] = {10, 20, 30, 40}; - - int resp_status = BT_ATT_ERROR_NONE; - - BLE_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); - - /* Get the attribute new values here */ - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_READ, offset, - resp_status, char_value, 1 - offset); -} - -static void __bt_gatt_read_value_req_cb( - const char *remote_address, int request_id, - bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data) -{ - char char_value[1] = { 80 }; /* 80% */ - - int resp_status = BT_ATT_ERROR_NONE; - - BLE_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); - - /* Get the attribute new values here */ - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_READ, offset, - resp_status, char_value, 1 - offset); -} - -static void __bt_gatt_write_value_req_cb(const char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, bool response_needed, int offset, - const char *value, int len, void *user_data) -{ - int i, resp_status = BT_ATT_ERROR_NONE; - - BLE_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", - remote_address, request_id, response_needed, offset, len); - - for (i = 0; i < len; i++) - BLE_PRT("%d ", value[i]); - - if (len > 4) { - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_WRITE, offset, - BT_ATT_ERROR_OUT_OF_RANGE, NULL, 0); - - BLE_PRT("Invalid Len"); - return; - } - - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_WRITE, offset, - resp_status, NULL, 0); -} - -static void __bt_gatt_write_value_desc_req_cb(const char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, bool response_needed, int offset, - const char *value, int len, void *user_data) -{ - int i, resp_status = BT_ATT_ERROR_NONE; - - BLE_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", - remote_address, request_id, response_needed, offset, len); - - for (i = 0; i < len; i++) - BLE_PRT("%d ", value[i]); - - if (len > 2) { - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_WRITE, offset, - BT_ATT_ERROR_OUT_OF_RANGE, NULL, 0); - - BLE_PRT("Invalid Len"); - return; - } - - bt_gatt_server_send_response(request_id, - BT_GATT_REQUEST_TYPE_WRITE, offset, - resp_status, NULL, 0); -} - - -static void __bt_gatt_notification_state_change_cb(bool notify, - bt_gatt_server_h server, bt_gatt_h gatt_handle, - void *user_data) -{ - BLE_PRT("Notification %s [%d]", notify ? "enabled" : "disabled", notify); - BLE_PRT("server %s\n", (char *)server); -} - - -static int __bt_register_hogp_service(void) -{ - int ret = BT_ERROR_NONE; - bt_gatt_h service1 = NULL; /* Human Interface Device */ - bt_gatt_h service2 = NULL; /* Battery Service */ - bt_gatt_h characteristic1_1 = NULL; /* HID Information */ - bt_gatt_h characteristic1_2 = NULL; /* Report Map */ - bt_gatt_h characteristic1_3 = NULL; /* Boot Mouse input Report */ - bt_gatt_h characteristic1_4 = NULL; /* Report */ - bt_gatt_h characteristic1_5 = NULL; /* Report */ - bt_gatt_h characteristic1_6 = NULL; /* HID Control Point */ - bt_gatt_h characteristic1_7 = NULL; /* Protocal Mode */ - bt_gatt_h characteristic2_1 = NULL; /* Battery Level */ - bt_gatt_h characteristic2_2 = NULL; /* Custom read / write */ - bt_gatt_h descriptor1_3 = NULL; /* CCCD */ - bt_gatt_h descriptor1_4_1 = NULL; /* CCCD */ - bt_gatt_h descriptor1_4_2 = NULL; /* Report Reference */ - bt_gatt_h descriptor1_5_1 = NULL; /* Report Reference */ - bt_gatt_h descriptor1_5_2 = NULL; /* CCCD */ - bt_gatt_h descriptor2 = NULL; /* CCCD */ - char *service_uuid1 = "1812"; /* HID Service */ - char *service_uuid2 = "180f"; /* Battery Service */ - char *char_uuid1_1 = "2a4a"; /* HID information */ - char *char_uuid1_2 = "2a4b"; - char *char_uuid1_3 = "2a33"; - char *char_uuid1_4 = "2a4d"; - char *char_uuid1_5 = "2a4d"; - char *char_uuid1_6 = "2a4c"; - char *char_uuid1_7 = "2a4e"; - char *desc_uuid1_3 = "2902"; /* Client Characteristic Configuration */ - char *desc_uuid1_4_1 = "2902"; /* Client Characteristic Configuration */ - char *desc_uuid1_4_2 = "2908"; /* Report Reference */ - char *desc_uuid1_5_1 = "2908"; /* Report Reference */ - char *desc_uuid1_5_2 = "2901"; /* Characteristic User Description */ - char *char_uuid2_1 = "2a19"; /* Battery Level */ - char *char_uuid2_2 = "2af8"; /* Custom UUID */ - char *desc_uuid2 = "2902"; /* Client Characteristic Configuration */ - int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - int properties_read = BT_GATT_PROPERTY_READ; - int properties_read_write = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; - int properties_notify_read = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; - int properties_write_no_response = BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; - int properties_read_write_no_response = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; - - char char_value[1] = { 80 }; /* 80% */ - char char_value_unknown[4] = {10, 20, 30, 40}; - char desc_value_configration[2] = {0, 0}; /* Notification & Indication */ - - ret = bt_gatt_server_initialize(); - BLE_PRT("bt_gatt_server_initialize : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_create(&server); - BLE_PRT("bt_gatt_server_create : %s", __bt_get_error_message(ret)); - - /* HID Service */ - ret = bt_gatt_service_create(service_uuid1, BT_GATT_SERVICE_TYPE_PRIMARY, &service1); - BLE_PRT("bt_gatt_service_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_1, permissions, - properties_read, char_value_unknown, - 4, &characteristic1_1); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_1, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_1); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_2, permissions, - properties_read, char_value_unknown, - 4, &characteristic1_2); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_2, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_2); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_3, permissions, - properties_notify_read, char_value_unknown, - 4, &characteristic1_3); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_3, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic1_3, - __bt_gatt_notification_state_change_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_3); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_3, permissions, - desc_value_configration, 2, &descriptor1_3); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_3, - __bt_gatt_write_value_desc_req_cb, NULL); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_3, descriptor1_3); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_4, permissions, - properties_notify_read, char_value_unknown, - 4, &characteristic1_4); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_4, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic1_4, - __bt_gatt_notification_state_change_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_4); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_4_1, permissions, - desc_value_configration, 2, &descriptor1_4_1); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_4_1, - __bt_gatt_write_value_desc_req_cb, NULL); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_4, descriptor1_4_1); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_4_2, permissions, - desc_value_configration, 2, &descriptor1_4_2); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_4_2, - __bt_gatt_write_value_desc_req_cb, NULL); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_4, descriptor1_4_2); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_5, permissions, - properties_read_write, char_value_unknown, - 4, &characteristic1_5); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_5, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_server_set_write_value_requested_cb(characteristic1_5, - __bt_gatt_write_value_req_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_5); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_5_1, permissions, - desc_value_configration, 2, &descriptor1_5_1); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_5_1, - __bt_gatt_write_value_desc_req_cb, NULL); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_5, descriptor1_5_1); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_5_2, permissions, - desc_value_configration, 2, &descriptor1_5_2); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_5, descriptor1_5_2); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_6, permissions, - properties_write_no_response, char_value_unknown, - 4, &characteristic1_6); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_6); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1_7, permissions, - properties_read_write_no_response, char_value_unknown, - 4, &characteristic1_7); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_7, - __bt_gatt_read_value1_req_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_7); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service1); - BLE_PRT("bt_gatt_server_register_service : %s", __bt_get_error_message(ret)); - - /* Battery Service */ - ret = bt_gatt_service_create(service_uuid2, BT_GATT_SERVICE_TYPE_PRIMARY, &service2); - BLE_PRT("bt_gatt_service_create : %s ", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_1, permissions, - properties_notify_read, char_value, - 1, &characteristic2_1); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic2_1, - __bt_gatt_read_value_req_cb, NULL); - - ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic2_1, - __bt_gatt_notification_state_change_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_1); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2, permissions, - desc_value_configration, 2, &descriptor2); - BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_1, descriptor2); - BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_2, permissions, - properties_read_write, char_value_unknown, - 4, &characteristic2_2); - BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_read_value_requested_cb(characteristic2_2, - __bt_gatt_read_value_req_cb, NULL); - - ret = bt_gatt_server_set_write_value_requested_cb(characteristic2_2, - __bt_gatt_write_value_req_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_2); - BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service2); - BLE_PRT("bt_gatt_server_register_service : %s", __bt_get_error_message(ret)); - - /* Scan Parameters */ - - /* Device INformation */ - - ret = bt_gatt_server_start(); - BLE_PRT("bt_gatt_server_start : %s\n", __bt_get_error_message(ret)); - - return ret; -} - -static int __bt_unregister_hogp_service(void) -{ - int ret = BT_ERROR_NONE; - - ret = bt_gatt_server_unregister_all_services(server); - BLE_PRT("returns %s", __bt_get_error_message(ret)); - - ret = bt_gatt_server_deinitialize(); - BLE_PRT("returns %s\n", __bt_get_error_message(ret)); - - server = NULL; - - return ret; -} - -static void __bt_advertising_state_changed_cb(int result, - bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, - void *user_data) -{ - BLE_PRT("Result : %d", result); - BLE_PRT("Advertiser : %p", advertiser); - BLE_PRT("Advertising %s [%d]", - adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? - "started" : "stopped", adv_state); -} - -static int __bt_start_advertisement(void) -{ - int ret = BT_ERROR_NONE; - - const char *battery_svc_uuid_16 = "180f"; - const char *hid_svc_uuid_16 = "1812"; - const char *gatt_svc_uuid_16 = "1801"; - int appearance = 192; /* 192 is generic watch */ - - ret = bt_adapter_le_create_advertiser(&advertiser); - BLE_PRT("created le advertiser(%d)", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); - BLE_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, hid_svc_uuid_16); - BLE_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, gatt_svc_uuid_16); - BLE_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_appearance(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); - BLE_PRT("add appearance data [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, true); - BLE_PRT("add tx_power_level [0x%04x]", ret); - - /* Default scsn response data */ - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - BLE_PRT("set device name [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_connectable(advertiser, true); - BLE_PRT("add scan response data [0x%04x]", ret); - - ret = bt_adapter_le_start_advertising_new(advertiser, __bt_advertising_state_changed_cb, NULL); - BLE_PRT("bt_adapter_le_start_advertising_new [0x%04x]\n", ret); - - return ret; -} - -static int __bt_stop_advertisement(void) -{ - int ret = BT_ERROR_NONE; - - ret = bt_adapter_le_stop_advertising(advertiser); - BLE_PRT("bt_adapter_le_stop_advertising [0x%04x]\n", ret); - - advertiser = NULL; - - return ret; -} - -static gboolean __bt_start_service(gpointer user_data) -{ - if (__bt_register_hogp_service() != BT_ERROR_NONE) { - BLE_PRT("__bt_register_hogp_service() failed."); - g_main_loop_quit(g_mainloop); - return FALSE; - } - - if (__bt_start_advertisement() != BT_ERROR_NONE) { - BLE_PRT("__bt_start_advertisement() failed."); - g_main_loop_quit(g_mainloop); - return FALSE; - } - - return FALSE; -} - -void __bt_gatt_connection_state_changed_cb(int result, - bool connected, const char *remote_address, void *user_data) -{ - if (connected) { - BLE_PRT("GATT connected [%s]", remote_address); - - if (__bt_stop_advertisement() != BT_ERROR_NONE) - BLE_PRT("__bt_stop_advertisement() failed."); - } else { - BLE_PRT("GATT Disconnected [%s]", remote_address); - - __bt_unregister_hogp_service(); - - usleep(50000); - - __bt_register_hogp_service(); - - if (__bt_start_advertisement() != BT_ERROR_NONE) - BLE_PRT("__bt_start_advertisement() failed."); - } -} - -int main() -{ - int timeout_id = -1; - int ret = BT_ERROR_NONE; - char *local_address = NULL; - - g_mainloop = g_main_loop_new(NULL, FALSE); - - BLE_PRT("BLE Mouse starts"); - - if (bt_initialize() != BT_ERROR_NONE) { - BLE_PRT("bt_initialize() failed."); - return -1; - } - - if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { - BLE_PRT("bt_adapter_get_state() failed."); - return -1; - } - - /* Enable BT */ - if (bt_state == BT_ADAPTER_DISABLED) { - if (bt_adapter_set_state_changed_cb( - __bt_state_changed_impl, NULL) != BT_ERROR_NONE) { - BLE_PRT("bt_adapter_set_state_changed_cb() failed."); - return -1; - } - - if (bt_adapter_enable() == BT_ERROR_NONE) { - BLE_PRT("bt_adapter_state_changed_cb will be called."); - timeout_id = g_timeout_add(60000, - __timeout_func, g_mainloop); - g_main_loop_run(g_mainloop); - g_source_remove(timeout_id); - } else { - BLE_PRT("bt_adapter_enable() failed."); - return -1; - } - } else { - BLE_PRT("BT was already enabled."); - } - - if (bt_state != BT_ADAPTER_ENABLED) { - BLE_PRT("BT is not enabled."); - return -1; - } - - ret = bt_adapter_get_address(&local_address); - BLE_PRT("\n\nLocal BT address: %s\n", local_address); - - g_free(local_address); - - ret = bt_gatt_set_connection_state_changed_cb( - __bt_gatt_connection_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - BLE_PRT("returns %s\n", __bt_get_error_message(ret)); - - g_idle_add(__bt_start_service, NULL); - - g_main_loop_run(g_mainloop); - - bt_deinitialize(); - - BLE_PRT("BLE Mouse ends."); - return 0; -} diff --git a/test/bt_chat_client.c b/test/bt_chat_client.c deleted file mode 100644 index d6f7708..0000000 --- a/test/bt_chat_client.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "BLUETOOTH_CHAT_CLIENT" - -/** - * Variables - **/ -static GMainLoop *g_mainloop = NULL; -static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; -static int socket_fd = -1; -static char *bt_address = NULL; -static char *server_name = "chat_server"; -static char quit_command[5] = "Quit"; -static int bonding_state = BT_ERROR_OPERATION_FAILED; - - -/** - * Callback functions - **/ -gboolean timeout_func(gpointer data) -{ - LOGE("[%s] Callback: Timeout.", __FUNCTION__); - g_main_loop_quit((GMainLoop *)data); - return FALSE; -} - -void bt_state_changed_impl(int result, - bt_adapter_state_e adapter_state, void *user_data) -{ - if (adapter_state == BT_ADAPTER_ENABLED) { - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: BT was enabled successfully.", - __FUNCTION__); - bt_state = BT_ADAPTER_ENABLED; - } else { - LOGE("[%s] Callback: Failed to enable BT.", - __FUNCTION__); - } - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -void bt_socket_connection_state_changed_impl(int result, - bt_socket_connection_state_e connection_state, - bt_socket_connection_s *connection, - void *user_data) -{ - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: Result is BT_ERROR_NONE.", - __FUNCTION__); - } else { - LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", - __FUNCTION__); - } - - if (connection_state == BT_SOCKET_CONNECTED) { - LOGI("[%s] Callback: Connected.", - __FUNCTION__); - if (result == BT_ERROR_NONE && connection != NULL) { - socket_fd = connection->socket_fd; - LOGI("[%s] Callback: Socket of connection - %d.", - __FUNCTION__, socket_fd); - LOGI("[%s] Callback: Role of connection - %d.", - __FUNCTION__, connection->local_role); - LOGI("[%s] Callback: Address of connection - %s.", - __FUNCTION__, connection->remote_address); - - if (bt_socket_send_data(socket_fd, - quit_command, - strlen(quit_command)) == BT_ERROR_NONE) { - LOGI("[%s] Callback: Send quit command.", - __FUNCTION__); - } else { - LOGE("[%s] Callback: bt_socket_send_data() failed.", - __FUNCTION__); - if (g_mainloop) - g_main_loop_quit(g_mainloop); - } - } else { - LOGI("[%s] Callback: Failed to connect", - __FUNCTION__); - if (g_mainloop) - g_main_loop_quit(g_mainloop); - } - } else { - LOGI("[%s] Callback: Disconnected.", - __FUNCTION__); - } -} - -void bt_socket_data_received_impl(bt_socket_received_data_s *data, - void *user_data) -{ - if (socket_fd == data->socket_fd) { - if (data->data_size > 0) { - if (!strncmp(data->data, - quit_command, data->data_size)) { - LOGI("[%s] Callback: Quit command.", - __FUNCTION__); - if (g_mainloop) - g_main_loop_quit(g_mainloop); - } - } else { - LOGE("[%s] Callback: No data.", - __FUNCTION__); - } - } else { - LOGI("[%s] Callback: Another socket - %d.", - __FUNCTION__, data->socket_fd); - } -} - -bool bt_adapter_bonded_device_impl(bt_device_info_s *device_info, - void *user_data) -{ - int i = 0; - if (device_info != NULL) { - if (device_info->remote_name != NULL && - !strcmp(device_info->remote_name, (char *)user_data)) { - LOGI("[%s] Callback: chat_server is found in bonded list.", - __FUNCTION__); - if (device_info->remote_address != NULL) { - LOGI("[%s] Callback: Address of chat_server - %s.", - __FUNCTION__, device_info->remote_address); - bt_address = strdup(device_info->remote_address); - LOGI("[%s] Callback: The number of service_count - %d.", - __FUNCTION__, device_info->service_count); - if (device_info->service_count <= 0) { - bonding_state = BT_ERROR_SERVICE_SEARCH_FAILED; - } else { - bonding_state = BT_ERROR_NONE; - for (i = 0; i < device_info->service_count; i++) { - LOGI("[%s] Callback: service[%d] - %s", - __FUNCTION__, - i+1, - device_info->service_uuid[i]); - } - LOGI("[%s] Callback: is_bonded - %d.", - __FUNCTION__, - device_info->is_bonded); - LOGI("[%s] Callback: is_connected - %d.", - __FUNCTION__, - device_info->is_connected); - LOGI("[%s] Callback: is_authorized - %d.", - __FUNCTION__, - device_info->is_authorized); - } - } else { - LOGE("[%s] Callback: Address of chat_server is NULL.", - __FUNCTION__); - } - - return false; - } - } - - return true; -} - -void bt_adapter_device_discovery_state_changed_impl(int result, - bt_adapter_device_discovery_state_e discovery_state, - bt_adapter_device_discovery_info_s *discovery_info, - void *user_data) -{ - if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) { - if (discovery_info->remote_address != NULL && - !strcmp(discovery_info->remote_name, server_name)) { - LOGI("[%s] Callback: chat_server is found.", __FUNCTION__); - LOGI("[%s] Callback: Address of chat_server - %s.", - __FUNCTION__, - discovery_info->remote_address); - LOGI("[%s] Callback: Device major class - %d.", - __FUNCTION__, - discovery_info->bt_class.major_device_class); - LOGI("[%s] Callback: Device minor class - %d.", - __FUNCTION__, - discovery_info->bt_class.minor_device_class); - LOGI("[%s] Callback: Service major class - %d.", - __FUNCTION__, - discovery_info->bt_class.major_service_class_mask); - bt_address = strdup(discovery_info->remote_address); - LOGI("[%s] Callback: is_bonded - %d.", - __FUNCTION__, - discovery_info->is_bonded); - bt_adapter_stop_device_discovery(); - } else { - LOGE("[%s] Callback: Another device is found.", - __FUNCTION__); - } - } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) { - LOGI("[%s] Callback: device discovery finished.", - __FUNCTION__); - if (g_mainloop) - g_main_loop_quit(g_mainloop); - } -} - -void bt_device_bond_created_impl(int result, - bt_device_info_s *device_info, void *user_data) -{ - if (device_info != NULL && - !strcmp(device_info->remote_address, bt_address)) { - bonding_state = result; - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: A bond with chat_server is created.", - __FUNCTION__); - LOGI("[%s] Callback: The number of service - %d.", - __FUNCTION__, device_info->service_count); - - int i = 0; - for (i = 0; i < device_info->service_count; i++) { - LOGI("[%s] Callback: service[%d] - %s", - __FUNCTION__, i+1, - device_info->service_uuid[i]); - } - LOGI("[%s] Callback: is_bonded - %d.", - __FUNCTION__, device_info->is_bonded); - LOGI("[%s] Callback: is_connected - %d.", - __FUNCTION__, device_info->is_connected); - } else { - LOGE("[%s] Callback: Creating a bond is failed.", - __FUNCTION__); - } - } else { - LOGE("[%s] Callback: A bond with another device is created.", - __FUNCTION__); - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -void bt_device_service_searched_impl(int result, - bt_device_sdp_info_s *sdp_info, void *user_data) -{ - if (sdp_info != NULL && - !strcmp(sdp_info->remote_address, bt_address)) { - bonding_state = result; - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: Services of chat_service are found.", - __FUNCTION__); - LOGI("[%s] Callback: The number of service - %d.", - __FUNCTION__, sdp_info->service_count); - - int i = 0; - for (i = 0; i < sdp_info->service_count; i++) { - LOGI("[%s] Callback: service[%d] - %s", - __FUNCTION__, i+1, - sdp_info->service_uuid[i]); - } - } - } else { - LOGE("[%s] Callback: Services of another device are found.", - __FUNCTION__); - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -int main() -{ - g_mainloop = g_main_loop_new(NULL, FALSE); - const char *my_uuid = "11011101-0000-1000-8000-00805F9B34FB"; - int timeout_id = -1; - - LOGI("[%s] Client starts.", __FUNCTION__); - - if (bt_initialize() != BT_ERROR_NONE) { - LOGE("[%s] bt_initialize() failed.", - __FUNCTION__); - return -1; - } - - if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_get_state() failed.", - __FUNCTION__); - return -1; - } - - /* Enable BT */ - if (bt_state == BT_ADAPTER_DISABLED) { - if (bt_adapter_set_state_changed_cb( - bt_state_changed_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_adapter_enable() == BT_ERROR_NONE) { - LOGI("[%s] bt_adapter_state_changed_cb will be called.", - __FUNCTION__); - timeout_id = g_timeout_add(60000, - timeout_func, g_mainloop); - g_main_loop_run(g_mainloop); - g_source_remove(timeout_id); - } else { - LOGE("[%s] bt_adapter_enable() failed.", - __FUNCTION__); - return -1; - } - } else { - LOGI("[%s] BT was already enabled.", - __FUNCTION__); - } - - /* Device discovery */ - if (bt_state == BT_ADAPTER_ENABLED) { - if (bt_adapter_foreach_bonded_device( - bt_adapter_bonded_device_impl, - server_name) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_foreach_bonded_device() failed.", - __FUNCTION__); - return -1; - } - - if (bt_address == NULL) { - if (bt_adapter_set_device_discovery_state_changed_cb( - bt_adapter_device_discovery_state_changed_impl, NULL) - != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_set_device_discovery_state_changed_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) { - LOGI("[%s] bt_adapter_device_discovery_state_changed_cb will be called.", - __FUNCTION__); - g_main_loop_run(g_mainloop); - } else { - LOGE("[%s] bt_adapter_start_device_discovery() failed.", - __FUNCTION__); - return -1; - } - } else { - LOGI("[%s] chat_server is found in bonded device list.", - __FUNCTION__); - } - } else { - LOGE("[%s] BT is not enabled.", - __FUNCTION__); - return -1; - } - - /* Create bond with a server */ - if (bonding_state == BT_ERROR_SERVICE_SEARCH_FAILED) { - if (bt_device_set_service_searched_cb( - bt_device_service_searched_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_device_set_service_searched_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_device_start_service_search(bt_address) == BT_ERROR_NONE) { - LOGI("[%s] bt_device_service_searched_cb will be called.", - __FUNCTION__); - g_main_loop_run(g_mainloop); - } else { - LOGE("[%s] bt_device_start_service_search() failed.", - __FUNCTION__); - return -1; - } - } else if (bonding_state != BT_ERROR_NONE) { - if (bt_device_set_bond_created_cb( - bt_device_bond_created_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_device_set_bond_created_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_device_create_bond(bt_address) == BT_ERROR_NONE) { - LOGI("[%s] bt_device_bond_created_cb will be called.", - __FUNCTION__); - g_main_loop_run(g_mainloop); - } else { - LOGE("[%s] bt_device_create_bond() failed.", - __FUNCTION__); - return -1; - } - } - - /* Connecting socket as a client */ - if (bonding_state == BT_ERROR_NONE) { - if (bt_socket_set_connection_state_changed_cb( - bt_socket_connection_state_changed_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_socket_set_data_received_cb( - bt_socket_data_received_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_set_data_received_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_socket_connect_rfcomm( - bt_address, my_uuid) == BT_ERROR_NONE) { - LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", - __FUNCTION__); - g_main_loop_run(g_mainloop); - } else { - LOGE("[%s] bt_socket_connect_rfcomm() failed.", - __FUNCTION__); - return -1; - } - - if (bt_socket_disconnect_rfcomm( - socket_fd) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_disconnect_rfcomm() failed.", - __FUNCTION__); - return -1; - } - } else { - LOGE("[%s] Bond is not created.", - __FUNCTION__); - return -1; - } - - bt_deinitialize(); - - LOGI("[%s] Client ends.", __FUNCTION__); - return 0; -} diff --git a/test/bt_chat_server.c b/test/bt_chat_server.c deleted file mode 100644 index f2d9542..0000000 --- a/test/bt_chat_server.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "BLUETOOTH_CHAT_SERVER" - -/** - * Variables - **/ -static GMainLoop *g_mainloop = NULL; -static bt_adapter_visibility_mode_e visibility_mode = - BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; -static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; -static int service_socket = -1; -static int connected_socket = -1; -static char *quit_command = "Quit"; - - -/** - * Callback functions - **/ -gboolean timeout_func(gpointer data) -{ - LOGE("[%s] Timeout.", __FUNCTION__); - if (g_mainloop) - g_main_loop_quit((GMainLoop *)data); - - return FALSE; -} - -void bt_state_changed_impl(int result, - bt_adapter_state_e adapter_state, - void *user_data) -{ - if (adapter_state == BT_ADAPTER_ENABLED) { - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: BT was enabled successfully.", - __FUNCTION__); - bt_state = BT_ADAPTER_ENABLED; - } else { - LOGE("[%s] Callback: Failed to enable BT.", - __FUNCTION__); - } - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -void bt_socket_connection_state_changed_impl(int result, - bt_socket_connection_state_e connection_state, - bt_socket_connection_s *connection, - void *user_data) -{ - if (result == BT_ERROR_NONE) { - LOGI("[%s] Callback: Result is BT_ERROR_NONE.", - __FUNCTION__); - } else { - LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", - __FUNCTION__); - } - - if (connection_state == BT_SOCKET_CONNECTED) { - LOGI("[%s] Callback: Connected.", - __FUNCTION__); - if (connection != NULL) { - connected_socket = connection->socket_fd; - LOGI("[%s] Callback: Socket of connection - %d.", - __FUNCTION__, connected_socket); - LOGI("[%s] Callback: Role of connection - %d.", - __FUNCTION__, connection->local_role); - LOGI("[%s] Callback: Address of connection - %s.", - __FUNCTION__, connection->remote_address); - } else { - LOGI("[%s] Callback: No connection data", - __FUNCTION__); - } - } else { - LOGI("[%s] Callback: Disconnected.", - __FUNCTION__); - LOGI("[%s] Callback: Socket of connection - %d.", - __FUNCTION__, connected_socket); - LOGI("[%s] Callback: Role of connection - %d.", - __FUNCTION__, connection->local_role); - LOGI("[%s] Callback: Address of connection - %s.", - __FUNCTION__, connection->remote_address); - } -} - -void bt_socket_data_received_impl(bt_socket_received_data_s *data, - void *user_data) -{ - if (data->data_size > 0) { - if (!strncmp(data->data, quit_command, data->data_size)) { - LOGI("[%s] Callback: Quit command.", __FUNCTION__); - if (g_mainloop) - g_main_loop_quit(g_mainloop); - } - - if (bt_socket_send_data(connected_socket, - quit_command, strlen(quit_command)) == BT_ERROR_NONE) { - LOGI("[%s] Callback: Send quit command.", - __FUNCTION__); - } else { - LOGE("[%s] Callback: bt_socket_send_data() failed.", - __FUNCTION__); - } - } else { - LOGE("[%s] Callback: No data.", __FUNCTION__); - } -} - - -int main() -{ - g_mainloop = g_main_loop_new(NULL, FALSE); - const char *my_uuid = "11011101-0000-1000-8000-00805F9B34FB"; - int timeout_id = -1; - - LOGI("[%s] Server starts.", - __FUNCTION__); - - if (bt_initialize() != BT_ERROR_NONE) { - LOGE("[%s] bt_initialize() failed.", - __FUNCTION__); - return -1; - } - - if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_get_state() failed.", - __FUNCTION__); - return -1; - } - - /* Enable BT */ - if (bt_state == BT_ADAPTER_DISABLED) { - if (bt_adapter_set_state_changed_cb( - bt_state_changed_impl, NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_adapter_enable() == BT_ERROR_NONE) { - LOGI("[%s] bt_adapter_state_changed_cb will be called.", - __FUNCTION__); - timeout_id = g_timeout_add(60000, - timeout_func, g_mainloop); - g_main_loop_run(g_mainloop); - g_source_remove(timeout_id); - } else { - LOGE("[%s] bt_adapter_enable() failed.", - __FUNCTION__); - return -1; - } - } else { - LOGI("[%s] BT was already enabled.", - __FUNCTION__); - } - - /* Set name as "chat_server" */ - if (bt_state == BT_ADAPTER_ENABLED) { - char *name = NULL; - if (bt_adapter_get_name(&name) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_get_name() failed.", - __FUNCTION__); - return -1; - } - - if (NULL == name) - return -1; - - if (strncmp(name, "chat_server", strlen(name)) != 0) { - if (bt_adapter_set_name( - "chat_server") != BT_ERROR_NONE) { - if (NULL != name) - free(name); - LOGE("[%s] bt_adapter_set_name() failed.", - __FUNCTION__); - return -1; - } - } - free(name); - } else { - LOGE("[%s] BT is not enabled.", - __FUNCTION__); - return -1; - } - /* Set visibility as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE */ - if (bt_adapter_get_visibility( - &visibility_mode, - NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_get_visibility() failed.", - __FUNCTION__); - return -1; - } - - if (visibility_mode != BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) { - if (bt_adapter_set_visibility( - BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, - 0) != BT_ERROR_NONE) { - LOGE("[%s] bt_adapter_set_visibility() failed.", - __FUNCTION__); - return -1; - } - visibility_mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; - } else { - LOGI("[%s] Visibility mode was already set as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE.", - __FUNCTION__); - } - - /* Connecting socket as a server */ - if (bt_socket_create_rfcomm(my_uuid, - &service_socket) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_create_rfcomm() failed.", - __FUNCTION__); - return -1; - } - LOGI("[%s] socket is created - %d.", - __FUNCTION__, - service_socket); - - if (bt_socket_set_connection_state_changed_cb( - bt_socket_connection_state_changed_impl, - NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_socket_set_data_received_cb(bt_socket_data_received_impl, - NULL) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_set_data_received_cb() failed.", - __FUNCTION__); - return -1; - } - - if (bt_socket_listen_and_accept_rfcomm( - service_socket, 5) == BT_ERROR_NONE) { - LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", - __FUNCTION__); - g_main_loop_run(g_mainloop); - } else { - LOGE("[%s] bt_socket_listen_and_accept_rfcomm() failed.", - __FUNCTION__); - return -1; - } - - sleep(5); /* Wait for completing delivery */ - if (bt_socket_destroy_rfcomm(service_socket) != BT_ERROR_NONE) { - LOGE("[%s] bt_socket_destroy_rfcomm() failed.", - __FUNCTION__); - return -1; - } else { - LOGE("[%s] bt_socket_destroy_rfcomm() succeeded.", - __FUNCTION__); - } - - bt_deinitialize(); - - LOGI("[%s] Server ends.", __FUNCTION__); - return 0; -} diff --git a/test/bt_infinite_spp_test.c b/test/bt_infinite_spp_test.c deleted file mode 100644 index 97326d8..0000000 --- a/test/bt_infinite_spp_test.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include - -#undef LOG_TAG -#define LOG_TAG "BLUETOOTH_SPP_TEST" - -#define BT_DBG(fmt, args...) \ - SLOGD(fmt, ##args) -#define BT_INFO(fmt, args...) \ - SLOGI(fmt, ##args) -#define BT_ERR(fmt, args...) \ - SLOGE(fmt, ##args) - -typedef enum -{ - BT_SPP_TEST_ROLE_SERVER = 0x00, - BT_SPP_TEST_ROLE_CLIENT, -} bt_spp_test_role_e; - -#define BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH "/opt/usr/home/owner/media/Downloads/spp_test_addr" -#define BT_INFINITE_SPP_TEST_RESULT_FILE_PATH "/opt/usr/home/owner/media/Downloads/spp_result.log" - -bool __bt_connect_spp(void); -static gboolean __bt_send_data(gpointer user_data); -bool __bt_verify_data(char *data, int data_size); -bool __bt_bond_remote_device(void); -bool __bt_is_paired(void); - -static GMainLoop* g_mainloop = NULL; - -static bt_spp_test_role_e spp_role = BT_SPP_TEST_ROLE_SERVER; -static char remote_addr[18] = {0,}; -static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; - -const char *spp_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"; -static int server_fd = -1; -static int socket_fd = -1; -static bool is_receive_complete = false; - -static int packet_size = 65536; -static char *buf = NULL; -static int total_count = 32; -static int sent_count = 0; -static int receive_count = 0; -static int receive_index = 0; - -static struct timeval start_time = {0,}; -static struct timeval end_time = {0,}; -static struct timeval diff_time = {0,}; - -static int sum_time_ms = 0; -static int avg_time_ms = 0; -static int total_test_count = 0; - -void __bt_create_log_dump(void) -{ - char *argv[] = {"/usr/bin/crashctl", "dump_log", "normal", NULL}; - execv("/usr/bin/crashctl", argv); - - BT_ERR("Fail to verify data"); - -#if 0 - if (g_mainloop) - g_main_loop_quit(g_mainloop); - else - exit(0); -#endif -} - -static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, void *user_data) -{ - if (data == NULL) { - BT_ERR("data is NULL"); - return; - } - BT_INFO("FD = %d, Buffer len = %d", data->socket_fd, data->data_size); - - if (__bt_verify_data(data->data, data->data_size) == false) - __bt_create_log_dump(); - - if (is_receive_complete == true) - g_idle_add(__bt_send_data, NULL); -} - -static void __bt_device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data) -{ - if (result != BT_ERROR_NONE) { - BT_ERR("result[0x%X]", result); - return; - } - - if (strcmp(device_info->remote_address, remote_addr) == 0) { - if (__bt_connect_spp() == false) - BT_ERR("__bt_connect_spp() failed."); - } -} - -static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) -{ - bool *is_paired = (bool*)user_data; - - if (strcmp(device_info->remote_address, remote_addr) == 0) { - BT_INFO("remote_addr is exist."); - *is_paired = true; - return false; - } - - return true; -} - -void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data) -{ - BT_INFO("result [0x%04x] state = %d", result, adapter_state); - - if (result == BT_ERROR_NONE) { - bt_state = adapter_state; - if (adapter_state == BT_ADAPTER_ENABLED) { - if (__bt_is_paired() == true) - __bt_connect_spp(); - else - __bt_bond_remote_device(); - } - } -} - -void __bt_socket_connection_state_changed_cb(int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data) -{ - if (connection_state == BT_SOCKET_CONNECTED) { - BT_INFO("RFCOMM connected, result [0x%04x] Fd = %d, device add = %s, Role = %s", - result, connection->socket_fd, connection->remote_address, - (connection->local_role == BT_SOCKET_SERVER) ? "SERVER" : "CLIENT"); - - if (connection->socket_fd > 0) { - socket_fd = connection->socket_fd; - if (spp_role == BT_SPP_TEST_ROLE_CLIENT) - g_idle_add(__bt_send_data, NULL); - } else { - BT_ERR("socket_fd is INVALID"); - } - } else { - BT_INFO("RFCOMM disconnected, result [0x%04x] Fd = %d, device add = %s", - result, connection->socket_fd, connection->remote_address); - __bt_create_log_dump(); - } -} - -void __bt_spp_calc_speed(void) -{ - int total_time_ms; - FILE *fp = NULL; - static char str_speed[30] = "\0"; - int speed; - - diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec; - diff_time.tv_usec = end_time.tv_usec - start_time.tv_usec; - - if(diff_time.tv_usec < 0) - { - diff_time.tv_sec = diff_time.tv_sec - 1; - diff_time.tv_usec = diff_time.tv_usec + 1000000; - } - - fp = fopen(BT_INFINITE_SPP_TEST_RESULT_FILE_PATH, "a+"); - /* Fix : NULL_RETURNS */ - if (fp == NULL) { - BT_ERR("Cannot open file: %s\n", BT_INFINITE_SPP_TEST_RESULT_FILE_PATH); - return; - } - total_time_ms = (diff_time.tv_sec * 1000); - total_time_ms += diff_time.tv_usec / 1000; - - speed = (packet_size * total_count * 8) / total_time_ms; - - BT_INFO("%s @ %d kbps", "2MB", speed); - snprintf(str_speed, 30, "%s @ %d kbps", "2MB", speed); - fprintf(fp, "%s\n", str_speed); - - total_test_count++; - sum_time_ms += total_time_ms; - if (total_test_count % 10 == 0) { - avg_time_ms = sum_time_ms / total_test_count; - speed = (packet_size * total_count * 8) / avg_time_ms; - BT_INFO("[AVG(%d times)] %d kbps", total_test_count, speed); - snprintf(str_speed, 30, "[AVG(%d times)] %d kbps", total_test_count, speed); - fprintf(fp, "%s\n", str_speed); - } - - if (total_test_count == 1000) { - sum_time_ms = 0; - avg_time_ms = 0; - total_test_count = 0; - } - - fclose(fp); -} - -void __bt_make_data(void) -{ - int i; - int j; - char w = 0x20; - - memset(buf, 0x00, packet_size); - for (i = 0; i < packet_size / 256; i++) { - for (j = 0; j < 256; j++) { - buf[i * 256 + j] = w; - } - - w++; - if (w > 0x7e) - w = 0x20; - } -} - -bool __bt_verify_data(char *data, int data_size) -{ - int i; - - if (receive_count == 0 && receive_index == 0) - gettimeofday(&start_time, NULL); - - for (i = 0; i < data_size; i++) { - if (data[i] != buf[receive_index]) { - BT_ERR("data error. rcv_cnt=%d, data[%d]=%d, buf[%d]=%d", receive_count, i, data[i], receive_index, buf[receive_index]); - return false; - } - - receive_index++; - if (receive_index == packet_size) { - receive_index = 0; - receive_count++; - - if (receive_count == total_count) - is_receive_complete = true; - } - } - - if (is_receive_complete == true) { - gettimeofday(&end_time, NULL); - __bt_spp_calc_speed(); - receive_count = 0; - receive_index = 0; - } - - return true; -} - -static gboolean __bt_send_data(gpointer user_data) -{ - int ret = BT_ERROR_NONE; - int write = 0; - int state = 0; - struct timeval tv_write_timeout = {0, }; - fd_set wfds; - int fail_count = 0; - - tv_write_timeout.tv_sec = 1; - - is_receive_complete = false; - - if (sent_count == 0) - gettimeofday(&start_time, NULL); - - while (write < packet_size) { - FD_ZERO(&wfds); - FD_SET(socket_fd, &wfds); - state = select(socket_fd + 1, NULL, &wfds, NULL, &tv_write_timeout); - if (state == -1) { - BT_ERR("select() error.[0x%X]", ret); - __bt_create_log_dump(); - return FALSE; - } else { - if (FD_ISSET(socket_fd, &wfds)) { - ret = bt_socket_send_data(socket_fd, buf + write, packet_size - write); - if(ret <= 0) { - BT_ERR("bt_socket_send_data() failed.[0x%X]", ret); - __bt_create_log_dump(); - return FALSE; - } else { - write += ret; - } - fail_count = 0; - } else { - BT_ERR("socket is NOT ready.(fail_count = %d)", fail_count); - if (fail_count++ == 10) { - BT_ERR("__bt_send_data failed."); - __bt_create_log_dump(); - return FALSE; - } - } - } - } - - sent_count++; - if (sent_count == total_count) { - BT_INFO("Last packet."); - gettimeofday(&end_time, NULL); - __bt_spp_calc_speed(); - sent_count = 0; - } else { - return TRUE; - } - - return FALSE; -} - -static bool __bt_adapter_foreach_bonded_device_cb(bt_device_info_s *device_info, void *user_data) -{ - if (device_info != NULL) { - if (bt_device_set_authorization(device_info->remote_address, BT_DEVICE_AUTHORIZED) != BT_ERROR_NONE) - BT_ERR("Fail to authorize"); - } - - return true; -} - -bool __bt_connect_spp(void) -{ - int ret = BT_ERROR_NONE; - - if (spp_role == BT_SPP_TEST_ROLE_SERVER) { - if (bt_adapter_foreach_bonded_device(__bt_adapter_foreach_bonded_device_cb, NULL) != BT_ERROR_NONE) - BT_ERR("Fail to get bonded devices"); - - if (server_fd < 0) { - ret = bt_socket_create_rfcomm(spp_secure_uuid, &server_fd); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_socket_create_rfcomm() failed.[0x%X]", ret); - return false; - } - } - - ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_socket_listen_and_accept_rfcomm() failed.[0x%X]", ret); - return false; - } - } else { - ret = bt_socket_connect_rfcomm(remote_addr, spp_secure_uuid); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_socket_connect_rfcomm() failed.[0x%X]", ret); - bt_socket_destroy_rfcomm(server_fd); - return false; - } - } - - return true; -} - -bool __bt_bond_remote_device(void) -{ - int ret = BT_ERROR_NONE; - - ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_device_set_bond_created_cb() failed.[0x%X]", ret); - return false; - } - - if (spp_role == BT_SPP_TEST_ROLE_CLIENT) { - ret = bt_device_create_bond(remote_addr); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_device_create_bond() failed.[0x%X]", ret); - return false; - } - } - - return true; -} - -bool __bt_is_paired(void) -{ - int ret = BT_ERROR_NONE; - bool is_paired = false; - - ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, &is_paired); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_adapter_foreach_bonded_device() failed.[0x%X]", ret); - return false; - } - - return is_paired; -} - -bool __bt_init(void) -{ - int ret = BT_ERROR_NONE; - - ret = bt_initialize(); - if(ret != BT_ERROR_NONE) { - BT_ERR("bt_initialize() failed.[0x%X]", ret); - return false; - } - - ret = bt_adapter_get_state(&bt_state); - if(ret != BT_ERROR_NONE) { - BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret); - return false; - } - - ret = bt_adapter_set_state_changed_cb(__bt_adapter_state_changed_cb, NULL); - if(ret != BT_ERROR_NONE) { - BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret); - return false; - } - - ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_socket_set_connection_state_changed_cb() failed.[0x%X]", ret); - return false; - } - - ret = bt_socket_set_data_received_cb(__bt_socket_data_received_cb, NULL); - if (ret != BT_ERROR_NONE) { - BT_ERR("bt_socket_set_data_received_cb() failed.[0x%X]", ret); - return false; - } - - if (buf == NULL) { - buf = malloc(packet_size); - if (buf == NULL) { - BT_ERR("Out of memory"); - return false; - } - __bt_make_data(); - } - - return true; -} - -void __bt_deinit(void) -{ - int ret = BT_ERROR_NONE; - - if (buf) - free(buf); - - if (server_fd >= 0) - bt_socket_destroy_rfcomm(server_fd); - - ret = bt_socket_unset_data_received_cb(); - if (ret != BT_ERROR_NONE) - BT_ERR("bt_socket_unset_data_received_cb() failed.[0x%X]", ret); - - ret = bt_socket_unset_connection_state_changed_cb(); - if (ret != BT_ERROR_NONE) - BT_ERR("bt_socket_unset_connection_state_changed_cb() failed.[0x%X]", ret); - - ret = bt_device_unset_bond_created_cb(); - if (ret != BT_ERROR_NONE) - BT_ERR("bt_device_unset_bond_created_cb() failed.[0x%X]", ret); - - ret = bt_deinitialize(); - if(ret != BT_ERROR_NONE) - BT_ERR("bt_deinitialize() failed.[0x%X]", ret); -} - -bool __bt_set_remote_address(void) -{ - FILE *fp = NULL; - - if ((fp = fopen(BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH, "r")) == NULL) { - BT_ERR("remote_addr file is NOT exist."); - return false; - } - - if (fgets(remote_addr, 18, fp) == NULL) { - BT_ERR("remote_addr is INVALID."); - fclose(fp); - return false; - } - - fclose(fp); - return true; -} - -int main(int argc, char *argv[]) -{ - if (argc == 2 && strcmp(argv[1], "client") == 0) - spp_role = BT_SPP_TEST_ROLE_CLIENT; - BT_INFO("SPP test role is %s", spp_role==BT_SPP_TEST_ROLE_SERVER?"SERVER":"CLIENT"); - - if (spp_role == BT_SPP_TEST_ROLE_CLIENT) { - if (__bt_set_remote_address() == false) - return -1; - } - - if (__bt_init() == false) - goto fail; - - if (bt_state == BT_ADAPTER_ENABLED) { - if (spp_role == BT_SPP_TEST_ROLE_SERVER) { - if (bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0) != BT_ERROR_NONE) - BT_ERR("Fail to set visibility"); - - __bt_connect_spp(); - } else { - if (__bt_is_paired() == true) { - if (__bt_connect_spp() == false) - goto fail; - } else { - if (__bt_bond_remote_device() == false) - goto fail; - } - } - } - - g_mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(g_mainloop); - -fail: - if (g_mainloop) - g_main_loop_unref(g_mainloop); - - __bt_deinit(); - - return 0; -} diff --git a/test/bt_infinite_spp_test_server.service b/test/bt_infinite_spp_test_server.service deleted file mode 100644 index f622aee..0000000 --- a/test/bt_infinite_spp_test_server.service +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=BT SPP test infinitely - -[Service] -Type=oneshot -ExecStart=/usr/bin/bt_infinite_spp_test -RemainAfterExit=yes diff --git a/test/bt_mesh_unit_test.c b/test/bt_mesh_unit_test.c deleted file mode 100644 index 49e1442..0000000 --- a/test/bt_mesh_unit_test.c +++ /dev/null @@ -1,1945 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved * - * - * @author: Anupam Roy - * @author: Himanshu - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#ifdef ARCH64 -#include -#endif -#include - -#include "bluetooth.h" -#include "bluetooth_type_internal.h" -#include "bluetooth_internal.h" -#include "bluetooth_private.h" -#include "bt_mesh_unit_test.h" - -static bt_mesh_unit_test_table_e current_tc_table; - -static bool need_to_set_params = false; -static int g_test_id = -1; -static tc_params_t g_test_param = {0,}; - -static bt_mesh_node_h local_node = NULL; -static bt_mesh_node_h node; -static bt_mesh_network_h network; -static char *device_uuid; - -static bt_mesh_netkey_h netkey; - -static bt_mesh_group_h group; -static char *token; -static bt_mesh_authentication_type_e request_type = BT_MESH_AUTH_ALPHANUMERIC_DISPLAY; - -GMainLoop *main_loop = NULL; - -tc_table_t tc_configuration[] = { - {"Back" - , BT_MESH_UNIT_TEST_FUNCTION_BACK}, - {"bt_mesh_network_discover_node" - , BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE}, - {"bt_mesh_node_reset" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET}, - {"bt_mesh_node_get_features" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES}, - {"bt_mesh_node_foreach_netkeys" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS}, - {"bt_mesh_node_foreach_appkeys" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS}, - {"bt_mesh_node_get_ttl" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL}, - {"bt_mesh_node_set_ttl" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL}, - {"bt_mesh_node_configure_netkey" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY}, - {"bt_mesh_node_configure_appkey" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY}, - {"bt_mesh_model_bind_appkey" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY}, - {"bt_mesh_model_unbind_appkey" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY}, - {"bt_mesh_model_get_appkey_list" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST}, - {"bt_mesh_model_configure_group_subscription" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION}, - {"bt_mesh_model_configure_virtual_group_subscription" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION}, - {"bt_mesh_model_get_subscription_list" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST}, - {"bt_mesh_model_set_publication" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION}, - {"bt_mesh_model_get_publication" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION}, - {"bt_mesh_appkey_get_netkey" - , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY}, - {"select this menu to set parameters and then select the function again" - , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0X0000}, -}; - -tc_table_t tc_network[] = { - {"Back" - , BT_MESH_UNIT_TEST_FUNCTION_BACK}, - {"bt_mesh_node_create" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE}, - {"bt_mesh_node_destroy" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY}, - {"bt_mesh_node_create_element" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT}, - {"bt_mesh_node_get_network" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK}, - {"bt_mesh_element_create_model" - , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL}, - {"bt_mesh_model_get_id" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID}, - {"bt_mesh_model_destroy" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY}, - {"bt_mesh_model_get_element" - , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT}, - {"bt_mesh_element_destroy" - , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY}, - {"bt_mesh_element_get_node" - , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE}, - {"bt_mesh_node_foreach_element" - , BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS}, - {"bt_mesh_element_foreach_models" - , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS}, - {"bt_mesh_network_create" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE}, - {"bt_mesh_network_load" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD}, - {"bt_mesh_network_set_name" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME}, - {"bt_mesh_network_get_name" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME}, - {"bt_mesh_network_add_netkey" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY}, - {"bt_mesh_network_foreach_netkeys" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS}, - {"bt_mesh_netkey_get_index" - , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX}, - {"bt_mesh_netkey_update" - , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE}, - {"bt_mesh_netkey_delete" - , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE}, - {"bt_mesh_netkey_add_appkey" - , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY}, - {"bt_mesh_netkey_foreach_appkeys" - , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS}, - {"bt_mesh_appkey_get_index" - , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX}, - {"bt_mesh_appkey_update" - , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE}, - {"bt_mesh_appkey_delete" - , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE}, - {"bt_mesh_network_foreach_devices" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES}, - {"bt_mesh_network_create_group" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP}, - {"bt_mesh_network_create_virtual_group" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP}, - {"bt_mesh_network_remove_group" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP}, - {"bt_mesh_network_foreach_groups" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS}, - {"bt_mesh_network_unprovisioned_device_scan" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN}, - {"bt_mesh_stop_unprovisioned_device_scan" - , BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN}, - {"bt_mesh_network_provision_device" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE}, - {"bt_mesh_authentication_set_request_cb" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB}, - {"bt_mesh_authentication_reply" - , BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY}, - {"bt_mesh_network_set_provisioning_capabilities" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES}, - {"bt_mesh_network_get_provisioning_capabilities" - , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES}, - {"select this menu to set parameters and then select the function again" - , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0X0000}, -}; - -tc_table_t tc_main[] = { - {"bt_mesh_initialize" - , BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE}, - {"bt_mesh_deinitialize" - , BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE}, - {"Network" - , BT_MESH_UNIT_TEST_TABLE_NETWORK}, - {"Configuration" - , BT_MESH_UNIT_TEST_TABLE_CONFIGURATION}, - {"Finish" - , BT_MESH_UNIT_TEST_TABLE_FINISH}, - {NULL , 0x0000}, -}; - -static void __bt_free_test_param(tc_params_t *param) -{ - int i = 0; - - for (i = 0; i < param->param_count; i++) - g_free(param->params[i]); - g_free(param->params); - param->params = NULL; - param->param_count = 0; -} - -void tc_usage_print(void){ - int i=0; - tc_table_t *tc_table = NULL; - switch (current_tc_table) { - case BT_MESH_UNIT_TEST_TABLE_NETWORK: - tc_table = tc_network; - break; - case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: - tc_table = tc_configuration; - break; - default: - tc_table = tc_main; - break; - } - while (tc_table[i].tc_name) { - TC_PRT("Key %d : usage %s", tc_table[i].tc_code,tc_table[i].tc_name); - i++; - } -} - -static const char *__bt_get_error_message(bt_error_e err) -{ - const char *err_str = NULL; - - switch (err) { - case BT_ERROR_NONE: - err_str = "BT_ERROR_NONE"; - break; - case BT_ERROR_CANCELLED: - err_str = "BT_ERROR_CANCELLED"; - break; - case BT_ERROR_INVALID_PARAMETER: - err_str = "BT_ERROR_INVALID_PARAMETER"; - break; - case BT_ERROR_OUT_OF_MEMORY: - err_str = "BT_ERROR_OUT_OF_MEMORY"; - break; - case BT_ERROR_RESOURCE_BUSY: - err_str = "BT_ERROR_RESOURCE_BUSY"; - break; - case BT_ERROR_TIMED_OUT: - err_str = "BT_ERROR_TIMED_OUT"; - break; - case BT_ERROR_NOW_IN_PROGRESS: - err_str = "BT_ERROR_NOW_IN_PROGRESS"; - break; - case BT_ERROR_NOT_INITIALIZED: - err_str = "BT_ERROR_NOT_INITIALIZED"; - break; - case BT_ERROR_NOT_ENABLED: - err_str = "BT_ERROR_NOT_ENABLED"; - break; - case BT_ERROR_ALREADY_DONE: - err_str = "BT_ERROR_ALREADY_DONE"; - break; - case BT_ERROR_OPERATION_FAILED: - err_str = "BT_ERROR_OPERATION_FAILED"; - break; - case BT_ERROR_NOT_IN_PROGRESS: - err_str = "BT_ERROR_NOT_IN_PROGRESS"; - break; - default: - err_str = "NOT defined"; - break; - } - return err_str; -} - -void print_network_handle(bt_mesh_network_h network) -{ - if(network == NULL) - return; - bt_mesh_network_s* net = (bt_mesh_network_s*) network; - TC_PRT("network_handle = [%p]", (void*)net); - TC_PRT("net->is_local [%d]", net->is_local); - TC_PRT("net->is_discovered [%d]", net->is_discovered); - TC_PRT("net->uuid [%s]", net->uuid); - TC_PRT("net->token [%s]", net->token); - TC_PRT("net->name [%s]", net->name); - TC_PRT("net->num_nodes [%d]", net->num_nodes); -} - -void print_node_handle(bt_mesh_node_h node) -{ - if(node == NULL) - return; - bt_mesh_node_s* node_info = (bt_mesh_node_s*) node; - TC_PRT("node_handle = [%p]",(void*)node_info); - TC_PRT("node->is_local [%d]", node_info->is_local); - TC_PRT("node->is_attached [%d]", node_info->is_attached); - if (node_info->is_attached) { - TC_PRT("node->parent_network [%s]", node_info->parent->name); - TC_PRT("node->uuid [%s]", node_info->uuid); - TC_PRT("node->unicast [%d]", node_info->unicast); - } - -} - -void print_element_handle(bt_mesh_element_h element) -{ - if(element == NULL) - return; - bt_mesh_element_s* element_info = (bt_mesh_element_s*) element; - TC_PRT("element_handle = [%p]", (void*)element_info); - TC_PRT("element->is_local [%d]", element_info->is_local); - TC_PRT("element->index [%d]", element_info->index); -} - -void print_model_handle(bt_mesh_model_h model) -{ - if(model == NULL) - return; - bt_mesh_model_s* model_info = (bt_mesh_model_s*) model; - TC_PRT("model_handle = [%p]", (void*)model_info); - TC_PRT("model->is_local [%d]", model_info->is_local); - TC_PRT("model->id [0x%4.4x]", model_info->id); - TC_PRT("model->pub_addr [0x%2.2x]", model_info->pub_addr); -} - -void print_netkey_handle(bt_mesh_netkey_h netkey) -{ - if(netkey == NULL) - return; - bt_mesh_netkey_s* netkey_info = (bt_mesh_netkey_s*) netkey; - TC_PRT("netkey_handle = [%p]", (void*)netkey_info); - TC_PRT("Parent network_name [%s]", netkey_info->parent->name); - TC_PRT("Netkey_index [%d]", netkey_info->netkey_index); -} - -void print_appkey_handle(bt_mesh_appkey_h appkey) -{ - if(appkey == NULL) - return; - bt_mesh_appkey_s* appkey_info = (bt_mesh_appkey_s*) appkey; - TC_PRT("appkey_handle = [%p]", (void*)appkey_info); - TC_PRT("Parent netkey_index [%d]", appkey_info->parent->netkey_index); - TC_PRT("appkey_index [%d]", appkey_info->appkey_index); -} - -void print_group_handle(bt_mesh_group_h group) -{ - if(group == NULL) - return; - bt_mesh_group_s* group_info = (bt_mesh_group_s*) group; - TC_PRT("group_handle = [%p]", (void*)group_info); - TC_PRT("group->parent_network->name [%s]", group_info->parent->name); - TC_PRT("group->addr [%d]", group_info->addr); - TC_PRT("group->label_uuid [%s]", group_info->label_uuid); - TC_PRT("group->is_virtual [%d]", group_info->is_virtual); - TC_PRT("group->ref_count [%d]", group_info->ref_count); -} - -bool __bt_mesh_network_device_info_cb(int result, bt_mesh_network_h network, int total, - const char *dev_uuid, uint16_t primary_unicast, void *user_data) -{ - TC_PRT("bt_mesh_network_device_info_cb"); - TC_PRT("Total number of Devices in network [%d]", total); - - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("primary unicast address is [%d]",primary_unicast); - TC_PRT("Device UUID [%s]", dev_uuid); - return true; -} - -bool __bt_mesh_network_group_info_cb(int result, bt_mesh_network_h network, int total, - bt_mesh_group_h group, void *user_data) -{ - bt_mesh_group_s* grp = (bt_mesh_group_s*) group; - TC_PRT("bt_mesh_network_group_info_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_group_handle(grp); - } - return true; -} - -void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network, bt_mesh_node_h node_param, - void *user_data) -{ - TC_PRT("bt_mesh_node_discover_status_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - //print_network_handle(network); - print_node_handle(node_param); - if (result == BT_ERROR_NONE) - node = node_param; -} - -static bool __bt_mesh_elem_foreach_model_cb(int result, bt_mesh_element_h element, int total, - bt_mesh_model_h model, bt_mesh_model_id_s *model_id, void *user_data) -{ - TC_PRT("__bt_mesh_elem_foreach_model_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - TC_PRT("Total number of Models in the element [%d]", total); - print_element_handle(element); - if (total) { - print_model_handle(model); - TC_PRT("Model Comp ID [0x%2.2x] Model ID [0x%2.2x]", - model_id->company_id, model_id->model_id); - } - return true; - } else - return false; -} - -static bool __bt_mesh_node_foreach_elem_cb(int result, bt_mesh_node_h node, int total, - bt_mesh_element_h element, int elem_index, uint16_t element_addr, void *user_data) -{ - TC_PRT("__bt_mesh_node_foreach_elem_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - TC_PRT("Total number of elements in the node [%d]", total); - print_node_handle(node); - if (total) { - print_element_handle(element); - TC_PRT("Element address [0x%2.2x]", element_addr); - TC_PRT("Element index [%d]", elem_index); - } - return true; - } else - return false; -} - -static void __bt_mesh_node_configure_netkey_cb(int result, bt_mesh_node_key_configuration_e op, - bt_mesh_node_h node, bt_mesh_netkey_h netkey, void *user_data) -{ - TC_PRT("__bt_mesh_node_configure_netkey_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_node_handle(node); - if (op == BT_MESH_NODE_KEY_ADD) - TC_PRT("NetKey Added!"); - else if (op == BT_MESH_NODE_KEY_UPDATE) - TC_PRT("NetKey Updated!"); - else - TC_PRT("NetKey Deleted!"); - print_netkey_handle(netkey); - } -} - -static void __bt_mesh_node_configure_appkey_cb(int result, bt_mesh_node_key_configuration_e op, - bt_mesh_node_h node, bt_mesh_netkey_h netkey, - bt_mesh_appkey_h appkey, void *user_data) -{ - TC_PRT("__bt_mesh_node_configure_netkey_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_node_handle(node); - if (op == BT_MESH_NODE_KEY_ADD) - TC_PRT("AppKey Added!"); - else if (op == BT_MESH_NODE_KEY_UPDATE) - TC_PRT("AppKey Updated!"); - else - TC_PRT("AppKey Deleted!"); - print_appkey_handle(netkey); - print_appkey_handle(appkey); - } -} - -static void __bt_mesh_node_features_cb(int result, bt_mesh_node_h node, - bt_mesh_node_features_s *features, void *user_data) -{ - TC_PRT("__bt_mesh_node_features_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_node_handle(node); - TC_PRT("CID [0x%2.2x]\n", features->cid); - TC_PRT("PID [0x%2.2x]\n", features->pid); - TC_PRT("VID [0x%2.2x]\n", features->vid); - TC_PRT("CRPL [0x%2.2x]\n", features->crpl); - - if (features->features & BT_MESH_FEATURE_RELAY) - TC_PRT("Features: RELAY Supported"); - if (features->features & BT_MESH_FEATURE_PROXY) - TC_PRT("Features: PROXY Supported"); - if (features->features & BT_MESH_FEATURE_FRIEND) - TC_PRT("Features: FRIEND Supported"); - if (features->features & BT_MESH_FEATURE_LOWPOWER) - TC_PRT("Features: LOW POWER Supported\n"); - } -} - -static bool __bt_mesh_node_foreach_netkeys_cb(int result, bt_mesh_node_h node, int total, - bt_mesh_netkey_h netkey, - uint16_t netkey_index, void *user_data) -{ - TC_PRT("__bt_mesh_node_foreach_netkeys_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - TC_PRT("Total Netkeys in node [%d]", total); - print_node_handle(node); - print_netkey_handle(netkey); - return true; - } - return false; -} - -static bool __bt_mesh_node_foreach_appkeys_cb(int result, bt_mesh_node_h node, int total, - bt_mesh_netkey_h netkey, bt_mesh_appkey_h appkey, - uint16_t appkey_index, void *user_data) -{ - TC_PRT("__bt_mesh_node_foreach_appkeys_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - TC_PRT("Total Appkeys in node [%d]", total); - print_node_handle(node); - print_netkey_handle(netkey); - print_appkey_handle(appkey); - return true; - } - return false; -} - -void __bt_mesh_node_ttl_cb(int result, bt_mesh_node_h node, - bt_mesh_node_ttl_operation_e ttl_op, uint8_t ttl, void *user_data) -{ - TC_PRT("bt_mesh_node_ttl_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_node_handle(node); - TC_PRT("ttl_op is [%s]", ttl_op? "TTL Set" : "TTL Get"); - TC_PRT("ttl value is [%d]",ttl); - } -} - -void __bt_mesh_model_bind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey, - void *user_data) -{ - TC_PRT("bt_mesh_model_bind_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - print_model_handle(model); - print_appkey_handle(netkey); - } -} - -void __bt_mesh_model_unbind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey, - void *user_data) -{ - TC_PRT("bt_mesh_model_unbind_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - print_model_handle(model); - print_appkey_handle(netkey); - } -} - -void __bt_mesh_model_appkey_list_cb(int result, bt_mesh_model_h model, int total, const GSList *appkeylist, - void *user_data) -{ - TC_PRT("bt_mesh_model_appkey_list_cb"); - const GSList *l; - - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - TC_PRT("Total number of AppKeys bound to the model [%d]", total); - print_model_handle(model); - - for (l = appkeylist; l != NULL; l = l->next) { - bt_mesh_appkey_h appkey = (bt_mesh_appkey_h) l->data; - print_appkey_handle(appkey); - } - } -} - -void __bt_mesh_model_subscription_op_cb(int result, bt_mesh_model_subscription_op_e op, - bt_mesh_model_h model, bt_mesh_group_h group, void *user_data) -{ - TC_PRT("bt_mesh_model_subscription_op_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - switch(op) { - case 0: - TC_PRT("Model Subscription Operation is ADD"); - break; - case 1: - TC_PRT("Model Subscription Operation is DELETE"); - break; - case 2: - TC_PRT("Model Subscription Operation is DELETE ALL"); - break; - case 3: - TC_PRT("Model Subscription Operation is OVERWRITE"); - break; - default: - TC_PRT("Invalid Model Subscription Operation"); - break; - } - print_model_handle(model); - print_group_handle(group); - } -} - -bool __bt_mesh_model_subscription_list_cb(int result, bt_mesh_model_h model, int total, const GSList *sub_addr, - void *user_data) -{ - const GSList *l; - TC_PRT("bt_mesh_model_subscription_list_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - TC_PRT("Total number of AppKeys bound to the model [%d]", total); - print_model_handle(model); - - for (l = sub_addr; l != NULL; l = l->next) { - bt_mesh_group_h group = (bt_mesh_group_h) l->data; - print_group_handle(group); - } - } - return true; -} - -void __bt_mesh_model_publication_status_cb(int result, bt_mesh_model_h model, bt_mesh_group_h group, - bt_mesh_appkey_h appkey, void *user_data) -{ - TC_PRT("bt_mesh_model_publication_status_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (result == BT_ERROR_NONE) { - print_model_handle(model); - print_group_handle(group); - print_appkey_handle(appkey); - } -} - -void __bt_mesh_network_create_cb(int result, bt_mesh_network_h network, const char *network_name, void *user_data) -{ - TC_PRT("bt_mesh_network_create_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - print_network_handle(network); -} - -bool __bt_mesh_appkey_info_cb(int result, bt_mesh_network_h network, int total, - bt_mesh_netkey_h netkey, bt_mesh_appkey_h appkey, uint16_t appkey_index, void *user_data) -{ - TC_PRT("bt_mesh_network_appkey_info_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - //print_network_handle(network); - //print_netkey_handle(netkey); - print_appkey_handle(appkey); - TC_PRT("Total appkeys are [%d]",total); - return true; -} - -bool __bt_mesh_network_netkey_info_cb(int result, bt_mesh_network_h network, int total, - bt_mesh_netkey_h netkey, uint16_t netkey_index, void *user_data) -{ - TC_PRT("bt_mesh_network_netkey_info_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - //print_network_handle(network); - print_netkey_handle(netkey); - TC_PRT("Total netkeys are [%d]",total); - if (result == BT_ERROR_NONE && netkey_index == 0) { - TC_PRT("Attempt to delete Primary Subnet"); - result = bt_mesh_netkey_delete(netkey); - TC_PRT("return %s\n", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) - TC_PRT("Primary netkey is deleted"); - else - TC_PRT("Primary NetKey deletion failed"); - } - return true; -} - -void __bt_mesh_network_scan_unprovisioned_device_result_cb(int result, bt_mesh_network_h network, - bt_mesh_scanning_state_e state, bt_mesh_scan_result_s *scan_res, void *user_data) -{ - TC_PRT("bt_mesh_network_scan_unprovisioned_device_result_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - if (state == BT_MESH_SCANNING_STARTED) { - TC_PRT("The scanning state is: STARTED"); - print_network_handle(network); - } - else if (state == BT_MESH_SCANNING_FINISHED) { - TC_PRT("The scanning state is: STOPPED"); - print_network_handle(network); - } - else { - TC_PRT("Scan Result found"); - TC_PRT("Device UUID is %s\n", scan_res->uuid); - TC_PRT("RSSI values is %d\n", scan_res->rssi); - TC_PRT("OOB Info 0x%x\n", scan_res->oob_info); - } -} - -void __bt_mesh_network_device_provision_cb(int result, bt_mesh_network_h network, - const char* dev_uuid, void* user_data) -{ - TC_PRT("bt_mesh_network_device_provision_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - print_network_handle(network); - if(dev_uuid == NULL) - TC_PRT("dev_uuid is NULL"); - else { - TC_PRT("The device_uuid is [%s]", dev_uuid); - device_uuid = g_strdup(dev_uuid); - } -} - -void __bt_mesh_authentication_request_cb(int result, bt_mesh_authentication_type_e auth_type, - char *auth_value, void *user_data) -{ - TC_PRT("bt_mesh_authentication_request_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("auth_value is [%s]", auth_value); - TC_PRT("auth_type is [%d]", auth_type); - request_type = auth_type; -} - -int test_set_params(int test_id, char *param){ - static int param_index = 0; - int param_count = 0; - - if (param_index > 0 && param_index == g_test_param.param_count) - goto done; - switch (current_tc_table) { - case BT_MESH_UNIT_TEST_TABLE_NETWORK: { - switch(test_id) { - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE: - param_count = 2; - switch(param_index) { - case 0: - TC_PRT("Input param(%d) (network_name)\n",param_index + 1); - break; - case 1: - TC_PRT("Input param(%d) (Node Handle)\n",param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY: - param_count = 1; - TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK: - param_count = 1; - TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT: - param_count = 1; - TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL: - param_count = 2; - switch(param_index) { - case 0: - TC_PRT("Input param(%d) (Element Handle)\n" ,param_index + 1); - break; - case 1: - TC_PRT("Input param(%d) (Model ID)\n",param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE: - param_count=1; - TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID: - param_count=1; - TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY: - param_count=1; - TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT: - param_count=1; - TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY: - param_count=1; - TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS: - param_count = 1; - TC_PRT("Input param(%d) (Node Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS: - param_count = 1; - TC_PRT("Input param(%d) (Element Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP: - param_count = 1; - TC_PRT("Input param(%d) (group address)\n" ,param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN: - param_count = 1; - TC_PRT("Input param(%d) (Seconds)\n" ,param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: - param_count = 1; - TC_PRT("Input param(%d) (device_uuid)\n",param_index+1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: - param_count=1; - TC_PRT("Input param(%d) (network_name)",param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: - param_count=2; - switch(param_index) { - case 0: - TC_PRT("Input param(%d) (auth_value)\n",param_index +1); - break; - case 1: - TC_PRT("Input param(%d) (auth_reply)\n",param_index + 1); - TC_PRT("0: false, 1: true"); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: - param_count = 4; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) is_public_oob",param_index + 1); - TC_PRT("0: false, 1: true\n"); - break; - case 1: - TC_PRT("\nInput param(%d) is_static_oob",param_index + 1); - TC_PRT("0: false, 1 : true\n"); - break; - case 2: - TC_PRT("\nInput param(%d) output_oob",param_index + 1); - TC_PRT("BT_MESH_OUT_OOB_METHOD_BLINK = 0x01"); - TC_PRT("BT_MESH_OUT_OOB_METHOD_BEEP = 0x02"); - TC_PRT("BT_MESH_OUT_OOB_METHOD_VIBRATE = 0x04"); - TC_PRT("BT_MESH_OUT_OOB_METHOD_NUMERIC = 0x08"); - TC_PRT("BT_MESH_OUT_OOB_METHOD_ALPHANUMERIC = 0x10\n"); - break; - case 3: - TC_PRT("\nInput param(%d) input_oob",param_index + 1); - TC_PRT("BT_MESH_IN_OOB_METHOD_PUSH = 0x01"); - TC_PRT("BT_MESH_IN_OOB_METHOD_TWIST = 0x02"); - TC_PRT("BT_MESH_IN_OOB_METHOD_NUMERIC = 0x04"); - TC_PRT("BT_MESH_IN_OOB_METHOD_ALPHANUMERIC = 0x08\n"); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX: - param_count = 1; - TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE: - param_count = 1; - TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE: - param_count = 1; - TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY: - param_count = 1; - TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS: - param_count = 1; - TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX: - param_count = 1; - TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE: - param_count = 1; - TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE: - param_count = 1; - TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("\nSelect the function again\n"); - break; - default: - TC_PRT("There is no parameter to set\n"); - break; - } - break; - } - case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: { - switch(test_id) { - case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE: - param_count = 1; - TC_PRT("Input param(%d) (device_uuid)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES: - param_count = 1; - TC_PRT("Input param(%d) (Node Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS: - param_count = 1; - TC_PRT("Input param(%d) (Node Handle)", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS: - param_count = 2; - switch(param_index) { - case 0: - TC_PRT("Input param(%d) (Node Handle)", param_index + 1); - break; - case 1: - TC_PRT("Input param(%d) (Netkey Handle)\n", param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: - param_count = 1; - TC_PRT("Input param(%d) (AppKey Handle)\n", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION: - param_count = 1; - TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION: - param_count = 3; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) Model handle\n", param_index + 1); - break; - case 1: - TC_PRT("\nInput param(%d) AppKey handle\n", param_index + 1); - break; - case 2: - TC_PRT("\nInput param(%d) Group Handle\n", param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST: - param_count = 1; - TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION: - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION: - param_count = 3; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) Model handle\n", param_index + 1); - break; - case 1: - TC_PRT("\nInput param(%d) Model operation", param_index + 1); - TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_ADD = 0"); - TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_DELETE = 1"); - TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_DELETE_ALL = 2"); - TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_OVERWRITE = 3\n"); - break; - case 2: - TC_PRT("\nInput param(%d) Group Handle\n", param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST: - param_count = 1; - TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY: - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY: - param_count = 2; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) Model Handle\n", param_index + 1); - break; - case 1: - TC_PRT("\nInput param(%d) AppKey handle\n", param_index + 1); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY: - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY: - param_count = 3; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); - break; - case 1: - TC_PRT("\nInput param(%d) Key Handle\n", param_index + 1); - break; - case 2: - TC_PRT("\nInput param(%d) Key Config Option", param_index + 1); - TC_PRT("BT_MESH_NODE_KEY_ADD = 0"); - TC_PRT("BT_MESH_NODE_KEY_UPDATE = 1"); - TC_PRT("BT_MESH_NODE_KEY_DELETE = 2\n"); - break; - } - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL: - param_count=1; - TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); - break; - case BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL: - param_count = 2; - switch(param_index) { - case 0: - TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); - break; - case 1: - TC_PRT("\nInput param(%d) TTL value\n", param_index + 1); - break; - } - break; - default: - TC_PRT("There is no parameter to set\n"); - break; - } - break; - } - default: - TC_PRT("There is no parameter to set\n"); - need_to_set_params = false; - break; - } - done: - if (need_to_set_params) { - if (param_index == 0) { - g_test_param.param_count = param_count; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - param[len - 1] = '\0'; - g_test_param.params[param_index - 1] = g_strdup(param); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - param_index++; - } - - return 0; -} - -int test_input_callback(void *data) -{ - int ret = 0; -#ifdef ARCH64 - int test_id = (uintptr_t)data; -#else - int test_id = (int)data; -#endif - - switch (current_tc_table) { - case BT_MESH_UNIT_TEST_TABLE_MAIN: { - switch (test_id) { - case 0x00ff: - TC_PRT("Finished\n"); - g_main_loop_quit(main_loop); - break; - case BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE: - ret = bt_mesh_initialize(); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - case BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE: - ret = bt_mesh_deinitialize(); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - default: - break; - } - break; - } - case BT_MESH_UNIT_TEST_TABLE_NETWORK:{ - switch (test_id) { - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE:{ - bt_mesh_node_features_s features; - features.features = BT_MESH_FEATURE_RELAY; - features.features |= BT_MESH_FEATURE_LOWPOWER; - - ret = bt_mesh_node_create(&features, &local_node); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_node_handle(local_node); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY: { - bt_mesh_node_h node_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameters first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_destroy(node_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK: { - bt_mesh_network_h net_h; - bt_mesh_node_h node_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameters first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_get_network(node_h, &net_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_network_handle(net_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT: { - bt_mesh_element_h elem_h; - bt_mesh_node_h node_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameters first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_create_element(node_h, &elem_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_element_handle(elem_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL: { - bt_mesh_element_h elem_h; - bt_mesh_model_h model_h; - bt_mesh_model_id_s mod_id; - memset(&mod_id, 0x00, sizeof(bt_mesh_model_id_s)); - - if (g_test_param.param_count != 2) { - TC_PRT("Enter parameters first!"); - break; - } - elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - mod_id.model_id = strtoul(g_test_param.params[1], NULL, 16); - mod_id.company_id = 0xFFFF; - TC_PRT("The model_id is [0x%2.2x]\n", mod_id.model_id); - ret = bt_mesh_element_create_model(elem_h, &mod_id, &model_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_model_handle(model_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE: { - bt_mesh_element_h elem_h; - bt_mesh_node_h node_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_element_get_node(elem_h, &node_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - - if (ret == BT_ERROR_NONE) - print_node_handle(node_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID: { - bt_mesh_model_id_s model_id; - memset(&model_id, 0x00, sizeof(bt_mesh_model_id_s)); - bt_mesh_model_h mod_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_model_get_id(mod_h, &model_id); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) { - TC_PRT("The Model ID is [0x%2.2x]", model_id.model_id); - TC_PRT("The Company ID is [0x%2.2x]", model_id.company_id); - } - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY: { - bt_mesh_model_h mod_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_model_destroy(mod_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT: { - bt_mesh_model_h mod_h; - bt_mesh_element_h elem_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_model_get_element(mod_h, &elem_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_element_handle(elem_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY: { - bt_mesh_element_h elem_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_element_destroy(elem_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS: { - bt_mesh_node_h node_h = 0; - if (g_test_param.param_count != 1){ - TC_PRT("Enter Input parameter first.\n"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_foreach_element(node_h, __bt_mesh_node_foreach_elem_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS: { - bt_mesh_element_h element_h = 0; - if (g_test_param.param_count != 1){ - TC_PRT("Enter Input parameter first.\n"); - break; - } - element_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_element_foreach_models(element_h, __bt_mesh_elem_foreach_model_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE: { - char* network_name = "Mesh Test Network"; - bt_mesh_node_h node_h; - if (g_test_param.param_count != 2) { - TC_PRT("Enter Input parameter first.\n"); - break; - } - network_name = g_strdup(g_test_param.params[0]); - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - ret = bt_mesh_network_create(node_h, (const char*)network_name, &network, &token); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) { - TC_PRT("Network Created, token [%s]", token); - print_network_handle(network); - } - g_free(network_name); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD: { - char *token_str; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - token_str = g_strdup(g_test_param.params[0]); - ret = bt_mesh_network_load(token_str, &network); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_network_handle(network); - g_free(token_str); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: { - char* network_name="tempName"; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!"); - break; - } - network_name = g_strdup(g_test_param.params[0]); - ret = bt_mesh_network_set_name(network,(const char*)network_name); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - g_free(network_name); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME: { - char* network_name; - ret = bt_mesh_network_get_name(network, &network_name); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("network name is [%s]", network_name); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY: { - /* netkey 1*/ - bt_mesh_netkey_h n_h; - ret = bt_mesh_network_add_netkey(network, &n_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_netkey_handle(n_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS: { - ret = bt_mesh_network_foreach_netkeys(network, - __bt_mesh_network_netkey_info_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX: { - uint16_t index = 0xFFFF; - bt_mesh_netkey_h netkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - /* Get index for netkey 1 */ - ret = bt_mesh_netkey_get_index(netkey_h, &index); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("The index of the netkey is: [%d]", index); - - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE: { - bt_mesh_netkey_h netkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_netkey_update(netkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE: { - bt_mesh_netkey_h netkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_netkey_delete(netkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("netkey is deleted"); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY: { - bt_mesh_netkey_h netkey_h; - bt_mesh_appkey_h appkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_netkey_add_appkey(netkey_h, &appkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_appkey_handle(appkey_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS: { - /* Get all appkeys for NetKey 1 */ - bt_mesh_netkey_h netkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_netkey_foreach_appkeys(netkey_h, __bt_mesh_appkey_info_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX: { - uint16_t index = 0xFFFF; - bt_mesh_appkey_h appkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - /* Get appkey index for appkey 1 */ - ret = bt_mesh_appkey_get_index(appkey_h, &index); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("The index of the appkey is: [%d]", index); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE: { - bt_mesh_appkey_h appkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_appkey_update(appkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE: { - bt_mesh_appkey_h appkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set parameter first!"); - break; - } - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_appkey_delete(appkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("appkey is deleted"); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES: { - ret = bt_mesh_network_foreach_devices(network, __bt_mesh_network_device_info_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP: { - uint16_t group_addr = 0xc001; - bt_mesh_group_h group_h; - if (g_test_param.param_count != 1) { - TC_PRT("Enter parameter first!!\n"); - break; - } - group_addr = strtoul(g_test_param.params[0], NULL, 16); - TC_PRT("Group addrrss [0x%2.2x]", group_addr); - ret = bt_mesh_network_create_group(network, group_addr, &group_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_group_handle(group_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP: { - bt_mesh_group_h group_h; - ret = bt_mesh_network_create_virtual_group(network, &group_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_group_handle(group_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP: { - ret = bt_mesh_network_remove_group(group); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS: { - ret = bt_mesh_network_foreach_groups(network, - __bt_mesh_network_group_info_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN: { - bt_mesh_scan_params_s scan_params; - memset(&scan_params, 0x00, sizeof(bt_mesh_scan_params_s)); - if(g_test_param.param_count != 1) { - TC_PRT("Enter Input parameter first.\n"); - break; - } - scan_params.seconds = strtoul(g_test_param.params[0], NULL, 16); - TC_PRT("The scan is set for [%u] seconds", scan_params.seconds); - ret = bt_mesh_network_unprovisioned_device_scan(network, &scan_params, - __bt_mesh_network_scan_unprovisioned_device_result_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN: { - ret = bt_mesh_stop_unprovisioned_device_scan(network); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - TC_PRT("Device SCAN : STOPPED"); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: { - const char *dev_uuid = "abababababababababababababababab"; - if(g_test_param.param_count != 1) { - TC_PRT("Enter Input parameter first.\n"); - break; - } - dev_uuid = g_test_param.params[0]; - TC_PRT("The dev_uuid is [%s]\n",dev_uuid); - ret = bt_mesh_network_provision_device(network, dev_uuid, - __bt_mesh_network_device_provision_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB: { - ret = bt_mesh_authentication_set_request_cb( - __bt_mesh_authentication_request_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: { - char* value; - int len; - bool auth_reply; - if(g_test_param.param_count !=2){ - TC_PRT("Enter Input parameter first.\n"); - break; - } - len = strlen(g_test_param.params[0]); - value = g_malloc0(len+1); - g_strlcpy(value, g_test_param.params[0], len+1); - auth_reply = atoi(g_test_param.params[1]); - TC_PRT("\nauth_value is [%s]\n", value); - TC_PRT("auth_reply is [%d]\n", auth_reply); - TC_PRT("auth_type is [%d]\n", request_type); - ret = bt_mesh_authentication_reply(request_type, (const char*)value, auth_reply); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: { - bt_mesh_provisioner_capabilities_s capabilities; - if(g_test_param.param_count !=4) { - TC_PRT("Enter Input parameter first."); - break; - } - capabilities.public_oob = atoi(g_test_param.params[0]); - capabilities.static_oob = atoi(g_test_param.params[1]); - capabilities.out_oob = (int)strtol(g_test_param.params[2], NULL, 16); - capabilities.in_oob = (int)strtol(g_test_param.params[3], NULL, 16); - TC_PRT("CAP: PUBLIC OOB [%d]", capabilities.public_oob); - TC_PRT("CAP: STATIC OOB [%d]", capabilities.static_oob); - TC_PRT("CAP: OUT OOB [%d]", capabilities.out_oob); - TC_PRT("CAP: IN OOB [%d]", capabilities.in_oob); - ret = bt_mesh_network_set_provisioning_capabilities(network, &capabilities); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES: { - // TODO: need to implement - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: { - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - } - default: - break; - } - __bt_free_test_param(&g_test_param); - break; - } - case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: { - switch (test_id) { - case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE: { - char* dev_uu = "tempName"; - if (g_test_param.param_count > 0) { - dev_uu = g_strdup(g_test_param.params[0]); - } else { - TC_PRT("Set Input parameter first!"); - break; - } - ret = bt_mesh_network_discover_node(network, (const char*)dev_uu, - __bt_mesh_node_discover_status_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET: { - // TODO: need to implement - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES: { - bt_mesh_node_h node_h = 0; - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_get_features(node_h, __bt_mesh_node_features_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS: { - bt_mesh_node_h node_h = 0; - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_foreach_netkeys(node_h, __bt_mesh_node_foreach_netkeys_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS: { - bt_mesh_node_h node_h = 0; - bt_mesh_netkey_h netkey_h = 0; - if (g_test_param.param_count != 2) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - - ret = bt_mesh_node_foreach_appkeys(node_h, netkey_h, - __bt_mesh_node_foreach_appkeys_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL: { - bt_mesh_node_h node_h = 0; - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ret = bt_mesh_node_get_ttl(node_h, __bt_mesh_node_ttl_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL: { - bt_mesh_node_h node_h = 0; - int ttl = 120; - if (g_test_param.param_count != 2) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - ttl = atoi(g_test_param.params[1]); - - ret = bt_mesh_node_set_ttl(node_h, (uint8_t) ttl, __bt_mesh_node_ttl_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY: { - bt_mesh_node_h node_h = 0; - bt_mesh_netkey_h netkey_h = 0; - bt_mesh_node_key_configuration_e config = 0; - if (g_test_param.param_count != 3) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - config = atoi(g_test_param.params[2]); - - ret = bt_mesh_node_configure_netkey(node_h, config, netkey_h, - __bt_mesh_node_configure_netkey_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY: { - bt_mesh_node_h node_h = 0; - bt_mesh_appkey_h appkey_h = 0; - bt_mesh_node_key_configuration_e config = 0; - if (g_test_param.param_count != 3) { - TC_PRT("Set Input parameter first!"); - break; - } - node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - config = atoi(g_test_param.params[2]); - - ret = bt_mesh_node_configure_appkey(node_h, config, appkey_h, - __bt_mesh_node_configure_appkey_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY: { - bt_mesh_model_h model_h = 0; - bt_mesh_appkey_h appkey_h = 0; - if (g_test_param.param_count != 2) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - - ret = bt_mesh_model_bind_appkey(model_h, appkey_h, __bt_mesh_model_bind_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY: { - bt_mesh_model_h model_h = 0; - bt_mesh_appkey_h appkey_h = 0; - if (g_test_param.param_count != 2) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - - ret = bt_mesh_model_unbind_appkey(model_h, appkey_h, __bt_mesh_model_unbind_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST: { - bt_mesh_model_h model_h = 0; - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - - ret = bt_mesh_model_get_appkey_list(model_h, __bt_mesh_model_appkey_list_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION: { - bt_mesh_model_h model_h = 0; - bt_mesh_group_h group_h = 0; - bt_mesh_model_subscription_op_e op = BT_MESH_MODEL_SUBSCRIPTION_ADD; - - if (g_test_param.param_count != 3) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - op = atoi(g_test_param.params[1]); - group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); - - ret = bt_mesh_model_configure_group_subscription(op, model_h, group_h, - __bt_mesh_model_subscription_op_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION: { - bt_mesh_model_h model_h = 0; - bt_mesh_group_h group_h = 0; - bt_mesh_model_subscription_op_e op = BT_MESH_MODEL_SUBSCRIPTION_ADD; - - if (g_test_param.param_count != 3) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - op = atoi(g_test_param.params[1]); - group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); - - ret = bt_mesh_model_configure_virtual_group_subscription(op, model_h, group_h, - __bt_mesh_model_subscription_op_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST: { - bt_mesh_model_h model_h = 0; - - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - - ret = bt_mesh_model_get_subscription_list(model_h, __bt_mesh_model_subscription_list_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION: { - bt_mesh_model_h model_h = 0; - bt_mesh_model_h appkey_h = 0; - bt_mesh_group_h group_h = 0; - bt_mesh_model_pub_params_s param; - - memset(¶m, 0x00, sizeof(bt_mesh_model_pub_params_s)); - - if (g_test_param.param_count != 3) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); - group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); - - param.ttl = 120; - param.num_steps = 10; - param.per_res = BT_MESH_PUBLICATION_STEP_RES_1_SECOND; - param.retrans_cnt = BT_MESH_MAX_PUBISH_RETRANSMIT_COUNT; - param.retrans_step = BT_MESH_MAX_PUBISH_RETRANSMIT_INTERVAL_STEPS; - - ret = bt_mesh_model_set_publication(model_h, appkey_h, group_h, ¶m, - __bt_mesh_model_publication_status_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION: { - bt_mesh_model_h model_h = 0; - - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - - ret = bt_mesh_model_get_publication(model_h, __bt_mesh_model_publication_status_cb, NULL); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: { - bt_mesh_appkey_h appkey_h = 0; - bt_mesh_netkey_h netkey_h; - - if (g_test_param.param_count != 1) { - TC_PRT("Set Input parameter first!"); - break; - } - appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); - - ret = bt_mesh_appkey_get_netkey(appkey_h, &netkey_h); - TC_PRT("return %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - print_network_handle(netkey_h); - break; - } - case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: { - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - } - default: - break; - } - __bt_free_test_param(&g_test_param); - break; - } - default: - break; - } - return 0; -} - - -static gboolean key_event_cb(GIOChannel *chan, - GIOCondition cond, - gpointer data) -{ - char buf[BUFFER_LEN] = { 0 }; - -#ifdef ARCH64 - unsigned long len = 0; -#else - unsigned int len = 0; -#endif - int test_id; - bool is_call_api = false; - - memset(buf, 0, sizeof(buf)); - - if (g_io_channel_read_chars(chan, buf, sizeof(buf), - &len, NULL) == G_IO_STATUS_ERROR) { - TC_PRT("IO Channel read error"); - return FALSE; - } - - if (need_to_set_params == true) { - if (g_test_id == -1) { - test_id = atoi(buf); - g_test_id = test_id; - } - test_set_params(g_test_id, buf); - return TRUE; - } else { - TC_PRT("%s", buf); - test_id = atoi(buf); - - g_test_id = -1; - need_to_set_params = false; - } - - if (current_tc_table == BT_MESH_UNIT_TEST_TABLE_MAIN) { - if (test_id == 0) - current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; - else if(test_id >= BT_MESH_UNIT_TEST_TABLE_NETWORK - && test_id < BT_MESH_UNIT_TEST_TABLE_FINISH) { - current_tc_table = test_id; - } - else { - is_call_api = true; - } - } - - else { - if (buf[0] == '0' && buf[2] == 0) { - current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; - } -#if 0 - if(test_id == 0) { - current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; - } -#endif - else { - is_call_api = true; - } - } - - tc_usage_print(); - if (test_id && is_call_api) { -#ifdef ARCH64 - g_idle_add(test_input_callback, (void *)(uintptr_t)test_id); -#else - g_idle_add(test_input_callback, (void *)test_id); -#endif - } - return TRUE; -} - -void sig_handler(int signo) -{ - if (signo == SIGINT) { - bt_mesh_deinitialize(); - exit(0); - } -} - -int main() -{ - GIOChannel *key_io; - - current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; - - key_io = g_io_channel_unix_new(fileno(stdin)); - - g_io_channel_set_encoding(key_io, NULL, NULL); - g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); - - g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - key_event_cb, NULL); - - g_io_channel_unref(key_io); - - main_loop = g_main_loop_new(NULL, FALSE); - - if (signal(SIGINT, sig_handler) == SIG_ERR) - TC_PRT("\n can't catch SIGINT\n"); - - g_main_loop_run(main_loop); - - bt_mesh_deinitialize(); - - return 0; -} diff --git a/test/bt_mesh_unit_test.h b/test/bt_mesh_unit_test.h deleted file mode 100644 index 10d02b5..0000000 --- a/test/bt_mesh_unit_test.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved - * - * @author: Anupam Roy - * - * 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. - */ - -#define BUFFER_LEN 49 - -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define TC_PRT(format, args...) PRT(format"\n", ##args) - -typedef struct { - const char *tc_name; - int tc_code; -} tc_table_t; - -typedef struct { - int param_count; - char **params; -} tc_params_t; - - -typedef enum { - BT_MESH_UNIT_TEST_TABLE_MAIN = 1, - BT_MESH_UNIT_TEST_TABLE_NETWORK = 3, - BT_MESH_UNIT_TEST_TABLE_CONFIGURATION, - BT_MESH_UNIT_TEST_TABLE_FINISH = 0XFF, -} bt_mesh_unit_test_table_e; - -typedef enum { - BT_MESH_UNIT_TEST_FUNCTION_BACK = 0, - BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE = 1, - BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE, - BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE = 1, - BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY, - BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT, - BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK, - BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT, - BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY, - BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE, - BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS, - BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS, - BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX, - BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE, - BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE, - BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY, - BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS, - BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX, - BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE, - BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN, - BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB, - BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES, - BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES, - BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE=1, - BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET, - BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES, - BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS, - BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS, - BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL, - BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL, - BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY, - BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION, - BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION, - BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY, - BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, -} bt_mesh_unit_test_function_e; - -int test_input_callback(void *data); diff --git a/test/bt_onoff.c b/test/bt_onoff.c deleted file mode 100644 index fb593c4..0000000 --- a/test/bt_onoff.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file bt_onoff.c - * @brief This is the source file for bt activation/deactivation. - */ - -#include -#include - -#include "bluetooth.h" -#include "bluetooth_internal.h" - -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define TC_PRT(format, args...) PRT(format"\n", ##args) - -GMainLoop *main_loop = NULL; -static guint onoff_timer = 0; -static int cnt = 0; - -static gboolean __bt_onoff_timeout_cb(gpointer data); - -static void __bt_retry_onoff(bt_adapter_state_e state) -{ - int ret; - - cnt++; - - TC_PRT("Retry cnt: %d", cnt); - - onoff_timer = g_timeout_add(20000, (GSourceFunc)__bt_onoff_timeout_cb, NULL); - - if (state == BT_ADAPTER_DISABLED) - ret = bt_adapter_enable(); - else - ret = bt_adapter_disable(); - - TC_PRT("bt_adapter_%s() error(%d)", - state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); -} - -static void __bt_adapter_state_changed_cb(int result, - bt_adapter_state_e adapter_state, void *user_data) -{ - TC_PRT("state(%d), error(%d)", adapter_state, result); - - if (onoff_timer) - g_source_remove(onoff_timer); - onoff_timer = 0; - - if (result != BT_ERROR_NONE) { - char *argv[] = {NULL}; - execv("all_log_dump.sh", argv); - } - - __bt_retry_onoff(adapter_state); -} - -static gboolean __bt_onoff_timeout_cb(gpointer data) -{ - TC_PRT("Timed out"); - - char *argv[] = {NULL}; - execv("all_log_dump.sh", argv); - - if (main_loop) - g_main_loop_quit(main_loop); - else - exit(0); - - return FALSE; -} - -int main(int argc, char *argv[]) -{ - int ret; - bt_adapter_state_e state; - - if (bt_initialize() != BT_ERROR_NONE) { - TC_PRT("bt_initialize() failed."); - return -1; - } - if (bt_adapter_set_state_changed_cb( - __bt_adapter_state_changed_cb, NULL) != BT_ERROR_NONE) { - TC_PRT("bt_adapter_set_state_changed_cb() failed."); - goto DONE; - } - - main_loop = g_main_loop_new(NULL, FALSE); - - bt_adapter_get_state(&state); - ret = bt_adapter_get_state(&state); - TC_PRT("state(%d), error(%d)", state, ret); - - onoff_timer = g_timeout_add(20000, - (GSourceFunc)__bt_onoff_timeout_cb, - NULL); - - if (argc <= 1) { - if (state == BT_ADAPTER_DISABLED) - ret = bt_adapter_enable(); - else - ret = bt_adapter_disable(); - - TC_PRT("bt_adapter_%s() error(%d)", - state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); - } else { - if (argv[1][0] == '0') { - if (state == BT_ADAPTER_DISABLED) { - TC_PRT("Already disabled"); - goto DONE; - } else { - ret = bt_adapter_disable(); - TC_PRT("bt_adapter_disable() error(%d)", - ret); - if (ret != BT_ERROR_NONE) - goto DONE; - } - } else { - if (state == BT_ADAPTER_ENABLED) { - TC_PRT("Already eabled"); - goto DONE; - } else { - ret = bt_adapter_enable(); - TC_PRT("bt_adapter_enable() error(%d)", ret); - if (ret != BT_ERROR_NONE) - goto DONE; - } - } - } - - g_main_loop_run(main_loop); - -DONE: - if (onoff_timer) - g_source_remove(onoff_timer); - onoff_timer = 0; - bt_adapter_unset_state_changed_cb(); - bt_deinitialize(); - - return 0; -} diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c deleted file mode 100644 index 0331d63..0000000 --- a/test/bt_unit_test.c +++ /dev/null @@ -1,10655 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** - * @file bt_unit_test.c - * @brief This is the source file for capi unit test. - */ - -#include -#include -#include -#include -#include -#include -#include -#ifdef ARCH64 -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bluetooth.h" -#include "bluetooth_internal.h" -#include "bluetooth_extension.h" -#include "bluetooth_private.h" -#include "bluetooth-telephony-api.h" -#include "bt_unit_test.h" - -const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB"; -const char *hid_uuid = "00001124-0000-1000-8000-00805f9b34fb"; -const char *opp_uuid = "00001105-0000-1000-8000-00805f9b34fb"; -const char *custom_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"; - -/* HPS UUIDs. defined by SIG */ -#define HPS_UUID "1823" -#define HTTP_URI_UUID "2ab6" -#define HTTP_HDR_UUID "2ab7" -#define HTTP_ENTITY_UUID "2ab9" -#define HTTP_CP_UUID "2aba" -#define HTTP_STATUS_UUID "2ab8" -#define HTTP_SECURITY_UUID "2abb" -#define HTTP_STATUS_DESC_UUID "2902" -#define IPSP_PORT 3344 -static bt_unit_test_table_e current_tc_table; -static char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; -static char ipsp_iface_name[17] = ""; -static bool input_automated_test_delay = false; - -/* For HDP profile TEST */ -static char *appid = "/org/bluez/health_app_2"; -static char *data_hdp = "aaa"; -static unsigned channel_hdp = 0; - -static bool need_to_set_params = false; -static int g_test_id = -1; -static tc_params_t g_test_param = {0,}; - -static int server_fd; -static int client_fd; -static int custom_server_fd; -static int custom_client_fd; -static int ipsp_server_sock = 0; -static int ipsp_client_sock = 0; - -static int bt_onoff_cnt = 0; -static int bt_onoff_cnt_success = 0; -static int bt_onoff_cnt_fail = 0; -static int total_time = 0; -static struct timeval check_time = {0,}; - -static int absolute_volume = 0; - -int service_index; -int char_service_index; - -static bt_advertiser_h advertiser = NULL; -static bt_advertiser_h advertiser_list[3] = {NULL, }; -static int advertiser_index = 0; - -bt_gatt_client_h client = NULL; -bt_gatt_client_h hps_client = NULL; - -bt_gatt_server_h server = NULL; -typedef struct { - bt_gatt_h svc; - bt_gatt_h chr; - bt_gatt_h desc; -} gatt_handle_t; -gatt_handle_t battery_h; -gatt_handle_t heart_rate_h; -gatt_handle_t thermometer_h; -gatt_handle_t custom_h; -gatt_handle_t ipsp_h; - -bt_proximity_reporter_h reporter; -bt_proximity_monitor_h monitor; -bt_scan_filter_h pxp_scan_filter; - -bt_tds_provider_h provider; -char *tds_act_address; -bt_tds_seeker_h seeker; - -bt_otp_client_h otp_client; -bt_hrp_collector_h collector; -bool set_notif = true; - - -static unsigned char *hash = NULL; -static unsigned char *randomizer = NULL; -int hash_len; -int rand_len; - -bt_call_list_h call_list; -GMainLoop *main_loop = NULL; - -tc_table_t tc_main[] = { - /* Categories */ - {"SET ADDRESS" - , BT_UNIT_TEST_FUNCTION_SET_ADDRESS}, - {"bt_initialize" - , BT_UNIT_TEST_FUNCTION_INITIALIZE}, - {"bt_deinitialize" - , BT_UNIT_TEST_FUNCTION_DEINITIALIZE}, - {"Adapter" - , BT_UNIT_TEST_TABLE_ADAPTER}, - {"Adapter LE" - , BT_UNIT_TEST_TABLE_ADAPTER_LE}, - {"Device" - , BT_UNIT_TEST_TABLE_DEVICE}, - {"Socket" - , BT_UNIT_TEST_TABLE_SOCKET}, - {"Opp" - , BT_UNIT_TEST_TABLE_OPP}, - {"Audio(ag, a2dp, call)" - , BT_UNIT_TEST_TABLE_AUDIO}, - {"Pan(nap, panu)" - , BT_UNIT_TEST_TABLE_PAN}, - {"Gatt" - , BT_UNIT_TEST_TABLE_GATT}, - {"HPS" - , BT_UNIT_TEST_TABLE_HPS}, - {"Avrcp" - , BT_UNIT_TEST_TABLE_AVRCP}, - {"Hid" - , BT_UNIT_TEST_TABLE_HID}, - {"IPSP" - , BT_UNIT_TEST_TABLE_IPSP}, - {"HDP" - , BT_UNIT_TEST_TABLE_HDP}, - {"DPM" - , BT_UNIT_TEST_TABLE_DPM}, - {"PXP" - , BT_UNIT_TEST_TABLE_PXP}, - {"HF Role" - , BT_UNIT_TEST_TABLE_HF}, - {"PBAP Client" - , BT_UNIT_TEST_TABLE_PBAP_CLIENT}, - {"etc.(Automated test, AppControl)" - , BT_UNIT_TEST_TABLE_ETC}, - {"TDS Provider" - , BT_UNIT_TEST_TABLE_TDS_PROVIDER}, - {"TDS Seeker" - , BT_UNIT_TEST_TABLE_TDS_SEEKER}, - {"OTP" - , BT_UNIT_TEST_TABLE_OTP}, - {"HRS" - , BT_UNIT_TEST_TABLE_HRP_SENSOR}, - {"HRC" - , BT_UNIT_TEST_TABLE_HRP_COLLECTOR}, - {"Initialize All" - , BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL}, - {"FINISH" - , BT_UNIT_TEST_TABLE_FINISH}, - {NULL , 0x0000}, -}; - -tc_table_t tc_adapter[] = { - /* Adapter functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_adapter_get_state" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE}, - {"bt_adapter_enable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE}, - {"bt_adapter_disable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE}, - {"bt_adapter_recover" - , BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER}, - {"bt_adapter_start_device_discovery" - , BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY}, - {"bt_adapter_stop_device_discovery" - , BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY}, - {"bt_adapter_is_discovering" - , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING}, - {"bt_adapter_foreach_bonded_device" - , BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE}, - {"bt_adapter_foreach_profile_connected_devices" - , BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES}, - {"bt_adapter_get_bonded_device_info" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO}, - {"bt_adapter_is_service_used" - , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED}, - {"bt_adapter_get_visibility" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY}, - {"bt_adapter_set_visibility" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY}, - {"bt_adapter_set_device_discovery_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, - {"bt_adapter_unset_device_discovery_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, - {"bt_adapter_get_local_oob_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA}, - {"bt_adapter_set_remote_oob_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA}, - {"bt_adapter_remove_remote_oob_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA}, - {"bt_adapter_get_local_oob_ext_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA}, - {"bt_adapter_set_remote_oob_ext_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA}, - {"bt_adapter_read_battery_info" - , BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO}, - {"bt_adapter_init_battery_monitor" - , BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR}, - {"bt_adapter_deinit_battery_monitor" - , BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR}, - {"bt_adapter_set_visibility_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB}, - {"bt_adapter_unset_visibility_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB}, - {"bt_adapter_set_visibility_duration_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB}, - {"bt_adapter_unset_visibility_duration_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB}, - {"bt_adapter_set_connectable_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB}, - {"bt_adapter_unset_connectable_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB}, - {"bt_adapter_get_connectable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE}, - {"bt_adapter_set_connectable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE}, - {"bt_adapter_get_version" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION}, - {"bt_adapter_get_local_info" - , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO}, - {"bt_adapter_set_manufacturer_data_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB}, - {"bt_adapter_unset_manufacturer_data_changed_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB}, - {"bt_adapter_set_manufacturer_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA}, - {"bt_adapter_set_authentication_req_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB}, - {"bt_adapter_set_authentication_request_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW}, - {"bt_adapter_unset_authentication_req_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB}, - {"bt_adapter_unset_authentication_request_cb" - , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW}, - {"bt_adapter_passkey_reply(passkey, TRUE)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT}, - {"bt_adapter_passkey_reply(passkey, FALSE)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL}, - {"bt_adapter_passkey_confirmation_reply(TRUE)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT}, - {"bt_adapter_passkey_confirmation_reply(FALSE)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_adapter_le[] = { - /* Adapter functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_adapter_le_get_state" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE}, - {"bt_adapter_le_enable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE}, - {"bt_adapter_le_disable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE}, - {"bt_adapter_le_set_scan_mode" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE}, - {"bt_adapter_le_set_scan_type" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE}, - {"bt_adapter_le_set_customized_scan_mode" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED}, - {"bt_adapter_le_start_scan" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN}, - {"bt_adapter_le_stop_scan" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN}, - {"bt_adapter_le_add_advertising_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA}, - {"bt_adapter_le_set_advertising_mode" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE}, - {"bt_adapter_le_set_advertising_filter_policy" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY}, - {"bt_adapter_le_set_advertising_connectable" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE}, - {"bt_adapter_le_set_advertising_custom_tx_power_level" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER}, - {"bt_adapter_le_start_advertising_new" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW}, - {"bt_adapter_le_stop_advertising" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING}, - {"bt_adapter_le_add_white_list" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST}, - {"bt_adapter_le_remove_white_list" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST}, - {"bt_adapter_le_enable_privacy" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY}, - {"bt_adapter_le_get_local_oob_ext_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA}, - {"bt_adapter_le_set_remote_oob_ext_data" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA}, - {"Register scan filter (Device Address)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS}, - {"Register scan filter (Device Name)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME}, - {"Register scan filter (Service UUID)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID}, - {"Register scan filter (Service Solicitation UUID)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID}, - {"Register scan filter (Manufacturer DATA)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA}, - {"Register iBeaconscan filter (Manufacturer DATA)" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA}, - {"Unregister all scan filters" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS}, - {"bt_adater_le_read_maximum_data_length" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH}, - {"bt_adater_le_wite_host_suggested_def_data_length" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, - {"bt_adater_le_read_host_suggested_def_data_length" - , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, - {"bt_adapter_le_is_2m_phy_supported" - , BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT}, - {"bt_adapter_le_is_coded_phy_supported" - , BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_device[] = { - /* Device functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_device_set_authorization (true)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE}, - {"bt_device_set_authorization (false)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE}, - {"bt_device_set_authorization_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB}, - {"bt_device_unset_authorization_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB}, - {"bt_device_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB}, - {"bt_device_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB}, - {"bt_device_foreach_connected_profiles" - , BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES}, - {"bt_device_is_profile_connected" - , BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED}, - {"bt_device_set_bond_created_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB}, - {"bt_device_set_bond_destroyed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB}, - {"bt_device_disconnect" - , BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT}, - {"bt_device_create_bond" - , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND}, - {"bt_device_create_bond_by_type" - , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE}, - {"bt_device_destroy_bond" - , BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND}, - {"bt_device_update_le_connection_mode" - , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE}, - {"bt_device_le_conn_update" - , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION}, - {"bt_device_request_att_mtu" - , BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU}, - {"bt_device_set_att_mtu_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB}, - {"bt_device_unset_att_mtu_changed_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB}, - {"bt_device_get_att_mtu" - , BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU}, - {"bt_device_le_set_data_length" - , BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH}, - {"bt_device_le_data_length_changed_cb" - , BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {"bt_device_set_profile_trusted_A2DP(true)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE}, - {"bt_device_set_profile_trusted_A2DP(false)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE}, - {"bt_device_set_profile_trusted_HFP_HF(true)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE}, - {"bt_device_set_profile_trusted_HFP_HF(false)" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE}, - {"bt_device_set_trusted_profile_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB}, - {"bt_device_unset_trusted_profile_cb" - , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB}, - {NULL , 0x0000}, -}; - -tc_table_t tc_socket[] = { - /* Socket functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_socket_create_rfcomm" - , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM}, - {"bt_socket_destroy_rfcomm" - , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM}, - {"bt_socket_listen_and_accept_rfcomm" - , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM}, - {"bt_socket_listen" - , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN}, - {"bt_socket_accept" - , BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT}, - {"bt_socket_reject" - , BT_UNIT_TEST_FUNCTION_SOCKET_REJECT}, - {"bt_socket_connect_rfcomm" - , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM}, - {"bt_socket_disconnect_rfcomm" - , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM}, - {"bt_socket_send_data" - , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA}, - {"bt_socket_create_rfcomm with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID}, - {"bt_socket_destroy_rfcomm with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID}, - {"bt_socket_listen_and_accept_rfcomm with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID}, - {"bt_socket_connect_rfcomm with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID}, - {"bt_socket_disconnect_rfcomm with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID}, - {"bt_socket_send_data with custom uuid" - , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID}, - {"bt_socket_set_data_received_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB}, - {"bt_socket_unset_data_received_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB}, - {"bt_socket_set_connection_requested_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB}, - {"bt_socket_unset_connection_requested_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB}, - {"bt_socket_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB}, - {"bt_socket_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_opp[] = { - /* OPP functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_opp_client_initialize" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE}, - {"bt_opp_client_deinitialize" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE}, - {"bt_opp_client_add_file" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE}, - {"bt_opp_client_clear_files" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES}, - {"bt_opp_client_push_files" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES}, - {"bt_opp_client_cancel_push" - , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_audio[] = { - /* AG functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_audio_initialize" - , BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE}, - {"bt_audio_deinitialize" - , BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE}, - {"bt_audio_connect" - , BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT}, - {"bt_audio_disconnect" - , BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT}, - {"bt_audio_sink_connect" - , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT}, - {"bt_audio_sink_disconnect" - , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT}, - {"bt_audio_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB}, - {"bt_audio_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"bt_ag_open_sco" - , BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO}, - {"bt_ag_close_sco" - , BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO}, - {"bt_ag_is_sco_opened" - , BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED}, - {"bt_ag_set_sco_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB}, - {"bt_ag_unset_sco_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB}, - {"bt_ag_set_speaker_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB}, - {"bt_ag_unset_speaker_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB}, - {"bt_ag_set_microphone_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB}, - {"bt_ag_unset_microphone_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB}, - {"bt_ag_is_connected" - , BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED}, - {"BT_AG_CALL_EVENT_IDLE" - , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE}, - {"BT_AG_CALL_EVENT_ANSWERED" - , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED}, - {"BT_AG_CALL_EVENT_DIALING" - , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING}, - {"BT_AG_CALL_EVENT_ALERTING" - , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING}, - {"BT_AG_CALL_EVENT_INCOMING" - , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING}, - {"bt_call_list_create" - , BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE}, - {"bt_call_list_destroy" - , BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY}, - {"bt_call_list_reset" - , BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET}, - {"bt_call_list_add" - , BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD}, - {"bt_ag_notify_call_list" - , BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST}, - {"bt_ag_set_call_handling_event_cb" - , BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB}, - {"bt_ag_is_nrec_enabled" - , BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED}, - {"bt_ag_switch_headset" - , BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET}, - {"bt_audio_select_role(source)" - , BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE}, - {"bt_audio_select_role(sink)" - , BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE}, - {"bt_audio_set_absolute_volume" - , BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME}, - {"bt_audio_get_absolute_volume" - , BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME}, - {"bt_audio_is_avc_activated" - , BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED}, - {"bt_audio_set_absolute_volume_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB}, - {"bt_audio_unset_absolute_volume_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB}, - {"bt_audio_set_avc_status_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB}, - {"bt_audio_unset_avc_status_changed_cb" - , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB}, - /* A2DP SCMS-T functions */ - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_pan[] = { - /* Network functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_nap_activate" - , BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE}, - {"bt_nap_deactivate" - , BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE}, - {"bt_nap_disconnect_all" - , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL}, - {"bt_nap_disconnect" - , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT}, - {"bt_panu_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB}, - {"bt_panu_connect" - , BT_UNIT_TEST_FUNCTION_PANU_CONNECT}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_gatt[] = { - /* Gatt functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_gatt_connect" - , BT_UNIT_TEST_FUNCTION_GATT_CONNECT}, - {"bt_gatt_disconnect" - , BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT}, - {"bt_gatt_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB}, - {"bt_gatt_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB}, - {"bt_gatt_client_create" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE}, - {"bt_gatt_client_destroy" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY}, - {"bt_gatt_client_get_remote_address" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS}, - {"bt_gatt_client_print_all" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL}, - {"bt_gatt_client_read_value" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE}, - {"bt_gatt_client_write_value" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE}, - {"bt_gatt_client_set_char_value_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB}, - {"bt_gatt_client_unset_char_value_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB}, - {"bt_gatt_client_foreach_services" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES}, - {"bt_gatt_client_request_att_mtu_change" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU}, - {"bt_gatt_client_get_att_mtu" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU}, - {"bt_gatt_client_set_service_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB}, - {"bt_gatt_client_unset_service_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB}, - {"bt_gatt_client_set_att_mtu_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB}, - {"bt_gatt_client_unset_att_mtu_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB}, - {"bt_gatt_server_initialize" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE}, - {"bt_gatt_server_deinitilaize" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE}, - {"bt_gatt_server_unregister_all_services" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES}, - {"bt_gatt_server_foreach_services" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES}, - {"bt_gatt_server_get_device_mtu" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU}, - {"bt_gatt_server_set_att_mtu_changed_cb" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB}, - {"Register Battery Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC}, - {"Change Battery Level" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL}, - {"Register Heart Rate Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC}, - {"Notify Heart Rate Measurement" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT}, - {"Register Thermometer Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC}, - {"Change Thermometer Measurement" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT}, - {"Register Device Information Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC}, - {"Register Link Loss Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC}, - {"Register HID Over GATT Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC}, - {"Register Custom Service" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC}, - {"Change Custom Value" - , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL}, - {"Start Server" - , BT_UNIT_TEST_FUNCTION_GATT_START_SERVER}, - {"Get Specification Name from UUID" - , BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID}, - {"ANCS (Pair)" - , BT_UNIT_TEST_FUNCTION_ANCS_PAIR}, - {"ANCS (Watch notification)" - , BT_UNIT_TEST_FUNCTION_ANCS_WATCH}, - {"ANCS (Positive action)" - , BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION}, - {"ANCS (Negative action)" - , BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION}, - {"ANCS (Get Noti. Attr.)" - , BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR}, - {"bt_gatt_get_available_data_batching_packets" - , BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS}, - {"bt_gatt_enable_data_batching" - , BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING}, - {"bt_gatt_disable_data_batching" - , BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_hps[] = { - /* HPS functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_hps_client_create" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE}, - {"bt_hps_client_destroy" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY}, - {"bt_hps_client_print_all" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL}, - {"bt_hps_client_read_value" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE}, - {"bt_hps_client_set_uri" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI}, - {"bt_hps_client_set_hdr" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR}, - {"bt_hps_client_set_entity" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY}, - {"bt_hps_client_set_cp" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP}, - {"bt_hps_client_get_uri" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI}, - {"bt_hps_client_get_hdr" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR}, - {"bt_hps_client_get_entity" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY}, - {"bt_hps_client_get_security" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY}, - {"bt_hps_client_set_status_notification" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION}, - {"bt_hps_client_unset_status_notification" - , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_pxp[] = { - /* HPS functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"Proximity Reporter(Register)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER}, - {"Proximity Reporter(Unregister)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER}, - {"Proximity Reporter(Start Advertising Proximity Reporter)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING}, - {"Proximity Reporter (Set State Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB}, - {"Proximity Reporter (UnSet State Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"Proximity Reporter (Set Property Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB}, - {"Proximity Reporter (UnSet Property Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB}, - {"Proximity Reporter(Read Linkloss Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT}, - {"Proximity Reporter(Read Immediate Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT}, - {"Proximity Monitor(Create)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE}, - {"Proximity Monitor(Destroy)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY}, - {"Proximity Monitor(Connect)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT}, - {"Proximity Monitor(Disconnect)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT}, - {"Proximity Monitor (Set State Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB}, - {"Proximity Monitor (UnSet State Changed callback)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"Proximity Monitor(Set LE Scan Filter for Proximity UUID)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID}, - {"Proximity Monitor(Unet LE Scan Filter for Proximity UUID)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID}, - {"Proximity Monitor(Write Linkloss Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT}, - {"Proximity Monitor(Write Immediate Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT}, - {"Proximity Monitor(Read Linkloss Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT}, - {"Proximity Monitor(Read Immediate Alert Level)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT}, - {"Proximity Monitor(Read Signal Level)" - , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_avrcp[] = { - /* AVRCP functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_avrcp_target_initialize" - , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE}, - {"bt_avrcp_target_deinitialize" - , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE}, - {"bt_avrcp_set_equalizer_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB}, - {"bt_avrcp_set_repeat_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB}, - {"bt_avrcp_set_shuffle_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB}, - {"bt_avrcp_set_scan_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB}, - {"bt_avrcp_unset_equalizer_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB}, - {"bt_avrcp_unset_repeat_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB}, - {"bt_avrcp_unset_shuffle_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB}, - {"bt_avrcp_unset_scan_mode_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB}, - {"bt_avrcp_control_initialize" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE}, - {"bt_avrcp_control_deinitialize" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE}, - {"bt_avrcp_control_connect" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT}, - {"bt_avrcp_control_disconnect" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT}, - {"bt_avrcp_control_player_PLAY" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY}, - {"bt_avrcp_control_player_STOP" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP}, - {"bt_avrcp_control_player_PAUSE" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE}, - {"bt_avrcp_control_player_FF" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF}, - {"bt_avrcp_control_player_RW" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW}, - {"bt_avrcp_control_player_NEXT" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT}, - {"bt_avrcp_control_player_PREV" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV}, - {"bt_avrcp_control_player_SET_ABSOLUTE_VOLUME" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME}, - {"bt_avrcp_control_player_VOLUME_UP" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP}, - {"bt_avrcp_control_player_VOLUME_DOWN" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN}, - {"bt_avrcp_control_player_GET_REPEAT" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT}, - {"bt_avrcp_control_player_SET_REPEAT" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT}, - {"bt_avrcp_control_player_GET_SHUFFLE" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE}, - {"bt_avrcp_control_player_SET_SHUFFLE" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE}, - {"bt_avrcp_control_player_GET_POSITION" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION}, - {"bt_avrcp_control_player_GET_PLAY STATUS" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS}, - {"bt_avrcp_control_player_GET_TRACK_INFO" - , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO}, - {"bt_avrcp_set_position_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB}, - {"bt_avrcp_set_play_status_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB}, - {"bt_avrcp_set_track_info_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB}, - {"bt_avrcp_unset_position_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB}, - {"bt_avrcp_unset_play_status_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB}, - {"bt_avrcp_unset_track_info_changed_cb" - , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_hid[] = { - /* HID functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_hid_host_initialize" - , BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE}, - {"bt_hid_host_deinitialize" - , BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE}, - {"bt_hid_host_connect" - , BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT}, - {"bt_hid_host_disconnect" - , BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT}, - {"bt_hid_device_activate" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE}, - {"bt_hid_device_connect" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT}, - {"bt_hid_device_disconnect" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT}, - {"bt_hid_device_deactivate" - , BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE}, - {"bt_hid_device_send_mouse_event" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT}, - {"bt_hid_device_send_key_event" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT}, - {"bt_hid_device_send_custom_event" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT}, - {"bt_hid_device_set_data_received_cb" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB}, - {"bt_hid_device_unset_data_received_cd" - , BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_ipsp[] = { - /* IPSP functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_ipsp_register[Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_REGISTER}, - {"bt_ipsp_unregister[Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER}, - {"bt_ipsp_initialize[Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE}, - {"bt_ipsp_deinitialize[Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE}, - {"bt_ipsp_connect[Client role]" - , BT_UNIT_TEST_FUNCTION_IPSP_CONNECT}, - {"bt_ipsp_disconnect[Client role]" - , BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT}, - {"bt_ipsp_start_advertising[Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING}, - {"bt_ipsp_set_connection_state_changed_cb[Client/Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB}, - {"bt_ipsp_unset_connection_state_changed_cb[Client/Server role]" - , BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"bt_ipsp_create_ipsp_app_server_socket[Server App role]" - , BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET}, - {"bt_ipsp_connect_with_ipsp_app_server_socket[Client App role]" - , BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET}, - {"bt_ipsp_send_ipv6_application_data[Client/Server App role][Max 255 bytes]" - , BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA}, - {"bt_ipsp_recv_ipv6_application_data[Client/Server App role]" - , BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA}, - {"bt_ipsp_close_socket[Client/Server App role]" - , BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_HDP[] = { - /* HDP functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_hdp_register_sink_app" - , BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP}, - {"bt_hdp_unregister_sink_app" - , BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP}, - {"bt_hdp_connect_to_source" - , BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE}, - {"bt_hdp_disconnect" - , BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT}, - {"bt_hdp_send_data" - , BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA}, - {"bt_hdp_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB}, - {"bt_hdp_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB}, - {"bt_hdp_set_data_received_cb" - , BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB}, - {"bt_hdp_unset_data_received_cb" - , BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_DPM[] = { - /* DPM functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_dpm_Set_default_policies" - , BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES}, - {"bt_dpm_set_allow_bluetooth_mode" - , BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE}, - {"bt_dpm_get_allow_bluetooth_mode" - , BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE}, - {"bt_dpm_activate_device_restriction" - , BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION}, - {"bt_dpm_is_device_restriction_active" - , BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE}, - {"bt_dpm_activate_bluetoooth_uuid_restriction" - , BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION}, - {"bt_dpm_is_uuid_restriction_active" - , BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE}, - {"bt_dpm_add_devices_to_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST}, - {"bt_dpm_add_devices_to_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST}, - {"bt_dpm_add_uuids_to_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST}, - {"bt_dpm_add_uuids_to_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST}, - {"bt_dpm_get_devices_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST}, - {"bt_dpm_get_devices_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST}, - {"bt_dpm_get_uuids_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST}, - {"bt_dpm_get_uuids_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST}, - {"bt_dpm_clear_devices_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST}, - {"bt_dpm_clear_devices_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST}, - {"bt_dpm_clear_uuids_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST}, - {"bt_dpm_clear_uuids_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST}, - {"bt_dpm_remove_device_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST}, - {"bt_dpm_remove_device_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST}, - {"bt_dpm_remove_uuid_from_blacklist" - , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST}, - {"bt_dpm_remove_uuid_from_whitelist" - , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST}, - {"bt_dpm_set_allow_outgoing_call" - , BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL}, - {"bt_dpm_get_allow_outgoing_call" - , BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL}, - {"bt_dpm_set_pairing_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE}, - {"bt_dpm_get_pairing_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE}, - {"bt_dpm_set_profile_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE}, - {"bt_dpm_get_profile_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE}, - {"bt_dpm_set_desktop_connectivity_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE}, - {"bt_dpm_get_desktop_connectivity_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE}, - {"bt_dpm_set_discoverable_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE}, - {"bt_dpm_get_discoverable_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE}, - {"bt_dpm_set_limited_discoverable_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE}, - {"bt_dpm_get_limited_discoverable_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE}, - {"bt_dpm_set_data_transfer_state" - , BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE}, - {"bt_dpm_get_data_transfer_state" - , BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_hf[] = { - /* Handsfree role functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_hf_initialize" - , BT_UNIT_TEST_FUNCTION_HF_INITIALIZE}, - {"bt_hf_deinitialize" - , BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE}, - {"(CALL Handling) bt_hf_notify_call_event(answer)" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER}, - {"(CALL Handling) bt_hf_notify_call_event(initiate)" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT}, - {"(CALL Handling) bt_hf_notify_call_event(terminate)" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM}, - {"(CALL Status) bt_hf_get_call_status_info_list" - , BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST}, - {"(CALL Status) bt_hf_request_call_status_info_list" - , BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST}, - {"(CALL Status) bt_hf_set_call_handling_event_cb()" - , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB}, - {"(CALL Status) bt_hf_unset_call_handling_event_cb" - , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB}, - {"(CALL Status) bt_hf_set_call_status_updated_event_cb" - , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB}, - {"(CALL Status) bt_hf_unset_call_status_updated_event_cb" - , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB}, - {"(Volume) bt_hf_notify_speaker_gain" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN}, - {"(Volume) bt_hf_set_speaker_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB}, - {"(Volume) bt_hf_unset_speaker_gain_changed_cb" - , BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB}, - {"(Voice-recog) bt_hf_notify_voice_recognition_state(true)" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE}, - {"(Voice-recog) bt_hf_notify_voice_recognition_state(false)" - , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE}, - {"(SCO) bt_hf_is_sco_opened" - , BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED}, - {"(SCO) bt_hf_get_codec_id" - , BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID}, - {"(SCO) bt_hf_set_sco_state_changed_cb()" - , BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB}, - {"(SCO) bt_hf_unset_sco_state_changed_cb()" - , BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_pbap_client[] = { - /* PBAP Functions*/ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_pbap_client_initialize()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE}, - {"bt_pbap_client_deinitialize()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE}, - {"bt_pbap_client_set_connection_state_changed_cb()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB}, - {"bt_pbap_client_unset_connection_state_changed_cb()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"bt_pbap_client_connect()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT}, - {"bt_pbap_client_disconnect()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT}, - {"bt_pbap_client_is_connected()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED}, - {"bt_pbap_client_get_phone_book_size()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE}, - {"bt_pbap_client_get_phone_book()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL}, - {"bt_pbap_client_get_list()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST}, - {"bt_pbap_client_pull_vcard()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL}, - {"bt_pbap_client_search_phone_book()" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH}, - {"bt_pbap_client_get_list() Maxlist=0" - , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO}, - {"Select this menu to set parameters and then select the function again." - , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -tc_table_t tc_tds_provider[] = { - /* TDS provider functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"TDS Provider(Register)" - , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER}, - {"TDS Provider(Unregister)" - , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER}, - {"TDS Provider set activation req callback" - , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB}, - {"TDS Provider unset activation req callback" - , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB}, - {"TDS CUSTOM Provider(Create)" - , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE}, - {"TDS CUSTOM Provider(Destroy)" - , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY}, - {"TDS CUSTOM Provider(Set transport Data)" - , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA}, - {"TDS CUSTOM Provider(Set manuf Data)" - , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA}, - {"TDS CUSTOM Provider(Send Activation Response)" - , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP}, - {NULL , 0x0000}, -}; - -tc_table_t tc_tds_seeker[] = { - /* TDS Seeker functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"TDS Seeker Start Discovering Provider" - , BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER}, - {"TDS Seeker Stop Discovering Provider" - , BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER}, - {"TDS Seeker(Create)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE}, - {"TDS Seeker(Destroy)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY}, - {"TDS Set Seeker Connection cb" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK}, - {"TDS Seeker Connect(remote)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT}, - {"TDS Seeker DisConnect(remote)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT}, - {"TDS UnSet Seeker Connection cb" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK}, - {"TDS Read Complete Transport Data (remote)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA}, - {"TDS Activate Control Point (remote)" - , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT}, - {NULL , 0x0000}, -}; - -tc_table_t tc_otp[] = { - /* OTP functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"bt_otp_server_init" - , BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT}, - {"bt_otp_server_deinit" - , BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT}, - {"bt_otp_set_server_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB}, - {"bt_otp_unset_server_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB}, - {"bt_otp_client_create" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE}, - {"bt_otp_client_destroy" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY}, - {"bt_otp_client_set_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK}, - {"bt_otp_client_unset_connection_state_changed_cb" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK}, - {"bt_otp_client_connect" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT}, - {"bt_otp_client_disconnect" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT}, - {"bt_otp_client_discover_all_objects" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS}, - {"bt_otp_client_select_object" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ}, - {"bt_otp_client_read_object_contents" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS}, - {"bt_otp_client_create_object" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ}, - {"bt_otp_client_write_object" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ}, - {"bt_otp_client_execute_object" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ}, - {"bt_otp_client_delete_object" - , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ}, - {NULL , 0x0000}, -}; - -tc_table_t tc_hr_sensor[] = { - /* HR Sensor functions */ - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"[sensor]Set Location Value" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE}, - {"[sensor]Set Contact Value" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE}, - {"[sensor]Set Device Name" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME}, - {"[sensor] Create Sensor" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE}, - {"[sensor] Notify Collector" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY}, - {"[sensor] Destroy Sensor" - , BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY}, - {NULL , 0x0000}, -}; - -tc_table_t tc_hr_collector[] = { - {"BACK" - , BT_UNIT_TEST_FUNCTION_BACK}, - {"[collector]Set Connection State callback" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK}, - {"[collector]Set/Unset Notification" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION}, - {"[collector]Start Scan" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN}, - {"[collector]Stop Scan" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN}, - {"[collector]Connect Sensor" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT}, - {"[collector]Disconnect Sensor" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT}, - {"[collector]Create Collector" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE}, - {"[collector]Destroy Collector" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY}, - {"[collector]Read Body Sensor Location" - , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC}, - {NULL , 0x0000}, -}; - - -tc_table_t tc_automated_test[] = { - /* Automated test Functions*/ - {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, - {"On/Off repeat test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST}, - {"On/Off repeat(1sec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY}, - {"On/Off repeat(Nsec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY}, - {"AppControl default" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT}, - {"AppControl 2.3 BT onoff" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF}, - {"AppControl 2.3 BT Visibility" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY}, - {"AppControl 2.4 BT onoff" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF}, - {"AppControl 2.4 BT Visibility" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY}, - {"Check feature(ex.tizen.org/feature/network.bluetooth)" , BT_UNIT_TEST_FUNCTION_CHECK_FEATURE}, - - {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, - {NULL , 0x0000}, -}; - -static void __bt_initialize_all(void); - -void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, - void *user_data); - -void tc_usage_print(void) -{ - int i = 0; - tc_table_t *tc_table = NULL; - - switch (current_tc_table) { - case BT_UNIT_TEST_TABLE_SET_ADDRESS: - TC_PRT("Key 0 : usage BACK"); - TC_PRT("Input the address of remote device." - "(e.g.,F6:FB:8F:D8:C8:7C)\n\n"); - return; - case BT_UNIT_TEST_TABLE_ADAPTER: - tc_table = tc_adapter; - break; - case BT_UNIT_TEST_TABLE_ADAPTER_LE: - tc_table = tc_adapter_le; - break; - case BT_UNIT_TEST_TABLE_DEVICE: - tc_table = tc_device; - break; - case BT_UNIT_TEST_TABLE_SOCKET: - tc_table = tc_socket; - break; - case BT_UNIT_TEST_TABLE_OPP: - tc_table = tc_opp; - break; - case BT_UNIT_TEST_TABLE_AUDIO: - tc_table = tc_audio; - break; - case BT_UNIT_TEST_TABLE_PAN: - tc_table = tc_pan; - break; - case BT_UNIT_TEST_TABLE_GATT: - tc_table = tc_gatt; - break; - case BT_UNIT_TEST_TABLE_HPS: - tc_table = tc_hps; - break; - case BT_UNIT_TEST_TABLE_AVRCP: - tc_table = tc_avrcp; - break; - case BT_UNIT_TEST_TABLE_HID: - tc_table = tc_hid; - break; - case BT_UNIT_TEST_TABLE_IPSP: - tc_table = tc_ipsp; - break; - case BT_UNIT_TEST_TABLE_HDP: - tc_table = tc_HDP; - break; - case BT_UNIT_TEST_TABLE_DPM: - tc_table = tc_DPM; - break; - case BT_UNIT_TEST_TABLE_PXP: - tc_table = tc_pxp; - break; - case BT_UNIT_TEST_TABLE_HF: - if (!TIZEN_PROFILE_WEARABLE_IVI) - goto __default__; - tc_table = tc_hf; - break; - case BT_UNIT_TEST_TABLE_PBAP_CLIENT: - if (!TIZEN_PROFILE_WEARABLE_IVI) - goto __default__; - tc_table = tc_pbap_client; - break; - case BT_UNIT_TEST_TABLE_ETC: - if (input_automated_test_delay == true) { - TC_PRT("Input the delay for automated" - "test.(e.g., 10)\n\n"); - return; - } - tc_table = tc_automated_test; - break; - case BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL: - __bt_initialize_all(); - TC_PRT("Key 0 : usage BACK"); - return; - case BT_UNIT_TEST_TABLE_TDS_PROVIDER: - tc_table = tc_tds_provider; - break; - case BT_UNIT_TEST_TABLE_TDS_SEEKER: - tc_table = tc_tds_seeker; - break; - case BT_UNIT_TEST_TABLE_OTP: - tc_table = tc_otp; - break; - case BT_UNIT_TEST_TABLE_HRP_SENSOR: - tc_table = tc_hr_sensor; - break; - case BT_UNIT_TEST_TABLE_HRP_COLLECTOR: - tc_table = tc_hr_collector; - break; - case BT_UNIT_TEST_TABLE_MAIN: -__default__: - default: - tc_table = tc_main; - break; - } - - while (tc_table[i].tc_name) { - TC_PRT("Key %d : usage %s", tc_table[i].tc_code, - tc_table[i].tc_name); - i++; - } - printf("\n\n"); -} - -static void __bt_free_test_param(tc_params_t *param) -{ - int i = 0; - - for (i = 0; i < param->param_count; i++) - g_free(param->params[i]); - g_free(param->params); - param->params = NULL; - param->param_count = 0; -} - -static const char *__bt_get_error_message(bt_error_e err) -{ - const char *err_str = NULL; - - switch (err) { - case BT_ERROR_NONE: - err_str = "BT_ERROR_NONE"; - break; - case BT_ERROR_CANCELLED: - err_str = "BT_ERROR_CANCELLED"; - break; - case BT_ERROR_INVALID_PARAMETER: - err_str = "BT_ERROR_INVALID_PARAMETER"; - break; - case BT_ERROR_OUT_OF_MEMORY: - err_str = "BT_ERROR_OUT_OF_MEMORY"; - break; - case BT_ERROR_RESOURCE_BUSY: - err_str = "BT_ERROR_RESOURCE_BUSY"; - break; - case BT_ERROR_TIMED_OUT: - err_str = "BT_ERROR_TIMED_OUT"; - break; - case BT_ERROR_NOW_IN_PROGRESS: - err_str = "BT_ERROR_NOW_IN_PROGRESS"; - break; - case BT_ERROR_NOT_INITIALIZED: - err_str = "BT_ERROR_NOT_INITIALIZED"; - break; - case BT_ERROR_NOT_ENABLED: - err_str = "BT_ERROR_NOT_ENABLED"; - break; - case BT_ERROR_ALREADY_DONE: - err_str = "BT_ERROR_ALREADY_DONE"; - break; - case BT_ERROR_OPERATION_FAILED: - err_str = "BT_ERROR_OPERATION_FAILED"; - break; - case BT_ERROR_NOT_IN_PROGRESS: - err_str = "BT_ERROR_NOT_IN_PROGRESS"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; - break; - case BT_ERROR_AUTH_REJECTED: - err_str = "BT_ERROR_AUTH_REJECTED"; - break; - case BT_ERROR_AUTH_FAILED: - err_str = "BT_ERROR_AUTH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; - break; - case BT_ERROR_SERVICE_SEARCH_FAILED: - err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; - break; - case BT_ERROR_PERMISSION_DENIED: - err_str = "BT_ERROR_PERMISSION_DENIED"; - break; - case BT_ERROR_SERVICE_NOT_FOUND: - err_str = "BT_ERROR_SERVICE_NOT_FOUND"; - break; - case BT_ERROR_NO_DATA: - err_str = "BT_ERROR_NO_DATA"; - break; - case BT_ERROR_NOT_SUPPORTED: - err_str = "BT_ERROR_NOT_SUPPORTED"; - break; - case BT_ERROR_DEVICE_POLICY_RESTRICTION: - err_str = "DEVICE_POLICY_RESTRICTION"; - break; - default: - err_str = "NOT Defined"; - break; - } - - return err_str; -} - -void __bt_adapter_state_changed_cb(int result, - bt_adapter_state_e adapter_state, void *user_data) -{ - TC_PRT("__bt_adapter_state_changed_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("state: %s", - (adapter_state == BT_ADAPTER_ENABLED) ? - "ENABLED" : "DISABLED"); -} - -static void __bt_adapter_disable_battery_cb(bt_battery_info_s *data) -{ - TC_PRT("Battery data: %ld %ld %d %d", data->session_start_time, - data->session_end_time, data->session_scan_time, data->session_connected_time); - if (data->atm_list == NULL) { - TC_PRT("No data transaction in this session"); - return; - } - - TC_PRT("Displaying app-wise transaction details"); - for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) { - bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data); - TC_PRT("uid: %ld, pid: %ld, received bytes: %d, sent bytes: %d, time: %u", - (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time); - } -} - -static void __bt_adapter_device_visibility_mode_changed_cb(int result, - bt_adapter_visibility_mode_e visibility_mode, - void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("visibility_mode: %d", visibility_mode); -} - -static void __bt_adapter_device_visibility_duration_changed_cb(int duration, - void *user_data) -{ - TC_PRT("visibility_duration: %d", duration); -} - -static void __bt_adapter_connectable_changed_cb(int result, - bool connectable, void *user_data) -{ - if (result != BT_ERROR_NONE) { - TC_PRT("connectable change is failed : [0x%04x]", result); - return; - } - - TC_PRT("%s", connectable ? "Connectable" : "Non-connectable"); -} - -static void __bt_adapter_manufacturer_data_changed_cb(char *data, - int len, void *user_data) -{ - int i; - - TC_PRT("manufacturer data is changed"); - for (i = 0; i < len; i++) - TC_PRT("[%d] %02x", i, data[i]); -} - -static void __bt_adapter_authentication_req_cb( - int result, bt_authentication_type_info_e auth_type, - char *device_name, char *remote_addr, - char *pass_key, void *user_data) -{ - TC_PRT("__bt_adapter_authentication_req_cb:" - " device name = %s", device_name); - TC_PRT("__bt_adapter_authentication_req_cb:" - " device address = %s", remote_addr); - - if (auth_type == BT_AUTH_PIN_REQUEST) { - TC_PRT("Auth Type = BT_AUTH_PIN_REQUEST"); - } else if (auth_type == BT_AUTH_PASSKEY_CONFIRM_REQUEST) { - TC_PRT("Auth Type = BT_AUTH_PASSKEY_CONFIRM_REQUEST"); - TC_PRT("Passkey: [%s]", pass_key); - } else if (auth_type == BT_AUTH_KEYBOARD_PASSKEY_DISPLAY) { - TC_PRT("Auth Type = BT_AUTH_KEYBOARD_PASSKEY_DISPLAY"); - TC_PRT("Passkey: [%s]", pass_key); - } -} - -static void __bt_adapter_authentication_request_cb( - bool incoming, bt_authentication_type_info_e auth_type, - char *device_name, char *remote_addr, - char *pass_key, void *user_data) -{ - TC_PRT("__bt_adapter_authentication_request_cb:" - " device name = %s", device_name); - TC_PRT("__bt_adapter_authentication_request_cb:" - " device address = %s", remote_addr); - - if (incoming == TRUE) - TC_PRT("It is an incoming request"); - else - TC_PRT("It is not an incoming request"); - - if (auth_type == BT_AUTH_PIN_REQUEST) { - TC_PRT("Auth Type = BT_AUTH_PIN_REQUEST"); - } else if (auth_type == BT_AUTH_PASSKEY_CONFIRM_REQUEST) { - TC_PRT("Auth Type = BT_AUTH_PASSKEY_CONFIRM_REQUEST"); - TC_PRT("Passkey: [%s]", pass_key); - } else if (auth_type == BT_AUTH_KEYBOARD_PASSKEY_DISPLAY) { - TC_PRT("Auth Type = BT_AUTH_KEYBOARD_PASSKEY_DISPLAY"); - TC_PRT("Passkey: [%s]", pass_key); - } -} - -static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, - void *user_data) -{ - int i; - char *str = NULL; - - TC_PRT("remote_address: %s", device_info->remote_address); - TC_PRT("remote_name: %s", device_info->remote_name); - TC_PRT("is_connected: %d", device_info->is_connected); - TC_PRT("service_count: %d", device_info->service_count); - TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask, - device_info->bt_class.major_device_class, - device_info->bt_class.minor_device_class); - - if (device_info->service_uuid == NULL) { - TC_PRT("No uuids"); - } else { - for (i = 0; i < device_info->service_count; i++) { - bt_get_uuid_name(device_info->service_uuid[i], &str); - - TC_PRT("[%d / %d] %s (%s)", i, device_info->service_count, - str ? str : "Unknown", device_info->service_uuid[i]); - g_free(str); - str = NULL; - } - } - - if (device_info->manufacturer_data_len > 0) { - TC_PRT("manufacturer specific data(len:%d)", - device_info->manufacturer_data_len); - printf("data ["); - for (i = 0; i < device_info->manufacturer_data_len; i++) - printf("%02x ", device_info->manufacturer_data[i]); - printf("]\n"); - } - printf("\n"); - - return true; -} - -static bool __bt_adapter_profile_connected_devices_cb( - const char *remote_address, void *user_data) -{ - TC_PRT("remote_address: %s", remote_address); - - return true; -} - -static void __bt_adapter_device_discovery_state_changed_cb( - int result, bt_adapter_device_discovery_state_e discovery_state, - bt_adapter_device_discovery_info_s *discovery_info, - void *user_data) -{ - int i; - - TC_PRT("discovery_state: %d", discovery_state); - - if (discovery_info == NULL) { - TC_PRT("No discovery_info!"); - return; - } - - TC_PRT("remote_address: %s", discovery_info->remote_address); - TC_PRT("remote_name: %s", discovery_info->remote_name); - TC_PRT("rssi: %d", discovery_info->rssi); - TC_PRT("is_bonded: %d", discovery_info->is_bonded); - TC_PRT("service 0x%x, major 0x%x, minor 0x%x", discovery_info->bt_class.major_service_class_mask, - discovery_info->bt_class.major_device_class, - discovery_info->bt_class.minor_device_class); - TC_PRT("service_count: %d", discovery_info->service_count); - - if (discovery_info->service_uuid == NULL) { - TC_PRT("No uuids"); - } else { - for (i = 0; i < discovery_info->service_count; i++) - TC_PRT("uuid: %s", discovery_info->service_uuid[i]); - } - - if (discovery_info->manufacturer_data_len > 0) { - TC_PRT("manufacturer specific data(len:%d)", - discovery_info->manufacturer_data_len); - printf("data ["); - for (i = 0; i < discovery_info->manufacturer_data_len; i++) - printf("%02x ", discovery_info->manufacturer_data[i]); - printf("]\n"); - } -} - -static GSList *le_scan_list; -gint __bt_compare_address(gpointer *a, gpointer *b) -{ - bt_adapter_le_device_scan_result_info_s *info = (bt_adapter_le_device_scan_result_info_s *)a; - char *address = (char *)b; - return g_strcmp0(info->remote_address, address); -} - -static void __bt_adapter_le_scan_result_cb( - int result, bt_adapter_le_device_scan_result_info_s *info, - void *user_data) -{ - int i; - bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; - bt_adapter_le_device_scan_result_info_s *adv_info; - - if (info == NULL) { - TC_PRT("No discovery_info!"); - return; - } - - TC_PRT(" "); - TC_PRT("%s Adv %d Scan resp %d RSSI %d Addr_type %d", - info->remote_address, info->adv_data_len, - info->scan_data_len, info->rssi, - info->address_type); - - if (info->adv_data_len > 31 || info->scan_data_len > 31) { - TC_PRT("###################"); - bt_adapter_le_stop_scan(); - TC_PRT("###################"); - return; - } - - GSList *l = NULL; - l = g_slist_find_custom(le_scan_list, info->remote_address, - (GCompareFunc)__bt_compare_address); - if (l == NULL) { - adv_info = g_malloc0(sizeof(bt_adapter_le_device_scan_result_info_s)); - adv_info->remote_address= g_strdup(info->remote_address); - adv_info->rssi = info->rssi; - le_scan_list = g_slist_append(le_scan_list, adv_info); - } else { - adv_info = l->data; - adv_info->rssi = info->rssi; - } - - for (i = 0; i < 2; i++) { - char **uuids; - char *device_name; - int tx_power_level; - bt_adapter_le_service_data_s *data_list; - int appearance; - int manufacturer_id; - char *manufacturer_data; - int manufacturer_data_len; - int count; - bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; - - pkt_type += i; - if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING - && info->adv_data == NULL) continue; - if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE - && info->scan_data == NULL) break; - - if (bt_adapter_le_get_scan_result_service_uuids( - info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) { - TC_PRT("UUID[%d] = %s", i + 1, uuids[i]); - g_free(uuids[i]); - } - g_free(uuids); - } - if (bt_adapter_le_get_scan_result_device_name( - info, pkt_type, &device_name) == BT_ERROR_NONE) { - TC_PRT("Device name = %s", device_name); - if (adv_info->adv_data == NULL) - adv_info->adv_data= g_strdup(device_name); - g_free(device_name); - } - if (bt_adapter_le_get_scan_result_tx_power_level( - info, pkt_type, &tx_power_level) == BT_ERROR_NONE) { - TC_PRT("TX Power level = %d", tx_power_level); - } - if (bt_adapter_le_get_scan_result_service_solicitation_uuids( - info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) { - TC_PRT("Solicitation UUID[%d] = %s", - i + 1, uuids[i]); - g_free(uuids[i]); - } - g_free(uuids); - } - if (bt_adapter_le_get_scan_result_service_data_list( - info, pkt_type, &data_list, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) - TC_PRT("Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", - i + 1, data_list[i].service_uuid[0], - data_list[i].service_uuid[1], - data_list[i].service_data[0]); - bt_adapter_le_free_service_data_list(data_list, count); - } - if (bt_adapter_le_get_scan_result_appearance( - info, pkt_type, &appearance) == BT_ERROR_NONE) { - TC_PRT("Appearance = %d", appearance); - } - if (bt_adapter_le_get_scan_result_manufacturer_data( - info, pkt_type, &manufacturer_id, &manufacturer_data, - &manufacturer_data_len) == BT_ERROR_NONE) { - - if (manufacturer_data_len > 1) { - TC_PRT("Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]", - manufacturer_id, manufacturer_data[0], - manufacturer_data[1], manufacturer_data_len); - } else { - TC_PRT("Manufacturer data[ID:%.4X, len:%d]", manufacturer_id, manufacturer_data_len); - } - - g_free(manufacturer_data); - } - if (bt_adapter_le_get_scan_result_ibeacon_report(info, pkt_type, - &ibeacon_info) == BT_ERROR_NONE) { - TC_PRT("APPLE IBEACON"); - TC_PRT("Company_id: %d", ibeacon_info->company_id); - TC_PRT("ibeacon_type: %d", ibeacon_info->ibeacon_type); - TC_PRT("uuid: %s", ibeacon_info->uuid); - TC_PRT("major_id: %d", ibeacon_info->major_id); - TC_PRT("minor_id: %d", ibeacon_info->minor_id); - TC_PRT("measured_power: %d", ibeacon_info->measured_power); - bt_adapter_le_free_ibeacon_report(ibeacon_info); - } - } -} - -static void __print_gatt_handler(bt_gatt_h gatt_handle) -{ - if (!gatt_handle) { - TC_PRT("Invalid handler"); - return; - } - - char *type; - char *role; - bt_gatt_common_s *handle = (bt_gatt_common_s *)gatt_handle; - - if (handle->type == BT_GATT_TYPE_SERVICE) - type = g_strdup("Service"); - else if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) - type = g_strdup("Characteristic"); - else if (handle->type == BT_GATT_TYPE_DESCRIPTOR) - type = g_strdup("Descriptor"); - else - type = g_strdup("Unknown"); - - if (handle->role == BT_GATT_ROLE_SERVER) - role = g_strdup("Server"); - else if (handle->role == BT_GATT_ROLE_CLIENT) - role = g_strdup("Client"); - else - role = g_strdup("Unknown"); - - TC_PRT("GATT %s [%s]", type, role); - TC_PRT("%s [%s]", handle->path, handle->uuid); - - g_free(type); - g_free(role); -} - -void __bt_gatt_server_read_value_requested_cb( - const char *remote_address, int request_id, - bt_gatt_server_h server, bt_gatt_h gatt_handle, - int offset, void *user_data) -{ - char char_value_1[3] = {0, 1, 2}; - int resp_status = BT_ATT_ERROR_NONE; - - __print_gatt_handler(gatt_handle); - TC_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); - printf("\n"); - - /* Get the attribute new values here */ - bt_gatt_server_send_response(request_id, - BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, offset, - resp_status, char_value_1, 3 - offset); -} - -void __bt_gatt_server_notification_state_change_cb(bool notify, - bt_gatt_server_h server, bt_gatt_h gatt_handle, - void *user_data) -{ - __print_gatt_handler(gatt_handle); - TC_PRT("Notification %s [%d]", notify ? "enabled" : "disabled", notify); - TC_PRT("server %s", (char *)server); - printf("\n\n"); -} - -static void __bt_adapter_le_advertising_state_changed_cb(int result, - bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, - void *user_data) -{ - TC_PRT("Result : %d", result); - TC_PRT("Advertiser : %p", advertiser); - TC_PRT("Advertising %s [%d]", - adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? - "started" : "stopped", adv_state); -} - -static void __bt_adapter_le_advertising_state_changed_cb_2(int result, - bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, - void *user_data) -{ - TC_PRT("Result : %d", result); - TC_PRT("Advertiser : %p", advertiser); - TC_PRT("Advertising %s [%d]", - adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? - "started" : "stopped", adv_state); -} - -static void __bt_adapter_le_advertising_state_changed_cb_3(int result, - bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, - void *user_data) -{ - TC_PRT("Result : %d", result); - TC_PRT("Advertiser : %p", advertiser); - TC_PRT("Advertising %s [%d]", - adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? - "started" : "stopped", adv_state); -} - -static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, - void *user_data) -{ - TC_PRT("+"); - - if (data == NULL) { - TC_PRT("No received data!"); - return; - } - - TC_PRT("Socket fd: %d", data->socket_fd); - TC_PRT("Data: %s", data->data); - TC_PRT("Size: %d", data->data_size); -} - -static void __bt_hid_device_data_received_cb(const bt_hid_device_received_data_s *data, - void *user_data) -{ - TC_PRT("+"); - char val = 0x01; - int ret = 0; - static char hidmode = 0x01; - if (data == NULL) { - TC_PRT("No received data"); - return; - } - TC_PRT("Address: %s", data->address); - TC_PRT("Type: %d", data->header_type); - TC_PRT("Param_type: %d", data->param_type); - - switch (data->header_type) { - case BT_HID_HEADER_HANDSHAKE: - TC_PRT("HANDSHAKE data"); - break; - case BT_HID_HEADER_HID_CONTROL: - TC_PRT("HID Control data"); - ret = bt_hid_device_disconnect(remote_addr); - TC_PRT("ret %d", ret); - break; - case BT_HID_HEADER_GET_REPORT: - TC_PRT("GET_REPORT data"); - TC_PRT("ReportId %d", data->data[1]); - - if (data->data[1] == 0x02) { - bt_hid_key_data_s send_data; - /* Will send character 'a' */ - char pressedkey[8] = { 4, 0, 0, 0, 0, 0, 0, 0 }; - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_GET_REPORT, - BT_HID_PARAM_DATA_RTYPE_INPUT, - (const char *)&send_data, - sizeof(send_data)); - } else if (data->data[1] == 0x01) { - TC_PRT("Send Mouse Event"); - bt_hid_mouse_data_s send_data; - - send_data.buttons = 1; - send_data.padding = BT_HID_MOUSE_BUTTON_NONE; - - send_data.axis_x = 10; - send_data.axis_y = 0; - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_GET_REPORT, - BT_HID_PARAM_DATA_RTYPE_INPUT, - (const char *)&send_data, - sizeof(send_data)); - } else { - TC_PRT("Invalid ReportId"); - val = BT_HID_HANDSHAKE_ERR_INVALID_REPORT_ID; - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_HANDSHAKE, - BT_HID_PARAM_DATA_RTYPE_INPUT, - &val, sizeof(val)); - } - TC_PRT("ret %d", ret); - break; - case BT_HID_HEADER_SET_REPORT: - TC_PRT("SET_REPORT data"); - val = BT_HID_HANDSHAKE_SUCCESSFUL; - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_HANDSHAKE, - BT_HID_PARAM_DATA_RTYPE_INPUT, - &val, sizeof(val)); - TC_PRT("ret %d", ret); - break; - case BT_HID_HEADER_DATA: - TC_PRT("TRANs DATA"); - break; - case BT_HID_HEADER_GET_PROTOCOL: - TC_PRT("GET PROTOCOL %x", hidmode); - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_GET_PROTOCOL, - BT_HID_PARAM_DATA_RTYPE_INPUT, - &hidmode, sizeof(hidmode)); - TC_PRT("ret %d", ret); - break; - case BT_HID_HEADER_SET_PROTOCOL: - TC_PRT("SET PROTOCOL"); - val = BT_HID_HANDSHAKE_SUCCESSFUL; - - if (data->data[0] & 0x01) { - TC_PRT("HID Report mode set"); - hidmode = 0x01; - } else { - TC_PRT("HID Boot mode set"); - hidmode = 0x00; - } - ret = bt_hid_device_reply_to_report(remote_addr, - BT_HID_HEADER_HANDSHAKE, - BT_HID_PARAM_DATA_RTYPE_INPUT, - &val, sizeof(val)); - TC_PRT("ret %d", ret); - break; - default: - TC_PRT("Unkonw"); - break; - } - - switch (data->param_type) { - case BT_HID_PARAM_DATA_RTYPE_INPUT: - TC_PRT("Input Report"); - break; - case BT_HID_PARAM_DATA_RTYPE_OUTPUT: - TC_PRT("Output Report"); - break; - } -} - -static void __bt_socket_connection_requested_cb(int socket_fd, - const char *remote_address, void *user_data) -{ - TC_PRT("Socket fd: %d", socket_fd); - TC_PRT("remote_address: %s", remote_address); -} - -static void __bt_socket_connection_state_changed_cb(int result, - bt_socket_connection_state_e connection_state, - bt_socket_connection_s *connection, - void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("connection_state: %d", connection_state); - - if (connection == NULL) { - TC_PRT("No connection data!"); - return; - } - - TC_PRT("socket fd: %d", connection->socket_fd); - TC_PRT("server socket fd: %d", connection->server_fd); - TC_PRT("role: %d", connection->local_role); - TC_PRT("remote address: %s", connection->remote_address); - if (strcmp(spp_uuid, connection->service_uuid) == 0) { - TC_PRT("service_uuid: %s", spp_uuid); - client_fd = connection->socket_fd; - } else { - TC_PRT("service_uuid: %s", connection->service_uuid); - custom_client_fd = connection->socket_fd; - } -} - -static void __bt_adapter_le_state_changed_cb(int result, - bt_adapter_le_state_e adapter_le_state, void *user_data) -{ - TC_PRT("__bt_adapter_le_state_changed_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("state: %s", - (adapter_le_state == BT_ADAPTER_LE_ENABLED) ? - "ENABLED" : "DISABLED"); -} - -static void __bt_le_set_data_length_changed_cb(int result, - const char *remote_address, int max_tx_octets, - int max_tx_time, int max_rx_octets, - int max_rx_time, void *user_data) -{ - TC_PRT("__bt_le_set_data_length_changed_cb \n"); - TC_PRT("max_tx_octets: %d max_tx_time: %d" - "max_rx_octets: %d max_rx_time: %d", - max_tx_octets, max_tx_time, - max_rx_octets, max_rx_time); - TC_PRT("result: %s", __bt_get_error_message(result)); -} - -void __bt_opp_client_push_responded_cb(int result, - const char *remote_address, void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("remote_address: %s", remote_address); -} - -void __bt_opp_client_push_progress_cb(const char *file, - long long size, int percent, void *user_data) -{ - TC_PRT("size: %ld", (long)size); - TC_PRT("percent: %d", percent); - TC_PRT("file: %s", file); -} - -void __bt_opp_client_push_finished_cb(int result, - const char *remote_address, void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("remote_address: %s", remote_address); -} - -void __bt_audio_connection_state_changed_cb(int result, - bool connected, const char *remote_address, - bt_audio_profile_type_e type, void *user_data) -{ - TC_PRT("result [%s]", __bt_get_error_message(result)); - TC_PRT("connected [%d]", connected); - TC_PRT("address [%s]", remote_address); - TC_PRT("type [%d]", type); -} - -void __bt_audio_absolute_volume_changed_cb(unsigned int volume, void *user_data) -{ - TC_PRT("volume [%d]", volume); -} - -void __bt_audio_avc_status_changed_cb(bool activated, void *user_data) -{ - TC_PRT("activated [%d]", activated); -} - -void __bt_ag_sco_state_changed_cb(int result, - bool opened, void *user_data) -{ - TC_PRT("result [%s]", __bt_get_error_message(result)); - TC_PRT("opened [%s]", opened ? "YES" : "NO"); -} - -void __bt_ag_speaker_gain_changed_cb(int gain, void *user_data) -{ - TC_PRT("gain [%d]", gain); -} - -void __bt_ag_microphone_gain_changed_cb(int gain, void *user_data) -{ - TC_PRT("gain [%d]", gain); -} - -void __bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_e event, - unsigned int call_id, void *user_data) -{ - TC_PRT("event[%d] call_id[%d]", event, call_id); -} - -void __bt_device_authorization_changed_cb(bt_device_authorization_e authorization, - char *remote_address, void *user_data) -{ - TC_PRT("__bt_device_authorization_changed_cb [%d]", authorization); - TC_PRT("address: %s", remote_address); -} - -void __bt_device_profile_trusted_cb(int result, char *remote_address, - int trusted_profile, bool supported, - bool trusted, void *user_data) -{ - TC_PRT("result [%s]", __bt_get_error_message(result)); - TC_PRT("trusted profile [%d]", trusted_profile); - TC_PRT("Is supported [%d]", supported); - TC_PRT("Is trusted [%d]", trusted); - TC_PRT("address: %s", remote_address); -} - -void __bt_device_connection_state_changed_cb(bool connected, - bt_device_connection_info_s *conn_info, void *user_data) -{ - TC_PRT("__bt_device_connection_state_changed_cb [%d]", connected); - TC_PRT("address [%s]", conn_info->remote_address); - TC_PRT("link type [%d]", conn_info->link); - if (!connected) { - int rssi; - TC_PRT("disconnection reason [%d]", conn_info->disconn_reason); - if (bt_device_get_link_loss_rssi(&rssi) == BT_ERROR_NONE) - TC_PRT("RSSI = %d", rssi); - } -} - -void __bt_device_att_mtu_changed_cb(int result, bt_device_att_mtu_info_s *mtu_info, void *user_data) -{ - TC_PRT("__bt_device_att_mtu_changed_cb"); - - if (result != BT_ERROR_NONE) { - TC_PRT("Callback: Request ATT MTU failed."); - TC_PRT("result: %s", __bt_get_error_message(result)); - } - - if (mtu_info) { - TC_PRT("status [%d]", mtu_info->status); - TC_PRT("address [%s]", mtu_info->remote_address); - TC_PRT("MTU [%d]", mtu_info->mtu); - } -} - -bool __bt_device_connected_profile(bt_profile_e profile, void *user_data) -{ - TC_PRT("__bt_device_connected_profile [0x%04x]", profile); - return true; -} - -void __bt_device_bond_created_cb(int result, - bt_device_info_s *device_info, void *user_data) -{ - if (result == BT_ERROR_NONE) { - TC_PRT("Callback: A bond is created."); - TC_PRT("Callback: The number of service - %d.", - device_info->service_count); - TC_PRT("Callback: class : %d %d %d", (int)device_info->bt_class.major_device_class, device_info->bt_class.minor_device_class, device_info->bt_class.major_service_class_mask); - - int i = 0; - for (i = 0; i < device_info->service_count; i++) { - TC_PRT("Callback: service[%d] - %s", - i+1, device_info->service_uuid[i]); - } - TC_PRT("Callback: is_bonded - %d.", - device_info->is_bonded); - TC_PRT("Callback: is_connected - %d.", - device_info->is_connected); - - if (device_info->manufacturer_data_len > 0) { - TC_PRT("manufacturer specific data(len:%d)", - device_info->manufacturer_data_len); - printf("data ["); - for (i = 0; i < device_info->manufacturer_data_len; i++) - printf("%02x ", device_info->manufacturer_data[i]); - printf("]\n"); - } - } else { - TC_PRT("Callback: Creating a bond is failed."); - TC_PRT("result: %s", __bt_get_error_message(result)); - } -} - -void __bt_device_bond_destroyed_cb(int result, - char *remote_address, void *user_data) -{ - if (result == BT_ERROR_NONE) { - TC_PRT("Callback: A bond is destroyed."); - TC_PRT("Callback: Address - %s.", remote_address); - } else { - TC_PRT("Callback: Destroying a bond is failed."); - TC_PRT("result: %s", __bt_get_error_message(result)); - } -} - -void __bt_print_repeat_test_summary(void) -{ - static struct timeval current_time = {0,}; - static struct timeval diff_time = {0,}; - int time_diff; - - gettimeofday(¤t_time, NULL); - - diff_time.tv_sec = current_time.tv_sec - check_time.tv_sec; - diff_time.tv_usec = current_time.tv_usec - check_time.tv_usec; - if (diff_time.tv_usec < 0) { - diff_time.tv_sec = diff_time.tv_sec - 1; - diff_time.tv_usec = diff_time.tv_usec + 1000000; - } - time_diff = (diff_time.tv_sec * 1000); - time_diff += diff_time.tv_usec / 1000; - - TC_PRT("try: %d, success: %d, fail: %d, time(%d msec)\n", - bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, - time_diff); - - total_time += time_diff; -} - -void __bt_print_repeat_test_final_summary() -{ - TC_PRT("try: %d, success: %d, fail: %d," - "Total_time(%d msec), Average_time(%d msec)\n", - bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, - total_time, total_time / bt_onoff_cnt); -} - -void __bt_gatt_connection_state_changed_cb(int result, - bool connected, const char *remote_address, void *user_data) -{ - if (result != BT_ERROR_NONE) - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (connected) { - TC_PRT("GATT connected [%s]", remote_address); - strncpy(remote_addr, remote_address, strlen(remote_addr)); - - bt_le_conn_update_s param; - - param.interval_min = 90; - param.interval_max = 90; - param.latency = 0; - param.time_out = 2000; - bt_device_le_conn_update(remote_addr, ¶m); - } else { - TC_PRT("GATT DISconnected [%s]", remote_address); - } -} - -void __bt_hps_connection_state_changed_cb(int result, - bool connected, const char *remote_address, void *user_data) -{ - int ret; - if (result != BT_ERROR_NONE) - TC_PRT("result: %s", __bt_get_error_message(result)); - - if (connected) { - TC_PRT("HPS connected [%s]", remote_address); - /* Fix : STRING_OVERFLOW */ - strncpy(remote_addr, remote_address, strlen(remote_addr)); - if (hps_client) { - bt_gatt_client_destroy(hps_client); - hps_client = NULL; - } - ret = bt_gatt_client_create(remote_addr, &hps_client); - TC_PRT("returns bt_gatt_client_create %s\n", - __bt_get_error_message(ret)); - - } else { - TC_PRT("HPS DISconnected [%s]", remote_address); - } -} - -void __bt_gatt_client_service_changed_cb(bt_gatt_client_h c, - bt_gatt_client_service_change_type_e type, - const char *uuid, void *user_data) -{ - char *addr = NULL; - char *svc = NULL; - int ret; - - ret = bt_gatt_client_get_remote_address(client, &addr); - if (ret != BT_ERROR_NONE) - TC_PRT("Cannot get remote address"); - - ret = bt_get_uuid_name(uuid, &svc); - if (ret != BT_ERROR_NONE) - svc = g_strdup(uuid); - - TC_PRT("Remote device [%s] : %s is %s", addr, svc, - type == BT_GATT_CLIENT_SERVICE_ADDED ? - "Added" : "Removed"); - g_free(svc); - g_free(addr); -} - -void __bt_gatt_client_att_mtu_changed_cb(bt_gatt_client_h c, const bt_gatt_client_att_mtu_info_s *mtu_info, void *user_data) -{ - char *addr = NULL; - int ret; - - TC_PRT("__bt_gatt_client_att_mtu_changed_cb"); - - ret = bt_gatt_client_get_remote_address(client, &addr); - if (ret != BT_ERROR_NONE) { - TC_PRT("Cannot get remote address"); - return; - } - - if (mtu_info) { - TC_PRT("status [%d]", mtu_info->status); - TC_PRT("address [%s]", mtu_info->remote_address); - TC_PRT("MTU [%d]", mtu_info->mtu); - } - - g_free(addr); -} - -int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h) -{ - int ret; - int s_val; - unsigned int u_val; - char *buf; - int len; - - if (strcasecmp(type, "int8") == 0) { - s_val = atoi(value); - buf = (char *)&s_val; - len = 1; - } else if (strcasecmp(type, "int16") == 0) { - s_val = atoi(value); - buf = (char *)&s_val; - len = 2; - } else if (strcasecmp(type, "int32") == 0) { - s_val = atoi(value); - buf = (char *)&s_val; - len = 4; - } else if (strcasecmp(type, "uint8") == 0) { - u_val = strtoul(value, NULL, 10); - buf = (char *)&u_val; - len = 1; - } else if (strcasecmp(type, "uint16") == 0) { - u_val = strtoul(value, NULL, 10); - buf = (char *)&u_val; - len = 2; - } else if (strcasecmp(type, "uint32") == 0) { - u_val = strtoul(value, NULL, 10); - buf = (char *)&u_val; - len = 4; - } else if (strcasecmp(type, "str") == 0) { - buf = value; - len = strlen(buf); - } else - return BT_ERROR_INVALID_PARAMETER; - - ret = bt_gatt_set_value(h, buf, len); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_set_value is failed : %d", ret); - - return ret; -} - -void __bt_gatt_client_print_value(bt_gatt_h h) -{ - int ret; - char *str = NULL; - char *value = NULL; - int len = 0; - bool hex_format = false; - int i; - - ret = bt_gatt_get_value(h, &value, &len); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_get_value is failed : %d", ret); - return; - } - - for (i = 0; i < len; i++) - if (isalnum(value[i]) == 0) { - hex_format = true; - break; - } - - if (hex_format) { - str = g_malloc0(len * 5 + 1); - for (i = 0; i < len; i++) { - if (i > 0) - str[i * 5 - 1] = ' '; - - snprintf(&str[i * 5], 5, "0x%02X", value[i]); - } - } else { - str = g_malloc0(len + 1); - memcpy(str, value, len); - } - - TC_PRT("Value : %s", str); - - g_free(str); - g_free(value); -} - -bool __bt_gatt_print_info_cb(int total, - int index, bt_gatt_h gatt_handle, void *user_data) -{ - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(gatt_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("[%d / %d] %s (%s)", - index, total, - str ? str : "Unknown", uuid); - - g_free(str); - g_free(uuid); - - return true; -} - -void __bt_gatt_client_write_complete_cb(int result, - bt_gatt_h gatt_handle, void *data) -{ - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(gatt_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("Write %s for %s (%s)", - result == BT_ATT_ERROR_NONE ? "Success" : "Fail", - str ? str : "Unknown", uuid); - - g_free(str); - g_free(uuid); - - return; -} - -void __bt_gatt_client_read_complete_cb(int result, - bt_gatt_h gatt_handle, void *data) -{ - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(gatt_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("Read %s for %s (%s)", - result == BT_ATT_ERROR_NONE ? "Success" : "Fail", - str ? str : "Unknown", uuid); - - g_free(str); - g_free(uuid); - - if (result != BT_ATT_ERROR_NONE) - return; - - __bt_gatt_client_print_value(gatt_handle); - - return; -} - -bool __bt_gatt_client_foreach_desc_cb(int total, - int index, bt_gatt_h desc_handle, void *data) -{ - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(desc_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("\t\t[%d / %d] %s (%s)", - index, total, - str ? str : "Unknown", uuid); - __bt_gatt_client_print_value(desc_handle); - - g_free(str); - g_free(uuid); - - return true; -} - -bool __bt_gatt_client_foreach_chr_cb(int total, - int index, bt_gatt_h chr_handle, void *data) -{ - int ret; - char *uuid = NULL; - char *str = NULL; - int properties = 0; - - bt_gatt_get_uuid(chr_handle, &uuid); - bt_get_uuid_name(uuid, &str); - bt_gatt_characteristic_get_properties(chr_handle, &properties); - - TC_PRT("\t[%d / %d] %s (%s) (0x%X)", index, total, str ? str : "Unknown", uuid, properties); - __bt_gatt_client_print_value(chr_handle); - - g_free(str); - g_free(uuid); - - ret = bt_gatt_characteristic_foreach_descriptors(chr_handle, - __bt_gatt_client_foreach_desc_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_characteristic_foreach_descriptors is failed : %d", ret); - - return true; -} - -bool __bt_gatt_client_foreach_svc_cb(int total, - int index, bt_gatt_h svc_handle, void *data) -{ -#ifdef ARCH64 - int test_id = (int)(uintptr_t) data; -#else - int test_id = (int)data; -#endif - int ret; - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(svc_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("[%d / %d] %s (%s)", - index, total, - str ? str : "Unknown", uuid); - - g_free(str); - g_free(uuid); - - if (test_id == BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL) { -#ifdef ARCH64 - ret = bt_gatt_service_foreach_characteristics(svc_handle, - __bt_gatt_client_foreach_chr_cb, (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_service_foreach_characteristics(svc_handle, - __bt_gatt_client_foreach_chr_cb, (void *)test_id); -#endif - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret); - } - - return true; -} - -bool __bt_hps_client_svc_cb(int total, - int index, bt_gatt_h svc_handle, void *data) -{ -#ifdef ARCH64 - int test_id = (int) (uintptr_t) data; -#else - int test_id = (int)data; -#endif - int ret; - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(svc_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - if (!g_strcmp0(uuid, HPS_UUID)) { - - TC_PRT("[%d / %d] %s (%s)", - index, total, - str ? str : "Unknown", uuid); - - if (test_id == BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL) { -#ifdef ARCH64 - ret = bt_gatt_service_foreach_characteristics(svc_handle, - __bt_gatt_client_foreach_chr_cb, - (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_service_foreach_characteristics(svc_handle, - __bt_gatt_client_foreach_chr_cb, - (void *)test_id); -#endif - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret); - } - } - - g_free(str); - g_free(uuid); - return true; -} - -static void __ancs_write_completed_cb(int result, - bt_gatt_h request_handle, void *user_data) -{ - if (result != BT_ERROR_NONE) { - TC_PRT("write request is failed : %d", result); - return; - } - - TC_PRT("write request is done"); - - return; -} - -static int __ancs_write_value_to_control_point(bt_gatt_client_h client, - char *value, int len) -{ - bt_gatt_h ancs_svc = NULL; - bt_gatt_h control_point = NULL; - char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; - char *chr_uuid = "69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9"; - int ret; - - ret = bt_gatt_client_get_service(client, - svc_uuid, &ancs_svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - return ret; - } - - ret = bt_gatt_service_get_characteristic(ancs_svc, - chr_uuid, &control_point); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed"); - return ret; - } - - ret = bt_gatt_characteristic_set_write_type(control_point, - BT_GATT_WRITE_TYPE_WRITE); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_characteristic_set_write_type is failed : %d", ret); - return ret; - } - - ret = bt_gatt_set_value(control_point, value, len); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - return ret; - } - - ret = bt_gatt_client_write_value(control_point, - __ancs_write_completed_cb, NULL); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - return ret; - } - - return ret; -} - -void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, - char *value, int len, void *user_data) -{ - char *uuid = NULL; - int i; - - bt_gatt_get_uuid(chr, &uuid); - - TC_PRT("Value changed for [%s]", uuid); - TC_PRT("len [%d]", len); - for (i = 0; i < len; i++) - TC_PRT("value %u", value[i]); - - g_free(uuid); - - return; -} -void __bt_hrp_heart_rate_value_changed_cb(bt_gatt_h chr, - unsigned short hr_value, void *user_data) -{ - char *uuid = NULL; - - bt_gatt_get_uuid(chr, &uuid); - - TC_PRT("Value changed for [%s]", uuid); - TC_PRT("Value [%d]", hr_value); - - g_free(uuid); - - return; -} - -void __bt_HP_client_cp_req_status_changed_cb(bt_gatt_h chr, - char *value, int len, void *user_data) -{ - char *uuid = NULL; - int i; - - bt_gatt_get_uuid(chr, &uuid); - - TC_PRT("Value changed for [%s]", uuid); - TC_PRT("len [%d]", len); - for (i = 0; i < len; i++) - TC_PRT("value %u", value[i]); - - g_free(uuid); - - return; -} - -void __bt_proximity_reporter_property_changed_cb(int result, const char *remote_address, - int service_type, int prop_value, void *user_data) -{ - TC_PRT("reporter_property result [%s]", __bt_get_error_message(result)); - TC_PRT("remote_address : %s", remote_address); - TC_PRT("service_type : %d", service_type); - TC_PRT("prop_value : %d", prop_value); -} - -void __bt_proximity_monitor_connection_state_changed_cb(int result, const char *remote_address, - bt_proximity_monitor_h monitor_s, bool connected, int supported_service, void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - if (connected) { - TC_PRT("PXP connected(address = %s)", remote_address); - TC_PRT("PXP Reporter supported Service\n"); - if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT) - TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n"); - if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT) - TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n"); - if (supported_service & BT_PROXIMITY_TX_POWER) - TC_PRT("BT_PROXIMITY_TX_POWER"); - } else { - TC_PRT("PXP DISconnected"); - } - } -} - -void __bt_proximity_reporter_connection_state_changed_cb(int result, const char *remote_address, - bt_proximity_reporter_h reporter_s, bool connected, int supported_service, void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - if (connected) { - TC_PRT("PXP connected(address = %s)", remote_address); - TC_PRT("PXP Reporter supported Service\n"); - if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT) - TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n"); - if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT) - TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n"); - if (supported_service & BT_PROXIMITY_TX_POWER) - TC_PRT("BT_PROXIMITY_TX_POWER"); - } else { - TC_PRT("PXP DISconnected"); - } - } -} - -void __tds_activation_req_cb(char *rem_bd_addr, - bt_tds_transport_e transport, unsigned char *buf, int len, void *user_data) -{ - int i; - - TC_PRT("remote_address : %s", rem_bd_addr); - TC_PRT("transport : %d", transport); - for (i = 0; i < len; i++) - TC_PRT("Act req data[%d] : %.2x", i, buf[i]); - - g_free(tds_act_address); - tds_act_address = g_strdup(rem_bd_addr); -} - -void __bt_gatt_server_att_mtu_changed_cb(bt_gatt_server_h s, const bt_gatt_server_att_mtu_info_s *mtu_info, void *user_data) -{ - TC_PRT("__bt_gatt_server_att_mtu_changed_cb"); - - if (mtu_info) { - TC_PRT("status [%d]", mtu_info->status); - TC_PRT("address [%s]", mtu_info->remote_address); - TC_PRT("MTU [%d]", mtu_info->mtu); - } - -} - -void __bt_gatt_server_notification_sent_cb(int result, - const char *remote_address, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void *user_data) -{ - TC_PRT("result [%s]", __bt_get_error_message(result)); - TC_PRT("remote_address : %s", remote_address); - TC_PRT("completed : %d", completed); - TC_PRT("characteristic : %p", characteristic); -} - -void __bt_gatt_server_write_value_requested_cb(const char *remote_address, - int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, bool response_needed, int offset, - const char *value, int len, void *user_data) -{ - int i, resp_status = BT_ATT_ERROR_NONE; - - __print_gatt_handler(gatt_handle); - TC_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", - remote_address, request_id, response_needed, offset, len); - - for (i = 0; i < len; i++) - printf("%d ", value[i]); - - bt_gatt_server_send_response(request_id, - BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE, offset, - resp_status, NULL, 0); - - printf("\n"); -} - -bool __bt_gatt_server_foreach_svc_cb(int total, - int index, bt_gatt_h svc_handle, void *data) -{ - char *uuid = NULL; - char *str = NULL; - - bt_gatt_get_uuid(svc_handle, &uuid); - bt_get_uuid_name(uuid, &str); - - TC_PRT("[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid); - - g_free(str); - g_free(uuid); - - return true; -} - -void __bt_gatt_char_write_cb(void *user_data) -{ - TC_PRT("__bt_gatt_char_write_cb"); - return; -} - -void __bt_gatt_char_read_cb(unsigned char *value, - int value_length, void *user_data) -{ - int i; - - TC_PRT("__bt_gatt_char_read_cb"); - - TC_PRT("value_length %d", value_length); - - for (i = 0; i < value_length; i++) - TC_PRT("value %u", value[i]); - - return; -} - -void __bt_avrcp_target_connection_state_changed_cb(bool connected, - const char *remote_address, void *user_data) -{ - TC_PRT("__bt_avrcp_target_connection_state_changed_cb"); - TC_PRT("connected %d", connected); - TC_PRT("remote_address %s", remote_address); -} - -void __bt_avrcp_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, - void *user_data) -{ - TC_PRT("__bt_avrcp_equalizer_state_changed_cb"); - TC_PRT("equalizer %d (1: OFF, 2: ON)", equalizer); -} - -void __bt_avrcp_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, - void *user_data) -{ - TC_PRT("__bt_avrcp_repeat_mode_changed_cb"); - TC_PRT("repeat %d (1: OFF, 2: SINGLE, 3: All, 4:GROUP)", repeat); -} - -void __bt_avrcp_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, - void *user_data) -{ - TC_PRT("__bt_avrcp_shuffle_mode_changed_cb"); - TC_PRT("shuffle -> %d (1: OFF, 2: All TRACK, 3:GROUP)", shuffle); -} - -void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, - void *user_data) -{ - TC_PRT("__bt_avrcp_scan_mode_changed_cb"); - TC_PRT("scan -> %d", scan); -} - -void __bt_avrcp_control_connection_state_changed_cb(bool connected, - const char *remote_address, void *user_data) -{ - TC_PRT("__bt_avrcp_target_connection_state_changed_cb"); - TC_PRT("connected %d", connected); - TC_PRT("remote_address %s", remote_address); -} - -void __bt_avrcp_song_position_changed_cb(unsigned int postion, - void *user_data) -{ - TC_PRT("__bt_avrcp_song_position_changed_cb"); - TC_PRT("Position %d", postion); -} - -void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, - void *user_data) -{ - TC_PRT("__bt_avrcp_player_state_changed_cb"); - TC_PRT("Player state -> %d (0: stopped, 1: Playing, 2:Paused, 3:FF, 4:REW)", state); -} - -void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, - void *user_data) -{ - TC_PRT("__bt_avrcp_track_info_changed_cb"); - TC_PRT("title %s", metadata->title); - TC_PRT("artist %s", metadata->artist); - TC_PRT("album %s", metadata->album); - TC_PRT("genre %s", metadata->genre); - TC_PRT("total_tracks %d", metadata->total_tracks); - TC_PRT("number %d", metadata->number); - TC_PRT("duration %d", metadata->duration); -} - -void panu_conn_state_changed(int result, bool connected, - const char *remote_address, bt_panu_service_type_e type, - void *user_data) -{ - TC_PRT("result [%s]", __bt_get_error_message(result)); - TC_PRT("connected [%d]", connected); - TC_PRT("address [%s]", remote_address); - TC_PRT("type [%d]", type); - -} - -void __bt_hid_host_connection_state_changed_cb(int result, - bool connected, const char *remote_address, - void *user_data) -{ - TC_PRT("__bt_hid_host_connection_state_changed_cb: called"); - TC_PRT("result: %s", __bt_get_error_message(result)); -} - -void __bt_hdp_connected_cb(int result, const char *remote_address, - const char *app_id, bt_hdp_channel_type_e type, - unsigned int channel, void *user_data) -{ - TC_PRT("__bt_hdp_connected_cb: called"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("remote_address: %s", remote_address); - TC_PRT("app_id: %s", app_id); - TC_PRT("type: %x", type); - TC_PRT("channel: %d", channel); - - channel_hdp = channel; -} - -void __bt_hdp_disconnected_cb(int result, const char *remote_address, - unsigned int channel, void *user_data) -{ - TC_PRT("__bt_hdp_connected_cb: called"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("remote_address: %s", remote_address); - TC_PRT("channel: %d", channel); - - channel_hdp = channel; -} - -void __bt_hdp_data_received_cb(unsigned int channel, const char *data, - unsigned int size, void *user_data) -{ - TC_PRT("__bt_hdp_data_received_cb: called"); - TC_PRT("data: %s", data); - TC_PRT("size: %d", size); - TC_PRT("channel: %d", channel); -} - -void __bt_hid_device_connection_state_changed_cb(int result, - bool connected, const char *remote_address, void *user_data) -{ - TC_PRT("__bt_hid_device_connection_state_changed_cb:"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("Remote Address %s", remote_address); - TC_PRT("Connected %d", connected); -} - -void __bt_ipsp_init_state_changed_cb(int result, - bool ipsp_initialized, void *user_data) -{ - TC_PRT("result: %s", __bt_get_error_message(result)); - if (ipsp_initialized) { - TC_PRT("IPSP Init state: INITIALIZED"); - } else { - TC_PRT("IPSP Init state: UN-INITIALIZED"); - _bt_unset_cb(BT_EVENT_IPSP_INIT_STATE_CHANGED); - } -} - -void __bt_ipsp_connection_state_changed_cb(int result, - bool connected, const char *remote_address, const char *iface_name, void *user_data) -{ - TC_PRT("__bt_le_ipsp_connection_state_changed_cb: called"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("Connected: %d", connected); - TC_PRT("Remote BT address : %s", remote_address); - if (connected) - TC_PRT("Local BT Interface : %s is Up", iface_name); - else - TC_PRT("Local BT Interface : %s is Down", iface_name); - strncpy(ipsp_iface_name, iface_name, sizeof(ipsp_iface_name)); - ipsp_iface_name[sizeof(ipsp_iface_name) - 1] = '\0'; -} - -void __bt_hf_sco_state_changed_cb(int result, - bool opened, void *user_data) -{ - TC_PRT("opened [%s]", opened ? "YES" : "NO"); -} - -void __bt_hf_set_call_handling_event_cb(bt_hf_call_handling_event_e event, - char *phone_number, void *user_data) -{ - switch (event) { - case BT_HF_CALL_HANDLING_EVENT_ANSWER: - TC_PRT("[call_handling_event_cb] event [ANSWER]"); - break; - case BT_HF_CALL_HANDLING_EVENT_RELEASE: - TC_PRT("[call_handling_event_cb] event [RELEASE]"); - break; - case BT_HF_CALL_HANDLING_EVENT_REJECT: - TC_PRT("[call_handling_event_cb] event [REJECT]"); - break; - case BT_HF_CALL_HANDLING_EVENT_RING: - TC_PRT("[call_handling_event_cb] event [RING]"); - break; - case BT_HF_CALL_HANDLING_EVENT_CALL_STARTED: - TC_PRT("[call_handling_event_cb] event [CALL_STARTED]"); - break; - case BT_HF_CALL_HANDLING_EVENT_CALL_ENDED: - TC_PRT("[call_handling_event_cb] event [CALL_ENDED]"); - break; - case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_ENABLED: - TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_ENABLED]"); - break; - case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_DISABLED: - TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_DISABLED]"); - break; - case BT_HF_CALL_HANDLING_EVENT_WAITING: - TC_PRT("[call_handling_event_cb] event [WAITING]"); - break; - case BT_HF_CALL_HANDLING_EVENT_HELD: - TC_PRT("[call_handling_event_cb] event [HELD]"); - break; - case BT_HF_CALL_HANDLING_EVENT_UNHELD: - TC_PRT("[call_handling_event_cb] event [UNHELD]"); - break; - case BT_HF_CALL_HANDLING_EVENT_SWAPPED: - TC_PRT("[call_handling_event_cb] event [SWAPPED]"); - break; - default: - TC_PRT("[call_handling_event_cb] event [UNKNOWN]"); - } - - TC_PRT("[call_handling_event_cb] phone_number [%s]", - phone_number); -} - -void __bt_hf_call_status_updated_event_cb(GSList *call_info_list, - void *user_data) -{ - TC_PRT("[call_status_updated_event_cb]"); - for (; call_info_list; call_info_list = g_slist_next(call_info_list)) { - bt_hf_call_status_info_s *call_info = call_info_list->data; - TC_PRT(" > Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]", - call_info->number, call_info->direction, - call_info->status, call_info->multi_party, - call_info->index); - } - - bt_hf_free_call_status_info_list(call_info_list); -} - -void __bt_hf_speaker_gain_changed_cb(int gain, - void *user_data) -{ - TC_PRT("__bt_hf_speaker_gain_changed_cb"); - TC_PRT("Gain= %d", gain); -} - -void __bt_pbap_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) -{ - TC_PRT("__bt_pbap_connection_state_changed_cb"); - TC_PRT("Result: %d", result); - TC_PRT("Remote Device: %s", remote_address); - TC_PRT("Connected Status: %d", connected); -} - -void __bt_pbap_phonebook_size_cb(int result, const char *remote_address, - int size, void *user_data) -{ - TC_PRT("__bt_pbap_phonebook_size_cb"); - TC_PRT("Result: %d", result); - TC_PRT("Remote Device: %s", remote_address); - TC_PRT("Phonebook Size: %d", size); -} - -void __bt_pbap_phonebook_pull_cb(int result, const char *remote_address, - const char *vcf_file, void *user_data) -{ - TC_PRT("__bt_pbap_phonebook_pull_cb"); - TC_PRT("Result: %d", result); - TC_PRT("Remote Device: %s", remote_address); - TC_PRT("Phonebook Download File: %s", vcf_file); - TC_PRT("Phonebook Download Status: %s", - (result == BT_ERROR_NONE) ? "Successful" : "Unsuccessful"); -} - -void __bt_pbap_vcard_list_cb(int result, const char *remote_address, - const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data) -{ - int i; - - TC_PRT("__bt_pbap_vcard_list_cb"); - TC_PRT("Result: %d", result); - TC_PRT("Remote Device: %s", remote_address); - TC_PRT("vCard Count: %d", count); - - for (i = 0; i < count; i++) - TC_PRT("vCard[%d]: %s", vcard_info[i].index, vcard_info[i].contact_name); - - TC_PRT("Listing Status: %s", - (result == BT_ERROR_NONE) ? "Successful" : "Unsuccessful"); -} - -void __bt_repeat_test_adapter_state_changed_cb(int result, - bt_adapter_state_e adapter_state, void *user_data) -{ - unsigned int delay = *(unsigned int *)user_data; - - TC_PRT("__bt_repeat_test_adapter_state_changed_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - TC_PRT("state: %s, delay(%dsec)", - (adapter_state == BT_ADAPTER_ENABLED) ? - "ENABLED" : "DISABLED", delay); - - __bt_print_repeat_test_summary(); - - if (result != BT_ERROR_NONE) { - char *argv[] = {NULL}; - - TC_PRT("make dump\n"); - execv("all_log_dump.sh", argv); - - bt_onoff_cnt_fail++; - } else { - bt_onoff_cnt_success++; - - if (delay) - sleep(delay); - } - - gettimeofday(&check_time, NULL); - if (adapter_state == BT_ADAPTER_DISABLED) - bt_adapter_enable(); - else - bt_adapter_disable(); - - bt_onoff_cnt++; -} - -/* TDS Seeker Callbacks */ -static void __bt_tds_provider_scan_result_cb(int result, const char *remote_address, - bt_tds_transport_block_list_s *info, bt_adapter_le_device_scan_result_info_s *scan_info, - void *user_data) -{ - int k; - int l; - TC_PRT("__bt_tds_provider_scan_result_cb"); - TC_PRT("result: %s", __bt_get_error_message(result)); - - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - TC_PRT("Number of Transport Block [%d]", info->num_transport_block); - - if (result == BT_ERROR_NONE) { - for (k = 0; k < info->num_transport_block; k++) { - TC_PRT("Block Num[%d] Transport Name [%d]", k+1, info->data[k]->transport); - TC_PRT("Block Num[%d] Transport state [%d]", k+1, info->data[k]->state); - TC_PRT("Block Num[%d] Is Data complete [%d]", k+1, info->data[k]->is_data_complete); - TC_PRT("Block Num[%d] Length of TDS Block data [%d]", k+1, info->data[k]->length); - - for (l = 0; l < info->data[k]->length; l++) - TC_PRT("Transport Specific data [%d] = [0x%x]", l, info->data[k]->data[l]); - } - } -} - -static void __bt_tds_seeker_connection_state_changed_cb(int result, const char *remote_address, - bt_tds_seeker_h seeker, bool connected, void *user_data) -{ - TC_PRT("Result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - if (connected) - TC_PRT("TDS Seeker connected(address = %s)", remote_address); - else - TC_PRT("TDS Seeker Disconnected (address = %s)", remote_address); - } else - BT_ERR("TDS Connection failed!"); -} - -static void __bt_hrp_collector_connection_state_changed_cb(int result, const char *remote_address, - bt_hrp_collector_h seeker, bool connected, void *user_data) -{ - TC_PRT("Result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - if (connected) - TC_PRT("HRP Collector connected(address = %s)", remote_address); - else - TC_PRT("HRP Collector Disconnected (address = %s)", remote_address); - } else - BT_ERR("HRP Collection Connection failed!"); -} - - -static void __bt_tds_seeker_complete_transport_data_cb(int result, const char *remote_address, - bt_tds_transport_block_list_s *info, void *user_data) -{ - int k; - int l; - TC_PRT("__bt_tds_seeker_complete_transport_data_cb"); - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - - if (result == BT_ERROR_NONE) { - TC_PRT("Number of Transport Block [%d]", info->num_transport_block); - for (k = 0; k < info->num_transport_block; k++) { - TC_PRT("Block Num[%d] Transport Name [%d]", k+1, info->data[k]->transport); - TC_PRT("Block Num[%d] Transport state [%d]", k+1, info->data[k]->state); - TC_PRT("Block Num[%d] Is Data complete [%d]", k+1, info->data[k]->is_data_complete); - TC_PRT("Block Num[%d] Length of TDS Block data [%d]", k+1, info->data[k]->length); - - for (l = 0; l < info->data[k]->length; l++) - TC_PRT("Transport Specific data [%d] = [0x%x]", l, info->data[k]->data[l]); - } - } else - BT_ERR("TDS Data receive request failed!"); -} - -static void __bt_tds_control_point_activation_result_cb(int result, const char *remote_address, - unsigned char *data, int length, void *user_data) -{ - int k; - TC_PRT("__bt_tds_control_point_activation_result_cb"); - TC_PRT("Result [%d]", result); - TC_PRT("Address[%s]", remote_address); - - if (result == BT_ERROR_NONE) { - TC_PRT("Data length [%d]", length); - for (k = 0; k < length; k++) - TC_PRT("Data[%d] [0x%x]", k, data[k]); - } -} - -void __bt_otp_server_state_changed_cb(int result, bool status) -{ - TC_PRT("__bt_otp_server_state_changed_cb"); - TC_PRT("Result: %d", result); - TC_PRT("Server Status: %s", status ? "enabled" : "disabled"); -} - -static void __bt_otp_client_connection_state_changed_cb(int result, const char *remote_address, - bt_otp_client_h otp_client, bool connected, void *user_data) -{ - TC_PRT("Result: %s", __bt_get_error_message(result)); - if (result == BT_ERROR_NONE) { - if (connected) - TC_PRT("OTP Client connected(address = %s)", remote_address); - else - TC_PRT("OTP Client Disconnected (address = %s)", remote_address); - } else - BT_ERR("OTP Connection failed!"); -} - -static void __bt_otp_client_object_discovery_cb(int result, const char *remote_address, - bt_otp_object_list_s *obj_list, void *user_data) -{ - int k; - TC_PRT("__bt_otp_client_object_discovery_cb"); - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - - if (result == BT_ERROR_NONE) { - TC_PRT("Number of Objects [%d]", obj_list->num_objects); - - for (k = 0; k < obj_list->num_objects; k++) - TC_PRT("Object[%d] Id: [%llu] Name: [%s]", k+1, obj_list->data[k]->id, obj_list->data[k]->name); - - } else { - BT_ERR("Object discovery failed!"); - } -} - -static void __bt_otp_client_object_select_cb(int result, const char *remote_address, - unsigned long long obj_id, void *user_data) -{ - TC_PRT("__bt_otp_client_object_select_cb"); - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - - if (result == BT_ERROR_NONE) - TC_PRT("Object selected successfully! Current object[%llu]", obj_id); - else - BT_ERR("Object selection failed! Current object[%llu]", obj_id); -} - -static void __bt_otp_client_read_object_complete_cb(int result, const char *remote_address, - char *file_path, void *user_data) -{ - if (result == BT_ERROR_NONE) - TC_PRT("Read object success!, File location [%s]", file_path); - else - BT_ERR("Read object failed!"); -} - -static void __bt_otp_client_object_create_cb(int result, const char *remote_address, - unsigned long long obj_id, void *user_data) -{ - if (result == BT_ERROR_NONE) - TC_PRT("Object[%llu] created successfully in remote server!", obj_id); - else - BT_ERR("Object creation failed!"); -} - -static void __bt_otp_client_object_write_cb(int result, const char *remote_address, - unsigned int length, void *user_data) -{ - if (result == BT_ERROR_NONE) - TC_PRT("Object write success!, [%u] bytes written", length); - else - BT_ERR("Object write failed!, [%u] bytes written", length); -} - -static void __bt_otp_client_object_execute_cb(int result, const char *remote_address, - unsigned long long obj_id, void *user_data) -{ - TC_PRT("__bt_otp_client_object_execute_cb"); - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - - if (result == BT_ERROR_NONE) - TC_PRT("Object[%llu] launched successfully!", obj_id); - else - BT_ERR("Object[%llu] launch failed!", obj_id); -} - -static void __bt_otp_client_object_delete_cb(int result, const char *remote_address, - unsigned long long obj_id, void *user_data) -{ - TC_PRT("__bt_otp_client_object_delete_cb"); - TC_PRT("Result: %s", __bt_get_error_message(result)); - TC_PRT("Remote addr [%s]", remote_address); - - if (result == BT_ERROR_NONE) - TC_PRT("Object[%llu] deleted successfully!", obj_id); - else - BT_ERR("Object[%llu] delete failed!", obj_id); -} - -void __bt_gatt_client_read_request_completed_cb(int result, - bt_gatt_h request_handle, void *user_data) -{ - TC_PRT("[HR]Result : %d", result); -} - -void __bt_gatt_client_write_request_completed_cb(int result, - bt_gatt_h request_handle, void *user_data) -{ - TC_PRT("[HR]Result : %d", result); -} - -void _bt_hrp_collector_bsl_read_completed_cb(int result, - bt_hrp_collector_h request_handle, bt_body_sensor_location_e location, void *user_data) -{ - TC_PRT("[HR]Result : %d", result); - TC_PRT("[HR]request_handle : %p", request_handle); - TC_PRT("[HR]location [%d]", location); - -} - -static void __bt_initialize_all(void) -{ - int ret; - TC_PRT("Initialize and set callback functions"); - - ret = bt_initialize(); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_set_state_changed_cb( - __bt_adapter_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_set_connectable_changed_cb( - __bt_adapter_connectable_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_device_set_bond_created_cb( - __bt_device_bond_created_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_device_set_bond_destroyed_cb( - __bt_device_bond_destroyed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_device_set_connection_state_changed_cb( - __bt_device_connection_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_device_set_att_mtu_changed_cb( - __bt_device_att_mtu_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_gatt_set_connection_state_changed_cb( - __bt_gatt_connection_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_set_device_discovery_state_changed_cb( - __bt_adapter_device_discovery_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - if (TIZEN_PROFILE_WEARABLE_IVI) { - ret = bt_pbap_client_set_connection_state_changed_cb(__bt_pbap_connection_state_changed_cb, - NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - ret = bt_socket_set_connection_state_changed_cb( - __bt_socket_connection_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_le_set_state_changed_cb( - __bt_adapter_le_state_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - return; -} - -int test_set_params(int test_id, char *param) -{ - static int param_index = 0; - const char *param_type = NULL; - int param_count = 0; - - if (param_index > 0 && param_index == g_test_param.param_count) - goto done; - - switch (current_tc_table) { - case BT_UNIT_TEST_TABLE_ADAPTER: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: - param_count = 1; - TC_PRT("Input param(%d) (non-discoverable: -1, always: 0, limited-discoverable(time): N)", param_index + 1); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: - param_count = 5; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_ADAPTER_LE: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: - param_count = 1; - TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE: - param_count = 1; - TC_PRT("Scan type\n (0 : Passive, 1: Active)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED: - param_count = 2; - switch (param_index) { - case 0: - TC_PRT("Input Scan Interval (Unit : ms)"); - break; - case 1: - TC_PRT("Input Scan Window (Unit : ms)"); - break; - } - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS: - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME: - param_count = 1; - TC_PRT("Input data for LE scan filter"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: - param_count = 1; - TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS"); - TC_PRT("\t (Default scan response : Service Data &Local name & Manufacturer data)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: - param_count = 1; - TC_PRT("Input mode \n (0 : Balanced(500 ms), 1 : Low Latency(150 ms), 2 : Low Energy (1000 ms))"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: - param_count = 1; - TC_PRT("Input filter_policy \n (0 : No use White List, 1 : Allow scan, 2 : Allow conneciton, 3 : Allow scan & conneciton)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: - param_count = 1; - TC_PRT("Input adv type \n (0 : Non-connectable (ADV_SCAN_IND), 1 : Connectable (ADV_IND) "); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER: - param_count = 1; - TC_PRT("Input adv Tx power level \n ( 1 ~ -127 dBm) "); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: - param_count = 1; - TC_PRT("Input adv slot id \n (Default is 0, Maximum is 2) "); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA: - param_count = 4; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - switch (param_index) { - case 0: - TC_PRT("Remote address"); - break; - case 1: - TC_PRT("Address type (0 : Public, 1 : Random"); - break; - case 2: - TC_PRT("confirmation"); - break; - case 3: - TC_PRT("random"); - break; - } - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_DEVICE: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: - case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: - param_count = 1; - TC_PRT("Input param(%d) mode (0 : balanced, 1 : low latency, 2 : low power) ", param_index + 1); - break; - case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION: - param_count = 4; - switch (param_index) { - case 0: - TC_PRT("Input interval min (8 ~ 4000)"); - break; - case 1: - TC_PRT("Input interval max (8 ~ 4000)"); - break; - case 2: - TC_PRT("Input slave latency ( 0 ~ 499)"); - break; - case 3: - TC_PRT("Input supervision timeout ( 100 ~ 32000)"); - break; - } - break; - case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: - param_count = 1; - param_type = "int(1, 2, 10, ...., 512)"; - TC_PRT("Input param(%d) : %s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: - param_count = 2; - switch (param_index) { - case 0: - TC_PRT("Input max octets (27 ~ 251)"); - break; - case 1: - TC_PRT("Input max time (328 ~ 2120)"); - break; - } - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_SOCKET: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: - case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: - case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_OPP: { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_AUDIO: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: - case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: - case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: - case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_PAN: { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_GATT: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { - param_count = 3; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - case 2: - TC_PRT("Input write_type (0 : no response, 1 : with reponse, 2 : signed)"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { - param_count = 3; - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - case 2: - TC_PRT("Input Descriptor UUID or nothing"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: { - param_count = 5; - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - case 2: - TC_PRT("Input Descriptor UUID or nothing"); - break; - case 3: - TC_PRT("Input Value Type (avail. : uint8, uint16, uint32, int8, int16, int32, str)"); - break; - case 4: - TC_PRT("Input Value"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: { - param_count = 2; - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: { - param_count = 2; - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: - case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: - case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING: { - param_count = 2; - switch (param_index) { - case 0: - TC_PRT("Input buffer_threshold (1 ~ 32767)"); - break; - case 1: - TC_PRT("Input timeout (1 ~ 32767)"); - break; - } - break; - } - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_HPS: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { - param_count = 1; - TC_PRT("Input Value Type (avail. : \n1.HTTP_GET, \n2.HTTP_HEAD, \ - \n3.HTTP_POST, \n4.HTTP_PUT, \n5.HTTP_DELETE, \ - \n6.HTTPS_GET, \n7.HTTPS_HEAD, \n8.HTTPS_POST, \ - \n9.HTTPS_PUT, \n10.HTTPS_DELETE, \n11.HTTP_CANCEL"); - break; - } - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_DPM: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: - param_count = 1; - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_HANDSFREE_ONLY, \n2.BT_DPM_BT_RESTRICTED"); - break; - - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: - case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: - param_count = 1; - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); - break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: - param_count = 1; - TC_PRT("Input device Address"); - break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: - param_count = 1; - TC_PRT("Input UUID"); - break; - case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: - param_count = 2; - switch (param_index) { - case 0: - TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ - \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ - \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ - \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ - \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ - \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ - \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ - \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ - \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ - \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); - break; - case 1: - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); - break; - } - break; - case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: - param_count = 1; - TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ - \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ - \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ - \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ - \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ - \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ - \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ - \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ - \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ - \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); - - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_PXP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: - param_count = 1; - TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH"); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_AVRCP: { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_HID: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: - param_count = 1; - TC_PRT("Select TV control mode (1 : Vol Up, 2 : Vol Down, 3 : CH Up, 4 : CH Down) : "); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_IPSP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: - param_count = 1; - TC_PRT("IPSP Client : Input IPSP App server's IPv6 address to connect :"); - break; - case BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA: { - param_count = 2; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - - switch (param_index) { - case 0: - TC_PRT("IPSP : Input current role of Application[Server[0] / Client[1] :"); - break; - case 1: - TC_PRT("IPSP : input data to send :"); - break; - } - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: - param_count = 1; - TC_PRT("IPSP : Input current role of Application[Server[0]/Client[1] :"); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_HDP: { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_HF: - { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_PBAP_CLIENT: - if (!TIZEN_PROFILE_WEARABLE_IVI) - goto __default__; - { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_ETC: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT: - param_count = 1; - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - TC_PRT("Input launch-type string(ex. setting, headset, hid)"); - break; - case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: - param_count = 1; - TC_PRT("Input feature string(ex. tizen.org/feature/network.bluetooth)"); - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_OTP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: - param_count = 1; - TC_PRT("Input Value in string"); - break; - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: - param_count = 1; - TC_PRT("Input Value in uint64_t"); - break; - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: - param_count = 4; - - switch (param_index) { - case 0: - TC_PRT("Input file path"); - break; - case 1: - TC_PRT("Input offset"); - break; - case 2: - TC_PRT("Input Length"); - break; - case 3: - TC_PRT("Input mode"); - break; - } - break; - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } -__default__: - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - -done: - if (need_to_set_params) { - if (param_index == 0) { - g_test_param.param_count = param_count; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - /* Remove new line character */ - param[len - 1] = '\0'; - g_test_param.params[param_index - 1] = g_strdup(param); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - param_index++; - } - - return 0; -} - -int test_input_callback(void *data) -{ - int ret = 0; -#ifdef ARCH64 - int test_id = (uintptr_t)data; -#else - int test_id = (int)data; -#endif - - switch (current_tc_table) { - case BT_UNIT_TEST_TABLE_MAIN: { - switch (test_id) { - case 0x00ff: - TC_PRT("Finished"); - g_main_loop_quit(main_loop); - break; - - case BT_UNIT_TEST_FUNCTION_INITIALIZE: - ret = bt_initialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DEINITIALIZE: - ret = bt_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_ADAPTER: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE: { - bt_adapter_state_e state = BT_ADAPTER_DISABLED; - - ret = bt_adapter_get_state(&state); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("state: %d", state); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE: - ret = bt_adapter_enable(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE: - ret = bt_adapter_disable(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER: - ret = bt_adapter_recover(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY: - ret = bt_adapter_start_device_discovery(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY: - ret = bt_adapter_stop_device_discovery(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING: { - bool is_discovering = FALSE; - ret = bt_adapter_is_discovering(&is_discovering); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - else - TC_PRT("is_discovering: %d", is_discovering); - - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE: { - ret = bt_adapter_foreach_bonded_device( - __bt_adapter_bonded_device_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES: { - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_SPP, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("SPP connected devices returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_HFP_HF, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("HFP HF connected devices returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SOURCE, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("A2DP Source connected devices returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SINK, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("A2DP Sink connected devices returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_AVRCP_CONTROL, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("AVRCP Control connected devices returns %s\n", __bt_get_error_message(ret)); - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_AVRCP_TARGET, - __bt_adapter_profile_connected_devices_cb, NULL); - TC_PRT("AVRCP Target connected devices returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO: { - bt_device_info_s *device_info = NULL; - int i; - char *str = NULL; - - ret = bt_adapter_get_bonded_device_info(remote_addr, - &device_info); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - if (device_info) { - TC_PRT("address: %s", device_info->remote_address); - TC_PRT("name: %s", device_info->remote_name); - TC_PRT("is_connected: %d", device_info->is_connected); - TC_PRT("is_authorized: %d", device_info->is_authorized); - TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask, - device_info->bt_class.major_device_class, - device_info->bt_class.minor_device_class); - - TC_PRT("service_count: %d", device_info->service_count); - if (device_info->service_uuid == NULL) { - TC_PRT("No uuids"); - } else { - for (i = 0; i < device_info->service_count; i++) { - bt_get_uuid_name(device_info->service_uuid[i], &str); - - TC_PRT("[%d / %d] %s (%s)", i, device_info->service_count, - str ? str : "Unknown", device_info->service_uuid[i]); - g_free(str); - } - } - - if (device_info->manufacturer_data_len > 0) { - TC_PRT("manufacturer specific data(len:%d)", - device_info->manufacturer_data_len); - printf("data ["); - for (i = 0; i < device_info->manufacturer_data_len; i++) - printf("%02x ", device_info->manufacturer_data[i]); - printf("]\n"); - } - printf("\n"); - } - - bt_adapter_free_device_info(device_info); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED: { - bool used = FALSE; - - ret = bt_adapter_is_service_used(opp_uuid, &used); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("used: %d", used); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY: { - bt_adapter_visibility_mode_e visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; - int time = 0; - - ret = bt_adapter_get_visibility(&visibility_mode, &time); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("mode: %d", visibility_mode); - TC_PRT("time: %d", time); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: { - int mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; - int timeout_sec = 0; - - if (g_test_param.param_count > 0) { - if (g_test_param.params[0][0] == '-') - mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; - else if (g_test_param.params[0][0] == '0') - mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; - else { - mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE; - timeout_sec = atoi(g_test_param.params[0]); - } - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_set_visibility(mode, timeout_sec); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB: - ret = bt_adapter_set_device_discovery_state_changed_cb( - __bt_adapter_device_discovery_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB: - ret = bt_adapter_unset_device_discovery_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA: { - ret = bt_adapter_get_local_oob_data(&hash, &randomizer, - &hash_len, &rand_len); - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("hash = [%s]", hash); - TC_PRT("randomizer = [%s]", randomizer); - } - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA: { - ret = bt_adapter_set_remote_oob_data(remote_addr, hash, - randomizer, hash_len, rand_len); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA: { - unsigned char *data[4]; - int len[4]; - int i; - - ret = bt_adapter_get_local_oob_ext_data( - &data[0], &data[1], &len[0], &len[1], - &data[2], &data[3], &len[2], &len[3]); - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - for (i = 0; i < 4; i++) { - int j; - - printf("Data[%d] : ", i); - - for (j = 0; j < len[i]; j++) - printf("%02x", data[i][j]); - - printf("\n"); - - g_free(data[i]); - } - } - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO: { - bt_battery_info_s battery_data; - memset(&battery_data, 0, sizeof(bt_battery_info_s)); - ret = bt_adapter_read_battery_info(&battery_data); - if (ret < 0) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("Battery data: %ld %ld %d %d", battery_data.session_start_time, - battery_data.session_end_time, battery_data.session_scan_time, battery_data.session_connected_time); - - TC_PRT("Tx time [%d], Rx time [%d], Idle time [%d]", battery_data.tx_time, - battery_data.rx_time, battery_data.idle_time); - - if(battery_data.atm_list == NULL) { - TC_PRT("No data transaction in this session"); - break; - } - - TC_PRT("Displaying app-wise transaction details"); - for (GSList *l = battery_data.atm_list; l != NULL; l = g_slist_next(l)) { - bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data); - TC_PRT("uid: %ld, pid: %ld, received bytes: %d, sent bytes: %d, time: %u", - (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time); - } - } - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR: { - int ret = bt_adapter_init_battery_monitor(__bt_adapter_disable_battery_cb, NULL); - if (ret == BLUETOOTH_ERROR_NONE) - TC_PRT("Battery monitor initialized and activated"); - else - TC_PRT("Battery monitor could not be initialized and activated"); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR: { - int ret = bt_adapter_deinit_battery_monitor(); - if (ret == BLUETOOTH_ERROR_NONE) - TC_PRT("Battery monitor deinitialized successfully"); - else - TC_PRT("Battery monitor could not be deinitialized"); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: { - char remote_addr[18]; - unsigned char *param_data[4]; - int len[4]; - int i; - char tmp[3]; - long val; - - if (g_test_param.param_count != 5) { - TC_PRT("Input parameter first!"); - break; - } - - g_strlcpy(remote_addr, g_test_param.params[0], - sizeof(remote_addr)); - - for (i = 0; i < 4; i++) { - len[i] = strlen(g_test_param.params[i + 1]) / 2; - param_data[i] = g_malloc0(len[i]); - } - - for (i = 0; i < 4; i++) { - int j; - - printf("param_data[%d] : ", i); - for (j = 0; j < len[i]; j++) { - g_strlcpy(tmp, g_test_param.params[i + 1] + 2 * j, sizeof(tmp)); - val = strtol(tmp, NULL, 16); - param_data[i][j] = val; - printf("%02x", param_data[i][j]); - } - printf("\n"); - } - - ret = bt_adapter_set_remote_oob_ext_data(remote_addr, - param_data[0], param_data[1], len[0], len[1], - param_data[2], param_data[3], len[2], len[3]); - - __bt_free_test_param(&g_test_param); - - for (i = 0; i < 4; i++) - g_free(param_data[i]); - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA: { - ret = bt_adapter_remove_remote_oob_data(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB: - ret = bt_adapter_set_visibility_mode_changed_cb( - __bt_adapter_device_visibility_mode_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB: - ret = bt_adapter_unset_visibility_mode_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB: - ret = bt_adapter_set_visibility_duration_changed_cb( - __bt_adapter_device_visibility_duration_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB: - ret = bt_adapter_unset_visibility_duration_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB: { - ret = bt_adapter_set_connectable_changed_cb( - __bt_adapter_connectable_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB: { - ret = bt_adapter_unset_connectable_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE: { - bool connectable = false; - - ret = bt_adapter_get_connectable(&connectable); - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - TC_PRT("%s", connectable ? "Connectable" : "Non-connectable"); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: { - bool connectable = false; - - bt_adapter_get_connectable(&connectable); - - if (g_test_param.param_count > 0) { - if (g_strrstr(g_test_param.params[0], "true")) - connectable = true; - else - connectable = false; - - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_set_connectable(!connectable); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION: { - char *version = NULL; - - ret = bt_adapter_get_version(&version); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - else { - TC_PRT("Version: [%s]", version); - g_free(version); - } - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO: { - char *chipset = NULL; - char *firmware = NULL; - char *stack_version = NULL; - char *profiles = NULL; - - ret = bt_adapter_get_local_info(&chipset, &firmware, - &stack_version, &profiles); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - else { - TC_PRT("Local info: [%s, %s, %s]", chipset, firmware, stack_version); - TC_PRT("Local info(Profiles):\n%s", profiles); - g_free(chipset); - g_free(firmware); - g_free(stack_version); - g_free(profiles); - } - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB: - { - ret = bt_adapter_set_manufacturer_data_changed_cb( - __bt_adapter_manufacturer_data_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB: - ret = bt_adapter_unset_manufacturer_data_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA: - { - char param_data[20] = {0x03, 0xFF, 0x01, 0x02}; - int len = 4; - int i = 0; - - if (g_test_param.param_count > 0) { - len = 0; - for (i = 0; i < (strlen(g_test_param.params[0]) - 1); i += 2) { - if (g_test_param.params[0][i] >= 'A' && g_test_param.params[0][i] <= 'F') - param_data[i/2] = (g_test_param.params[0][i] - 'A' + 0X0A) << 4; - else - param_data[i/2] = (g_test_param.params[0][i] - '0') << 4; - - if (g_test_param.params[0][i+1] >= 'A' && g_test_param.params[0][i+1] <= 'F') - param_data[i/2] += (g_test_param.params[0][i+1] - 'A' + 0X0A); - else - param_data[i/2] += (g_test_param.params[0][i+1] - '0'); - len++; - } - - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_set_manufacturer_data(param_data, len); - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB: - { - ret = bt_adapter_set_authentication_req_cb( - __bt_adapter_authentication_req_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW: - { - ret = bt_adapter_set_authentication_request_cb( - __bt_adapter_authentication_request_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB: - { - ret = bt_adapter_unset_authentication_req_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW: - { - ret = bt_adapter_unset_authentication_request_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT: - { - char *passkey = NULL; - TC_PRT("bt_adapter_passkey_reply: Authenticate Logitech Mouse: reply = Accept"); - passkey = g_strdup("0000"); /* Passkey - "0000" for mouse */ - ret = bt_adapter_passkey_reply(passkey, TRUE); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else - TC_PRT("bt_adapter_passkey_reply: accept authentication result = %d", ret); - g_free(passkey); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL: - { - char *passkey = NULL; - TC_PRT("bt_adapter_passkey_reply: cancel authentication reply"); - passkey = g_strdup("0000"); /* Passkey - "0000" */ - ret = bt_adapter_passkey_reply(passkey, FALSE); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else - TC_PRT("bt_adapter_passkey_reply: Logitech Mouse cancel authentication result = %d", ret); - g_free(passkey); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT: - { - ret = bt_adapter_passkey_confirmation_reply(TRUE); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else - TC_PRT("bt_adapter_passkey_confirmation_reply accept, result = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT: - { - ret = bt_adapter_passkey_confirmation_reply(FALSE); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else - TC_PRT("bt_adapter_passkey_confirmation_reply reject, result = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_ADAPTER_LE: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE: { - bt_adapter_le_state_e le_state = BT_ADAPTER_LE_DISABLED; - - ret = bt_adapter_le_get_state(&le_state); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("le_state: %d", le_state); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE: { - ret = bt_adapter_le_enable(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE: { - ret = bt_adapter_le_disable(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: { - int mode = BT_ADAPTER_LE_SCAN_MODE_BALANCED; - - if (g_test_param.param_count > 0) { - mode = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_scan_mode(mode); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE: { - int type = BT_ADAPTER_LE_PASSIVE_SCAN; - - if (g_test_param.param_count > 0) { - type = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_scan_type(type); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN: { - ret = bt_adapter_le_start_scan( - __bt_adapter_le_scan_result_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN: { - ret = bt_adapter_le_stop_scan(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - GSList *l = NULL; - int cnt = 0; - bt_adapter_le_device_scan_result_info_s *info; - printf("LE scan result :\n"); - for (l = le_scan_list; l != NULL; l = g_slist_next(l)) { - info = l->data; - if (info) { - printf("[%d] %s, %d dBm", ++cnt, info->remote_address, info->rssi); - if (info->adv_data) - printf(", %s", info->adv_data); - printf("\n"); - g_free(info->remote_address); - g_free(info->adv_data); - g_free(info); - } - } - g_slist_free(le_scan_list); - le_scan_list = NULL; - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: { - int adv_data_type = 3; /* default all */ - int manufacturer_id = 117; - char *manufacture = NULL; - char manufacture_0[] = {0x0, 0x0, 0x0, 0x0}; - char manufacture_1[] = {0x01, 0x01, 0x01, 0x01}; - char manufacture_2[] = {0x02, 0x02, 0x02, 0x02}; - char manufacture_3[] = {0x03, 0x03, 0x03, 0x03}; - char service_data[] = {0x01, 0x02, 0x03}; - const char *time_svc_uuid_16 = "1805"; - const char *battery_svc_uuid_16 = "180f"; - const char *heart_rate_svc_uuid_16 = "180d"; - const char *lmmediate_alert_svc_uuid_16 = "1802"; - const char *ancs_uuid_128 = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; - const char *ams_uuid_128 = "89D3502B-0F36-433A-8EF4-C502AD55F8DC"; - int appearance = 192; /* 192 is generic watch */ - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } else { - ret = bt_adapter_le_clear_advertising_data(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING); - if (ret != BT_ERROR_NONE) - TC_PRT("clear advertising data [0x%04x]", ret); - ret = bt_adapter_le_clear_advertising_data(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); - if (ret != BT_ERROR_NONE) - TC_PRT("clear scan response data [0x%04x]", ret); - } - - if (g_test_param.param_count > 0) { - adv_data_type = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - switch (adv_data_type) { - case 0: /* service uuid */ - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - manufacture = manufacture_0; - break; - - case 1: /* service solicitation */ - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - manufacture = manufacture_1; - break; - - case 2: /* appearance & tx power level */ - ret = bt_adapter_le_set_advertising_appearance(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); - if (ret != BT_ERROR_NONE) - TC_PRT("add appearance data [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, true); - if (ret != BT_ERROR_NONE) - TC_PRT("add appearance data [0x%04x]", ret); - manufacture = manufacture_2; - break; - - case 3: /* All */ - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_appearance(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); - if (ret != BT_ERROR_NONE) - TC_PRT("add appearance data [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, true); - if (ret != BT_ERROR_NONE) - TC_PRT("add tx_power_level [0x%04x]", ret); - - manufacture = manufacture_3; - break; - - case 4: /* ANCS */ - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, ancs_uuid_128); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) - TC_PRT("set device name [0x%04x]", ret); - - return 0; - - case 5: /* AMS */ - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, ams_uuid_128); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) - TC_PRT("set device name [0x%04x]", ret); - - return 0; - - default: - TC_PRT("No adv data"); - break; - } - - /* Default scsn response data */ - ret = bt_adapter_le_add_advertising_service_data(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, - service_data, sizeof(service_data)); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_data [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) - TC_PRT("set device name [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, - manufacturer_id, - manufacture, sizeof(manufacture_0)); - if (ret != BT_ERROR_NONE) - TC_PRT("add manufacturer data [0x%04x]", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA: { - const char *battery_svc_uuid_16 = "180f"; - const char *hid_svc_uuid_16 = "1812"; - const char *gatt_svc_uuid_16 = "1801"; - int appearance = 192; /* 192 is generic watch */ - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } else { - ret = bt_adapter_le_clear_advertising_data(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING); - if (ret != BT_ERROR_NONE) - TC_PRT("clear advertising data [0x%04x]", ret); - ret = bt_adapter_le_clear_advertising_data(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); - if (ret != BT_ERROR_NONE) - TC_PRT("clear scan response data [0x%04x]", ret); - } - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, hid_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_add_advertising_service_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, gatt_svc_uuid_16); - if (ret != BT_ERROR_NONE) - TC_PRT("add service_uuid [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_appearance(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); - if (ret != BT_ERROR_NONE) - TC_PRT("add appearance data [0x%04x]", ret); - - ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, true); - if (ret != BT_ERROR_NONE) - TC_PRT("add tx_power_level [0x%04x]", ret); - - /* Default scsn response data */ - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) - TC_PRT("set device name [0x%04x]", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: { - int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } - - if (g_test_param.param_count > 0) { - mode = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_advertising_mode(advertiser, mode); - if (ret != BT_ERROR_NONE) - TC_PRT("add scan response data [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: { - int filter_policy = BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_CONN_WL; - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } - - if (g_test_param.param_count > 0) { - filter_policy = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_advertising_filter_policy(advertiser, filter_policy); - if (ret != BT_ERROR_NONE) - TC_PRT("add scan response data [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: { - int type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE; - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } - - if (g_test_param.param_count > 0) { - type = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_advertising_connectable(advertiser, type); - if (ret != BT_ERROR_NONE) - TC_PRT("add scan response data [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER: { - int tx_power_level = 0; - - advertiser = advertiser_list[advertiser_index]; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } - - if (g_test_param.param_count > 0) { - tx_power_level = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_set_advertising_custom_tx_power_level(advertiser, tx_power_level); - if (ret != BT_ERROR_NONE) - TC_PRT("set Tx power level [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW: { - bt_adapter_le_advertising_state_changed_cb cb; - - if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; - else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; - else cb = __bt_adapter_le_advertising_state_changed_cb_3; - - advertiser = advertiser_list[advertiser_index]; - advertiser_index++; - advertiser_index %= 3; - - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - TC_PRT("created le advertiser(%d)", ret); - advertiser_list[advertiser_index] = advertiser; - } - - TC_PRT("advertiser: %p", advertiser); - - ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: { - int slot_id = 0; - - if (g_test_param.param_count > 0) { - slot_id = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - if (slot_id < 0 || - slot_id >= (sizeof(advertiser_list) / sizeof(advertiser_list[0]))) { - TC_PRT("wrong slot_id: %d", slot_id); - break; - } - - advertiser = advertiser_list[slot_id]; - - ret = bt_adapter_le_stop_advertising(advertiser); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST: { - ret = bt_adapter_le_add_white_list(remote_addr, - BT_DEVICE_PUBLIC_ADDRESS); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST: { - ret = bt_adapter_le_remove_white_list(remote_addr, - BT_DEVICE_PUBLIC_ADDRESS); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: { - static bool enable_privacy = false; - - if (enable_privacy == false) - enable_privacy = true; - else - enable_privacy = false; - - if (g_test_param.param_count > 0) { - if (g_strrstr(g_test_param.params[0], "true")) - enable_privacy = true; - else - enable_privacy = false; - - __bt_free_test_param(&g_test_param); - } - - ret = bt_adapter_le_enable_privacy(enable_privacy); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA: { - char *local_address; - bt_device_address_type_e address_type = 0; - unsigned char *confirm; - unsigned char *random; - int confirm_len; - int random_len; - int i; - - bt_adapter_le_get_local_oob_ext_data(&local_address, &address_type, - &confirm, &random, - &confirm_len, &random_len); - - printf("local address : %s\n", local_address); - printf("address type : %d\n", address_type); - printf("confirm : "); - for (i=0; i 0) { - ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } else { - ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, remote_addr); - } - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME: { - bt_scan_filter_h scan_filter; - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - if (g_test_param.param_count > 0) { - ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } else { - ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, "Galaxy"); - } - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID: { - bt_scan_filter_h scan_filter; - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_set_service_uuid(scan_filter, "1805"); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID: { - bt_scan_filter_h scan_filter; - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(scan_filter, "1805"); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA: { - bt_scan_filter_h scan_filter = NULL; - int manufacturer_id = 117; /* samsung */ - char param_data[] = {0x42, 0x04}; - /* Use "appearance & tx power level" of bt_adapter_le_add_XXX_advertising_data */ - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_set_manufacturer_data(scan_filter, - manufacturer_id, param_data, sizeof(param_data)); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA: { - bt_scan_filter_h scan_filter; - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS: { - ret = bt_adapter_le_scan_filter_unregister_all(); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { - - TC_PRT("Testing: Write Host suggested default LE Data length"); - - unsigned int def_tx_octects = 30; - unsigned int def_tx_time = 330; - ret = bt_adapter_le_write_host_suggested_default_data_length( - def_tx_octects, def_tx_time); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { - - TC_PRT("Read host suggested default LE Data length"); - - unsigned int def_tx_octets = 0; - unsigned int def_tx_time = 0; - ret = bt_adapter_le_read_suggested_default_data_length( - &def_tx_octets, &def_tx_time); - TC_PRT("host suggested default le data length values are %d %d", - def_tx_octets, def_tx_time); - break; - } - case BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT: { - - TC_PRT("Check LE 2M PHY Feature support"); - bool is_2m_phy_supported = FALSE; - - ret = bt_adapter_le_is_2m_phy_supported(&is_2m_phy_supported); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("LE 2M PHY Support [%s]", is_2m_phy_supported ? "YES" : "NO"); - break; - } - case BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT: { - - TC_PRT("Check LE CODED PHY Feature support"); - bool is_coded_phy_supported = FALSE; - - ret = bt_adapter_le_is_coded_phy_supported(&is_coded_phy_supported); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("LE CODED PHY Support [%s]", is_coded_phy_supported ? "YES" : "NO"); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_DEVICE: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE: { - ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, TRUE); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE: { - ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, FALSE); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE: { - ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, TRUE); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE: { - ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, FALSE); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB: - ret = bt_device_set_trusted_profile_cb( - __bt_device_profile_trusted_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB: - ret = bt_device_unset_trusted_profile_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE: { - ret = bt_device_set_authorization(remote_addr, BT_DEVICE_AUTHORIZED); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE: { - ret = bt_device_set_authorization(remote_addr, BT_DEVICE_UNAUTHORIZED); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB: - ret = bt_device_set_authorization_changed_cb( - __bt_device_authorization_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB: - ret = bt_device_unset_authorization_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB: - ret = bt_device_set_connection_state_changed_cb( - __bt_device_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB: - ret = bt_device_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES: { - ret = bt_device_foreach_connected_profiles(remote_addr, - __bt_device_connected_profile, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: { - bool connected_status = false; - bt_profile_e profile = BT_PROFILE_HSP; - - if (g_test_param.param_count > 0) { - profile = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_device_is_profile_connected(remote_addr, - profile, &connected_status); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - TC_PRT("Profile [%s]", - connected_status ? "Connected" : "Disconnected"); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB: { - ret = bt_device_set_bond_created_cb( - __bt_device_bond_created_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB: { - ret = bt_device_set_bond_destroyed_cb( - __bt_device_bond_destroyed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT: { - ret = bt_device_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND: { - ret = bt_device_create_bond(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: { - bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE; - - if (g_test_param.param_count > 0) { - link_type = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_device_create_bond_by_type(remote_addr, - link_type); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND: { - ret = bt_device_destroy_bond(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE: { - bool bredr_connected = false; - bool le_connected = false; - - ret = bt_device_get_connection_state(remote_addr, - BT_DEVICE_CONNECTION_LINK_BREDR, - &bredr_connected); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_device_get_connection_state(remote_addr, - BT_DEVICE_CONNECTION_LINK_LE, - &le_connected); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - TC_PRT("BR/EDR [%s], LE [%s]", - bredr_connected ? "Connected" : "Disconnected", - le_connected ? "Connected" : "Disconnected"); - - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: { - unsigned int mtu = 512; /* MAX MTU Value */ - - if (g_test_param.param_count > 0) { - mtu = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_device_request_att_mtu(remote_addr, mtu); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU: { - unsigned int mtu = 0; - ret = bt_device_get_att_mtu(remote_addr, &mtu); - TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB: { - ret = bt_device_set_att_mtu_changed_cb(__bt_device_att_mtu_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB: { - ret = bt_device_unset_att_mtu_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION: { - bt_le_conn_update_s param; - - if (g_test_param.param_count == 0) - break; - - param.interval_min = atof(g_test_param.params[0]); - param.interval_max = atof(g_test_param.params[1]); - param.latency = atoi(g_test_param.params[2]); - param.time_out = atoi(g_test_param.params[3]); - - __bt_free_test_param(&g_test_param); - - ret = bt_device_le_conn_update(remote_addr, ¶m); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: { - - TC_PRT("Set LE Data length paramters cmd"); - - unsigned int tx_octets = 50; - unsigned int tx_time = 500; - - if (g_test_param.param_count > 0) { - tx_octets = atoi(g_test_param.params[0]); - tx_time = atoi(g_test_param.params[1]); - - __bt_free_test_param(&g_test_param); - } - - TC_PRT("settting le data length values tx octects: %d tx time: %d", - tx_octets, tx_time); - ret = bt_device_le_set_data_length(remote_addr, - tx_octets, tx_time); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB: { - - TC_PRT("Setting LE Data length change callback"); - - ret = bt_device_le_set_data_length_change_cb( - __bt_le_set_data_length_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: { - int mode = BT_DEVICE_LE_CONNECTION_MODE_BALANCED; - - if (g_test_param.param_count > 0) { - mode = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - ret = bt_device_update_le_connection_mode(remote_addr, mode); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_SOCKET: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM: { - int socket_fd = 0; - - ret = bt_socket_create_rfcomm(spp_uuid, &socket_fd); - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("socket_fd: %d", socket_fd); - server_fd = socket_fd; - } - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM: - ret = bt_socket_destroy_rfcomm(server_fd); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM: - ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN: - ret = bt_socket_listen(server_fd, 1); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT: { - int socket_fd = 0; - - ret = bt_socket_accept(server_fd); - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("socket_fd: %d", socket_fd); - client_fd = socket_fd; - } - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_REJECT: - ret = bt_socket_reject(server_fd); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM: { - ret = bt_socket_connect_rfcomm(remote_addr, spp_uuid); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM: - ret = bt_socket_disconnect_rfcomm(client_fd); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: { - char data[] = "Sending test"; - - if (g_test_param.param_count > 0) { - ret = bt_socket_send_data(client_fd, - g_test_param.params[0], - strlen(g_test_param.params[0]) + 1); - - __bt_free_test_param(&g_test_param); - } else { - ret = bt_socket_send_data(client_fd, - data, sizeof(data)); - } - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: { - int socket_fd = 0; - - if (g_test_param.param_count > 0) { - ret = bt_socket_create_rfcomm(g_test_param.params[0], &socket_fd); - - __bt_free_test_param(&g_test_param); - } else { - ret = bt_socket_create_rfcomm(custom_uuid, &socket_fd); - } - - if (ret < BT_ERROR_NONE) { - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("socket_fd: %d", socket_fd); - custom_server_fd = socket_fd; - } - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID: - ret = bt_socket_destroy_rfcomm(custom_server_fd); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID: - ret = bt_socket_listen_and_accept_rfcomm(custom_server_fd, 1); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: { - if (g_test_param.param_count > 0) { - ret = bt_socket_connect_rfcomm(remote_addr, g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } else { - ret = bt_socket_connect_rfcomm(remote_addr, custom_uuid); - } - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID: - ret = bt_socket_disconnect_rfcomm(custom_client_fd); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID: { - char param_data[] = "Sending test"; - - if (g_test_param.param_count > 0) { - ret = bt_socket_send_data(custom_client_fd, - g_test_param.params[0], - strlen(g_test_param.params[0]) + 1); - - __bt_free_test_param(&g_test_param); - } else { - ret = bt_socket_send_data(custom_client_fd, - param_data, sizeof(param_data)); - } - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB: - ret = bt_socket_set_data_received_cb( - __bt_socket_data_received_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB: - ret = bt_socket_unset_data_received_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB: - ret = bt_socket_set_connection_requested_cb( - __bt_socket_connection_requested_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB: - ret = bt_socket_unset_connection_requested_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB: - ret = bt_socket_set_connection_state_changed_cb( - __bt_socket_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB: - ret = bt_socket_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_OPP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE: - ret = bt_opp_client_initialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE: - ret = bt_opp_client_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE: - ret = bt_opp_client_add_file("/opt/media/Images/image1.jpg"); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES: - ret = bt_opp_client_clear_files(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES: { - ret = bt_opp_client_push_files(remote_addr, - __bt_opp_client_push_responded_cb, - __bt_opp_client_push_progress_cb, - __bt_opp_client_push_finished_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH: - ret = bt_opp_client_cancel_push(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_AUDIO: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE: - ret = bt_audio_initialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE: - ret = bt_audio_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: { - bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL; - - if (g_test_param.param_count > 0) { - audio_profile = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_audio_connect(remote_addr, audio_profile); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: { - bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL; - - if (g_test_param.param_count > 0) { - audio_profile = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_audio_disconnect(remote_addr, audio_profile); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT: { - bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK; - - if (g_test_param.param_count > 0) { - audio_profile = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_audio_connect(remote_addr, audio_profile); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT: { - bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK; - - if (g_test_param.param_count > 0) { - audio_profile = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_audio_disconnect(remote_addr, audio_profile); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB: - ret = bt_audio_set_connection_state_changed_cb( - __bt_audio_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB: - ret = bt_audio_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO: - ret = bt_ag_open_sco(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO: - ret = bt_ag_close_sco(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED: { - bool opened = false; - ret = bt_ag_is_sco_opened(&opened); - TC_PRT("opend[%s]", opened ? "YES" : "NO"); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB: - ret = bt_ag_set_sco_state_changed_cb( - __bt_ag_sco_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB: - ret = bt_ag_unset_sco_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB: - ret = bt_ag_set_speaker_gain_changed_cb( - __bt_ag_speaker_gain_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB: - ret = bt_ag_unset_speaker_gain_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB: - ret = bt_ag_set_microphone_gain_changed_cb( - __bt_ag_microphone_gain_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB: - ret = bt_ag_unset_microphone_gain_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED: { - bool connected = false; - ret = bt_ag_is_connected(&connected); - TC_PRT("returns %s\n", - connected ? "Connected" : "Disconnected"); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE: { - unsigned int call_id = 1; - - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_IDLE, - call_id, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED: { - unsigned int call_id = 1; - bool sco_required = true; - - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_ANSWERED, - call_id, NULL); - if (sco_required) - bt_ag_open_sco(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: { - unsigned int call_id = 1; - bool sco_required = TRUE; - const char *phone_number; - - if (g_test_param.param_count > 0) { - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_DIALING, - call_id, g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } else { - phone_number = g_strdup("01012345678"); - - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_DIALING, - call_id, phone_number); - } - - if (sco_required) - bt_ag_open_sco(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING: { - unsigned int call_id = 1; - - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_ALERTING, - call_id, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: { - unsigned int call_id = 1; - const char *phone_number; - - if (g_test_param.param_count > 0) { - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_INCOMING, - call_id, g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } else { - phone_number = g_strdup("01012345678"); - - ret = bt_ag_notify_call_event( - BT_AG_CALL_EVENT_INCOMING, - call_id, phone_number); - } - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE: - ret = bt_call_list_create(&call_list); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY: - ret = bt_call_list_destroy(call_list); - call_list = NULL; - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET: - ret = bt_call_list_reset(call_list); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: { - const char *phone_number; - - if (g_test_param.param_count > 0) { - ret = bt_call_list_add(call_list, 1, - BT_AG_CALL_STATE_ACTIVE, - g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } else { - phone_number = g_strdup("01012345678"); - - ret = bt_call_list_add(call_list, 1, - BT_AG_CALL_STATE_ACTIVE, - phone_number); - } - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST: - ret = bt_ag_notify_call_list(call_list); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB: - ret = bt_ag_set_call_handling_event_cb( - __bt_ag_set_call_handling_event_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED: { - bool enabled = false; - ret = bt_ag_is_nrec_enabled(&enabled); - TC_PRT("opend[%s]", enabled ? "YES" : "NO"); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: { - if (g_test_param.param_count < 0) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_ag_switch_headset(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - case BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE: { - bt_audio_role_e role = BT_A2DP_SOURCE; - ret = bt_audio_select_role(role); - TC_PRT("Asdp Source set change ret = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE: { - bt_audio_role_e role = BT_A2DP_SINK; - ret = bt_audio_select_role(role); - TC_PRT("Asdp Sink set change ret = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME: { - if (absolute_volume > 150) - absolute_volume = 0; - - ret = bt_audio_set_absolute_volume(absolute_volume); - TC_PRT("ret = %d", ret); - - if (ret == BT_ERROR_NONE) - absolute_volume = absolute_volume + 50; - - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME: { - unsigned int volume = 0; - ret = bt_audio_get_absolute_volume(&volume); - TC_PRT("ret = %d, volume: %d", ret, volume); - - if (ret == BT_ERROR_NONE) - absolute_volume = volume; - - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED: { - bool activated = false; - ret = bt_audio_is_avc_activated(&activated); - TC_PRT("ret = %d, activated = %d", ret, activated); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB: { - ret = bt_audio_set_absolute_volume_changed_cb(__bt_audio_absolute_volume_changed_cb, NULL); - TC_PRT("ret = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB: { - ret = bt_audio_unset_absolute_volume_changed_cb(); - TC_PRT("ret = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB: { - ret = bt_audio_set_avc_status_changed_cb(__bt_audio_avc_status_changed_cb, NULL); - TC_PRT("ret = %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB: { - ret = bt_audio_unset_avc_status_changed_cb(); - TC_PRT("ret = %d", ret); - break; - } - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_PAN: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE: - ret = bt_nap_activate(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE: - ret = bt_nap_deactivate(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL: - ret = bt_nap_disconnect_all(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT: { - ret = bt_nap_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_panu_set_connection_state_changed_cb( - panu_conn_state_changed, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PANU_CONNECT: { - ret = bt_panu_connect(remote_addr, - BT_PANU_SERVICE_TYPE_NAP); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_GATT: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: { - bool auto_connect = false; - - if (g_test_param.param_count > 0) { - if (g_strrstr(g_test_param.params[0], "true")) - auto_connect = true; - else - auto_connect = false; - - __bt_free_test_param(&g_test_param); - } - - ret = bt_gatt_connect(remote_addr, auto_connect); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT: { - ret = bt_gatt_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB: { - ret = bt_gatt_set_connection_state_changed_cb( - __bt_gatt_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB: { - ret = bt_gatt_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { - char *svc_uuid = NULL; - char *chr_uuid = NULL; - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - bt_gatt_write_type_e write_type; - - if (g_test_param.param_count < 3) { - TC_PRT("Input parameters first"); - break; - } - - svc_uuid = g_test_param.params[0]; - chr_uuid = g_test_param.params[1]; - - ret = bt_gatt_client_get_service(client, svc_uuid, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - write_type = atoi(g_test_param.params[2]); - ret = bt_gatt_characteristic_set_write_type(chr, write_type); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_characteristic_set_write_type is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE: { - if (client) { - bt_gatt_client_destroy(client); - client = NULL; - } - ret = bt_gatt_client_create(remote_addr, &client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY: { - if (!client) - break; - - ret = bt_gatt_client_destroy(client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - client = NULL; - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS: { - char *addr = NULL; - - ret = bt_gatt_client_get_remote_address(client, &addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - if (addr) { - TC_PRT("remote addr : %s\n", addr); - g_free(addr); - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL: { -#ifdef ARCH64 - ret = bt_gatt_client_foreach_services(client, - __bt_gatt_client_foreach_svc_cb, - (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_client_foreach_services(client, - __bt_gatt_client_foreach_svc_cb, - (void *)test_id); -#endif - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { - char *svc_uuid = NULL; - char *chr_uuid = NULL; - char *desc_uuid = NULL; - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - bt_gatt_h desc = NULL; - - if (g_test_param.param_count < 3) { - TC_PRT("Input parameters first"); - break; - } - - svc_uuid = g_test_param.params[0]; - chr_uuid = g_test_param.params[1]; - - ret = bt_gatt_client_get_service(client, - svc_uuid, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - chr_uuid, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - if (strlen(g_test_param.params[2]) > 0) { - desc_uuid = g_test_param.params[2]; - ret = bt_gatt_characteristic_get_descriptor(chr, - desc_uuid, &desc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - ret = bt_gatt_client_read_value(desc, - __bt_gatt_client_read_complete_cb, NULL); - } else { - ret = bt_gatt_client_read_value(chr, - __bt_gatt_client_read_complete_cb, NULL); - } - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_read_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: { - char *svc_uuid = NULL; - char *chr_uuid = NULL; - char *desc_uuid = NULL; - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - bt_gatt_h desc = NULL; - - if (g_test_param.param_count < 5) { - TC_PRT("Input parameters first"); - break; - } - - svc_uuid = g_test_param.params[0]; - chr_uuid = g_test_param.params[1]; - - ret = bt_gatt_client_get_service(client, - svc_uuid, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - chr_uuid, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - if (strlen(g_test_param.params[2]) > 0) { - desc_uuid = g_test_param.params[2]; - ret = bt_gatt_characteristic_get_descriptor(chr, - desc_uuid, &desc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = __bt_gatt_client_set_value(g_test_param.params[3], - g_test_param.params[4], desc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_write_value(desc, - __bt_gatt_client_write_complete_cb, NULL); - } else { - ret = __bt_gatt_client_set_value(g_test_param.params[3], - g_test_param.params[4], chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_write_value(chr, - __bt_gatt_client_write_complete_cb, NULL); - } - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: { - char *svc_uuid = NULL; - char *chr_uuid = NULL; - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - if (g_test_param.param_count < 2) { - TC_PRT("Input parameters first"); - break; - } - - svc_uuid = g_test_param.params[0]; - chr_uuid = g_test_param.params[1]; - - ret = bt_gatt_client_get_service(client, - svc_uuid, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - chr_uuid, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, - __bt_gatt_client_value_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: { - char *svc_uuid = NULL; - char *chr_uuid = NULL; - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - if (g_test_param.param_count < 2) { - TC_PRT("Input parameters first"); - break; - } - - svc_uuid = g_test_param.params[0]; - chr_uuid = g_test_param.params[1]; - - ret = bt_gatt_client_get_service(client, - svc_uuid, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - chr_uuid, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES: { -#ifdef ARCH64 - ret = bt_gatt_client_foreach_services(client, - __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_client_foreach_services(client, - __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id); -#endif - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed"); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU: { - unsigned int mtu = 512; /* MAX MTU Value */ - - if (g_test_param.param_count > 0) { - mtu = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_gatt_client_request_att_mtu_change(client, mtu); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU: { - unsigned int mtu = 0; - ret = bt_gatt_client_get_att_mtu(client, &mtu); - TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB: { - ret = bt_gatt_client_set_service_changed_cb(client, - __bt_gatt_client_service_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_set_service_changed_cb is failed"); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB: { - ret = bt_gatt_client_unset_service_changed_cb(client); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_unset_service_changed_cb is failed"); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB: { - ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB: { - ret = bt_gatt_client_unset_att_mtu_changed_cb(client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE: { - - ret = bt_gatt_server_initialize(); - - TC_PRT("returns %s \n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE: { - - ret = bt_gatt_server_deinitialize(); - - server = NULL; - - TC_PRT("returns %s \n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES: { - ret = bt_gatt_server_unregister_all_services(server); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB: { - ret = bt_gatt_server_set_att_mtu_changed_cb(server, __bt_gatt_server_att_mtu_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - bt_gatt_h descriptor = NULL; - char *service_uuid = "180f"; /* Battery Service */ - char *char_uuid = "2a19"; /* Battery Level */ - char *desc_uuid = "2902"; /* CCCD */ - char char_value[1] = {80}; /* 80% */ - char desc_value[2] = {0, 0}; /* Notification & Indication */ - int permissions = BT_GATT_PERMISSION_READ; - int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, - char_value, sizeof(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, - __bt_gatt_server_notification_state_change_cb, NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - ret = bt_gatt_descriptor_create(desc_uuid, permissions, - desc_value, sizeof(desc_value), &descriptor); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - battery_h.svc = service; - battery_h.chr = characteristic; - battery_h.desc = descriptor; - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL: { - char char_value[1] = {1 + (rand()%100)}; - if (!server) { - TC_PRT("bt gatt server is not created"); - break; - } - ret = bt_gatt_set_value(battery_h.chr, char_value, 1); - TC_PRT("Value[%d], returns %s\n", char_value[0], __bt_get_error_message(ret)); - - /* notify only client remote_addr */ - ret = bt_gatt_server_notify_characteristic_changed_value(battery_h.chr, - __bt_gatt_server_notification_sent_cb, - remote_addr, NULL); - TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - bt_gatt_h descriptor = NULL; - char *service_uuid = "180d"; /* Heart Rate Service */ - char *char_uuid = "2a37"; /* Heart Rate Measurement */ - char *desc_uuid = "2902"; /* CCCD */ - char char_value_1[3] = {1, 0x38, 0}; /* Flag + Measurement value (56) */ - char desc_value[2] = {1, 0}; /* Notification enabled */ - int permissions = BT_GATT_PERMISSION_READ; - int properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; /* READ property added for testing */ - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, - char_value_1, sizeof(char_value_1), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - heart_rate_h.chr = characteristic; - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, - __bt_gatt_server_notification_state_change_cb, NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - ret = bt_gatt_descriptor_create(desc_uuid, permissions, - desc_value, sizeof(desc_value), &descriptor); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - char_uuid = "2a38"; /* Body Sensor Location */ - permissions = BT_GATT_PERMISSION_READ; - properties = BT_GATT_PROPERTY_READ; - char char_value_2 = 4; /* Hand */ - ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, - &char_value_2, sizeof(char_value_2), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - heart_rate_h.svc = service; - heart_rate_h.desc = descriptor; - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT: { - int char_value = 60 + (rand()%60); - if (!server) { - TC_PRT("bt gatt server is not created"); - break; - } - ret = bt_gatt_set_int_value(heart_rate_h.chr, - BT_DATA_TYPE_UINT16, char_value, 1); - TC_PRT("bt_gatt_set_value(value : %d) : %s\n", - char_value, __bt_get_error_message(ret)); - - /* Notify all client devices */ - ret = bt_gatt_server_notify_characteristic_changed_value(heart_rate_h.chr, - __bt_gatt_server_notification_sent_cb, - NULL, NULL); - TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - bt_gatt_h descriptor = NULL; - char *service_uuid = "1809"; /* Health Thermometer Service */ - char *char_uuid = "2a1c"; /* Temperature Measurement */ - char *desc_uuid = "2902"; /* CCCD */ - char char_value[5] = {0, 0x85, 0xff, 0xff, 0xfe}; /* Flag + Temperature Measurement Value (Celsius, -1.23) */ - char desc_value[2] = {2, 0}; /* Indication enabled */ - int permissions = BT_GATT_PERMISSION_READ; - int properties = BT_GATT_PROPERTY_INDICATE | BT_GATT_PROPERTY_READ; /* READ property added for testing */ - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, - BT_GATT_SERVICE_TYPE_PRIMARY, &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, - char_value, sizeof(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, - __bt_gatt_server_notification_state_change_cb, NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - ret = bt_gatt_descriptor_create(desc_uuid, permissions, - desc_value, sizeof(desc_value), &descriptor); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - thermometer_h.chr = characteristic; - thermometer_h.svc = service; - thermometer_h.desc = descriptor; - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT: { - if (!server) { - TC_PRT("bt gatt server is not created"); - break; - } - ret = bt_gatt_set_float_value(thermometer_h.chr, BT_DATA_TYPE_FLOAT, 123, -2, 1); - TC_PRT("bt_gatt_set_value(value : 1.23) : %s\n", __bt_get_error_message(ret)); - - /* notify only client remote_addr */ - ret = bt_gatt_server_notify_characteristic_changed_value(thermometer_h.chr, - __bt_gatt_server_notification_sent_cb, remote_addr, NULL); - TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - char *service_uuid = "180a"; /* Device Infromation Service */ - char *char_uuid = NULL; - char *char_value; - int permissions = BT_GATT_PERMISSION_READ; - int properties = BT_GATT_PROPERTY_READ; - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, - BT_GATT_SERVICE_TYPE_PRIMARY, &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - char_uuid = "2a29"; /* Manufacturer Name String */ - char_value = g_strdup("Samsung"); - ret = bt_gatt_characteristic_create(char_uuid, permissions, - properties, char_value, - strlen(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - g_free(char_value); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, - NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - char_uuid = "2a24"; /* Model Number String */ - char_value = g_strdup("TIZEN_HR 0408"); - ret = bt_gatt_characteristic_create(char_uuid, permissions, - properties, char_value, - strlen(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - g_free(char_value); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, - NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - char_uuid = "2a28"; /* S/W Revision String */ - char_value = g_strdup("NC2"); - ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, - char_value, strlen(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - g_free(char_value); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, - NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - char_uuid = "2a26"; /* Firmware Revision Name String */ - char_value = g_strdup("Firmware Ver 04"); - ret = bt_gatt_characteristic_create(char_uuid, permissions, - properties, char_value, - strlen(char_value), &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - g_free(char_value); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, - NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - char *service_uuid = "1803"; /* Link Loss Service */ - char *char_uuid = "2a06"; /* Alert Level */ - char char_value[1] = {2}; /* high alert */ - int value_length = 1; - int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, - BT_GATT_SERVICE_TYPE_PRIMARY, - &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid, permissions, - properties, char_value, - value_length, &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_set_write_value_requested_cb(characteristic, - __bt_gatt_server_write_value_requested_cb, - NULL); - TC_PRT("bt_gatt_server_set_write_value_requested_cb : %s\n", __bt_get_error_message(ret)); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC: { - bt_gatt_h service1 = NULL; - bt_gatt_h service2 = NULL; - bt_gatt_h service3 = NULL; - bt_gatt_h characteristic1_1 = NULL; - bt_gatt_h characteristic2_1 = NULL; - bt_gatt_h characteristic2_2 = NULL; - bt_gatt_h characteristic2_3 = NULL; - bt_gatt_h characteristic2_4 = NULL; - bt_gatt_h characteristic2_5 = NULL; - bt_gatt_h characteristic2_6 = NULL; - bt_gatt_h characteristic2_7 = NULL; - bt_gatt_h descriptor1_1 = NULL; - bt_gatt_h descriptor2_3 = NULL; - bt_gatt_h descriptor2_4_1 = NULL; - bt_gatt_h descriptor2_4_2 = NULL; - bt_gatt_h descriptor2_5_1 = NULL; - bt_gatt_h descriptor2_5_2 = NULL; - char *service_uuid1 = "180f"; /* Battery Service */ - char *service_uuid2 = "1812"; /* HID Service */ - char *service_uuid3 = "1801"; /* Generic Attribute Service */ - char *char_uuid1 = "2a19"; /* Battery Level */ - char *char_uuid2_1 = "2a4a"; /* HID information */ - char *char_uuid2_2 = "2a4b"; - char *char_uuid2_3 = "2a33"; - char *char_uuid2_4 = "2a4d"; - char *char_uuid2_5 = "2a4d"; - char *char_uuid2_6 = "2a4c"; - char *char_uuid2_7 = "2a4e"; - char *desc_uuid1_1 = "2902"; /* Client Characteristic Configuration */ - char *desc_uuid2_3 = "2902"; /* Client Characteristic Configuration */ - char *desc_uuid2_4_1 = "2902"; /* Client Characteristic Configuration */ - char *desc_uuid2_4_2 = "2908"; /* Report Reference */ - char *desc_uuid2_5_1 = "2908"; /* Report Reference */ - char *desc_uuid2_5_2 = "2901"; /* Characteristic User Description */ - int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; - - char char_value[1] = {80}; /* 80% */ - char char_value_unknown[4] = {10, 20, 30, 40}; - char desc_value_configration[2] = {0, 0}; /* Notification & Indication */ - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - /* Battery Service */ - ret = bt_gatt_service_create(service_uuid1, - BT_GATT_SERVICE_TYPE_PRIMARY, - &service1); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid1, permissions, - properties, char_value, - 1, &characteristic1_1); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service1, characteristic1_1); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid1_1, permissions, - desc_value_configration, 2, &descriptor1_1); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic1_1, descriptor1_1); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service1); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - /* HID Service */ - ret = bt_gatt_service_create(service_uuid2, - BT_GATT_SERVICE_TYPE_PRIMARY, - &service2); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_1, permissions, - properties, char_value_unknown, - 4, &characteristic2_1); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_1); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_2, permissions, - properties, char_value_unknown, - 4, &characteristic2_2); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_2); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_3, permissions, - properties, char_value_unknown, - 4, &characteristic2_3); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_3); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2_3, permissions, - desc_value_configration, 2, &descriptor2_3); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_3, descriptor2_3); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_4, permissions, - properties, char_value_unknown, - 4, &characteristic2_4); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_4); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2_4_1, permissions, - desc_value_configration, 2, &descriptor2_4_1); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_1); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2_4_2, permissions, - desc_value_configration, 2, &descriptor2_4_2); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_2); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_5, permissions, - properties, char_value_unknown, - 4, &characteristic2_5); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_5); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2_5_1, permissions, - desc_value_configration, 2, &descriptor2_5_1); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_1); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_descriptor_create(desc_uuid2_5_2, permissions, - desc_value_configration, 2, &descriptor2_5_2); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_2); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_6, permissions, - properties, char_value_unknown, - 4, &characteristic2_6); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_6); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_create(char_uuid2_7, permissions, - properties, char_value_unknown, - 4, &characteristic2_7); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_service_add_characteristic(service2, characteristic2_7); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service2); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - /* Generic Attribute Service */ - ret = bt_gatt_service_create(service_uuid3, - BT_GATT_SERVICE_TYPE_PRIMARY, - &service3); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service3); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC: { - bt_gatt_h service = NULL; - bt_gatt_h characteristic = NULL; - bt_gatt_h descriptor = NULL; - char *service_uuid = "000018f2-0000-1000-8000-00805f9b34fb"; - char *char_uuid = "00002af6-0000-1000-8000-00805f9b34fb"; - char *desc_uuid = "2902"; // CCCD - char char_value[4] = {10, 20, 30, 40}; - char desc_value[2] = {0, 0}; // Notification disabled - int value_length = 4; - int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - int properties = BT_GATT_PROPERTY_BROADCAST | BT_GATT_PROPERTY_READ | - BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_NOTIFY; - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, - BT_GATT_SERVICE_TYPE_PRIMARY, - &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - /* Read & Write & Notify characteristics UUID */ - ret = bt_gatt_characteristic_create(char_uuid, permissions, - properties, char_value, - value_length, &characteristic); - TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); - - bt_gatt_server_set_read_value_requested_cb(characteristic, - __bt_gatt_server_read_value_requested_cb, NULL); - - ret = bt_gatt_server_set_write_value_requested_cb(characteristic, - __bt_gatt_server_write_value_requested_cb, NULL); - - ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, - __bt_gatt_server_notification_state_change_cb, NULL); - - ret = bt_gatt_service_add_characteristic(service, characteristic); - TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); - - /* CCCD for Notify characteristics */ - ret = bt_gatt_descriptor_create(desc_uuid, permissions, - desc_value, value_length, &descriptor); - TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); - TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - - custom_h.svc = service; - custom_h.chr = characteristic; - custom_h.desc = descriptor; - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL: { - char char_value[4] = {50, 60, 70, 80}; - if (!server) { - TC_PRT("bt gatt server is not created"); - break; - } - ret = bt_gatt_set_value(custom_h.chr, char_value, 4); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - /* notify only client remote_addr */ - ret = bt_gatt_server_notify_characteristic_changed_value(custom_h.chr, - __bt_gatt_server_notification_sent_cb, remote_addr, NULL); - TC_PRT("bt_gatt_server_notify_characteristic_changed_value : %s\n", - __bt_get_error_message(ret)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_START_SERVER: { - ret = bt_gatt_server_start(); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID: { - char *name = NULL; - char *uuid = "0000180F-0000-1000-8000-00805F9B34FB"; - ret = bt_gatt_get_uuid_specification_name(uuid, &name); - TC_PRT("bt_gatt_get_uuid_specification_name : %s\n", __bt_get_error_message(ret)); - if (BT_ERROR_NONE == ret) { - TC_PRT("UUID [%s] Specification Name [%s]", uuid, name); - free(name); - } - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES: { -#ifdef ARCH64 - ret = bt_gatt_server_foreach_services(server, - __bt_gatt_server_foreach_svc_cb, (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_server_foreach_services(server, - __bt_gatt_server_foreach_svc_cb, (void *)test_id); -#endif - TC_PRT("bt_gatt_server_foreach_services: %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU: { - unsigned int mtu = 0; - ret = bt_gatt_server_get_device_mtu(remote_addr, &mtu); - TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_PAIR: { - bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE; - - if (g_test_param.param_count > 0) { - link_type = atoi(g_test_param.params[0]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_device_create_bond_by_type(remote_addr, link_type); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_WATCH: { - bt_gatt_h ancs_svc = NULL; - bt_gatt_h noti_source = NULL;; - char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; - char *chr_uuid = "9FBF120D-6301-42D9-8C58-25E699A21DBD"; - - ret = bt_gatt_client_get_service(client, svc_uuid, &ancs_svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(ancs_svc, - chr_uuid, ¬i_source); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_set_characteristic_value_changed_cb(noti_source, - __bt_gatt_client_value_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: { - char value[6]; - char *noti_id = NULL; - int id; - - if (g_test_param.param_count == 0) { - TC_PRT("Input parameters first"); - break; - } - - noti_id = g_test_param.params[0]; - id = atoi(noti_id); - - value[0] = 0x02; - memcpy(&value[1], &id, sizeof(int)); - value[5] = 0x00; - - __ancs_write_value_to_control_point(client, - value, sizeof(value)); - - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: { - char value[6]; - char *noti_id = NULL; - int id; - - if (g_test_param.param_count == 0) { - TC_PRT("Input parameters first"); - break; - } - - noti_id = g_test_param.params[0]; - id = atoi(noti_id); - - value[0] = 0x02; - memcpy(&value[1], &id, sizeof(int)); - value[5] = 0x01; - - __ancs_write_value_to_control_point(client, - value, sizeof(value)); - - break; - } - case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: { - bt_gatt_h ancs_svc = NULL; - bt_gatt_h data_source = NULL;; - char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; - char *chr_uuid = "22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB"; - - char value[19]; - char *noti_id = NULL; - int id; - - if (g_test_param.param_count == 0) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_gatt_client_get_service(client, - svc_uuid, &ancs_svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(ancs_svc, - chr_uuid, &data_source); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_set_characteristic_value_changed_cb(data_source, - __bt_gatt_client_value_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); - - noti_id = g_test_param.params[0]; - id = atoi(noti_id); - - value[0] = 0x00; - memcpy(&value[1], &id, sizeof(int)); - value[5] = 0x00; - value[6] = 0x01; - value[7] = 0xff; - value[8] = 0x00; - value[9] = 0x02; - value[10] = 0xff; - value[11] = 0x00; - value[12] = 0x03; - value[13] = 0xff; - value[14] = 0x00; - value[15] = 0x04; - value[16] = 0x05; - value[17] = 0x06; - value[18] = 0x07; - - __ancs_write_value_to_control_point(client, - value, sizeof(value)); - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS: { - int available = 0; - ret = bt_gatt_get_data_batching_available_packets(&available); - TC_PRT("returns %s, (available:%d)\n", __bt_get_error_message(ret), available); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING: { - int packet_threshold = 30; - int timeout = 20; - - if (g_test_param.param_count > 0) { - packet_threshold = atoi(g_test_param.params[0]); - timeout = atoi(g_test_param.params[1]); - - __bt_free_test_param(&g_test_param); - } - - ret = bt_gatt_enable_data_batching(remote_addr, packet_threshold, timeout); - TC_PRT("returns %s, (packet_threshold:%d, timeout:%d)\n", __bt_get_error_message(ret), packet_threshold, timeout); - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING: { - ret = bt_gatt_disable_data_batching(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_HPS: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: { - bool auto_connect = false; - - if (g_test_param.param_count > 0) { - if (g_strrstr(g_test_param.params[0], "true")) - auto_connect = true; - else - auto_connect = false; - - __bt_free_test_param(&g_test_param); - } - - ret = bt_gatt_connect(remote_addr, auto_connect); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - ret = bt_gatt_set_connection_state_changed_cb( - __bt_hps_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY: { - if (!hps_client) - break; - - ret = bt_gatt_client_destroy(hps_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - hps_client = NULL; - ret = bt_gatt_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL: { -#ifdef ARCH64 - ret = bt_gatt_client_foreach_services(hps_client, - __bt_hps_client_svc_cb, (void *)(uintptr_t)test_id); -#else - ret = bt_gatt_client_foreach_services(hps_client, - __bt_hps_client_svc_cb, (void *)test_id); -#endif - if (ret != BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - char *uri = NULL; - - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - uri = g_test_param.params[0]; - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_URI_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = __bt_gatt_client_set_value("str", uri, chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_write_value(chr, - __bt_gatt_client_write_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - char *hdr = NULL; - - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - hdr = g_test_param.params[0]; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_HDR_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = __bt_gatt_client_set_value("str", hdr, chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_write_value(chr, - __bt_gatt_client_write_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - char *entity = NULL; - - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - entity = g_test_param.params[0]; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_ENTITY_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = __bt_gatt_client_set_value("str", - entity, chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, - __bt_HP_client_cp_req_status_changed_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - ret = bt_gatt_client_write_value(chr, - __bt_gatt_client_write_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_CP_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = __bt_gatt_client_set_value("uint8", - g_test_param.params[0], chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_set_value is failed : %d", ret); - __bt_free_test_param(&g_test_param); - break; - } - - ret = bt_gatt_client_write_value(chr, - __bt_gatt_client_write_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_write_value is failed : %d", ret); - - __bt_free_test_param(&g_test_param); - break; - } - - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_URI_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_read_value(chr, - __bt_gatt_client_read_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_read_value is failed : %d", ret); - break; - } - - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_HDR_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_read_value(chr, - __bt_gatt_client_read_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_read_value is failed : %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_ENTITY_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_read_value(chr, - __bt_gatt_client_read_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_read_value is failed : %d", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_SECURITY_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_read_value(chr, - __bt_gatt_client_read_complete_cb, NULL); - - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_read_value is failed : %d", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_STATUS_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, - __bt_gatt_client_value_changed_cb, NULL); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION: { - bt_gatt_h svc = NULL; - bt_gatt_h chr = NULL; - - ret = bt_gatt_client_get_service(hps_client, - HPS_UUID, &svc); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_client_get_service is failed : %d", ret); - break; - } - - ret = bt_gatt_service_get_characteristic(svc, - HTTP_STATUS_UUID, &chr); - if (ret != BT_ERROR_NONE) { - TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); - break; - } - - ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr); - if (ret != BT_ERROR_NONE) - TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - - - case BT_UNIT_TEST_TABLE_AVRCP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE: - ret = bt_avrcp_target_initialize( - __bt_avrcp_target_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE: - ret = bt_avrcp_target_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB: - ret = bt_avrcp_set_equalizer_state_changed_cb( - __bt_avrcp_equalizer_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB: - ret = bt_avrcp_set_repeat_mode_changed_cb( - __bt_avrcp_repeat_mode_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB: - ret = bt_avrcp_set_shuffle_mode_changed_cb( - __bt_avrcp_shuffle_mode_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB: - ret = bt_avrcp_set_scan_mode_changed_cb( - __bt_avrcp_scan_mode_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB: - ret = bt_avrcp_unset_equalizer_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB: - ret = bt_avrcp_unset_repeat_mode_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB: - ret = bt_avrcp_unset_shuffle_mode_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB: - ret = bt_avrcp_unset_scan_mode_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE: - ret = bt_avrcp_control_initialize( - __bt_avrcp_control_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE: - ret = bt_avrcp_control_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT: - ret = bt_avrcp_control_connect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT: - ret = bt_avrcp_control_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_STOP); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PAUSE); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_FAST_FORWARD); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_REWIND); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT: - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_NEXT); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV: { - ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PREVIOUS); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME: { - static unsigned int volume_level = 1; - ret = bt_avrcp_control_set_absolute_volume(volume_level++); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP: { - ret = bt_avrcp_control_increase_volume(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN: { - ret = bt_avrcp_control_decrease_volume(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SEND_DELAY_REPORT: { - static unsigned int delay_level = 1; - ret = bt_avrcp_control_send_delay_report(delay_level++); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT: { - bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_GROUP; - ret = bt_avrcp_control_get_repeat_mode(&mode); - TC_PRT("Repet mode : %d returns %s\n", mode, - __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT: { - ret = bt_avrcp_control_set_repeat_mode(2); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE: { - bt_avrcp_shuffle_mode_e mode = BT_AVRCP_SHUFFLE_MODE_ALL_TRACK; - ret = bt_avrcp_control_get_shuffle_mode(&mode); - TC_PRT("Shuffle mode %d returns %s\n", mode, __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE: { - ret = bt_avrcp_control_set_shuffle_mode(1); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION: { - unsigned int position = 0; - ret = bt_avrcp_control_get_position(&position); - TC_PRT("position %d returns %s\n", position, __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS: { - unsigned int status = 0; - ret = bt_avrcp_control_get_play_status(&status); - TC_PRT("status %d returns %s\n", status, __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO: { - bt_avrcp_metadata_attributes_info_s *track; - ret = bt_avrcp_control_get_track_info(&track); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) { - TC_PRT("Title. %s\n", track->title); - TC_PRT("Artist %s\n", track->artist); - TC_PRT("Album %s\n", track->album); - TC_PRT("Genre %s\n", track->genre); - TC_PRT("Total tracks %d\n", track->total_tracks); - TC_PRT("Number %d\n", track->number); - TC_PRT("Duration %d\n", track->duration); - bt_avrcp_control_free_track_info(track); - } - break; - } - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB: - ret = bt_avrcp_set_position_changed_cb( - __bt_avrcp_song_position_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB: - ret = bt_avrcp_set_play_status_changed_cb( - __bt_avrcp_player_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB: - ret = bt_avrcp_set_track_info_changed_cb( - __bt_avrcp_track_info_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB: - ret = bt_avrcp_unset_position_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB: - ret = bt_avrcp_unset_play_status_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB: - ret = bt_avrcp_unset_track_info_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_HID: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE: - ret = bt_hid_host_initialize( - __bt_hid_host_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE: - ret = bt_hid_host_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT: { - ret = bt_hid_host_connect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT: { - ret = bt_hid_host_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE: { - ret = bt_hid_device_activate( - __bt_hid_device_connection_state_changed_cb, - NULL); - TC_PRT("returns %s", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT: { - ret = bt_hid_device_connect(remote_addr); - TC_PRT("returns %s", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE: { - ret = bt_hid_device_deactivate(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT: { - ret = bt_hid_device_disconnect(remote_addr); - TC_PRT("return %s", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT: { - bt_hid_mouse_data_s send_data; - int i; - - send_data.buttons = 1; - send_data.padding = BT_HID_MOUSE_BUTTON_LEFT; - - send_data.axis_x = 10; - send_data.axis_y = 0; - for (i = 0; i < 30; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = 0; - send_data.axis_y = 10; - for (i = 0; i < 30; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = -10; - send_data.axis_y = 0; - for (i = 0; i < 60; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = 0; - send_data.axis_y = -10; - for (i = 0; i < 60; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = 10; - send_data.axis_y = 0; - for (i = 0; i < 60; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = 0; - send_data.axis_y = 10; - for (i = 0; i < 30; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - send_data.axis_x = -10; - send_data.axis_y = 0; - for (i = 0; i < 30; i++) { - usleep(30000); - ret = bt_hid_device_send_mouse_event( - remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - } - TC_PRT("Completed"); - - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL: { - bt_hid_mouse_data_s send_data; - - send_data.buttons = BT_HID_MOUSE_BUTTON_NONE; - send_data.padding = 0x01; - - send_data.axis_x = 0; - send_data.axis_y = 0; - TC_PRT("Scroll UP"); - ret = bt_hid_device_send_mouse_event(remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL_DOWN: { - bt_hid_mouse_data_s send_data; - send_data.buttons = BT_HID_MOUSE_BUTTON_NONE; - send_data.padding = 0xff; - send_data.axis_x = 0; - send_data.axis_y = 0; - TC_PRT("Scroll Down"); - ret = bt_hid_device_send_mouse_event(remote_addr, &send_data); - if (ret < 0) - TC_PRT("returns %d\n", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT: { - bt_hid_key_data_s send_data; - /* Will send character 'a' */ - char pressedkey[8] = { 4, 0, 0, 0, 0, 0, 0, 0 }; - char pressedkey1[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - ret = bt_hid_device_send_key_event( - remote_addr, &send_data); - TC_PRT("returns %d\n", ret); - memcpy(send_data.key, pressedkey1, 8); - ret = bt_hid_device_send_key_event( - remote_addr, &send_data); - TC_PRT("returns %d\n", ret); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: { - unsigned char report_id = 0xF7; - char pressed_data[6] = {0x07, 0x00, 0x00, 0x00, 0x00, 0x00}; - char released_data[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static int mode = 1; - - if (g_test_param.param_count > 0) { - mode = atoi(g_test_param.params[0]); - __bt_free_test_param(&g_test_param); - } - - if (mode == 1) - pressed_data[0] = 0x07; /* Vol up */ - else if (mode == 2) - pressed_data[0] = 0x0B; /* Vol down */ - else if (mode == 3) - pressed_data[0] = 0x12; /* CH up */ - else if (mode == 4) - pressed_data[0] = 0x10; /* CH down */ - - ret = bt_hid_device_send_custom_event(remote_addr, - report_id, pressed_data, 6); - TC_PRT("returns %d\n", ret); - - ret = bt_hid_device_send_custom_event(remote_addr, - report_id, released_data, 6); - TC_PRT("returns %d\n", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB: { - ret = bt_hid_device_set_data_received_cb( - __bt_hid_device_data_received_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB: { - ret = bt_hid_device_unset_data_received_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_IPSP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_IPSP_REGISTER: { - bt_gatt_h service = NULL; - char *service_uuid = "1820"; /* IPSP Service */ - - ret = bt_gatt_server_initialize(); - TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); - - if (server == NULL) { - ret = bt_gatt_server_create(&server); - TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); - } - - ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); - TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); - - ret = bt_gatt_server_register_service(server, service); - TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); - ipsp_h.svc = service; - - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER: - if (server != NULL && ipsp_h.svc != NULL) { - ret = bt_gatt_server_unregister_service(server, - ipsp_h.svc); - TC_PRT("bt_gatt_server_unregister_service : returns %s\n", - __bt_get_error_message(ret)); - if (ret == BT_ERROR_NONE) - ipsp_h.svc = NULL; - } else { - TC_PRT("Gatt Server or IPSP not registered !"); - } - break; - case BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE: - /* Initialize IPSP server */ - if (server != NULL && ipsp_h.svc != NULL) { - ret = bt_ipsp_initialize( - &__bt_ipsp_init_state_changed_cb, - NULL); - TC_PRT("bt_le_ipsp_initialize : returns %s\n", __bt_get_error_message(ret)); - } else { - TC_PRT("Gatt Server or IPSP not registered !"); - } - break; - case BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE: - /* De-Initialize IPSP server */ - ret = bt_ipsp_deinitialize(); - TC_PRT("bt_le_ipsp_deinitialize : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT: - ret = bt_ipsp_connect(remote_addr); - TC_PRT("returns %s", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT: - ret = bt_ipsp_disconnect(remote_addr); - TC_PRT("returns %s", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING: { - const char *ipsp_svc_uuid_16 = "1820"; - - /* Add IPSP service in advertising data */ - advertiser = advertiser_list[advertiser_index]; - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - if (ret != BT_ERROR_NONE) { - TC_PRT("created le advertiser(%d)", ret); - break; - } - - advertiser_list[advertiser_index] = advertiser; - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) { - TC_PRT("set device name [0x%04x]", ret); - break; - } - } - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, ipsp_svc_uuid_16); - if (ret != BT_ERROR_NONE) { - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - break; - } - - /* Start advertising IPSP service */ - bt_adapter_le_advertising_state_changed_cb cb; - - if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; - else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; - else cb = __bt_adapter_le_advertising_state_changed_cb_3; - - advertiser = advertiser_list[advertiser_index]; - - advertiser_index++; - advertiser_index %= 3; - - TC_PRT("advertiser: %p", advertiser); - - ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB: - ret = bt_ipsp_set_connection_state_changed_cb( - __bt_ipsp_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB: - ret = bt_ipsp_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - case BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET: { - int serverSocket = 0; - struct ifaddrs *ifap, *ifa; - struct sockaddr_in6 serverAddr, clientAddr; - socklen_t clilen; - char host[NI_MAXHOST]; - char client_ipv6[100] = {0, }; - char *addr = NULL; - - TC_PRT("\n****** IPSP Application Server Started ******\n"); - - getifaddrs(&ifap); - - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { - if (ifa->ifa_addr->sa_family == AF_INET6) { - if (!memcmp(ifa->ifa_name, ipsp_iface_name, IFNAMSIZ)) { - getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), host, NI_MAXHOST, - NULL, 0, NI_NUMERICHOST); - TC_PRT("[IPV6]Host : %s \n", host); - addr = strchr(host, '%'); - if (addr != NULL) { - addr = g_strndup(host, (addr - host)); - TC_PRT("Found match Interface: %s and addr : %s\n", ifa->ifa_name, addr); - } - } - } - } - - freeifaddrs(ifap); - - if (addr != NULL) { - bzero((char *) &serverAddr, sizeof(serverAddr)); - - serverAddr.sin6_flowinfo = 0; - serverAddr.sin6_family = AF_INET6; - serverAddr.sin6_addr = in6addr_any; - serverAddr.sin6_port = htons(IPSP_PORT); - serverAddr.sin6_scope_id = if_nametoindex(ipsp_iface_name); - inet_pton(AF_INET6, addr, &(serverAddr.sin6_addr.s6_addr)); - - g_free(addr); - - /* Create the IPSP APP server socket */ - serverSocket = socket(AF_INET6, SOCK_STREAM, 0); - if (serverSocket < 0) { - TC_PRT("\nIPSP server Error : In socket creation !"); - break; - } - else - TC_PRT("\nIPSP Server : Socket created.."); - - - /* Bind the address struct to the socket */ - if (bind(serverSocket, (struct sockaddr *) &serverAddr, sizeof(serverAddr)) < 0) { - TC_PRT("\nIPSP server Error : In socket binding !"); - close(serverSocket); - break; - } - else - TC_PRT("\nIPSP Server : Socket binding done.."); - - - /* Listen on the socket, with 1 max connection requests queued */ - if (listen(serverSocket, 1) < 0) { - TC_PRT("\nIPSP server Error : In socket listening !"); - close(serverSocket); - break; - } - else - TC_PRT("\nIPSP server : Socket listening, waiting for connection...\n"); - - /* Accept call creates a new socket for the incoming connection */ - clilen = sizeof(clientAddr); - ipsp_server_sock = accept(serverSocket, (struct sockaddr *) &clientAddr, &clilen); - if (ipsp_server_sock < 0) { - TC_PRT("\nIPSP server Error : While accepting incoming connection !"); - close(serverSocket); - break; - } - - inet_ntop(AF_INET6, &(clientAddr.sin6_addr), client_ipv6, 100); - TC_PRT("\n****** IPSP server : Incoming connection from client... %s successful, ready to send/receive IPV6 data ******", client_ipv6); - - close(serverSocket); - } else { - TC_PRT("Matching Address is Not Found , Wait till the Connected Event is recieved from STACK"); - } - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: { - char *saddr = NULL; - struct sockaddr_in6 serverAddr; - struct hostent *server; - - if (g_test_param.param_count < 1) { - TC_PRT("Input IPSP Application's server IPv6 address first !"); - break; - } - saddr = g_test_param.params[0]; - - TC_PRT("\n****** IPSP Application Client Started ******\n"); - - /* Create the IPSP APP Client socket */ - ipsp_client_sock = socket(AF_INET6, SOCK_STREAM, 0); - if (ipsp_client_sock < 0) - TC_PRT("\nIPSP Client Error : In socket creation !"); - else - TC_PRT("\nIPSP Client : Socket created.."); - - /* Sockets Layer Call: gethostbyname2() */ - server = gethostbyname2(saddr, AF_INET6); - - if (server == NULL) - TC_PRT("\nIPSP Client Error : No such host !"); - else { - - TC_PRT("\nIPSP Client GetHostbyName Success!"); - memset((char *) &serverAddr, 0, sizeof(serverAddr)); - serverAddr.sin6_flowinfo = 0; - serverAddr.sin6_family = AF_INET6; - serverAddr.sin6_addr = in6addr_any; - serverAddr.sin6_port = htons(IPSP_PORT); - serverAddr.sin6_scope_id = if_nametoindex(ipsp_iface_name); - - memmove((char *) &serverAddr.sin6_addr.s6_addr, (char *) server->h_addr, server->h_length); - - TC_PRT("\nIPSP Client Attempt To Connect to server %s!", serverAddr.sin6_addr.s6_addr); - /* Connect with IPSP APP Server socket */ - if (connect(ipsp_client_sock, (struct sockaddr *) &serverAddr, sizeof(serverAddr)) < 0) - TC_PRT("\nIPSP Client Error : %d while connecting with server !", errno); - else - TC_PRT("\n****** IPSP Client : Connection with : %s successful, ready to send/receive IPV6 data ******\n", saddr); - - __bt_free_test_param(&g_test_param); - } - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA: { - int role = -1, n = 0; - char *param_data = NULL; - - if (g_test_param.param_count < 2) { - TC_PRT("IPSP Error : Input IPSP Application's role and data to send first !"); - break; - } - - role = atoi(g_test_param.params[0]); - param_data = g_test_param.params[1]; - - if (role == 0) { - if (ipsp_server_sock) { - TC_PRT("IPSP : Current role is IPSP Sever !"); - - /* Sockets Layer Call: send() */ - n = send(ipsp_server_sock, param_data, strlen(param_data) + 1, 0); - if (n < 0) - TC_PRT("\nIPSP Error : While sending data !"); - } else { - TC_PRT("IPSP Error: There is no connected server socket !"); - } - } else if (role == 1) { - if (ipsp_client_sock) { - /* Sockets Layer Call: send() */ - n = send(ipsp_client_sock, param_data, strlen(param_data) + 1, 0); - if (n < 0) - TC_PRT("\nIPSP Error : While sending data !"); - } else { - TC_PRT("IPSP Error: There is no connected client socket !"); - } - } else { - TC_PRT("IPSP Error: Please input the proper role !"); - } - __bt_free_test_param(&g_test_param); - - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: { - int role = -1, n; - char buffer[256] = {0}; - - if (g_test_param.param_count < 1) { - TC_PRT("IPSP Error : Input IPSP Application's role first !"); - break; - } - - role = atoi(g_test_param.params[0]); - - if (role == 0) { - if (ipsp_server_sock) { - TC_PRT("IPSP : Current role is IPSP Sever, ready to receive data !"); - - /* Sockets Layer Call: recv() */ - n = recv(ipsp_server_sock, buffer, 255, 0); - if (n < 0) - TC_PRT("\nIPSP Server Error : While receiving data from client !"); - - TC_PRT("\nIPSP Server : Message received from client: %s\n", buffer); - } else { - TC_PRT("IPSP Error: There is no connected or active server socket !"); - } - } else if (role == 1) { - if (ipsp_client_sock) { - TC_PRT("IPSP : Current role is IPSP Client, ready to receive data !"); - - /* Sockets Layer Call: recv() */ - n = recv(ipsp_client_sock, buffer, 255, 0); - if (n < 0) - TC_PRT("\nIPSP Client Error : %d while receiving data from server!", errno); - - TC_PRT("\nIPSP Client : Message received from server: %s\n", buffer); - } else { - TC_PRT("IPSP Error: There is no connected or active client socket !"); - } - } else { - TC_PRT("IPSP Error: Please input the proper role !"); - } - - __bt_free_test_param(&g_test_param); - - break; - } - case BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET: { - if (ipsp_server_sock) { - TC_PRT("IPSP server : Closing server socket.."); - close(ipsp_server_sock); - ipsp_server_sock = 0; - } - - if (ipsp_client_sock) { - TC_PRT("IPSP Client : Closing client socket.."); - close(ipsp_client_sock); - ipsp_client_sock = 0; - } - - break; - } - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - - case BT_UNIT_TEST_TABLE_HDP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP: - ret = bt_hdp_register_sink_app(0x1007, &appid); - TC_PRT("bt_hdp_register_sink_app : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP: - ret = bt_hdp_unregister_sink_app(appid); - TC_PRT("bt_hdp_unregister_sink_app : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE: - ret = bt_hdp_connect_to_source(remote_addr, - appid); - TC_PRT("bt_hdp_connect_to_source : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT: - ret = bt_hdp_disconnect(remote_addr, - channel_hdp); - TC_PRT("bt_hdp_disconnect : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA: - ret = bt_hdp_send_data(channel_hdp, - data_hdp, strlen(data_hdp)); - TC_PRT("bt_hdp_send_data : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB: - ret = bt_hdp_set_connection_state_changed_cb( - __bt_hdp_connected_cb, - __bt_hdp_disconnected_cb, NULL); - TC_PRT("bt_hdp_set_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB: - ret = bt_hdp_unset_connection_state_changed_cb(); - TC_PRT("bt_hdp_unset_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB: - ret = bt_hdp_set_data_received_cb( - __bt_hdp_data_received_cb, - NULL); - TC_PRT("bt_hdp_set_data_received_cb : returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB: - ret = bt_hdp_unset_data_received_cb(); - TC_PRT("bt_hdp_unset_data_received_cb : returns %s\n", __bt_get_error_message(ret)); - break; - default: - break; - } - break; - } - case BT_UNIT_TEST_TABLE_DPM: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES: { - const char *hfp_uuid = "0000111f-0000-1000-8000-00805f9b34fb"; - const char *hsp_uuid = "00001112-0000-1000-8000-00805f9b34fb"; - const char *a2dp_uuid = "0000110D-0000-1000-8000-00805F9B34FB"; - const char *avrcp_target_uuid = "0000110c-0000-1000-8000-00805f9b34fb"; - - ret = bt_dpm_set_allow_bluetooth_mode(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_allow_bluetooth_mode : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_activate_device_restriction(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_activate_device_restriction : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_activate_uuid_restriction(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_activate_uuid_restriction : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_allow_outgoing_call(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_allow_outgoing_call : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_pairing_state(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_pairing_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_profile_state(BT_DPM_POLICY_HFP_PROFILE_STATE, - BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_profile_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_desktop_connectivity_state(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_desktop_connectivity_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_discoverable_state(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_discoverable_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_limited_discoverable_state(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_limited_discoverable_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_set_data_transfer_state(BT_DPM_BT_ALLOWED); - - TC_PRT("bt_dpm_set_data_transfer_state : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(spp_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(opp_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(hid_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(hfp_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(hsp_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(a2dp_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - ret = bt_dpm_add_uuids_to_whitelist(avrcp_target_uuid); - - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - ret = bt_dpm_set_allow_bluetooth_mode(value); - - TC_PRT("bt_dpm_set_allow_bluetooth_mode : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE: { - bt_dpm_allow_e value = BT_DPM_ERROR; - ret = bt_dpm_get_allow_bluetooth_mode(&value); - TC_PRT("bt_dpm_get_allow_bluetooth_mode : allow: %d, returns %s\n", - value , __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_activate_device_restriction(value); - TC_PRT("bt_dpm_activate_device_restriction : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_is_device_restriction_active(&value); - TC_PRT("bt_dpm_is_device_restriction_active : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_activate_uuid_restriction(value); - TC_PRT("bt_dpm_activate_uuid_restriction : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_is_uuid_restriction_active(&value); - TC_PRT("bt_dpm_is_uuid_restriction_active : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_add_devices_to_blacklist(g_test_param.params[0]); - TC_PRT("bt_dpm_add_devices_to_blacklist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_add_devices_to_whitelist(g_test_param.params[0]); - TC_PRT("bt_dpm_add_devices_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_add_uuids_to_blacklist(g_test_param.params[0]); - TC_PRT("bt_dpm_add_uuids_to_blacklist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_add_uuids_to_whitelist(g_test_param.params[0]); - TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST: { - bt_dpm_device_list_s *device_list = NULL; - int i = 0; - char *str = NULL; - ret = bt_dpm_get_devices_from_blacklist(&device_list); - TC_PRT("bt_dpm_get_devices_from_blacklist : returns %s\n", - __bt_get_error_message(ret)); - if (device_list) { - TC_PRT("list len %d", device_list->count); - for (i = 0; i < device_list->count; i++) { - str = g_strdup((const gchar*)device_list->devices[i]); - TC_PRT("%d: %s\n", i, str); - g_free(str); - free(device_list->devices[i]); - } - free(device_list); - } - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST: { - bt_dpm_device_list_s *device_list = NULL; - int i = 0; - char *str = NULL; - ret = bt_dpm_get_devices_from_whitelist(&device_list); - TC_PRT("bt_dpm_get_devices_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - if (device_list) { - TC_PRT("list len %d", device_list->count); - for (i = 0; i < device_list->count; i++) { - str = g_strdup((const gchar*)device_list->devices[i]); - TC_PRT("%d: %s\n", i, str); - g_free(str); - free(device_list->devices[i]); - } - free(device_list); - } - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST: { - bt_dpm_uuids_list_s *uuids_list = NULL; - int i = 0; - char *str = NULL; - ret = bt_dpm_get_uuids_from_blacklist(&uuids_list); - TC_PRT("bt_dpm_get_uuids_from_blacklist : returns %s\n", - __bt_get_error_message(ret)); - - if (uuids_list) { - TC_PRT("list len %d", uuids_list->count); - for (i = 0; i < uuids_list->count; i++) { - str = g_strdup(uuids_list->uuids[i]); - TC_PRT("%d: %s\n", i, str); - g_free(str); - free(uuids_list->uuids[i]); - } - free(uuids_list); - } - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST: { - bt_dpm_uuids_list_s *uuids_list = NULL; - int i = 0; - char *str = NULL; - ret = bt_dpm_get_uuids_from_whitelist(&uuids_list); - TC_PRT("bt_dpm_get_uuids_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - - if (uuids_list) { - TC_PRT("list len %d", uuids_list->count); - for (i = 0; i < uuids_list->count; i++) { - str = g_strdup(uuids_list->uuids[i]); - TC_PRT("%d: %s\n", i, str); - g_free(str); - free(uuids_list->uuids[i]); - } - free(uuids_list); - } - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST: - ret = bt_dpm_clear_devices_from_blacklist(); - TC_PRT("bt_dpm_clear_devices_from_blacklist : returns %s\n", - __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST: - ret = bt_dpm_clear_devices_from_whitelist(); - TC_PRT("bt_dpm_clear_devices_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST: - ret = bt_dpm_clear_uuids_from_blacklist(); - TC_PRT("bt_dpm_clear_uuids_from_blacklist : returns %s\n", - __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST: - ret = bt_dpm_clear_uuids_from_whitelist(); - TC_PRT("bt_dpm_clear_uuids_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_remove_device_from_blacklist(g_test_param.params[0]); - TC_PRT("bt_dpm_add_devices_to_blacklist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_remove_device_from_whitelist(g_test_param.params[0]); - TC_PRT("bt_dpm_remove_device_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_remove_uuid_from_blacklist(g_test_param.params[0]); - TC_PRT("bt_dpm_remove_device_from_blacklist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - ret = bt_dpm_remove_uuid_from_whitelist(g_test_param.params[0]); - TC_PRT("bt_dpm_remove_uuid_from_whitelist : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_set_allow_outgoing_call(value); - TC_PRT("bt_dpm_set_allow_outgoing_call : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_allow_outgoing_call(&value); - TC_PRT("bt_dpm_get_allow_outgoing_call : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_set_pairing_state(value); - TC_PRT("bt_dpm_set_pairing_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_pairing_state(&value); - TC_PRT("bt_dpm_get_pairing_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: { - int profile, value; - if (g_test_param.param_count < 2) { - TC_PRT("Input parameters first"); - break; - } - profile = atoi(g_test_param.params[0]); - value = atoi(g_test_param.params[1]); - - ret = bt_dpm_set_profile_state(profile, value); - TC_PRT("bt_dpm_set_profile_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - int profile; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - profile = atoi(g_test_param.params[0]); - - ret = bt_dpm_get_profile_state(profile, &value); - TC_PRT("bt_dpm_get_profile_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_set_desktop_connectivity_state(value); - TC_PRT("bt_dpm_set_desktop_connectivity_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_desktop_connectivity_state(&value); - TC_PRT("bt_dpm_get_desktop_connectivity_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - ret = bt_dpm_set_discoverable_state(value); - TC_PRT("bt_dpm_set_discoverable_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_discoverable_state(&value); - TC_PRT("bt_dpm_get_discoverable_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_set_limited_discoverable_state(value); - TC_PRT("bt_dpm_set_limited_discoverable_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_limited_discoverable_state(&value); - TC_PRT("bt_dpm_get_limited_discoverable_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: { - int value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - value = atoi(g_test_param.params[0]); - - ret = bt_dpm_set_data_transfer_state(value); - TC_PRT("bt_dpm_set_data_transfer_state : returns %s\n", - __bt_get_error_message(ret)); - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE: { - bt_dpm_status_e value = BT_DPM_STATUS_ERROR; - ret = bt_dpm_get_data_transfer_state(&value); - TC_PRT("bt_dpm_get_data_transfer_state : allow: %d, returns %s\n", - value, __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_PXP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER: { - if (reporter) { - ret = bt_proximity_reporter_destroy(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_reporter_unset_property_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - reporter = NULL; - } - ret = bt_proximity_reporter_create(&reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER: { - ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_reporter_unset_property_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - - ret = bt_proximity_reporter_destroy(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - reporter = NULL; - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE: { - if (monitor) { - ret = bt_proximity_monitor_disconnect(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_monitor_destroy(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - monitor = NULL; - } - ret = bt_proximity_monitor_create(remote_addr, &monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY: { - ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_proximity_monitor_destroy(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - monitor = NULL; - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: { - ret = bt_proximity_monitor_connect(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: { - ret = bt_proximity_monitor_disconnect(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_proximity_monitor_set_connection_state_changed_cb(monitor, - __bt_proximity_monitor_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_proximity_reporter_set_connection_state_changed_cb(reporter, - __bt_proximity_reporter_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB: { - ret = bt_proximity_reporter_set_property_changed_cb(reporter, - __bt_proximity_reporter_property_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB: { - ret = bt_proximity_reporter_unset_property_changed_cb(reporter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID: { - if (pxp_scan_filter) { - ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - pxp_scan_filter = NULL; - } - ret = bt_adapter_le_scan_filter_create(&pxp_scan_filter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_le_scan_filter_set_type(pxp_scan_filter, - BT_ADAPTER_LE_SCAN_FILTER_TYPE_PROXIMITY_UUID); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_le_scan_filter_register(pxp_scan_filter); - if (ret != BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID: { - ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - pxp_scan_filter = NULL; - - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING: { - /* Add Reporter service in advertising data */ - advertiser = advertiser_list[advertiser_index]; - if (advertiser == NULL) { - ret = bt_adapter_le_create_advertiser(&advertiser); - if (ret != BT_ERROR_NONE) { - TC_PRT("created le advertiser(%d)", ret); - break; - } - - advertiser_list[advertiser_index] = advertiser; - ret = bt_adapter_le_set_advertising_device_name(advertiser, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) { - TC_PRT("set device name [0x%04x]", ret); - break; - } - } - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_IMMEDIATE_ALERT_SVC_UUID); - if (ret != BT_ERROR_NONE) { - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - break; - } - - ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, - BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_LINK_LOSS_SVC_UUID); - if (ret != BT_ERROR_NONE) { - TC_PRT("add service_solicitation_uuid [0x%04x]", ret); - break; - } - - /* Start advertising PXP Reporter service */ - bt_adapter_le_advertising_state_changed_cb cb; - - if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; - else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; - else cb = __bt_adapter_le_advertising_state_changed_cb_3; - - advertiser = advertiser_list[advertiser_index]; - - advertiser_index++; - advertiser_index %= 3; - - TC_PRT("advertiser: %p", advertiser); - - ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: { - int alert_value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - alert_value = atoi(g_test_param.params[0]); - ret = bt_proximity_monitor_set_linkloss_alert(monitor, alert_value); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: { - int alert_value; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - alert_value = atoi(g_test_param.params[0]); - ret = bt_proximity_monitor_set_immediate_alert(monitor, alert_value); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT: { - int alert_level = 0; - ret = bt_proximity_monitor_get_linkloss_alert(monitor, &alert_level); - TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT: { - int alert_level = 0; - ret = bt_proximity_monitor_get_immediate_alert(monitor, &alert_level); - TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL: { - int alert_level = 0; - ret = bt_proximity_monitor_get_signal_level(monitor, &alert_level); - TC_PRT("returns %s, signal_level: %d\n", __bt_get_error_message(ret), alert_level); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT: { - int alert_level = 0; - ret = bt_proximity_reporter_get_linkloss_alert(remote_addr, &alert_level); - TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); - break; - } - case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT: { - int alert_level = 0; - ret = bt_proximity_reporter_get_immediate_alert(remote_addr, &alert_level); - TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_HF: { - if (!TIZEN_PROFILE_WEARABLE_IVI) - break; - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HF_INITIALIZE: - ret = bt_hf_initialize(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE: - ret = bt_hf_deinitialize(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER: - ret = bt_hf_notify_call_event( - BT_HF_CALL_EVENT_ANSWER, - "9663868998"); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN: - ret = bt_hf_notify_speaker_gain(10); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB: - ret = bt_hf_set_speaker_gain_changed_cb( - __bt_hf_speaker_gain_changed_cb, - NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB: - ret = bt_hf_unset_speaker_gain_changed_cb(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE: - ret = bt_hf_notify_voice_recognition_state(true); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM: - ret = bt_hf_notify_call_event( - BT_HF_CALL_EVENT_IDLE, - "9663868998"); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT: - ret = bt_hf_notify_call_event( - BT_HF_CALL_EVENT_DIAL, - "9663868998"); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE: - ret = bt_hf_notify_voice_recognition_state(false); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED: { - bool is_opened = false; - ret = bt_hf_is_sco_opened(&is_opened); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("Sco is opened [%s]", is_opened ? "YES" : "NO"); - break; - } - case BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID: { - unsigned int codec_id = 0; - ret = bt_hf_get_codec_id(&codec_id); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("Codec ID [%d]", codec_id); - break; - } - case BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST: { - GSList *list; - ret = bt_hf_get_call_status_info_list(&list); - - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else { - for (; list; list = g_slist_next(list)) { - bt_hf_call_status_info_s *call_info = list->data; - TC_PRT("Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]", - call_info->number, call_info->direction, - call_info->status, call_info->multi_party, - call_info->index); - } - bt_hf_free_call_status_info_list(list); - } - break; - } - case BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST: { - ret = bt_hf_request_call_status_info_list(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB: - ret = bt_hf_set_sco_state_changed_cb( - __bt_hf_sco_state_changed_cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB: - ret = bt_hf_unset_sco_state_changed_cb(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB: - ret = bt_hf_set_call_handling_event_cb( - __bt_hf_set_call_handling_event_cb, - NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB: - ret = bt_hf_unset_call_handling_event_cb(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB: - ret = bt_hf_set_call_status_updated_event_cb( - __bt_hf_call_status_updated_event_cb, - NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB: - ret = bt_hf_unset_call_status_updated_event_cb(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_PBAP_CLIENT: { - if (!TIZEN_PROFILE_WEARABLE_IVI) - break; - switch (test_id) { - - /*PBAP Test Cases */ - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE: - ret = bt_pbap_client_initialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE: - ret = bt_pbap_client_deinitialize(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_pbap_client_set_connection_state_changed_cb(__bt_pbap_connection_state_changed_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB: { - ret = bt_pbap_client_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT: { - ret = bt_pbap_client_connect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT: { - ret = bt_pbap_client_disconnect(remote_addr); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED: { - bool connected_status = false; - - ret = bt_pbap_client_is_connected(remote_addr, &connected_status); - if (ret < BT_ERROR_NONE) - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - TC_PRT("PBAP Profile [%s]", - connected_status ? "Connected" : "Disconnected"); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE: { - ret = bt_pbap_client_get_phone_book_size(remote_addr, - 0, 0, - __bt_pbap_phonebook_size_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL: { - unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG | BT_PBAP_FIELD_X_IRMC_CALL_DATETIME; - - ret = bt_pbap_client_get_phone_book(remote_addr, - 0, 0, 0, 0, 0, 100, - fields, __bt_pbap_phonebook_pull_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST: { - ret = bt_pbap_client_get_list(remote_addr, - 0, 0, 0, 0, 100, - __bt_pbap_vcard_list_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL: { - long long unsigned fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG; - ret = bt_pbap_client_pull_vcard(remote_addr, - 0, 0, 0, 0, fields, - __bt_pbap_phonebook_pull_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH: { - ret = bt_pbap_client_search_phone_book(remote_addr, - 0, 0, - 0, "ff", - 0, 0, 100, - __bt_pbap_vcard_list_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO: { - ret = bt_pbap_client_get_list(remote_addr, - 0, 0, 0, 0, 0, - __bt_pbap_vcard_list_cb, - NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - - default: - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_TDS_PROVIDER: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER: { - ret = bt_tds_provider_register(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER: { - ret = bt_tds_provider_unregister(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - provider = NULL; - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB: { - ret = bt_tds_set_transport_activation_requested_cb(__tds_activation_req_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB: { - ret = bt_tds_unset_transport_activation_requested_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE: { - if (provider) { - ret = bt_tds_provider_destroy(provider); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - - provider = NULL; - } - ret = bt_tds_provider_create(&provider, BT_TDS_TRANSPORT_CUSTOM); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY: { - ret = bt_tds_provider_destroy(provider); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - provider = NULL; - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA: { - unsigned char buf[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Mac */ - 0x20, 0xFA, /* Operating Channel */ - 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; /* Hash */ - - ret = bt_tds_provider_set_transport_data(provider, - BT_TDS_TRANSPORT_STATE_OFF, buf, sizeof(buf)); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA: { - unsigned char buf[] = {0x00, 0x75, 0x4E, 0x24, 0x36, 0x28, 0x01, 0x13}; - - ret = bt_tds_provider_set_manufacturer_data(buf, sizeof(buf)); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP: { - ret = bt_tds_provider_send_activation_resp( - tds_act_address, BLUETOOTH_ERROR_NONE, provider); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - default: - break; - } - break; - } - case BT_UNIT_TEST_TABLE_TDS_SEEKER: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER: { - ret = bt_tds_start_seeking_providers(__bt_tds_provider_scan_result_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER: { - ret = bt_tds_stop_seeking_providers(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE: { - if (seeker) - seeker = NULL; - ret = bt_tds_seeker_create(remote_addr, &seeker); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY: { - if (seeker) { - ret = bt_tds_seeker_destroy(seeker); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK: { - if (seeker) { - ret = bt_tds_seeker_set_connection_state_changed_cb(seeker, - __bt_tds_seeker_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT: { - if (seeker) { - ret = bt_tds_seeker_connect(seeker); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT: { - if (seeker) { - ret = bt_tds_seeker_disconnect(seeker); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK: { - if (seeker) { - ret = bt_tds_seeker_unset_connection_state_changed_cb(seeker); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA: { - if (seeker) { - ret = bt_tds_seeker_get_complete_transport_blocks(seeker, - __bt_tds_seeker_complete_transport_data_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT: { - if (seeker) { - unsigned char buf[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, /* Mac */ - 0x0A, 0x0B}; /* Channel Info */ - bt_tds_transport_e transport = BT_TDS_TRANSPORT_CUSTOM; - ret = bt_tds_seeker_activate_control_point(seeker, transport, buf, sizeof(buf), - __bt_tds_control_point_activation_result_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - default: - break; - } - break; - } - case BT_UNIT_TEST_TABLE_OTP: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: { - char *directory = NULL; - - if (g_test_param.param_count < 1) - TC_PRT("No relative path set"); - else - directory = g_test_param.params[0]; - - TC_PRT("%s", directory); - - ret = bt_otp_server_initialize(directory); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - /* __bt_free_test_param(&g_test_param); */ - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT: { - ret = bt_otp_server_deinitialize(); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB: { - ret = bt_otp_set_server_state_changed_cb( - __bt_otp_server_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB: { - ret = bt_otp_unset_server_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE: { - if (otp_client) - otp_client = NULL; - ret = bt_otp_client_create(remote_addr, &otp_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY: { - if (otp_client) { - ret = bt_otp_client_destroy(otp_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK: { - if (otp_client) { - ret = bt_otp_client_set_connection_state_changed_cb(otp_client, - __bt_otp_client_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT: { - if (otp_client) { - ret = bt_otp_client_connect(otp_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT: { - if (otp_client) { - ret = bt_otp_client_disconnect(otp_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK: { - if (otp_client) { - ret = bt_otp_client_unset_connection_state_changed_cb(otp_client); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS: { - if (otp_client) { - ret = bt_otp_client_discover_all_objects(otp_client, - __bt_otp_client_object_discovery_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: { - if (otp_client) { - unsigned long long id; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - id = (unsigned long long)atoi(g_test_param.params[0]); - TC_PRT("Object ID[%llu]", id); - ret = bt_otp_client_select_object(otp_client, id, - __bt_otp_client_object_select_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS: { - if (otp_client) { - ret = bt_otp_client_read_object_contents(otp_client, - __bt_otp_client_read_object_complete_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: { - char *file_path = NULL; - if (g_test_param.param_count < 1) { - TC_PRT("Input parameters first"); - break; - } - - file_path = g_test_param.params[0]; - TC_PRT("%s", file_path); - - if (otp_client) { - ret = bt_otp_client_create_object(otp_client, - file_path, __bt_otp_client_object_create_cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - } - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: { - char *file_path = NULL; - int offset, length, mode; - - if (g_test_param.param_count < 4) { - TC_PRT("Input parameters first"); - break; - } - - file_path = g_test_param.params[0]; - TC_PRT("%s", file_path); - - offset = strtoul(g_test_param.params[1], NULL, 10); - length = strtoul(g_test_param.params[2], NULL, 10); - mode = strtoul(g_test_param.params[3], NULL, 10); - - if (otp_client) { - ret = bt_otp_client_write_object(otp_client, - file_path, offset, length, mode, - __bt_otp_client_object_write_cb, NULL); - if (ret < BT_ERROR_NONE) - TC_PRT("failed with [0x%04x]", ret); - else if (ret == BT_ERROR_NONE) - TC_PRT("Success"); - } - __bt_free_test_param(&g_test_param); - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ: { - if (otp_client) { - ret = bt_otp_client_execute_object(otp_client, - __bt_otp_client_object_execute_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ: { - if (otp_client) { - ret = bt_otp_client_delete_object(otp_client, - __bt_otp_client_object_delete_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - default: - break; - } - break; - } - case BT_UNIT_TEST_TABLE_HRP_SENSOR: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE: { - TC_PRT("HR SENSOR SET LOC VALUE\n"); - bt_body_sensor_location_e location = BT_BSL_WRIST; - bt_hrp_sensor_set_location_value(location); - - break; - } - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE: { - TC_PRT("HR SENSOR SET CONTACT VALUE\n"); - bool iscontact = true; - bt_hrp_sensor_set_contact_value(iscontact); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME: { - TC_PRT("HR SENSOR SET DEVICE NAME\n"); - char *name = g_strdup("SAMSUNG HR"); - bt_hrp_sensor_set_device_manufacturer_name(name); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE: { - TC_PRT("HR SENSOR CREATE\n"); - ret = bt_hrp_sensor_create(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY: { - TC_PRT("HR SENSOR UPDATE HR value\n"); - bt_hrp_sensor_set_heartrate_value(60 + (rand()%60)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY: { - TC_PRT("HR SENSOR DESTROY\n"); - ret = bt_hrp_sensor_destroy(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - default: - break; - } - break; - } - case BT_UNIT_TEST_TABLE_HRP_COLLECTOR: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK: { - TC_PRT("HR COLLECTOR CONNECTION STATE CALLBACK\n"); - if (collector) { - ret = bt_hrp_collector_set_connection_state_changed_cb(collector, - __bt_hrp_collector_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION: { - TC_PRT("HR COLLECTOR SET NOTIFICATION\n"); - if (set_notif == true) { - set_notif = false; - ret = bt_hrp_collector_set_notification(collector, - __bt_hrp_heart_rate_value_changed_cb, true); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } else { - set_notif = true; - ret = bt_hrp_collector_set_notification(collector, - __bt_hrp_heart_rate_value_changed_cb, false); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE: { - TC_PRT("HR COLLECTOR CREATE\n"); - ret = bt_hrp_collector_create(remote_addr, &collector); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN: { - TC_PRT("HR COLLECTOR START SCAN\n"); - ret = bt_hrp_collector_start_scan(__bt_adapter_le_scan_result_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN: { - TC_PRT("HR COLLECTOR STOP SCAN\n"); - ret = bt_hrp_collector_stop_scan(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT: { - TC_PRT("HR COLLECTOR CONNECT\n"); - ret = bt_hrp_collector_connect(collector); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT: { - TC_PRT("HR COLLECTOR DISCONNECT\n"); - ret = bt_hrp_collector_disconnect(collector); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC: { - TC_PRT("HR COLLECTOR GET BSL LOCATION\n"); - if (collector) { - ret = bt_hrp_collector_get_body_sensor_location(collector, _bt_hrp_collector_bsl_read_completed_cb); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - } - break; - } - case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY: { - TC_PRT("HR COLLECTOR DESTROY\n"); - ret = bt_hrp_collector_destory(collector); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - collector = NULL; - break; - } - default: - break; - } - break; - } - - case BT_UNIT_TEST_TABLE_ETC: { - static unsigned int delay = 0; - bt_onoff_cnt = 0; - bt_onoff_cnt_success = 0; - bt_onoff_cnt_fail = 0; - - total_time = 0; - gettimeofday(&check_time, NULL); - - if (input_automated_test_delay == true) { - delay = test_id; - test_id = BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY; - } - - switch (test_id) { - /*Automated Test Cases */ - case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST: { - bt_adapter_state_e state = BT_ADAPTER_DISABLED; - delay = 0; - - ret = bt_adapter_set_state_changed_cb( - __bt_repeat_test_adapter_state_changed_cb, - &delay); - TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_get_state(&state); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("Current state: %d", state); - - if (state == BT_ADAPTER_DISABLED) - bt_adapter_enable(); - else - bt_adapter_disable(); - break; - } - case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY: { - bt_adapter_state_e state = BT_ADAPTER_DISABLED; - delay = 1; - - ret = bt_adapter_set_state_changed_cb( - __bt_repeat_test_adapter_state_changed_cb, - &delay); - TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_get_state(&state); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("Current state: %d", state); - - if (state == BT_ADAPTER_DISABLED) - bt_adapter_enable(); - else - bt_adapter_disable(); - break; - } - case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY: { - bt_adapter_state_e state = BT_ADAPTER_DISABLED; - - input_automated_test_delay = false; - - ret = bt_adapter_set_state_changed_cb( - __bt_repeat_test_adapter_state_changed_cb, - &delay); - TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_get_state(&state); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - TC_PRT("Current state: %d", state); - - if (state == BT_ADAPTER_DISABLED) - bt_adapter_enable(); - else - bt_adapter_disable(); - break; - } - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT: { - char *mode = "setting"; - - if (g_test_param.param_count > 0) - mode = g_test_param.params[0]; - - app_control_h service = NULL; - - app_control_create(&service); - app_control_set_app_id(service, "com.samsung.bluetooth-single"); - app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); - app_control_add_extra_data(service, "launch-type", mode); - ret = app_control_send_launch_request(service, NULL, NULL); - TC_PRT("returns %d", ret); - - app_control_destroy(service); - break; - } - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF: { - app_control_h service = NULL; - - app_control_create(&service); - app_control_set_operation(service, APP_CONTROL_OPERATION_EDIT); - app_control_set_mime(service, "application/x-bluetooth-on-off"); - - ret = app_control_send_launch_request(service, NULL, NULL); - TC_PRT("returns %d", ret); - - app_control_destroy(service); - - break; - } - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY: { - app_control_h service = NULL; - - app_control_create(&service); - app_control_set_operation(service, APP_CONTROL_OPERATION_EDIT); - app_control_set_mime(service, "application/x-bluetooth-visibility"); - - ret = app_control_send_launch_request(service, NULL, NULL); - TC_PRT("returns %d", ret); - - app_control_destroy(service); - - break; - } - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF: { - app_control_h service = NULL; - - app_control_create(&service); - app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_ENABLE); - - ret = app_control_send_launch_request(service, NULL, NULL); - TC_PRT("returns %d", ret); - - app_control_destroy(service); - - break; - } - case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY: { - app_control_h service = NULL; - - app_control_create(&service); - app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY); - - ret = app_control_send_launch_request(service, NULL, NULL); - TC_PRT("returns %d", ret); - - app_control_destroy(service); - - break; - } - case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: { - int ret; - bool is_supported = false; - - if (g_test_param.param_count > 0) { - ret = system_info_get_custom_bool( - g_test_param.params[0], &is_supported); - if (ret != 0) - TC_PRT("returns %d", ret); - TC_PRT("%s is %s", g_test_param.params[0], - is_supported ? "true" : "false"); - __bt_free_test_param(&g_test_param); - } else { - ret = system_info_get_custom_bool( - "tizen.org/feature/network.bluetooth", &is_supported); - if (ret != 0) - TC_PRT("returns %d", ret); - TC_PRT("tizen.org/feature/network.bluetooth is %s", - is_supported ? "true" : "false"); - } - - break; - } - case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: - need_to_set_params = true; - TC_PRT("Select the function again"); - break; - default: - break; - } - - break; - } - default: - break; - } - - return 0; -} - -static gboolean key_event_cb(GIOChannel *chan, - GIOCondition cond, - gpointer data) -{ - char buf[BUFFER_LEN] = { 0 }; - -#ifdef ARCH64 - unsigned long len = 0; -#else - unsigned int len = 0; -#endif - int test_id; - bool is_call_api = false; - - memset(buf, 0, sizeof(buf)); - - if (g_io_channel_read_chars(chan, buf, sizeof(buf), - &len, NULL) == G_IO_STATUS_ERROR) { - TC_PRT("IO Channel read error"); - return FALSE; - } - - if (need_to_set_params == true) { - if (g_test_id == -1) { - test_id = atoi(buf); - g_test_id = test_id; - } - test_set_params(g_test_id, buf); - return TRUE; - } else { - TC_PRT("%s", buf); - test_id = atoi(buf); - - g_test_id = -1; - need_to_set_params = false; - } - - if (current_tc_table == BT_UNIT_TEST_TABLE_MAIN) { - if (buf[0] == '0' && buf[2] == 0) - current_tc_table = BT_UNIT_TEST_TABLE_SET_ADDRESS; - else if (test_id >= BT_UNIT_TEST_TABLE_ADAPTER - && test_id < BT_UNIT_TEST_TABLE_FINISH) - current_tc_table = test_id; - else - is_call_api = true; - } else { - if (buf[0] == '0' && buf[2] == 0) { - current_tc_table = BT_UNIT_TEST_TABLE_MAIN; - } else if (current_tc_table == BT_UNIT_TEST_TABLE_ETC - && test_id == BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY - && input_automated_test_delay == false) { - input_automated_test_delay = true; - } else { - is_call_api = true; - } - } - - tc_usage_print(); - - if (current_tc_table == BT_UNIT_TEST_TABLE_SET_ADDRESS - && is_call_api == true) { - memcpy(remote_addr, buf, 17); - remote_addr[17] = 0; - } else if (test_id && is_call_api) -#ifdef ARCH64 - g_idle_add(test_input_callback, (void *)(uintptr_t)test_id); -#else - g_idle_add(test_input_callback, (void *)test_id); -#endif - return TRUE; -} - -void sig_handler(int signo) -{ - if (signo == SIGINT) { - if (bt_onoff_cnt > 0) - __bt_print_repeat_test_final_summary(); - - bt_deinitialize(); - exit(0); - } -} - -int main() -{ - GIOChannel *key_io; - - current_tc_table = BT_UNIT_TEST_TABLE_MAIN; - - key_io = g_io_channel_unix_new(fileno(stdin)); - - g_io_channel_set_encoding(key_io, NULL, NULL); - g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); - - g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - key_event_cb, NULL); - - g_io_channel_unref(key_io); - - main_loop = g_main_loop_new(NULL, FALSE); - - if (signal(SIGINT, sig_handler) == SIG_ERR) - TC_PRT("\n can't catch SIGINT\n"); - - g_main_loop_run(main_loop); - - bt_deinitialize(); - - return 0; -} diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h deleted file mode 100644 index 375a497..0000000 --- a/test/bt_unit_test.h +++ /dev/null @@ -1,639 +0,0 @@ -/* - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ -#define __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ - - -#ifdef __cplusplus -extern "C" { -#endif - -#define BUFFER_LEN 49 -#define MAX_SERVICES 10 -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define TC_PRT(format, args...) PRT(format"\n", ##args) - -typedef enum { - BT_UNIT_TEST_TABLE_MAIN = 1, - BT_UNIT_TEST_TABLE_SET_ADDRESS, - BT_UNIT_TEST_TABLE_ADAPTER, - BT_UNIT_TEST_TABLE_ADAPTER_LE, - BT_UNIT_TEST_TABLE_DEVICE, - BT_UNIT_TEST_TABLE_SOCKET, - BT_UNIT_TEST_TABLE_OPP, - BT_UNIT_TEST_TABLE_AUDIO, - BT_UNIT_TEST_TABLE_PAN, - BT_UNIT_TEST_TABLE_GATT, - BT_UNIT_TEST_TABLE_HPS, - BT_UNIT_TEST_TABLE_AVRCP, - BT_UNIT_TEST_TABLE_HID, - BT_UNIT_TEST_TABLE_IPSP, - BT_UNIT_TEST_TABLE_HDP, - BT_UNIT_TEST_TABLE_DPM, - BT_UNIT_TEST_TABLE_PXP, - BT_UNIT_TEST_TABLE_HF, - BT_UNIT_TEST_TABLE_PBAP_CLIENT, - BT_UNIT_TEST_TABLE_ETC, - BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL, - BT_UNIT_TEST_TABLE_TDS_PROVIDER, - BT_UNIT_TEST_TABLE_TDS_SEEKER, - BT_UNIT_TEST_TABLE_OTP, - BT_UNIT_TEST_TABLE_HRP_SENSOR, - BT_UNIT_TEST_TABLE_HRP_COLLECTOR, - BT_UNIT_TEST_TABLE_FINISH = 0xFF, -} bt_unit_test_table_e; - -typedef enum { - BT_UNIT_TEST_FUNCTION_BACK = 0, - BT_UNIT_TEST_FUNCTION_SET_ADDRESS = 0, - BT_UNIT_TEST_FUNCTION_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE = 1, - BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER, - BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY, - BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY, - BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING, - BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE, - BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO, - BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO, - BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR, - BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION, - BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW, - BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT, - BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL, - BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT, - BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE = 1, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_CLEAR_WHITE_LIST, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, - BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, - BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT, - BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES, - BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT, - BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND, - BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE, - BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND, - BT_UNIT_TEST_FUNCTION_DEVICE_ENABLE_RSSI_MONITOR, - BT_UNIT_TEST_FUNCTION_DEVICE_DISABLE_RSSI_MONITOR, - BT_UNIT_TEST_FUNCTION_DEVICE_GET_RSSI_STRENGTH, - BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE, - BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE, - BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION, - BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU, - BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH, - BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE, - BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB, - BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM = 1, - BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM, - BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM, - BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN, - BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT, - BT_UNIT_TEST_FUNCTION_SOCKET_REJECT, - BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM, - BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM, - BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA, - BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID, - BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES, - BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH, - BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT, - BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT, - BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT, - BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT, - BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO, - BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO, - BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED, - BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED, - BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE, - BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED, - BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING, - BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING, - BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING, - BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE, - BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY, - BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET, - BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD, - BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST, - BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB, - BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED, - BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET, - BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE, - BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE, - BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME, - BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME, - BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED, - BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AG_IS_WBS_MODE, - BT_UNIT_TEST_FUNCTION_AG_SET_VENDOR_CMD_CB, - BT_UNIT_TEST_FUNCTION_AG_UNSET_VENDOR_CMD_CB, - BT_UNIT_TEST_FUNCTION_AG_NOTIFY_VENDOR_CMD, - BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_ENABLE, - BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_DISABLE, - BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE = 1, - BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE, - BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL, - BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT, - BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PANU_CONNECT, - BT_UNIT_TEST_FUNCTION_GATT_CONNECT = 1, - BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT, - BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC, - BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL, - BT_UNIT_TEST_FUNCTION_GATT_START_SERVER, - BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID, - BT_UNIT_TEST_FUNCTION_ANCS_PAIR, - BT_UNIT_TEST_FUNCTION_ANCS_WATCH, - BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION, - BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION, - BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR, - BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES, - BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS, - BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS, - BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID, - BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES, - BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION, - BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE, - BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST, - BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE, - BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES, - BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES, - BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS, - BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING, - BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE = 1, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION, - BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION, - BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SEND_DELAY_REPORT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS, - BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT, - BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT, - BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL_DOWN, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_IPSP_REGISTER = 1, - BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER, - BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE, - BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_IPSP_CONNECT, - BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT, - BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING, - BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET, - BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET, - BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA, - BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA, - BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET, - BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP = 1, - BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP, - BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE, - BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT, - BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA, - BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB, - BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB, - BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB, - BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES = 1, - BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE, - BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE, - BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION, - BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE, - BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION, - BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE, - BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST, - BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST, - BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL, - BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL, - BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE, - BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE, - BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE, - BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE, - BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE, - BT_UNIT_TEST_FUNCTION_HF_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM, - BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST, - BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST, - BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB, - BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB, - BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB, - BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN, - BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB, - BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE, - BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED, - BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID, - BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VENDOR_CMD, - BT_UNIT_TEST_FUNCTION_HF_SET_VENDOR_CMD_EVENT_CB, - BT_UNIT_TEST_FUNCTION_HF_UNSET_VENDOR_CMD_EVENT_CB, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE = 1, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH, - BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO, - BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST = 1, - BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY, - BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY, - BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT, - BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF, - BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY, - BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF, - BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY, - BT_UNIT_TEST_FUNCTION_CHECK_FEATURE, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER = 1, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT, - BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL, - - /* TDS Provider */ - BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER = 1, - BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER, - BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB, - BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB, - BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE, - BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY, - BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA, - BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA, - BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP, - - /* TDS Seeker */ - BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER = 1, - BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA, - BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT, - - /* OTP */ - BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT = 1, - BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT, - BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ, - BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ, - - /*HR-Sensor*/ - BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE = 1, - BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE, - BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME, - BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE, - BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY, - BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY, - /*HR-Collector*/ - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK = 1, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY, - BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC, - - BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, -} bt_unit_test_function_e; - -/** - * AMS EntityID type. - */ -typedef enum { - BT_AMS_ENTITY_ID_PLAYER = 0x00, /**< Player */ - BT_AMS_ENTITY_ID_QUEUE = 0x01, /**< Queue */ - BT_AMS_ENTITY_ID_TRACK = 0x02 /**< Track */ -} bt_ams_entity_id_type_e; - -/** - * AMS Entity Player's Attribute IDs type. - */ -typedef enum { - BT_AMS_PLAYER_ATTR_ID_NAME = 0x00, /**< PlayerAttributeIDName */ - BT_AMS_PLAYER_ATTR_ID_PLAYBACK_INFO = 0x01, /**< PlayerAttributeIDPlaybackInfo */ - BT_AMS_PLAYER_ATTR_ID_VOLUME = 0x02 /**< PlayerAttributeIDVolume */ -} bt_ams_player_attr_id_type_e; - -/** - * AMS Entity Queue's Attribute IDs type. - */ -typedef enum { - BT_AMS_QUEUE_ATTR_ID_INDEX = 0x00, /**< QueueAttributeIDIndex */ - BT_AMS_QUEUE_ATTR_ID_COUNT = 0x01, /**< QueueAttributeIDCount */ - BT_AMS_QUEUE_ATTR_ID_SHUFFLE_MODE = 0x02, /**< QueueAttributeIDShuffleMode */ - BT_AMS_QUEUE_ATTR_ID_REPEAT_MODE = 0x03 /**< QueueAttributeIDRepeatMode */ -} bt_ams_queue_attr_id_type_e; - -/** - * AMS Entity Track's Attribute IDs type. - */ -typedef enum { - BT_AMS_TRACK_ATTR_ID_ARTIST = 0x00, /**< TrackAttributeIDArtist */ - BT_AMS_TRACK_ATTR_ID_ALBUM = 0x01, /**< TrackAttributeIDAlbum */ - BT_AMS_TRACK_ATTR_ID_TITLE = 0x02, /**< TrackAttributeIDTitle */ - BT_AMS_TRACK_ATTR_ID_DURATION = 0x03 /**< TrackAttributeIDDuration */ -} bt_ams_track_attr_id_type_e; - -typedef struct { - const char *tc_name; - int tc_code; -} tc_table_t; - -typedef struct { - int param_count; - char **params; -} tc_params_t; - -#define BT_UNIT_TEST_PARAM_TYPE_BOOL "bool(true, false)" -#define BT_UNIT_TEST_PARAM_TYPE_INT "int(1, 2, 10, 777...)" -#define BT_UNIT_TEST_PARAM_TYPE_FLOAT "float(1.5, 0.625...)" -#define BT_UNIT_TEST_PARAM_TYPE_STRING "string(abc, HAHA..)" -#define BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY "byte array(03FF0102, 0015836CF7B2...)" - -int test_input_callback(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ */ diff --git a/test/hid_keyboard.c b/test/hid_keyboard.c deleted file mode 100644 index 5dca9db..0000000 --- a/test/hid_keyboard.c +++ /dev/null @@ -1,863 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "HID_KEYBOARD" - -#define INIT_BOND 0 - -#define KEYBOARD_RETURN 0x28 // Enter -#define KEYBOARD_ESCAPE 0x29 // Back -#define KEYBOARD_F5 0x3e // Smart Hub -#define KEYBOARD_F6 0x3f // Source -#define KEYBOARD_F7 0x40 // Channel List -#define KEYBOARD_F8 0x41 // Volume Mute -#define KEYBOARD_F9 0x42 // Volume Down -#define KEYBOARD_F10 0x43 // Volume Up -#define KEYBOARD_F11 0x44 // Channel Down -#define KEYBOARD_F12 0x45 // Channel Up -#define KEYBOARD_RIGHT 0x4f // Arrow Right -#define KEYBOARD_LEFT 0x50 // Arrow Left -#define KEYBOARD_DOWN 0x51 // Arrow Down -#define KEYBOARD_UP 0x52 // Arrow Up - -/** - * Variables - **/ -static GMainLoop *g_mainloop = NULL; -static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; -static char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; -static bool address_input = false; -#if INIT_BOND -static bool scanning = false; -static bool setup_in_progress = false; -static GSList *le_scan_list; -static bool g_wait_flag; -static int g_wait_count; -#endif - -static bool device_bonded = false; -static bool hid_connected = false; -static bool audio_connected = false; - -#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) -#define HID_PRT(format, args...) PRT(format"\n", ##args) - -#if INIT_BOND -#define WAIT_FOR_SYNC {\ - g_wait_flag = true;\ - g_wait_count = 0;\ - while (g_wait_flag == true && g_wait_count < 50) {\ - usleep(1000);\ - HID_PRT("Initial Setup...");\ - g_main_context_iteration(NULL, true);\ - g_wait_count++;\ - }\ -} -#endif - -typedef struct { - const char *tc_name; - int tc_code; -} tc_table_t; - -typedef enum { - BT_HID_DEVICE_SET_ADDRESS = 1, -#if INIT_BOND - BT_HID_DEVICE_TEST_SETUP, -#endif - BT_HID_DEVICE_TEST_VOLUME_UP, - BT_HID_DEVICE_TEST_VOLUME_DOWN, - BT_HID_DEVICE_TEST_CHANNEL_UP, - BT_HID_DEVICE_TEST_CHANNEL_DOWN, - BT_HID_DEVICE_TEST_CONNECT_HID, - BT_HID_DEVICE_TEST_DISCONNECT_HID, - BT_HID_DEVICE_TEST_CONNECT_AUDIO, - BT_HID_DEVICE_TEST_DISCONNECT_AUDIO, -#if INIT_BOND - BT_HID_DEVICE_TEST_SEARCH, - BT_HID_DEVICE_TEST_STOP_SEARCH, -#endif - BT_HID_DEVICE_TEST_FINISH = 0xFF, -} bt_hid_test_type_e; - -tc_table_t tc_hid_device[] = { - {"SET ADDRESS" - , BT_HID_DEVICE_SET_ADDRESS}, -#if INIT_BOND - {"Initial Setup (Bond & Connects)" - , BT_HID_DEVICE_TEST_SETUP}, -#endif - {"Volume Up" - , BT_HID_DEVICE_TEST_VOLUME_UP}, - {"Volume Down" - , BT_HID_DEVICE_TEST_VOLUME_DOWN}, - {"Channel Up" - , BT_HID_DEVICE_TEST_CHANNEL_UP}, - {"Channel Down" - , BT_HID_DEVICE_TEST_CHANNEL_DOWN}, - {"HID Connect only" - , BT_HID_DEVICE_TEST_CONNECT_HID}, - {"HID Disconnect only" - , BT_HID_DEVICE_TEST_DISCONNECT_HID}, - {"AUDIO Connect only" - , BT_HID_DEVICE_TEST_CONNECT_AUDIO}, - {"AUDIO Disconnect only" - , BT_HID_DEVICE_TEST_DISCONNECT_AUDIO}, -#if INIT_BOND - {"Search TV" - , BT_HID_DEVICE_TEST_SEARCH}, - {"Stop to search" - , BT_HID_DEVICE_TEST_STOP_SEARCH}, -#endif - {"Finish" - , BT_HID_DEVICE_TEST_FINISH}, - {NULL, 0x0000}, -}; - -static const char *__bt_get_error_message(bt_error_e err) -{ - const char *err_str = NULL; - - switch (err) { - case BT_ERROR_NONE: - err_str = "BT_ERROR_NONE"; - break; - case BT_ERROR_CANCELLED: - err_str = "BT_ERROR_CANCELLED"; - break; - case BT_ERROR_INVALID_PARAMETER: - err_str = "BT_ERROR_INVALID_PARAMETER"; - break; - case BT_ERROR_OUT_OF_MEMORY: - err_str = "BT_ERROR_OUT_OF_MEMORY"; - break; - case BT_ERROR_RESOURCE_BUSY: - err_str = "BT_ERROR_RESOURCE_BUSY"; - break; - case BT_ERROR_TIMED_OUT: - err_str = "BT_ERROR_TIMED_OUT"; - break; - case BT_ERROR_NOW_IN_PROGRESS: - err_str = "BT_ERROR_NOW_IN_PROGRESS"; - break; - case BT_ERROR_NOT_INITIALIZED: - err_str = "BT_ERROR_NOT_INITIALIZED"; - break; - case BT_ERROR_NOT_ENABLED: - err_str = "BT_ERROR_NOT_ENABLED"; - break; - case BT_ERROR_ALREADY_DONE: - err_str = "BT_ERROR_ALREADY_DONE"; - break; - case BT_ERROR_OPERATION_FAILED: - err_str = "BT_ERROR_OPERATION_FAILED"; - break; - case BT_ERROR_NOT_IN_PROGRESS: - err_str = "BT_ERROR_NOT_IN_PROGRESS"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; - break; - case BT_ERROR_AUTH_REJECTED: - err_str = "BT_ERROR_AUTH_REJECTED"; - break; - case BT_ERROR_AUTH_FAILED: - err_str = "BT_ERROR_AUTH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; - break; - case BT_ERROR_SERVICE_SEARCH_FAILED: - err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; - break; - case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: - err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; - break; - case BT_ERROR_PERMISSION_DENIED: - err_str = "BT_ERROR_PERMISSION_DENIED"; - break; - case BT_ERROR_SERVICE_NOT_FOUND: - err_str = "BT_ERROR_SERVICE_NOT_FOUND"; - break; - case BT_ERROR_NO_DATA: - err_str = "BT_ERROR_NO_DATA"; - break; - case BT_ERROR_NOT_SUPPORTED: - err_str = "BT_ERROR_NOT_SUPPORTED"; - break; - case BT_ERROR_DEVICE_POLICY_RESTRICTION: - err_str = "DEVICE_POLICY_RESTRICTION"; - break; - default: - err_str = "NOT Defined"; - break; - } - - return err_str; -} - -/** - * Callback functions - **/ -static gboolean __bt_timeout_func(gpointer data) -{ - HID_PRT("Timeout."); - if (g_mainloop) - g_main_loop_quit((GMainLoop *)data); - - return FALSE; -} - -static gboolean __bt_audio_connect_cb(gpointer user_data) -{ - int ret; - - if (audio_connected == true) - return FALSE; - - HID_PRT("Try to connect audio.."); - ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); - HID_PRT("returns %s", __bt_get_error_message(ret)); - - return TRUE; -} - -static void __bt_hid_device_connection_state_changed_cb(int result, - bool connected, const char *remote_address, void *user_data) -{ - HID_PRT("result: %s", __bt_get_error_message(result)); - HID_PRT("Remote Address: %s", remote_address); - HID_PRT("Connected [%d]", connected); - -#if INIT_BOND - g_wait_flag = false; -#endif - - if (connected == true && result == BT_ERROR_NONE) { - g_strlcpy(remote_addr, remote_address, 18); - hid_connected = true; - - /* Try to connect Audio */ - if (audio_connected == false) - g_timeout_add(2000, __bt_audio_connect_cb, NULL); - } else { - hid_connected = false; - } -} - -void __bt_audio_connection_state_changed_cb(int result, - bool connected, const char *remote_address, - bt_audio_profile_type_e type, void *user_data) -{ - HID_PRT("result [%s]", __bt_get_error_message(result)); - HID_PRT("connected [%d]", connected); - HID_PRT("address [%s]", remote_address); - HID_PRT("type [%d]", type); - -#if INIT_BOND - g_wait_flag = false; -#endif - - if (connected == true && result == BT_ERROR_NONE) { - g_strlcpy(remote_addr, remote_address, 18); - audio_connected = true; - } else { - audio_connected = false; - } -} - -static bool __bt_adapter_hid_profile_connected_devices_cb( - const char *remote_address, void *user_data) -{ - HID_PRT("remote_address: %s", remote_address); - - g_strlcpy(remote_addr, remote_address, 18); - - hid_connected = true; - - return true; -} - -static bool __bt_adapter_a2dp_profile_connected_devices_cb( - const char *remote_address, void *user_data) -{ - HID_PRT("remote_address: %s", remote_address); - - g_strlcpy(remote_addr, remote_address, 18); - - audio_connected = true; - - return true; -} - -void __bt_device_bond_created_cb(int result, - bt_device_info_s *device_info, void *user_data) -{ - if (result == BT_ERROR_NONE) { - HID_PRT("Callback: A bond is created."); - HID_PRT("Callback: is_bonded - %d.", device_info->is_bonded); - device_bonded = true; - } else { - HID_PRT("Callback: Creating a bond is failed."); - HID_PRT("result: %s", __bt_get_error_message(result)); - } - -#if INIT_BOND - g_wait_flag = false; -#endif -} - -static void __bt_state_changed_impl(int result, - bt_adapter_state_e adapter_state, - void *user_data) -{ - if (adapter_state == BT_ADAPTER_ENABLED) { - if (result == BT_ERROR_NONE) { - HID_PRT("Callback: BT was enabled successfully."); - bt_state = BT_ADAPTER_ENABLED; - } else { - HID_PRT("Callback: Failed to enable BT."); - } - } - - if (g_mainloop) - g_main_loop_quit(g_mainloop); -} - -#if INIT_BOND -gint __bt_compare_address(gpointer *a, gpointer *b) -{ - bt_adapter_le_device_scan_result_info_s *info = (bt_adapter_le_device_scan_result_info_s *)a; - char *address = (char *)b; - return g_strcmp0(info->remote_address, address); -} - -static void __bt_adapter_le_scan_result_cb( - int result, bt_adapter_le_device_scan_result_info_s *info, - void *user_data) -{ - int i; - bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; - bt_adapter_le_device_scan_result_info_s *adv_info; - - if (info == NULL) { - HID_PRT("No discovery_info!"); - return; - } - - if (info->adv_data_len > 31 || info->scan_data_len > 31) { - HID_PRT("###################"); - bt_adapter_le_stop_scan(); - HID_PRT("###################"); - return; - } - - GSList *l = NULL; - l = g_slist_find_custom(le_scan_list, info->remote_address, - (GCompareFunc)__bt_compare_address); - - if (l != NULL) { - adv_info = l->data; - adv_info->rssi = info->rssi; - return; - } - - adv_info = g_malloc0(sizeof(bt_adapter_le_device_scan_result_info_s)); - adv_info->remote_address= g_strdup(info->remote_address); - adv_info->rssi = info->rssi; - le_scan_list = g_slist_append(le_scan_list, adv_info); - - for (i = 0; i < 2; i++) { - char *device_name; - - pkt_type += i; - if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING - && info->adv_data == NULL) continue; - if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE - && info->scan_data == NULL) break; - - if (bt_adapter_le_get_scan_result_device_name( - info, pkt_type, &device_name) == BT_ERROR_NONE) { - - HID_PRT("\n%s Adv %d Scan resp %d RSSI %d Addr_type %d", - info->remote_address, info->adv_data_len, - info->scan_data_len, info->rssi, - info->address_type); - - HID_PRT("Device name = %s", device_name); - if (adv_info->adv_data == NULL) - adv_info->adv_data= g_strdup(device_name); - g_free(device_name); - return; - } - } -} - -static void __bt_find_remote_tv(void) -{ - int ret = BT_ERROR_NONE; - bt_scan_filter_h scan_filter = NULL; - int manufacturer_id = 117; /* samsung */ - - scanning = true; - - ret = bt_adapter_le_scan_filter_unregister_all(); - if (ret != BT_ERROR_NONE) - HID_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_create(&scan_filter); - if (ret != BT_ERROR_NONE) - HID_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_set_manufacturer_data(scan_filter, - manufacturer_id, NULL, 0); - if (ret != BT_ERROR_NONE) - HID_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_register(scan_filter); - if (ret != BT_ERROR_NONE) - HID_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_scan_filter_destroy(scan_filter); - if (ret != BT_ERROR_NONE) - HID_PRT("failed with [0x%04x]", ret); - - ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); - HID_PRT("returns %s\n", __bt_get_error_message(ret)); - - if (ret == BT_ERROR_NONE) - scanning = true; -} -#else -static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) -{ - if (device_info != NULL) { - if (g_strrstr(device_info->remote_name, "[TV]")) { - HID_PRT("TV is boned : %s [%s]", device_info->remote_name, device_info->remote_address); - g_strlcpy(remote_addr, device_info->remote_address, 18); - return false; - } - } - - return true; -} -#endif - -static gboolean __bt_start_service(gpointer user_data) -{ - int ret = BT_ERROR_NONE; - - ret = bt_audio_initialize(); - - ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0); - - ret = bt_adapter_set_name("Tizen Keyboard"); - - ret = bt_audio_select_role(BT_A2DP_SINK); - - ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL); - - ret = bt_audio_set_connection_state_changed_cb( - __bt_audio_connection_state_changed_cb, NULL); - - ret = bt_hid_device_activate( - __bt_hid_device_connection_state_changed_cb, - NULL); - HID_PRT("returns %s", __bt_get_error_message(ret)); - - if (ret != BT_ERROR_NONE && ret != BT_ERROR_NOW_IN_PROGRESS) { - HID_PRT("bt_hid_device_activate() failed."); - g_main_loop_quit(g_mainloop); - return FALSE; - } - - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_HID, - __bt_adapter_hid_profile_connected_devices_cb, NULL); - HID_PRT("HID connected devices returns %s\n", __bt_get_error_message(ret)); - - ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SOURCE, - __bt_adapter_a2dp_profile_connected_devices_cb, NULL); - HID_PRT("A2DP connected devices returns %s\n", __bt_get_error_message(ret)); - - if (hid_connected == false && audio_connected == false) { -#if INIT_BOND - HID_PRT("No TV is connected, try to search..."); - - __bt_find_remote_tv(); -#else - ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, NULL); -#endif - } - return FALSE; -} - -#if INIT_BOND -static void __bt_stop_setup(void) -{ - setup_in_progress = false; -} - -static int __bt_initial_setup(void) -{ - int ret = BT_ERROR_NONE; - bt_device_info_s *device_info = NULL; - - setup_in_progress = true; - - ret = bt_adapter_get_bonded_device_info(remote_addr, &device_info); - HID_PRT("returns %s\n", __bt_get_error_message(ret)); - - if (ret == BT_ERROR_NONE) { - /* Already bond */ - HID_PRT("Device is already paired"); - device_bonded = true; - } else { - /* Create Bond */ - ret = bt_device_create_bond(remote_addr); - HID_PRT("returns %s\n", __bt_get_error_message(ret)); - - if (ret != BT_ERROR_NONE) - return ret; - - WAIT_FOR_SYNC; - } - - if (device_bonded == false) - return BT_ERROR_OPERATION_FAILED; - - /* Connect HID first */ - ret = bt_hid_device_connect(remote_addr); - HID_PRT("HID connect for %s: returns %s", remote_addr, __bt_get_error_message(ret)); - - if (ret == BT_ERROR_NONE) - WAIT_FOR_SYNC; - - /* Connect Audio */ - ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); - HID_PRT("Audio connect for %s: returns %s", remote_addr, __bt_get_error_message(ret)); - - if (ret == BT_ERROR_NONE) - WAIT_FOR_SYNC; - - if (hid_connected == false || audio_connected == false) - ret = BT_ERROR_OPERATION_FAILED; - - setup_in_progress = false; - - return ret; -} -#endif - -static void __bt_tc_usage_print(void) -{ - int i = 0; - tc_table_t *tc_table = tc_hid_device; - - - while (tc_table[i].tc_name) { - HID_PRT("Key %d : usage %s", tc_table[i].tc_code, - tc_table[i].tc_name); - i++; - } - HID_PRT("\n"); -} - -static int __bt_test_input_callback(void *data) -{ - int ret = 0; -#ifdef ARCH64 - int test_id = (uintptr_t)data; -#else - int test_id = (int)data; -#endif - bt_hid_key_data_s send_data; - char pressedkey[8] = { KEYBOARD_F10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - char pressedkey1[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#if INIT_BOND - int cnt = 0; - GSList *l = NULL; - bt_adapter_le_device_scan_result_info_s *info; - - if (setup_in_progress == true && - test_id != BT_HID_DEVICE_TEST_SETUP && - test_id != BT_HID_DEVICE_TEST_FINISH) { - HID_PRT("Initial Setup is in progress,,"); - HID_PRT("Wait to finish setup"); - return 0; - } -#endif - - switch (test_id) { - case BT_HID_DEVICE_SET_ADDRESS: - HID_PRT("Input the address of remote device." - "(e.g.,F6:FB:8F:D8:C8:7C)\n\n"); - - address_input = true; - - break; -#if INIT_BOND - case BT_HID_DEVICE_TEST_SETUP: - if (setup_in_progress == true) { - HID_PRT("Stop the initial setup"); - __bt_stop_setup(); - } else { - if (__bt_initial_setup() != BT_ERROR_NONE) { - HID_PRT("Fail to setup: %s", __bt_get_error_message(ret)); - } - } - break; -#endif - case BT_HID_DEVICE_TEST_VOLUME_UP: - pressedkey[0] = KEYBOARD_F10; /* Vol up */ - - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - HID_PRT("returns %d\n", ret); - - memcpy(send_data.key, pressedkey1, 8); - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - - break; - case BT_HID_DEVICE_TEST_VOLUME_DOWN: - pressedkey[0] = KEYBOARD_F9; /* Vol down */ - - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - HID_PRT("returns %d\n", ret); - - memcpy(send_data.key, pressedkey1, 8); - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - - break; - case BT_HID_DEVICE_TEST_CHANNEL_UP: - pressedkey[0] = KEYBOARD_F12; /* CH up */ - - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - HID_PRT("returns %d\n", ret); - - memcpy(send_data.key, pressedkey1, 8); - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - - break; - case BT_HID_DEVICE_TEST_CHANNEL_DOWN: - pressedkey[0] = KEYBOARD_F11; /* CH down */ - - memcpy(send_data.key, pressedkey, 8); - send_data.modifier = 0; - - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - HID_PRT("returns %d\n", ret); - - memcpy(send_data.key, pressedkey1, 8); - ret = bt_hid_device_send_key_event(remote_addr, &send_data); - - break; - case BT_HID_DEVICE_TEST_CONNECT_AUDIO: - ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); - HID_PRT("returns %s", __bt_get_error_message(ret)); - break; - case BT_HID_DEVICE_TEST_DISCONNECT_AUDIO: - ret = bt_audio_disconnect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); - HID_PRT("returns %s", __bt_get_error_message(ret)); - break; - case BT_HID_DEVICE_TEST_CONNECT_HID: - ret = bt_hid_device_connect(remote_addr); - HID_PRT("returns %s", __bt_get_error_message(ret)); - break; - case BT_HID_DEVICE_TEST_DISCONNECT_HID: - ret = bt_hid_device_disconnect(remote_addr); - HID_PRT("returns %s", __bt_get_error_message(ret)); - break; -#if INIT_BOND - case BT_HID_DEVICE_TEST_SEARCH: - __bt_find_remote_tv(); - break; - case BT_HID_DEVICE_TEST_STOP_SEARCH: - scanning = false; - - ret = bt_adapter_le_stop_scan(); - HID_PRT("returns %s\n", __bt_get_error_message(ret)); - - HID_PRT("LE scan result :\n"); - for (l = le_scan_list; l != NULL; l = g_slist_next(l)) { - info = l->data; - if (info) { - if (info->adv_data) - HID_PRT("[%d] %s, %d dBm, %s", ++cnt, info->remote_address, info->rssi, info->adv_data); - - g_free(info->remote_address); - g_free(info->adv_data); - g_free(info); - } - } - g_slist_free(le_scan_list); - le_scan_list = NULL; - - break; -#endif - case BT_HID_DEVICE_TEST_FINISH: - HID_PRT("Finished"); - g_main_loop_quit(g_mainloop); - break; - default: - break; - } - - return 0; -} - - -static gboolean __bt_key_event_cb(GIOChannel *chan, - GIOCondition cond, - gpointer data) -{ - char buf[49] = { 0 }; - -#ifdef ARCH64 - unsigned long len = 0; -#else - unsigned int len = 0; -#endif - int test_id; - - memset(buf, 0, sizeof(buf)); - - if (g_io_channel_read_chars(chan, buf, sizeof(buf), - &len, NULL) == G_IO_STATUS_ERROR) { - HID_PRT("IO Channel read error"); - return FALSE; - } - - HID_PRT("%s", buf); - - if (address_input == true) { - memcpy(remote_addr, buf, 17); - remote_addr[17] = 0; - address_input = false; - } - -#if INIT_BOND - if (scanning == true) { - test_id = BT_HID_DEVICE_TEST_STOP_SEARCH; -#ifdef ARCH64 - g_idle_add(__bt_test_input_callback, (void *)(uintptr_t)test_id); -#else - g_idle_add(__bt_test_input_callback, (void *)test_id); -#endif - return TRUE; - } -#endif - - test_id = atoi(buf); - - __bt_tc_usage_print(); - -#ifdef ARCH64 - g_idle_add(__bt_test_input_callback, (void *)(uintptr_t)test_id); -#else - g_idle_add(__bt_test_input_callback, (void *)test_id); -#endif - return TRUE; -} - -int main() -{ - int timeout_id = -1; - int ret = BT_ERROR_NONE; - GIOChannel *key_io; - - g_mainloop = g_main_loop_new(NULL, FALSE); - - HID_PRT("HID Keyboard starts"); - - if (bt_initialize() != BT_ERROR_NONE) { - HID_PRT("bt_initialize() failed."); - return -1; - } - - if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { - HID_PRT("bt_adapter_get_state() failed."); - return -1; - } - - /* Enable BT */ - if (bt_state == BT_ADAPTER_DISABLED) { - if (bt_adapter_set_state_changed_cb( - __bt_state_changed_impl, NULL) != BT_ERROR_NONE) { - HID_PRT("bt_adapter_set_state_changed_cb() failed."); - return -1; - } - - if (bt_adapter_enable() == BT_ERROR_NONE) { - HID_PRT("bt_adapter_state_changed_cb will be called."); - timeout_id = g_timeout_add(60000, - __bt_timeout_func, g_mainloop); - g_main_loop_run(g_mainloop); - g_source_remove(timeout_id); - } else { - HID_PRT("bt_adapter_enable() failed."); - return -1; - } - } else { - HID_PRT("BT was already enabled."); - } - - if (bt_state != BT_ADAPTER_ENABLED) { - HID_PRT("BT is not enabled."); - return -1; - } - - g_idle_add(__bt_start_service, NULL); - - key_io = g_io_channel_unix_new(fileno(stdin)); - - g_io_channel_set_encoding(key_io, NULL, NULL); - g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); - - g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - __bt_key_event_cb, NULL); - - g_io_channel_unref(key_io); - - g_main_loop_run(g_mainloop); - - ret = bt_hid_device_deactivate(); - HID_PRT("returns %s\n", __bt_get_error_message(ret)); - - bt_deinitialize(); - - HID_PRT("HID Keyboard ends."); - return 0; -} diff --git a/test/spp_test_addr b/test/spp_test_addr deleted file mode 100644 index 5dd70bf..0000000 --- a/test/spp_test_addr +++ /dev/null @@ -1 +0,0 @@ -E4:FA:ED:75:D7:11 diff --git a/tests/test/CMakeLists.txt b/tests/test/CMakeLists.txt new file mode 100644 index 0000000..0d6a867 --- /dev/null +++ b/tests/test/CMakeLists.txt @@ -0,0 +1,25 @@ +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED glib-2.0 capi-appfw-app-control) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) +ENDFOREACH() + +INSTALL(TARGETS bt_unit_test DESTINATION bin) +INSTALL(TARGETS bt_mesh_unit_test DESTINATION bin) +INSTALL(TARGETS bt_onoff DESTINATION bin) +INSTALL(TARGETS ble_mouse DESTINATION bin) +INSTALL(TARGETS hid_keyboard DESTINATION bin) +INSTALL(TARGETS bt_infinite_spp_test DESTINATION bin) diff --git a/tests/test/ble_mouse.c b/tests/test/ble_mouse.c new file mode 100644 index 0000000..31305db --- /dev/null +++ b/tests/test/ble_mouse.c @@ -0,0 +1,681 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BLE_MOUSE" + +/** + * Variables + **/ +static GMainLoop *g_mainloop = NULL; +static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; +static bt_gatt_server_h server = NULL; +static bt_advertiser_h advertiser = NULL; + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define BLE_PRT(format, args...) PRT(format"\n", ##args) + +static const char *__bt_get_error_message(bt_error_e err) +{ + const char *err_str = NULL; + + switch (err) { + case BT_ERROR_NONE: + err_str = "BT_ERROR_NONE"; + break; + case BT_ERROR_CANCELLED: + err_str = "BT_ERROR_CANCELLED"; + break; + case BT_ERROR_INVALID_PARAMETER: + err_str = "BT_ERROR_INVALID_PARAMETER"; + break; + case BT_ERROR_OUT_OF_MEMORY: + err_str = "BT_ERROR_OUT_OF_MEMORY"; + break; + case BT_ERROR_RESOURCE_BUSY: + err_str = "BT_ERROR_RESOURCE_BUSY"; + break; + case BT_ERROR_TIMED_OUT: + err_str = "BT_ERROR_TIMED_OUT"; + break; + case BT_ERROR_NOW_IN_PROGRESS: + err_str = "BT_ERROR_NOW_IN_PROGRESS"; + break; + case BT_ERROR_NOT_INITIALIZED: + err_str = "BT_ERROR_NOT_INITIALIZED"; + break; + case BT_ERROR_NOT_ENABLED: + err_str = "BT_ERROR_NOT_ENABLED"; + break; + case BT_ERROR_ALREADY_DONE: + err_str = "BT_ERROR_ALREADY_DONE"; + break; + case BT_ERROR_OPERATION_FAILED: + err_str = "BT_ERROR_OPERATION_FAILED"; + break; + case BT_ERROR_NOT_IN_PROGRESS: + err_str = "BT_ERROR_NOT_IN_PROGRESS"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; + break; + case BT_ERROR_AUTH_REJECTED: + err_str = "BT_ERROR_AUTH_REJECTED"; + break; + case BT_ERROR_AUTH_FAILED: + err_str = "BT_ERROR_AUTH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; + break; + case BT_ERROR_SERVICE_SEARCH_FAILED: + err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; + break; + case BT_ERROR_PERMISSION_DENIED: + err_str = "BT_ERROR_PERMISSION_DENIED"; + break; + case BT_ERROR_SERVICE_NOT_FOUND: + err_str = "BT_ERROR_SERVICE_NOT_FOUND"; + break; + case BT_ERROR_NO_DATA: + err_str = "BT_ERROR_NO_DATA"; + break; + case BT_ERROR_NOT_SUPPORTED: + err_str = "BT_ERROR_NOT_SUPPORTED"; + break; + case BT_ERROR_DEVICE_POLICY_RESTRICTION: + err_str = "DEVICE_POLICY_RESTRICTION"; + break; + default: + err_str = "NOT Defined"; + break; + } + + return err_str; +} + +/** + * Callback functions + **/ +static gboolean __timeout_func(gpointer data) +{ + BLE_PRT("Timeout."); + if (g_mainloop) + g_main_loop_quit((GMainLoop *)data); + + return FALSE; +} + +static void __bt_state_changed_impl(int result, + bt_adapter_state_e adapter_state, + void *user_data) +{ + if (adapter_state == BT_ADAPTER_ENABLED) { + if (result == BT_ERROR_NONE) { + BLE_PRT("Callback: BT was enabled successfully."); + bt_state = BT_ADAPTER_ENABLED; + } else { + BLE_PRT("Callback: Failed to enable BT."); + } + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +static void __bt_gatt_read_value1_req_cb( + const char *remote_address, int request_id, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data) +{ + char char_value[4] = {10, 20, 30, 40}; + + int resp_status = BT_ATT_ERROR_NONE; + + BLE_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); + + /* Get the attribute new values here */ + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_READ, offset, + resp_status, char_value, 1 - offset); +} + +static void __bt_gatt_read_value_req_cb( + const char *remote_address, int request_id, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data) +{ + char char_value[1] = { 80 }; /* 80% */ + + int resp_status = BT_ATT_ERROR_NONE; + + BLE_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); + + /* Get the attribute new values here */ + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_READ, offset, + resp_status, char_value, 1 - offset); +} + +static void __bt_gatt_write_value_req_cb(const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, bool response_needed, int offset, + const char *value, int len, void *user_data) +{ + int i, resp_status = BT_ATT_ERROR_NONE; + + BLE_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", + remote_address, request_id, response_needed, offset, len); + + for (i = 0; i < len; i++) + BLE_PRT("%d ", value[i]); + + if (len > 4) { + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_WRITE, offset, + BT_ATT_ERROR_OUT_OF_RANGE, NULL, 0); + + BLE_PRT("Invalid Len"); + return; + } + + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_WRITE, offset, + resp_status, NULL, 0); +} + +static void __bt_gatt_write_value_desc_req_cb(const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, bool response_needed, int offset, + const char *value, int len, void *user_data) +{ + int i, resp_status = BT_ATT_ERROR_NONE; + + BLE_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", + remote_address, request_id, response_needed, offset, len); + + for (i = 0; i < len; i++) + BLE_PRT("%d ", value[i]); + + if (len > 2) { + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_WRITE, offset, + BT_ATT_ERROR_OUT_OF_RANGE, NULL, 0); + + BLE_PRT("Invalid Len"); + return; + } + + bt_gatt_server_send_response(request_id, + BT_GATT_REQUEST_TYPE_WRITE, offset, + resp_status, NULL, 0); +} + + +static void __bt_gatt_notification_state_change_cb(bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + void *user_data) +{ + BLE_PRT("Notification %s [%d]", notify ? "enabled" : "disabled", notify); + BLE_PRT("server %s\n", (char *)server); +} + + +static int __bt_register_hogp_service(void) +{ + int ret = BT_ERROR_NONE; + bt_gatt_h service1 = NULL; /* Human Interface Device */ + bt_gatt_h service2 = NULL; /* Battery Service */ + bt_gatt_h characteristic1_1 = NULL; /* HID Information */ + bt_gatt_h characteristic1_2 = NULL; /* Report Map */ + bt_gatt_h characteristic1_3 = NULL; /* Boot Mouse input Report */ + bt_gatt_h characteristic1_4 = NULL; /* Report */ + bt_gatt_h characteristic1_5 = NULL; /* Report */ + bt_gatt_h characteristic1_6 = NULL; /* HID Control Point */ + bt_gatt_h characteristic1_7 = NULL; /* Protocal Mode */ + bt_gatt_h characteristic2_1 = NULL; /* Battery Level */ + bt_gatt_h characteristic2_2 = NULL; /* Custom read / write */ + bt_gatt_h descriptor1_3 = NULL; /* CCCD */ + bt_gatt_h descriptor1_4_1 = NULL; /* CCCD */ + bt_gatt_h descriptor1_4_2 = NULL; /* Report Reference */ + bt_gatt_h descriptor1_5_1 = NULL; /* Report Reference */ + bt_gatt_h descriptor1_5_2 = NULL; /* CCCD */ + bt_gatt_h descriptor2 = NULL; /* CCCD */ + char *service_uuid1 = "1812"; /* HID Service */ + char *service_uuid2 = "180f"; /* Battery Service */ + char *char_uuid1_1 = "2a4a"; /* HID information */ + char *char_uuid1_2 = "2a4b"; + char *char_uuid1_3 = "2a33"; + char *char_uuid1_4 = "2a4d"; + char *char_uuid1_5 = "2a4d"; + char *char_uuid1_6 = "2a4c"; + char *char_uuid1_7 = "2a4e"; + char *desc_uuid1_3 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid1_4_1 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid1_4_2 = "2908"; /* Report Reference */ + char *desc_uuid1_5_1 = "2908"; /* Report Reference */ + char *desc_uuid1_5_2 = "2901"; /* Characteristic User Description */ + char *char_uuid2_1 = "2a19"; /* Battery Level */ + char *char_uuid2_2 = "2af8"; /* Custom UUID */ + char *desc_uuid2 = "2902"; /* Client Characteristic Configuration */ + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties_read = BT_GATT_PROPERTY_READ; + int properties_read_write = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; + int properties_notify_read = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; + int properties_write_no_response = BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; + int properties_read_write_no_response = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; + + char char_value[1] = { 80 }; /* 80% */ + char char_value_unknown[4] = {10, 20, 30, 40}; + char desc_value_configration[2] = {0, 0}; /* Notification & Indication */ + + ret = bt_gatt_server_initialize(); + BLE_PRT("bt_gatt_server_initialize : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_create(&server); + BLE_PRT("bt_gatt_server_create : %s", __bt_get_error_message(ret)); + + /* HID Service */ + ret = bt_gatt_service_create(service_uuid1, BT_GATT_SERVICE_TYPE_PRIMARY, &service1); + BLE_PRT("bt_gatt_service_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_1, permissions, + properties_read, char_value_unknown, + 4, &characteristic1_1); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_1, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_1); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_2, permissions, + properties_read, char_value_unknown, + 4, &characteristic1_2); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_2, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_2); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_3, permissions, + properties_notify_read, char_value_unknown, + 4, &characteristic1_3); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_3, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic1_3, + __bt_gatt_notification_state_change_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_3); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_3, permissions, + desc_value_configration, 2, &descriptor1_3); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_3, + __bt_gatt_write_value_desc_req_cb, NULL); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_3, descriptor1_3); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_4, permissions, + properties_notify_read, char_value_unknown, + 4, &characteristic1_4); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_4, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic1_4, + __bt_gatt_notification_state_change_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_4); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_4_1, permissions, + desc_value_configration, 2, &descriptor1_4_1); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_4_1, + __bt_gatt_write_value_desc_req_cb, NULL); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_4, descriptor1_4_1); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_4_2, permissions, + desc_value_configration, 2, &descriptor1_4_2); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_4_2, + __bt_gatt_write_value_desc_req_cb, NULL); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_4, descriptor1_4_2); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_5, permissions, + properties_read_write, char_value_unknown, + 4, &characteristic1_5); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_5, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic1_5, + __bt_gatt_write_value_req_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_5); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_5_1, permissions, + desc_value_configration, 2, &descriptor1_5_1); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_write_value_requested_cb(descriptor1_5_1, + __bt_gatt_write_value_desc_req_cb, NULL); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_5, descriptor1_5_1); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_5_2, permissions, + desc_value_configration, 2, &descriptor1_5_2); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_5, descriptor1_5_2); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_6, permissions, + properties_write_no_response, char_value_unknown, + 4, &characteristic1_6); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_6); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1_7, permissions, + properties_read_write_no_response, char_value_unknown, + 4, &characteristic1_7); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic1_7, + __bt_gatt_read_value1_req_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_7); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service1); + BLE_PRT("bt_gatt_server_register_service : %s", __bt_get_error_message(ret)); + + /* Battery Service */ + ret = bt_gatt_service_create(service_uuid2, BT_GATT_SERVICE_TYPE_PRIMARY, &service2); + BLE_PRT("bt_gatt_service_create : %s ", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_1, permissions, + properties_notify_read, char_value, + 1, &characteristic2_1); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic2_1, + __bt_gatt_read_value_req_cb, NULL); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic2_1, + __bt_gatt_notification_state_change_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_1); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2, permissions, + desc_value_configration, 2, &descriptor2); + BLE_PRT("bt_gatt_descriptor_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_1, descriptor2); + BLE_PRT("bt_gatt_characteristic_add_descriptor : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_2, permissions, + properties_read_write, char_value_unknown, + 4, &characteristic2_2); + BLE_PRT("bt_gatt_characteristic_create : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic2_2, + __bt_gatt_read_value_req_cb, NULL); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic2_2, + __bt_gatt_write_value_req_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_2); + BLE_PRT("bt_gatt_service_add_characteristic : %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service2); + BLE_PRT("bt_gatt_server_register_service : %s", __bt_get_error_message(ret)); + + /* Scan Parameters */ + + /* Device INformation */ + + ret = bt_gatt_server_start(); + BLE_PRT("bt_gatt_server_start : %s\n", __bt_get_error_message(ret)); + + return ret; +} + +static int __bt_unregister_hogp_service(void) +{ + int ret = BT_ERROR_NONE; + + ret = bt_gatt_server_unregister_all_services(server); + BLE_PRT("returns %s", __bt_get_error_message(ret)); + + ret = bt_gatt_server_deinitialize(); + BLE_PRT("returns %s\n", __bt_get_error_message(ret)); + + server = NULL; + + return ret; +} + +static void __bt_advertising_state_changed_cb(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, + void *user_data) +{ + BLE_PRT("Result : %d", result); + BLE_PRT("Advertiser : %p", advertiser); + BLE_PRT("Advertising %s [%d]", + adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? + "started" : "stopped", adv_state); +} + +static int __bt_start_advertisement(void) +{ + int ret = BT_ERROR_NONE; + + const char *battery_svc_uuid_16 = "180f"; + const char *hid_svc_uuid_16 = "1812"; + const char *gatt_svc_uuid_16 = "1801"; + int appearance = 192; /* 192 is generic watch */ + + ret = bt_adapter_le_create_advertiser(&advertiser); + BLE_PRT("created le advertiser(%d)", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + BLE_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, hid_svc_uuid_16); + BLE_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, gatt_svc_uuid_16); + BLE_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); + BLE_PRT("add appearance data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, true); + BLE_PRT("add tx_power_level [0x%04x]", ret); + + /* Default scsn response data */ + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + BLE_PRT("set device name [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_connectable(advertiser, true); + BLE_PRT("add scan response data [0x%04x]", ret); + + ret = bt_adapter_le_start_advertising_new(advertiser, __bt_advertising_state_changed_cb, NULL); + BLE_PRT("bt_adapter_le_start_advertising_new [0x%04x]\n", ret); + + return ret; +} + +static int __bt_stop_advertisement(void) +{ + int ret = BT_ERROR_NONE; + + ret = bt_adapter_le_stop_advertising(advertiser); + BLE_PRT("bt_adapter_le_stop_advertising [0x%04x]\n", ret); + + advertiser = NULL; + + return ret; +} + +static gboolean __bt_start_service(gpointer user_data) +{ + if (__bt_register_hogp_service() != BT_ERROR_NONE) { + BLE_PRT("__bt_register_hogp_service() failed."); + g_main_loop_quit(g_mainloop); + return FALSE; + } + + if (__bt_start_advertisement() != BT_ERROR_NONE) { + BLE_PRT("__bt_start_advertisement() failed."); + g_main_loop_quit(g_mainloop); + return FALSE; + } + + return FALSE; +} + +void __bt_gatt_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + BLE_PRT("GATT connected [%s]", remote_address); + + if (__bt_stop_advertisement() != BT_ERROR_NONE) + BLE_PRT("__bt_stop_advertisement() failed."); + } else { + BLE_PRT("GATT Disconnected [%s]", remote_address); + + __bt_unregister_hogp_service(); + + usleep(50000); + + __bt_register_hogp_service(); + + if (__bt_start_advertisement() != BT_ERROR_NONE) + BLE_PRT("__bt_start_advertisement() failed."); + } +} + +int main() +{ + int timeout_id = -1; + int ret = BT_ERROR_NONE; + char *local_address = NULL; + + g_mainloop = g_main_loop_new(NULL, FALSE); + + BLE_PRT("BLE Mouse starts"); + + if (bt_initialize() != BT_ERROR_NONE) { + BLE_PRT("bt_initialize() failed."); + return -1; + } + + if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { + BLE_PRT("bt_adapter_get_state() failed."); + return -1; + } + + /* Enable BT */ + if (bt_state == BT_ADAPTER_DISABLED) { + if (bt_adapter_set_state_changed_cb( + __bt_state_changed_impl, NULL) != BT_ERROR_NONE) { + BLE_PRT("bt_adapter_set_state_changed_cb() failed."); + return -1; + } + + if (bt_adapter_enable() == BT_ERROR_NONE) { + BLE_PRT("bt_adapter_state_changed_cb will be called."); + timeout_id = g_timeout_add(60000, + __timeout_func, g_mainloop); + g_main_loop_run(g_mainloop); + g_source_remove(timeout_id); + } else { + BLE_PRT("bt_adapter_enable() failed."); + return -1; + } + } else { + BLE_PRT("BT was already enabled."); + } + + if (bt_state != BT_ADAPTER_ENABLED) { + BLE_PRT("BT is not enabled."); + return -1; + } + + ret = bt_adapter_get_address(&local_address); + BLE_PRT("\n\nLocal BT address: %s\n", local_address); + + g_free(local_address); + + ret = bt_gatt_set_connection_state_changed_cb( + __bt_gatt_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + BLE_PRT("returns %s\n", __bt_get_error_message(ret)); + + g_idle_add(__bt_start_service, NULL); + + g_main_loop_run(g_mainloop); + + bt_deinitialize(); + + BLE_PRT("BLE Mouse ends."); + return 0; +} diff --git a/tests/test/bt_chat_client.c b/tests/test/bt_chat_client.c new file mode 100644 index 0000000..d6f7708 --- /dev/null +++ b/tests/test/bt_chat_client.c @@ -0,0 +1,451 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BLUETOOTH_CHAT_CLIENT" + +/** + * Variables + **/ +static GMainLoop *g_mainloop = NULL; +static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; +static int socket_fd = -1; +static char *bt_address = NULL; +static char *server_name = "chat_server"; +static char quit_command[5] = "Quit"; +static int bonding_state = BT_ERROR_OPERATION_FAILED; + + +/** + * Callback functions + **/ +gboolean timeout_func(gpointer data) +{ + LOGE("[%s] Callback: Timeout.", __FUNCTION__); + g_main_loop_quit((GMainLoop *)data); + return FALSE; +} + +void bt_state_changed_impl(int result, + bt_adapter_state_e adapter_state, void *user_data) +{ + if (adapter_state == BT_ADAPTER_ENABLED) { + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: BT was enabled successfully.", + __FUNCTION__); + bt_state = BT_ADAPTER_ENABLED; + } else { + LOGE("[%s] Callback: Failed to enable BT.", + __FUNCTION__); + } + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +void bt_socket_connection_state_changed_impl(int result, + bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection, + void *user_data) +{ + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: Result is BT_ERROR_NONE.", + __FUNCTION__); + } else { + LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", + __FUNCTION__); + } + + if (connection_state == BT_SOCKET_CONNECTED) { + LOGI("[%s] Callback: Connected.", + __FUNCTION__); + if (result == BT_ERROR_NONE && connection != NULL) { + socket_fd = connection->socket_fd; + LOGI("[%s] Callback: Socket of connection - %d.", + __FUNCTION__, socket_fd); + LOGI("[%s] Callback: Role of connection - %d.", + __FUNCTION__, connection->local_role); + LOGI("[%s] Callback: Address of connection - %s.", + __FUNCTION__, connection->remote_address); + + if (bt_socket_send_data(socket_fd, + quit_command, + strlen(quit_command)) == BT_ERROR_NONE) { + LOGI("[%s] Callback: Send quit command.", + __FUNCTION__); + } else { + LOGE("[%s] Callback: bt_socket_send_data() failed.", + __FUNCTION__); + if (g_mainloop) + g_main_loop_quit(g_mainloop); + } + } else { + LOGI("[%s] Callback: Failed to connect", + __FUNCTION__); + if (g_mainloop) + g_main_loop_quit(g_mainloop); + } + } else { + LOGI("[%s] Callback: Disconnected.", + __FUNCTION__); + } +} + +void bt_socket_data_received_impl(bt_socket_received_data_s *data, + void *user_data) +{ + if (socket_fd == data->socket_fd) { + if (data->data_size > 0) { + if (!strncmp(data->data, + quit_command, data->data_size)) { + LOGI("[%s] Callback: Quit command.", + __FUNCTION__); + if (g_mainloop) + g_main_loop_quit(g_mainloop); + } + } else { + LOGE("[%s] Callback: No data.", + __FUNCTION__); + } + } else { + LOGI("[%s] Callback: Another socket - %d.", + __FUNCTION__, data->socket_fd); + } +} + +bool bt_adapter_bonded_device_impl(bt_device_info_s *device_info, + void *user_data) +{ + int i = 0; + if (device_info != NULL) { + if (device_info->remote_name != NULL && + !strcmp(device_info->remote_name, (char *)user_data)) { + LOGI("[%s] Callback: chat_server is found in bonded list.", + __FUNCTION__); + if (device_info->remote_address != NULL) { + LOGI("[%s] Callback: Address of chat_server - %s.", + __FUNCTION__, device_info->remote_address); + bt_address = strdup(device_info->remote_address); + LOGI("[%s] Callback: The number of service_count - %d.", + __FUNCTION__, device_info->service_count); + if (device_info->service_count <= 0) { + bonding_state = BT_ERROR_SERVICE_SEARCH_FAILED; + } else { + bonding_state = BT_ERROR_NONE; + for (i = 0; i < device_info->service_count; i++) { + LOGI("[%s] Callback: service[%d] - %s", + __FUNCTION__, + i+1, + device_info->service_uuid[i]); + } + LOGI("[%s] Callback: is_bonded - %d.", + __FUNCTION__, + device_info->is_bonded); + LOGI("[%s] Callback: is_connected - %d.", + __FUNCTION__, + device_info->is_connected); + LOGI("[%s] Callback: is_authorized - %d.", + __FUNCTION__, + device_info->is_authorized); + } + } else { + LOGE("[%s] Callback: Address of chat_server is NULL.", + __FUNCTION__); + } + + return false; + } + } + + return true; +} + +void bt_adapter_device_discovery_state_changed_impl(int result, + bt_adapter_device_discovery_state_e discovery_state, + bt_adapter_device_discovery_info_s *discovery_info, + void *user_data) +{ + if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) { + if (discovery_info->remote_address != NULL && + !strcmp(discovery_info->remote_name, server_name)) { + LOGI("[%s] Callback: chat_server is found.", __FUNCTION__); + LOGI("[%s] Callback: Address of chat_server - %s.", + __FUNCTION__, + discovery_info->remote_address); + LOGI("[%s] Callback: Device major class - %d.", + __FUNCTION__, + discovery_info->bt_class.major_device_class); + LOGI("[%s] Callback: Device minor class - %d.", + __FUNCTION__, + discovery_info->bt_class.minor_device_class); + LOGI("[%s] Callback: Service major class - %d.", + __FUNCTION__, + discovery_info->bt_class.major_service_class_mask); + bt_address = strdup(discovery_info->remote_address); + LOGI("[%s] Callback: is_bonded - %d.", + __FUNCTION__, + discovery_info->is_bonded); + bt_adapter_stop_device_discovery(); + } else { + LOGE("[%s] Callback: Another device is found.", + __FUNCTION__); + } + } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) { + LOGI("[%s] Callback: device discovery finished.", + __FUNCTION__); + if (g_mainloop) + g_main_loop_quit(g_mainloop); + } +} + +void bt_device_bond_created_impl(int result, + bt_device_info_s *device_info, void *user_data) +{ + if (device_info != NULL && + !strcmp(device_info->remote_address, bt_address)) { + bonding_state = result; + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: A bond with chat_server is created.", + __FUNCTION__); + LOGI("[%s] Callback: The number of service - %d.", + __FUNCTION__, device_info->service_count); + + int i = 0; + for (i = 0; i < device_info->service_count; i++) { + LOGI("[%s] Callback: service[%d] - %s", + __FUNCTION__, i+1, + device_info->service_uuid[i]); + } + LOGI("[%s] Callback: is_bonded - %d.", + __FUNCTION__, device_info->is_bonded); + LOGI("[%s] Callback: is_connected - %d.", + __FUNCTION__, device_info->is_connected); + } else { + LOGE("[%s] Callback: Creating a bond is failed.", + __FUNCTION__); + } + } else { + LOGE("[%s] Callback: A bond with another device is created.", + __FUNCTION__); + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +void bt_device_service_searched_impl(int result, + bt_device_sdp_info_s *sdp_info, void *user_data) +{ + if (sdp_info != NULL && + !strcmp(sdp_info->remote_address, bt_address)) { + bonding_state = result; + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: Services of chat_service are found.", + __FUNCTION__); + LOGI("[%s] Callback: The number of service - %d.", + __FUNCTION__, sdp_info->service_count); + + int i = 0; + for (i = 0; i < sdp_info->service_count; i++) { + LOGI("[%s] Callback: service[%d] - %s", + __FUNCTION__, i+1, + sdp_info->service_uuid[i]); + } + } + } else { + LOGE("[%s] Callback: Services of another device are found.", + __FUNCTION__); + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +int main() +{ + g_mainloop = g_main_loop_new(NULL, FALSE); + const char *my_uuid = "11011101-0000-1000-8000-00805F9B34FB"; + int timeout_id = -1; + + LOGI("[%s] Client starts.", __FUNCTION__); + + if (bt_initialize() != BT_ERROR_NONE) { + LOGE("[%s] bt_initialize() failed.", + __FUNCTION__); + return -1; + } + + if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_get_state() failed.", + __FUNCTION__); + return -1; + } + + /* Enable BT */ + if (bt_state == BT_ADAPTER_DISABLED) { + if (bt_adapter_set_state_changed_cb( + bt_state_changed_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_adapter_enable() == BT_ERROR_NONE) { + LOGI("[%s] bt_adapter_state_changed_cb will be called.", + __FUNCTION__); + timeout_id = g_timeout_add(60000, + timeout_func, g_mainloop); + g_main_loop_run(g_mainloop); + g_source_remove(timeout_id); + } else { + LOGE("[%s] bt_adapter_enable() failed.", + __FUNCTION__); + return -1; + } + } else { + LOGI("[%s] BT was already enabled.", + __FUNCTION__); + } + + /* Device discovery */ + if (bt_state == BT_ADAPTER_ENABLED) { + if (bt_adapter_foreach_bonded_device( + bt_adapter_bonded_device_impl, + server_name) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_foreach_bonded_device() failed.", + __FUNCTION__); + return -1; + } + + if (bt_address == NULL) { + if (bt_adapter_set_device_discovery_state_changed_cb( + bt_adapter_device_discovery_state_changed_impl, NULL) + != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_set_device_discovery_state_changed_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) { + LOGI("[%s] bt_adapter_device_discovery_state_changed_cb will be called.", + __FUNCTION__); + g_main_loop_run(g_mainloop); + } else { + LOGE("[%s] bt_adapter_start_device_discovery() failed.", + __FUNCTION__); + return -1; + } + } else { + LOGI("[%s] chat_server is found in bonded device list.", + __FUNCTION__); + } + } else { + LOGE("[%s] BT is not enabled.", + __FUNCTION__); + return -1; + } + + /* Create bond with a server */ + if (bonding_state == BT_ERROR_SERVICE_SEARCH_FAILED) { + if (bt_device_set_service_searched_cb( + bt_device_service_searched_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_device_set_service_searched_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_device_start_service_search(bt_address) == BT_ERROR_NONE) { + LOGI("[%s] bt_device_service_searched_cb will be called.", + __FUNCTION__); + g_main_loop_run(g_mainloop); + } else { + LOGE("[%s] bt_device_start_service_search() failed.", + __FUNCTION__); + return -1; + } + } else if (bonding_state != BT_ERROR_NONE) { + if (bt_device_set_bond_created_cb( + bt_device_bond_created_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_device_set_bond_created_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_device_create_bond(bt_address) == BT_ERROR_NONE) { + LOGI("[%s] bt_device_bond_created_cb will be called.", + __FUNCTION__); + g_main_loop_run(g_mainloop); + } else { + LOGE("[%s] bt_device_create_bond() failed.", + __FUNCTION__); + return -1; + } + } + + /* Connecting socket as a client */ + if (bonding_state == BT_ERROR_NONE) { + if (bt_socket_set_connection_state_changed_cb( + bt_socket_connection_state_changed_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_socket_set_data_received_cb( + bt_socket_data_received_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_set_data_received_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_socket_connect_rfcomm( + bt_address, my_uuid) == BT_ERROR_NONE) { + LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", + __FUNCTION__); + g_main_loop_run(g_mainloop); + } else { + LOGE("[%s] bt_socket_connect_rfcomm() failed.", + __FUNCTION__); + return -1; + } + + if (bt_socket_disconnect_rfcomm( + socket_fd) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_disconnect_rfcomm() failed.", + __FUNCTION__); + return -1; + } + } else { + LOGE("[%s] Bond is not created.", + __FUNCTION__); + return -1; + } + + bt_deinitialize(); + + LOGI("[%s] Client ends.", __FUNCTION__); + return 0; +} diff --git a/tests/test/bt_chat_server.c b/tests/test/bt_chat_server.c new file mode 100644 index 0000000..f2d9542 --- /dev/null +++ b/tests/test/bt_chat_server.c @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BLUETOOTH_CHAT_SERVER" + +/** + * Variables + **/ +static GMainLoop *g_mainloop = NULL; +static bt_adapter_visibility_mode_e visibility_mode = + BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; +static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; +static int service_socket = -1; +static int connected_socket = -1; +static char *quit_command = "Quit"; + + +/** + * Callback functions + **/ +gboolean timeout_func(gpointer data) +{ + LOGE("[%s] Timeout.", __FUNCTION__); + if (g_mainloop) + g_main_loop_quit((GMainLoop *)data); + + return FALSE; +} + +void bt_state_changed_impl(int result, + bt_adapter_state_e adapter_state, + void *user_data) +{ + if (adapter_state == BT_ADAPTER_ENABLED) { + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: BT was enabled successfully.", + __FUNCTION__); + bt_state = BT_ADAPTER_ENABLED; + } else { + LOGE("[%s] Callback: Failed to enable BT.", + __FUNCTION__); + } + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +void bt_socket_connection_state_changed_impl(int result, + bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection, + void *user_data) +{ + if (result == BT_ERROR_NONE) { + LOGI("[%s] Callback: Result is BT_ERROR_NONE.", + __FUNCTION__); + } else { + LOGI("[%s] Callback: Result is not BT_ERROR_NONE.", + __FUNCTION__); + } + + if (connection_state == BT_SOCKET_CONNECTED) { + LOGI("[%s] Callback: Connected.", + __FUNCTION__); + if (connection != NULL) { + connected_socket = connection->socket_fd; + LOGI("[%s] Callback: Socket of connection - %d.", + __FUNCTION__, connected_socket); + LOGI("[%s] Callback: Role of connection - %d.", + __FUNCTION__, connection->local_role); + LOGI("[%s] Callback: Address of connection - %s.", + __FUNCTION__, connection->remote_address); + } else { + LOGI("[%s] Callback: No connection data", + __FUNCTION__); + } + } else { + LOGI("[%s] Callback: Disconnected.", + __FUNCTION__); + LOGI("[%s] Callback: Socket of connection - %d.", + __FUNCTION__, connected_socket); + LOGI("[%s] Callback: Role of connection - %d.", + __FUNCTION__, connection->local_role); + LOGI("[%s] Callback: Address of connection - %s.", + __FUNCTION__, connection->remote_address); + } +} + +void bt_socket_data_received_impl(bt_socket_received_data_s *data, + void *user_data) +{ + if (data->data_size > 0) { + if (!strncmp(data->data, quit_command, data->data_size)) { + LOGI("[%s] Callback: Quit command.", __FUNCTION__); + if (g_mainloop) + g_main_loop_quit(g_mainloop); + } + + if (bt_socket_send_data(connected_socket, + quit_command, strlen(quit_command)) == BT_ERROR_NONE) { + LOGI("[%s] Callback: Send quit command.", + __FUNCTION__); + } else { + LOGE("[%s] Callback: bt_socket_send_data() failed.", + __FUNCTION__); + } + } else { + LOGE("[%s] Callback: No data.", __FUNCTION__); + } +} + + +int main() +{ + g_mainloop = g_main_loop_new(NULL, FALSE); + const char *my_uuid = "11011101-0000-1000-8000-00805F9B34FB"; + int timeout_id = -1; + + LOGI("[%s] Server starts.", + __FUNCTION__); + + if (bt_initialize() != BT_ERROR_NONE) { + LOGE("[%s] bt_initialize() failed.", + __FUNCTION__); + return -1; + } + + if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_get_state() failed.", + __FUNCTION__); + return -1; + } + + /* Enable BT */ + if (bt_state == BT_ADAPTER_DISABLED) { + if (bt_adapter_set_state_changed_cb( + bt_state_changed_impl, NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_set_state_changed_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_adapter_enable() == BT_ERROR_NONE) { + LOGI("[%s] bt_adapter_state_changed_cb will be called.", + __FUNCTION__); + timeout_id = g_timeout_add(60000, + timeout_func, g_mainloop); + g_main_loop_run(g_mainloop); + g_source_remove(timeout_id); + } else { + LOGE("[%s] bt_adapter_enable() failed.", + __FUNCTION__); + return -1; + } + } else { + LOGI("[%s] BT was already enabled.", + __FUNCTION__); + } + + /* Set name as "chat_server" */ + if (bt_state == BT_ADAPTER_ENABLED) { + char *name = NULL; + if (bt_adapter_get_name(&name) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_get_name() failed.", + __FUNCTION__); + return -1; + } + + if (NULL == name) + return -1; + + if (strncmp(name, "chat_server", strlen(name)) != 0) { + if (bt_adapter_set_name( + "chat_server") != BT_ERROR_NONE) { + if (NULL != name) + free(name); + LOGE("[%s] bt_adapter_set_name() failed.", + __FUNCTION__); + return -1; + } + } + free(name); + } else { + LOGE("[%s] BT is not enabled.", + __FUNCTION__); + return -1; + } + /* Set visibility as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE */ + if (bt_adapter_get_visibility( + &visibility_mode, + NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_get_visibility() failed.", + __FUNCTION__); + return -1; + } + + if (visibility_mode != BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) { + if (bt_adapter_set_visibility( + BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, + 0) != BT_ERROR_NONE) { + LOGE("[%s] bt_adapter_set_visibility() failed.", + __FUNCTION__); + return -1; + } + visibility_mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; + } else { + LOGI("[%s] Visibility mode was already set as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE.", + __FUNCTION__); + } + + /* Connecting socket as a server */ + if (bt_socket_create_rfcomm(my_uuid, + &service_socket) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_create_rfcomm() failed.", + __FUNCTION__); + return -1; + } + LOGI("[%s] socket is created - %d.", + __FUNCTION__, + service_socket); + + if (bt_socket_set_connection_state_changed_cb( + bt_socket_connection_state_changed_impl, + NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_set_connection_state_changed_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_socket_set_data_received_cb(bt_socket_data_received_impl, + NULL) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_set_data_received_cb() failed.", + __FUNCTION__); + return -1; + } + + if (bt_socket_listen_and_accept_rfcomm( + service_socket, 5) == BT_ERROR_NONE) { + LOGI("[%s] bt_socket_connection_state_changed_cb will be called.", + __FUNCTION__); + g_main_loop_run(g_mainloop); + } else { + LOGE("[%s] bt_socket_listen_and_accept_rfcomm() failed.", + __FUNCTION__); + return -1; + } + + sleep(5); /* Wait for completing delivery */ + if (bt_socket_destroy_rfcomm(service_socket) != BT_ERROR_NONE) { + LOGE("[%s] bt_socket_destroy_rfcomm() failed.", + __FUNCTION__); + return -1; + } else { + LOGE("[%s] bt_socket_destroy_rfcomm() succeeded.", + __FUNCTION__); + } + + bt_deinitialize(); + + LOGI("[%s] Server ends.", __FUNCTION__); + return 0; +} diff --git a/tests/test/bt_infinite_spp_test.c b/tests/test/bt_infinite_spp_test.c new file mode 100644 index 0000000..97326d8 --- /dev/null +++ b/tests/test/bt_infinite_spp_test.c @@ -0,0 +1,538 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#undef LOG_TAG +#define LOG_TAG "BLUETOOTH_SPP_TEST" + +#define BT_DBG(fmt, args...) \ + SLOGD(fmt, ##args) +#define BT_INFO(fmt, args...) \ + SLOGI(fmt, ##args) +#define BT_ERR(fmt, args...) \ + SLOGE(fmt, ##args) + +typedef enum +{ + BT_SPP_TEST_ROLE_SERVER = 0x00, + BT_SPP_TEST_ROLE_CLIENT, +} bt_spp_test_role_e; + +#define BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH "/opt/usr/home/owner/media/Downloads/spp_test_addr" +#define BT_INFINITE_SPP_TEST_RESULT_FILE_PATH "/opt/usr/home/owner/media/Downloads/spp_result.log" + +bool __bt_connect_spp(void); +static gboolean __bt_send_data(gpointer user_data); +bool __bt_verify_data(char *data, int data_size); +bool __bt_bond_remote_device(void); +bool __bt_is_paired(void); + +static GMainLoop* g_mainloop = NULL; + +static bt_spp_test_role_e spp_role = BT_SPP_TEST_ROLE_SERVER; +static char remote_addr[18] = {0,}; +static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; + +const char *spp_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"; +static int server_fd = -1; +static int socket_fd = -1; +static bool is_receive_complete = false; + +static int packet_size = 65536; +static char *buf = NULL; +static int total_count = 32; +static int sent_count = 0; +static int receive_count = 0; +static int receive_index = 0; + +static struct timeval start_time = {0,}; +static struct timeval end_time = {0,}; +static struct timeval diff_time = {0,}; + +static int sum_time_ms = 0; +static int avg_time_ms = 0; +static int total_test_count = 0; + +void __bt_create_log_dump(void) +{ + char *argv[] = {"/usr/bin/crashctl", "dump_log", "normal", NULL}; + execv("/usr/bin/crashctl", argv); + + BT_ERR("Fail to verify data"); + +#if 0 + if (g_mainloop) + g_main_loop_quit(g_mainloop); + else + exit(0); +#endif +} + +static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, void *user_data) +{ + if (data == NULL) { + BT_ERR("data is NULL"); + return; + } + BT_INFO("FD = %d, Buffer len = %d", data->socket_fd, data->data_size); + + if (__bt_verify_data(data->data, data->data_size) == false) + __bt_create_log_dump(); + + if (is_receive_complete == true) + g_idle_add(__bt_send_data, NULL); +} + +static void __bt_device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data) +{ + if (result != BT_ERROR_NONE) { + BT_ERR("result[0x%X]", result); + return; + } + + if (strcmp(device_info->remote_address, remote_addr) == 0) { + if (__bt_connect_spp() == false) + BT_ERR("__bt_connect_spp() failed."); + } +} + +static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) +{ + bool *is_paired = (bool*)user_data; + + if (strcmp(device_info->remote_address, remote_addr) == 0) { + BT_INFO("remote_addr is exist."); + *is_paired = true; + return false; + } + + return true; +} + +void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data) +{ + BT_INFO("result [0x%04x] state = %d", result, adapter_state); + + if (result == BT_ERROR_NONE) { + bt_state = adapter_state; + if (adapter_state == BT_ADAPTER_ENABLED) { + if (__bt_is_paired() == true) + __bt_connect_spp(); + else + __bt_bond_remote_device(); + } + } +} + +void __bt_socket_connection_state_changed_cb(int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data) +{ + if (connection_state == BT_SOCKET_CONNECTED) { + BT_INFO("RFCOMM connected, result [0x%04x] Fd = %d, device add = %s, Role = %s", + result, connection->socket_fd, connection->remote_address, + (connection->local_role == BT_SOCKET_SERVER) ? "SERVER" : "CLIENT"); + + if (connection->socket_fd > 0) { + socket_fd = connection->socket_fd; + if (spp_role == BT_SPP_TEST_ROLE_CLIENT) + g_idle_add(__bt_send_data, NULL); + } else { + BT_ERR("socket_fd is INVALID"); + } + } else { + BT_INFO("RFCOMM disconnected, result [0x%04x] Fd = %d, device add = %s", + result, connection->socket_fd, connection->remote_address); + __bt_create_log_dump(); + } +} + +void __bt_spp_calc_speed(void) +{ + int total_time_ms; + FILE *fp = NULL; + static char str_speed[30] = "\0"; + int speed; + + diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec; + diff_time.tv_usec = end_time.tv_usec - start_time.tv_usec; + + if(diff_time.tv_usec < 0) + { + diff_time.tv_sec = diff_time.tv_sec - 1; + diff_time.tv_usec = diff_time.tv_usec + 1000000; + } + + fp = fopen(BT_INFINITE_SPP_TEST_RESULT_FILE_PATH, "a+"); + /* Fix : NULL_RETURNS */ + if (fp == NULL) { + BT_ERR("Cannot open file: %s\n", BT_INFINITE_SPP_TEST_RESULT_FILE_PATH); + return; + } + total_time_ms = (diff_time.tv_sec * 1000); + total_time_ms += diff_time.tv_usec / 1000; + + speed = (packet_size * total_count * 8) / total_time_ms; + + BT_INFO("%s @ %d kbps", "2MB", speed); + snprintf(str_speed, 30, "%s @ %d kbps", "2MB", speed); + fprintf(fp, "%s\n", str_speed); + + total_test_count++; + sum_time_ms += total_time_ms; + if (total_test_count % 10 == 0) { + avg_time_ms = sum_time_ms / total_test_count; + speed = (packet_size * total_count * 8) / avg_time_ms; + BT_INFO("[AVG(%d times)] %d kbps", total_test_count, speed); + snprintf(str_speed, 30, "[AVG(%d times)] %d kbps", total_test_count, speed); + fprintf(fp, "%s\n", str_speed); + } + + if (total_test_count == 1000) { + sum_time_ms = 0; + avg_time_ms = 0; + total_test_count = 0; + } + + fclose(fp); +} + +void __bt_make_data(void) +{ + int i; + int j; + char w = 0x20; + + memset(buf, 0x00, packet_size); + for (i = 0; i < packet_size / 256; i++) { + for (j = 0; j < 256; j++) { + buf[i * 256 + j] = w; + } + + w++; + if (w > 0x7e) + w = 0x20; + } +} + +bool __bt_verify_data(char *data, int data_size) +{ + int i; + + if (receive_count == 0 && receive_index == 0) + gettimeofday(&start_time, NULL); + + for (i = 0; i < data_size; i++) { + if (data[i] != buf[receive_index]) { + BT_ERR("data error. rcv_cnt=%d, data[%d]=%d, buf[%d]=%d", receive_count, i, data[i], receive_index, buf[receive_index]); + return false; + } + + receive_index++; + if (receive_index == packet_size) { + receive_index = 0; + receive_count++; + + if (receive_count == total_count) + is_receive_complete = true; + } + } + + if (is_receive_complete == true) { + gettimeofday(&end_time, NULL); + __bt_spp_calc_speed(); + receive_count = 0; + receive_index = 0; + } + + return true; +} + +static gboolean __bt_send_data(gpointer user_data) +{ + int ret = BT_ERROR_NONE; + int write = 0; + int state = 0; + struct timeval tv_write_timeout = {0, }; + fd_set wfds; + int fail_count = 0; + + tv_write_timeout.tv_sec = 1; + + is_receive_complete = false; + + if (sent_count == 0) + gettimeofday(&start_time, NULL); + + while (write < packet_size) { + FD_ZERO(&wfds); + FD_SET(socket_fd, &wfds); + state = select(socket_fd + 1, NULL, &wfds, NULL, &tv_write_timeout); + if (state == -1) { + BT_ERR("select() error.[0x%X]", ret); + __bt_create_log_dump(); + return FALSE; + } else { + if (FD_ISSET(socket_fd, &wfds)) { + ret = bt_socket_send_data(socket_fd, buf + write, packet_size - write); + if(ret <= 0) { + BT_ERR("bt_socket_send_data() failed.[0x%X]", ret); + __bt_create_log_dump(); + return FALSE; + } else { + write += ret; + } + fail_count = 0; + } else { + BT_ERR("socket is NOT ready.(fail_count = %d)", fail_count); + if (fail_count++ == 10) { + BT_ERR("__bt_send_data failed."); + __bt_create_log_dump(); + return FALSE; + } + } + } + } + + sent_count++; + if (sent_count == total_count) { + BT_INFO("Last packet."); + gettimeofday(&end_time, NULL); + __bt_spp_calc_speed(); + sent_count = 0; + } else { + return TRUE; + } + + return FALSE; +} + +static bool __bt_adapter_foreach_bonded_device_cb(bt_device_info_s *device_info, void *user_data) +{ + if (device_info != NULL) { + if (bt_device_set_authorization(device_info->remote_address, BT_DEVICE_AUTHORIZED) != BT_ERROR_NONE) + BT_ERR("Fail to authorize"); + } + + return true; +} + +bool __bt_connect_spp(void) +{ + int ret = BT_ERROR_NONE; + + if (spp_role == BT_SPP_TEST_ROLE_SERVER) { + if (bt_adapter_foreach_bonded_device(__bt_adapter_foreach_bonded_device_cb, NULL) != BT_ERROR_NONE) + BT_ERR("Fail to get bonded devices"); + + if (server_fd < 0) { + ret = bt_socket_create_rfcomm(spp_secure_uuid, &server_fd); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_socket_create_rfcomm() failed.[0x%X]", ret); + return false; + } + } + + ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_socket_listen_and_accept_rfcomm() failed.[0x%X]", ret); + return false; + } + } else { + ret = bt_socket_connect_rfcomm(remote_addr, spp_secure_uuid); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_socket_connect_rfcomm() failed.[0x%X]", ret); + bt_socket_destroy_rfcomm(server_fd); + return false; + } + } + + return true; +} + +bool __bt_bond_remote_device(void) +{ + int ret = BT_ERROR_NONE; + + ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_device_set_bond_created_cb() failed.[0x%X]", ret); + return false; + } + + if (spp_role == BT_SPP_TEST_ROLE_CLIENT) { + ret = bt_device_create_bond(remote_addr); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_device_create_bond() failed.[0x%X]", ret); + return false; + } + } + + return true; +} + +bool __bt_is_paired(void) +{ + int ret = BT_ERROR_NONE; + bool is_paired = false; + + ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, &is_paired); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_adapter_foreach_bonded_device() failed.[0x%X]", ret); + return false; + } + + return is_paired; +} + +bool __bt_init(void) +{ + int ret = BT_ERROR_NONE; + + ret = bt_initialize(); + if(ret != BT_ERROR_NONE) { + BT_ERR("bt_initialize() failed.[0x%X]", ret); + return false; + } + + ret = bt_adapter_get_state(&bt_state); + if(ret != BT_ERROR_NONE) { + BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret); + return false; + } + + ret = bt_adapter_set_state_changed_cb(__bt_adapter_state_changed_cb, NULL); + if(ret != BT_ERROR_NONE) { + BT_ERR("bt_adapter_get_state() failed.[0x%X]", ret); + return false; + } + + ret = bt_socket_set_connection_state_changed_cb(__bt_socket_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_socket_set_connection_state_changed_cb() failed.[0x%X]", ret); + return false; + } + + ret = bt_socket_set_data_received_cb(__bt_socket_data_received_cb, NULL); + if (ret != BT_ERROR_NONE) { + BT_ERR("bt_socket_set_data_received_cb() failed.[0x%X]", ret); + return false; + } + + if (buf == NULL) { + buf = malloc(packet_size); + if (buf == NULL) { + BT_ERR("Out of memory"); + return false; + } + __bt_make_data(); + } + + return true; +} + +void __bt_deinit(void) +{ + int ret = BT_ERROR_NONE; + + if (buf) + free(buf); + + if (server_fd >= 0) + bt_socket_destroy_rfcomm(server_fd); + + ret = bt_socket_unset_data_received_cb(); + if (ret != BT_ERROR_NONE) + BT_ERR("bt_socket_unset_data_received_cb() failed.[0x%X]", ret); + + ret = bt_socket_unset_connection_state_changed_cb(); + if (ret != BT_ERROR_NONE) + BT_ERR("bt_socket_unset_connection_state_changed_cb() failed.[0x%X]", ret); + + ret = bt_device_unset_bond_created_cb(); + if (ret != BT_ERROR_NONE) + BT_ERR("bt_device_unset_bond_created_cb() failed.[0x%X]", ret); + + ret = bt_deinitialize(); + if(ret != BT_ERROR_NONE) + BT_ERR("bt_deinitialize() failed.[0x%X]", ret); +} + +bool __bt_set_remote_address(void) +{ + FILE *fp = NULL; + + if ((fp = fopen(BT_INFINITE_SPP_TEST_REMOTE_ADDRESS_FILE_PATH, "r")) == NULL) { + BT_ERR("remote_addr file is NOT exist."); + return false; + } + + if (fgets(remote_addr, 18, fp) == NULL) { + BT_ERR("remote_addr is INVALID."); + fclose(fp); + return false; + } + + fclose(fp); + return true; +} + +int main(int argc, char *argv[]) +{ + if (argc == 2 && strcmp(argv[1], "client") == 0) + spp_role = BT_SPP_TEST_ROLE_CLIENT; + BT_INFO("SPP test role is %s", spp_role==BT_SPP_TEST_ROLE_SERVER?"SERVER":"CLIENT"); + + if (spp_role == BT_SPP_TEST_ROLE_CLIENT) { + if (__bt_set_remote_address() == false) + return -1; + } + + if (__bt_init() == false) + goto fail; + + if (bt_state == BT_ADAPTER_ENABLED) { + if (spp_role == BT_SPP_TEST_ROLE_SERVER) { + if (bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0) != BT_ERROR_NONE) + BT_ERR("Fail to set visibility"); + + __bt_connect_spp(); + } else { + if (__bt_is_paired() == true) { + if (__bt_connect_spp() == false) + goto fail; + } else { + if (__bt_bond_remote_device() == false) + goto fail; + } + } + } + + g_mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(g_mainloop); + +fail: + if (g_mainloop) + g_main_loop_unref(g_mainloop); + + __bt_deinit(); + + return 0; +} diff --git a/tests/test/bt_infinite_spp_test_server.service b/tests/test/bt_infinite_spp_test_server.service new file mode 100644 index 0000000..f622aee --- /dev/null +++ b/tests/test/bt_infinite_spp_test_server.service @@ -0,0 +1,7 @@ +[Unit] +Description=BT SPP test infinitely + +[Service] +Type=oneshot +ExecStart=/usr/bin/bt_infinite_spp_test +RemainAfterExit=yes diff --git a/tests/test/bt_mesh_unit_test.c b/tests/test/bt_mesh_unit_test.c new file mode 100644 index 0000000..49e1442 --- /dev/null +++ b/tests/test/bt_mesh_unit_test.c @@ -0,0 +1,1945 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved * + * + * @author: Anupam Roy + * @author: Himanshu + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#ifdef ARCH64 +#include +#endif +#include + +#include "bluetooth.h" +#include "bluetooth_type_internal.h" +#include "bluetooth_internal.h" +#include "bluetooth_private.h" +#include "bt_mesh_unit_test.h" + +static bt_mesh_unit_test_table_e current_tc_table; + +static bool need_to_set_params = false; +static int g_test_id = -1; +static tc_params_t g_test_param = {0,}; + +static bt_mesh_node_h local_node = NULL; +static bt_mesh_node_h node; +static bt_mesh_network_h network; +static char *device_uuid; + +static bt_mesh_netkey_h netkey; + +static bt_mesh_group_h group; +static char *token; +static bt_mesh_authentication_type_e request_type = BT_MESH_AUTH_ALPHANUMERIC_DISPLAY; + +GMainLoop *main_loop = NULL; + +tc_table_t tc_configuration[] = { + {"Back" + , BT_MESH_UNIT_TEST_FUNCTION_BACK}, + {"bt_mesh_network_discover_node" + , BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE}, + {"bt_mesh_node_reset" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET}, + {"bt_mesh_node_get_features" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES}, + {"bt_mesh_node_foreach_netkeys" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS}, + {"bt_mesh_node_foreach_appkeys" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS}, + {"bt_mesh_node_get_ttl" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL}, + {"bt_mesh_node_set_ttl" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL}, + {"bt_mesh_node_configure_netkey" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY}, + {"bt_mesh_node_configure_appkey" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY}, + {"bt_mesh_model_bind_appkey" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY}, + {"bt_mesh_model_unbind_appkey" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY}, + {"bt_mesh_model_get_appkey_list" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST}, + {"bt_mesh_model_configure_group_subscription" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION}, + {"bt_mesh_model_configure_virtual_group_subscription" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION}, + {"bt_mesh_model_get_subscription_list" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST}, + {"bt_mesh_model_set_publication" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION}, + {"bt_mesh_model_get_publication" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION}, + {"bt_mesh_appkey_get_netkey" + , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY}, + {"select this menu to set parameters and then select the function again" + , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0X0000}, +}; + +tc_table_t tc_network[] = { + {"Back" + , BT_MESH_UNIT_TEST_FUNCTION_BACK}, + {"bt_mesh_node_create" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE}, + {"bt_mesh_node_destroy" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY}, + {"bt_mesh_node_create_element" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT}, + {"bt_mesh_node_get_network" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK}, + {"bt_mesh_element_create_model" + , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL}, + {"bt_mesh_model_get_id" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID}, + {"bt_mesh_model_destroy" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY}, + {"bt_mesh_model_get_element" + , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT}, + {"bt_mesh_element_destroy" + , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY}, + {"bt_mesh_element_get_node" + , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE}, + {"bt_mesh_node_foreach_element" + , BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS}, + {"bt_mesh_element_foreach_models" + , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS}, + {"bt_mesh_network_create" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE}, + {"bt_mesh_network_load" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD}, + {"bt_mesh_network_set_name" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME}, + {"bt_mesh_network_get_name" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME}, + {"bt_mesh_network_add_netkey" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY}, + {"bt_mesh_network_foreach_netkeys" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS}, + {"bt_mesh_netkey_get_index" + , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX}, + {"bt_mesh_netkey_update" + , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE}, + {"bt_mesh_netkey_delete" + , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE}, + {"bt_mesh_netkey_add_appkey" + , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY}, + {"bt_mesh_netkey_foreach_appkeys" + , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS}, + {"bt_mesh_appkey_get_index" + , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX}, + {"bt_mesh_appkey_update" + , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE}, + {"bt_mesh_appkey_delete" + , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE}, + {"bt_mesh_network_foreach_devices" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES}, + {"bt_mesh_network_create_group" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP}, + {"bt_mesh_network_create_virtual_group" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP}, + {"bt_mesh_network_remove_group" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP}, + {"bt_mesh_network_foreach_groups" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS}, + {"bt_mesh_network_unprovisioned_device_scan" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN}, + {"bt_mesh_stop_unprovisioned_device_scan" + , BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN}, + {"bt_mesh_network_provision_device" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE}, + {"bt_mesh_authentication_set_request_cb" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB}, + {"bt_mesh_authentication_reply" + , BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY}, + {"bt_mesh_network_set_provisioning_capabilities" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES}, + {"bt_mesh_network_get_provisioning_capabilities" + , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES}, + {"select this menu to set parameters and then select the function again" + , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0X0000}, +}; + +tc_table_t tc_main[] = { + {"bt_mesh_initialize" + , BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE}, + {"bt_mesh_deinitialize" + , BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE}, + {"Network" + , BT_MESH_UNIT_TEST_TABLE_NETWORK}, + {"Configuration" + , BT_MESH_UNIT_TEST_TABLE_CONFIGURATION}, + {"Finish" + , BT_MESH_UNIT_TEST_TABLE_FINISH}, + {NULL , 0x0000}, +}; + +static void __bt_free_test_param(tc_params_t *param) +{ + int i = 0; + + for (i = 0; i < param->param_count; i++) + g_free(param->params[i]); + g_free(param->params); + param->params = NULL; + param->param_count = 0; +} + +void tc_usage_print(void){ + int i=0; + tc_table_t *tc_table = NULL; + switch (current_tc_table) { + case BT_MESH_UNIT_TEST_TABLE_NETWORK: + tc_table = tc_network; + break; + case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: + tc_table = tc_configuration; + break; + default: + tc_table = tc_main; + break; + } + while (tc_table[i].tc_name) { + TC_PRT("Key %d : usage %s", tc_table[i].tc_code,tc_table[i].tc_name); + i++; + } +} + +static const char *__bt_get_error_message(bt_error_e err) +{ + const char *err_str = NULL; + + switch (err) { + case BT_ERROR_NONE: + err_str = "BT_ERROR_NONE"; + break; + case BT_ERROR_CANCELLED: + err_str = "BT_ERROR_CANCELLED"; + break; + case BT_ERROR_INVALID_PARAMETER: + err_str = "BT_ERROR_INVALID_PARAMETER"; + break; + case BT_ERROR_OUT_OF_MEMORY: + err_str = "BT_ERROR_OUT_OF_MEMORY"; + break; + case BT_ERROR_RESOURCE_BUSY: + err_str = "BT_ERROR_RESOURCE_BUSY"; + break; + case BT_ERROR_TIMED_OUT: + err_str = "BT_ERROR_TIMED_OUT"; + break; + case BT_ERROR_NOW_IN_PROGRESS: + err_str = "BT_ERROR_NOW_IN_PROGRESS"; + break; + case BT_ERROR_NOT_INITIALIZED: + err_str = "BT_ERROR_NOT_INITIALIZED"; + break; + case BT_ERROR_NOT_ENABLED: + err_str = "BT_ERROR_NOT_ENABLED"; + break; + case BT_ERROR_ALREADY_DONE: + err_str = "BT_ERROR_ALREADY_DONE"; + break; + case BT_ERROR_OPERATION_FAILED: + err_str = "BT_ERROR_OPERATION_FAILED"; + break; + case BT_ERROR_NOT_IN_PROGRESS: + err_str = "BT_ERROR_NOT_IN_PROGRESS"; + break; + default: + err_str = "NOT defined"; + break; + } + return err_str; +} + +void print_network_handle(bt_mesh_network_h network) +{ + if(network == NULL) + return; + bt_mesh_network_s* net = (bt_mesh_network_s*) network; + TC_PRT("network_handle = [%p]", (void*)net); + TC_PRT("net->is_local [%d]", net->is_local); + TC_PRT("net->is_discovered [%d]", net->is_discovered); + TC_PRT("net->uuid [%s]", net->uuid); + TC_PRT("net->token [%s]", net->token); + TC_PRT("net->name [%s]", net->name); + TC_PRT("net->num_nodes [%d]", net->num_nodes); +} + +void print_node_handle(bt_mesh_node_h node) +{ + if(node == NULL) + return; + bt_mesh_node_s* node_info = (bt_mesh_node_s*) node; + TC_PRT("node_handle = [%p]",(void*)node_info); + TC_PRT("node->is_local [%d]", node_info->is_local); + TC_PRT("node->is_attached [%d]", node_info->is_attached); + if (node_info->is_attached) { + TC_PRT("node->parent_network [%s]", node_info->parent->name); + TC_PRT("node->uuid [%s]", node_info->uuid); + TC_PRT("node->unicast [%d]", node_info->unicast); + } + +} + +void print_element_handle(bt_mesh_element_h element) +{ + if(element == NULL) + return; + bt_mesh_element_s* element_info = (bt_mesh_element_s*) element; + TC_PRT("element_handle = [%p]", (void*)element_info); + TC_PRT("element->is_local [%d]", element_info->is_local); + TC_PRT("element->index [%d]", element_info->index); +} + +void print_model_handle(bt_mesh_model_h model) +{ + if(model == NULL) + return; + bt_mesh_model_s* model_info = (bt_mesh_model_s*) model; + TC_PRT("model_handle = [%p]", (void*)model_info); + TC_PRT("model->is_local [%d]", model_info->is_local); + TC_PRT("model->id [0x%4.4x]", model_info->id); + TC_PRT("model->pub_addr [0x%2.2x]", model_info->pub_addr); +} + +void print_netkey_handle(bt_mesh_netkey_h netkey) +{ + if(netkey == NULL) + return; + bt_mesh_netkey_s* netkey_info = (bt_mesh_netkey_s*) netkey; + TC_PRT("netkey_handle = [%p]", (void*)netkey_info); + TC_PRT("Parent network_name [%s]", netkey_info->parent->name); + TC_PRT("Netkey_index [%d]", netkey_info->netkey_index); +} + +void print_appkey_handle(bt_mesh_appkey_h appkey) +{ + if(appkey == NULL) + return; + bt_mesh_appkey_s* appkey_info = (bt_mesh_appkey_s*) appkey; + TC_PRT("appkey_handle = [%p]", (void*)appkey_info); + TC_PRT("Parent netkey_index [%d]", appkey_info->parent->netkey_index); + TC_PRT("appkey_index [%d]", appkey_info->appkey_index); +} + +void print_group_handle(bt_mesh_group_h group) +{ + if(group == NULL) + return; + bt_mesh_group_s* group_info = (bt_mesh_group_s*) group; + TC_PRT("group_handle = [%p]", (void*)group_info); + TC_PRT("group->parent_network->name [%s]", group_info->parent->name); + TC_PRT("group->addr [%d]", group_info->addr); + TC_PRT("group->label_uuid [%s]", group_info->label_uuid); + TC_PRT("group->is_virtual [%d]", group_info->is_virtual); + TC_PRT("group->ref_count [%d]", group_info->ref_count); +} + +bool __bt_mesh_network_device_info_cb(int result, bt_mesh_network_h network, int total, + const char *dev_uuid, uint16_t primary_unicast, void *user_data) +{ + TC_PRT("bt_mesh_network_device_info_cb"); + TC_PRT("Total number of Devices in network [%d]", total); + + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("primary unicast address is [%d]",primary_unicast); + TC_PRT("Device UUID [%s]", dev_uuid); + return true; +} + +bool __bt_mesh_network_group_info_cb(int result, bt_mesh_network_h network, int total, + bt_mesh_group_h group, void *user_data) +{ + bt_mesh_group_s* grp = (bt_mesh_group_s*) group; + TC_PRT("bt_mesh_network_group_info_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_group_handle(grp); + } + return true; +} + +void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network, bt_mesh_node_h node_param, + void *user_data) +{ + TC_PRT("bt_mesh_node_discover_status_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + //print_network_handle(network); + print_node_handle(node_param); + if (result == BT_ERROR_NONE) + node = node_param; +} + +static bool __bt_mesh_elem_foreach_model_cb(int result, bt_mesh_element_h element, int total, + bt_mesh_model_h model, bt_mesh_model_id_s *model_id, void *user_data) +{ + TC_PRT("__bt_mesh_elem_foreach_model_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + TC_PRT("Total number of Models in the element [%d]", total); + print_element_handle(element); + if (total) { + print_model_handle(model); + TC_PRT("Model Comp ID [0x%2.2x] Model ID [0x%2.2x]", + model_id->company_id, model_id->model_id); + } + return true; + } else + return false; +} + +static bool __bt_mesh_node_foreach_elem_cb(int result, bt_mesh_node_h node, int total, + bt_mesh_element_h element, int elem_index, uint16_t element_addr, void *user_data) +{ + TC_PRT("__bt_mesh_node_foreach_elem_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + TC_PRT("Total number of elements in the node [%d]", total); + print_node_handle(node); + if (total) { + print_element_handle(element); + TC_PRT("Element address [0x%2.2x]", element_addr); + TC_PRT("Element index [%d]", elem_index); + } + return true; + } else + return false; +} + +static void __bt_mesh_node_configure_netkey_cb(int result, bt_mesh_node_key_configuration_e op, + bt_mesh_node_h node, bt_mesh_netkey_h netkey, void *user_data) +{ + TC_PRT("__bt_mesh_node_configure_netkey_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_node_handle(node); + if (op == BT_MESH_NODE_KEY_ADD) + TC_PRT("NetKey Added!"); + else if (op == BT_MESH_NODE_KEY_UPDATE) + TC_PRT("NetKey Updated!"); + else + TC_PRT("NetKey Deleted!"); + print_netkey_handle(netkey); + } +} + +static void __bt_mesh_node_configure_appkey_cb(int result, bt_mesh_node_key_configuration_e op, + bt_mesh_node_h node, bt_mesh_netkey_h netkey, + bt_mesh_appkey_h appkey, void *user_data) +{ + TC_PRT("__bt_mesh_node_configure_netkey_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_node_handle(node); + if (op == BT_MESH_NODE_KEY_ADD) + TC_PRT("AppKey Added!"); + else if (op == BT_MESH_NODE_KEY_UPDATE) + TC_PRT("AppKey Updated!"); + else + TC_PRT("AppKey Deleted!"); + print_appkey_handle(netkey); + print_appkey_handle(appkey); + } +} + +static void __bt_mesh_node_features_cb(int result, bt_mesh_node_h node, + bt_mesh_node_features_s *features, void *user_data) +{ + TC_PRT("__bt_mesh_node_features_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_node_handle(node); + TC_PRT("CID [0x%2.2x]\n", features->cid); + TC_PRT("PID [0x%2.2x]\n", features->pid); + TC_PRT("VID [0x%2.2x]\n", features->vid); + TC_PRT("CRPL [0x%2.2x]\n", features->crpl); + + if (features->features & BT_MESH_FEATURE_RELAY) + TC_PRT("Features: RELAY Supported"); + if (features->features & BT_MESH_FEATURE_PROXY) + TC_PRT("Features: PROXY Supported"); + if (features->features & BT_MESH_FEATURE_FRIEND) + TC_PRT("Features: FRIEND Supported"); + if (features->features & BT_MESH_FEATURE_LOWPOWER) + TC_PRT("Features: LOW POWER Supported\n"); + } +} + +static bool __bt_mesh_node_foreach_netkeys_cb(int result, bt_mesh_node_h node, int total, + bt_mesh_netkey_h netkey, + uint16_t netkey_index, void *user_data) +{ + TC_PRT("__bt_mesh_node_foreach_netkeys_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + TC_PRT("Total Netkeys in node [%d]", total); + print_node_handle(node); + print_netkey_handle(netkey); + return true; + } + return false; +} + +static bool __bt_mesh_node_foreach_appkeys_cb(int result, bt_mesh_node_h node, int total, + bt_mesh_netkey_h netkey, bt_mesh_appkey_h appkey, + uint16_t appkey_index, void *user_data) +{ + TC_PRT("__bt_mesh_node_foreach_appkeys_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + TC_PRT("Total Appkeys in node [%d]", total); + print_node_handle(node); + print_netkey_handle(netkey); + print_appkey_handle(appkey); + return true; + } + return false; +} + +void __bt_mesh_node_ttl_cb(int result, bt_mesh_node_h node, + bt_mesh_node_ttl_operation_e ttl_op, uint8_t ttl, void *user_data) +{ + TC_PRT("bt_mesh_node_ttl_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_node_handle(node); + TC_PRT("ttl_op is [%s]", ttl_op? "TTL Set" : "TTL Get"); + TC_PRT("ttl value is [%d]",ttl); + } +} + +void __bt_mesh_model_bind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey, + void *user_data) +{ + TC_PRT("bt_mesh_model_bind_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + print_model_handle(model); + print_appkey_handle(netkey); + } +} + +void __bt_mesh_model_unbind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey, + void *user_data) +{ + TC_PRT("bt_mesh_model_unbind_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + print_model_handle(model); + print_appkey_handle(netkey); + } +} + +void __bt_mesh_model_appkey_list_cb(int result, bt_mesh_model_h model, int total, const GSList *appkeylist, + void *user_data) +{ + TC_PRT("bt_mesh_model_appkey_list_cb"); + const GSList *l; + + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + TC_PRT("Total number of AppKeys bound to the model [%d]", total); + print_model_handle(model); + + for (l = appkeylist; l != NULL; l = l->next) { + bt_mesh_appkey_h appkey = (bt_mesh_appkey_h) l->data; + print_appkey_handle(appkey); + } + } +} + +void __bt_mesh_model_subscription_op_cb(int result, bt_mesh_model_subscription_op_e op, + bt_mesh_model_h model, bt_mesh_group_h group, void *user_data) +{ + TC_PRT("bt_mesh_model_subscription_op_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + switch(op) { + case 0: + TC_PRT("Model Subscription Operation is ADD"); + break; + case 1: + TC_PRT("Model Subscription Operation is DELETE"); + break; + case 2: + TC_PRT("Model Subscription Operation is DELETE ALL"); + break; + case 3: + TC_PRT("Model Subscription Operation is OVERWRITE"); + break; + default: + TC_PRT("Invalid Model Subscription Operation"); + break; + } + print_model_handle(model); + print_group_handle(group); + } +} + +bool __bt_mesh_model_subscription_list_cb(int result, bt_mesh_model_h model, int total, const GSList *sub_addr, + void *user_data) +{ + const GSList *l; + TC_PRT("bt_mesh_model_subscription_list_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + TC_PRT("Total number of AppKeys bound to the model [%d]", total); + print_model_handle(model); + + for (l = sub_addr; l != NULL; l = l->next) { + bt_mesh_group_h group = (bt_mesh_group_h) l->data; + print_group_handle(group); + } + } + return true; +} + +void __bt_mesh_model_publication_status_cb(int result, bt_mesh_model_h model, bt_mesh_group_h group, + bt_mesh_appkey_h appkey, void *user_data) +{ + TC_PRT("bt_mesh_model_publication_status_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (result == BT_ERROR_NONE) { + print_model_handle(model); + print_group_handle(group); + print_appkey_handle(appkey); + } +} + +void __bt_mesh_network_create_cb(int result, bt_mesh_network_h network, const char *network_name, void *user_data) +{ + TC_PRT("bt_mesh_network_create_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + print_network_handle(network); +} + +bool __bt_mesh_appkey_info_cb(int result, bt_mesh_network_h network, int total, + bt_mesh_netkey_h netkey, bt_mesh_appkey_h appkey, uint16_t appkey_index, void *user_data) +{ + TC_PRT("bt_mesh_network_appkey_info_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + //print_network_handle(network); + //print_netkey_handle(netkey); + print_appkey_handle(appkey); + TC_PRT("Total appkeys are [%d]",total); + return true; +} + +bool __bt_mesh_network_netkey_info_cb(int result, bt_mesh_network_h network, int total, + bt_mesh_netkey_h netkey, uint16_t netkey_index, void *user_data) +{ + TC_PRT("bt_mesh_network_netkey_info_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + //print_network_handle(network); + print_netkey_handle(netkey); + TC_PRT("Total netkeys are [%d]",total); + if (result == BT_ERROR_NONE && netkey_index == 0) { + TC_PRT("Attempt to delete Primary Subnet"); + result = bt_mesh_netkey_delete(netkey); + TC_PRT("return %s\n", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) + TC_PRT("Primary netkey is deleted"); + else + TC_PRT("Primary NetKey deletion failed"); + } + return true; +} + +void __bt_mesh_network_scan_unprovisioned_device_result_cb(int result, bt_mesh_network_h network, + bt_mesh_scanning_state_e state, bt_mesh_scan_result_s *scan_res, void *user_data) +{ + TC_PRT("bt_mesh_network_scan_unprovisioned_device_result_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + if (state == BT_MESH_SCANNING_STARTED) { + TC_PRT("The scanning state is: STARTED"); + print_network_handle(network); + } + else if (state == BT_MESH_SCANNING_FINISHED) { + TC_PRT("The scanning state is: STOPPED"); + print_network_handle(network); + } + else { + TC_PRT("Scan Result found"); + TC_PRT("Device UUID is %s\n", scan_res->uuid); + TC_PRT("RSSI values is %d\n", scan_res->rssi); + TC_PRT("OOB Info 0x%x\n", scan_res->oob_info); + } +} + +void __bt_mesh_network_device_provision_cb(int result, bt_mesh_network_h network, + const char* dev_uuid, void* user_data) +{ + TC_PRT("bt_mesh_network_device_provision_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + print_network_handle(network); + if(dev_uuid == NULL) + TC_PRT("dev_uuid is NULL"); + else { + TC_PRT("The device_uuid is [%s]", dev_uuid); + device_uuid = g_strdup(dev_uuid); + } +} + +void __bt_mesh_authentication_request_cb(int result, bt_mesh_authentication_type_e auth_type, + char *auth_value, void *user_data) +{ + TC_PRT("bt_mesh_authentication_request_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("auth_value is [%s]", auth_value); + TC_PRT("auth_type is [%d]", auth_type); + request_type = auth_type; +} + +int test_set_params(int test_id, char *param){ + static int param_index = 0; + int param_count = 0; + + if (param_index > 0 && param_index == g_test_param.param_count) + goto done; + switch (current_tc_table) { + case BT_MESH_UNIT_TEST_TABLE_NETWORK: { + switch(test_id) { + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE: + param_count = 2; + switch(param_index) { + case 0: + TC_PRT("Input param(%d) (network_name)\n",param_index + 1); + break; + case 1: + TC_PRT("Input param(%d) (Node Handle)\n",param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY: + param_count = 1; + TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK: + param_count = 1; + TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT: + param_count = 1; + TC_PRT("Input param(%d) (node Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL: + param_count = 2; + switch(param_index) { + case 0: + TC_PRT("Input param(%d) (Element Handle)\n" ,param_index + 1); + break; + case 1: + TC_PRT("Input param(%d) (Model ID)\n",param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE: + param_count=1; + TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID: + param_count=1; + TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY: + param_count=1; + TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT: + param_count=1; + TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY: + param_count=1; + TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS: + param_count = 1; + TC_PRT("Input param(%d) (Node Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS: + param_count = 1; + TC_PRT("Input param(%d) (Element Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP: + param_count = 1; + TC_PRT("Input param(%d) (group address)\n" ,param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN: + param_count = 1; + TC_PRT("Input param(%d) (Seconds)\n" ,param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: + param_count = 1; + TC_PRT("Input param(%d) (device_uuid)\n",param_index+1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: + param_count=1; + TC_PRT("Input param(%d) (network_name)",param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: + param_count=2; + switch(param_index) { + case 0: + TC_PRT("Input param(%d) (auth_value)\n",param_index +1); + break; + case 1: + TC_PRT("Input param(%d) (auth_reply)\n",param_index + 1); + TC_PRT("0: false, 1: true"); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: + param_count = 4; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) is_public_oob",param_index + 1); + TC_PRT("0: false, 1: true\n"); + break; + case 1: + TC_PRT("\nInput param(%d) is_static_oob",param_index + 1); + TC_PRT("0: false, 1 : true\n"); + break; + case 2: + TC_PRT("\nInput param(%d) output_oob",param_index + 1); + TC_PRT("BT_MESH_OUT_OOB_METHOD_BLINK = 0x01"); + TC_PRT("BT_MESH_OUT_OOB_METHOD_BEEP = 0x02"); + TC_PRT("BT_MESH_OUT_OOB_METHOD_VIBRATE = 0x04"); + TC_PRT("BT_MESH_OUT_OOB_METHOD_NUMERIC = 0x08"); + TC_PRT("BT_MESH_OUT_OOB_METHOD_ALPHANUMERIC = 0x10\n"); + break; + case 3: + TC_PRT("\nInput param(%d) input_oob",param_index + 1); + TC_PRT("BT_MESH_IN_OOB_METHOD_PUSH = 0x01"); + TC_PRT("BT_MESH_IN_OOB_METHOD_TWIST = 0x02"); + TC_PRT("BT_MESH_IN_OOB_METHOD_NUMERIC = 0x04"); + TC_PRT("BT_MESH_IN_OOB_METHOD_ALPHANUMERIC = 0x08\n"); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX: + param_count = 1; + TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE: + param_count = 1; + TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE: + param_count = 1; + TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY: + param_count = 1; + TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS: + param_count = 1; + TC_PRT("Input param(%d) (NetKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX: + param_count = 1; + TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE: + param_count = 1; + TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE: + param_count = 1; + TC_PRT("Input param(%d) (AppKey Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("\nSelect the function again\n"); + break; + default: + TC_PRT("There is no parameter to set\n"); + break; + } + break; + } + case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: { + switch(test_id) { + case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE: + param_count = 1; + TC_PRT("Input param(%d) (device_uuid)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES: + param_count = 1; + TC_PRT("Input param(%d) (Node Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS: + param_count = 1; + TC_PRT("Input param(%d) (Node Handle)", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS: + param_count = 2; + switch(param_index) { + case 0: + TC_PRT("Input param(%d) (Node Handle)", param_index + 1); + break; + case 1: + TC_PRT("Input param(%d) (Netkey Handle)\n", param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: + param_count = 1; + TC_PRT("Input param(%d) (AppKey Handle)\n", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION: + param_count = 1; + TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION: + param_count = 3; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) Model handle\n", param_index + 1); + break; + case 1: + TC_PRT("\nInput param(%d) AppKey handle\n", param_index + 1); + break; + case 2: + TC_PRT("\nInput param(%d) Group Handle\n", param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST: + param_count = 1; + TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION: + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION: + param_count = 3; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) Model handle\n", param_index + 1); + break; + case 1: + TC_PRT("\nInput param(%d) Model operation", param_index + 1); + TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_ADD = 0"); + TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_DELETE = 1"); + TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_DELETE_ALL = 2"); + TC_PRT("BT_MESH_MODEL_SUBSCRIPTION_OVERWRITE = 3\n"); + break; + case 2: + TC_PRT("\nInput param(%d) Group Handle\n", param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST: + param_count = 1; + TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY: + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY: + param_count = 2; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) Model Handle\n", param_index + 1); + break; + case 1: + TC_PRT("\nInput param(%d) AppKey handle\n", param_index + 1); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY: + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY: + param_count = 3; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); + break; + case 1: + TC_PRT("\nInput param(%d) Key Handle\n", param_index + 1); + break; + case 2: + TC_PRT("\nInput param(%d) Key Config Option", param_index + 1); + TC_PRT("BT_MESH_NODE_KEY_ADD = 0"); + TC_PRT("BT_MESH_NODE_KEY_UPDATE = 1"); + TC_PRT("BT_MESH_NODE_KEY_DELETE = 2\n"); + break; + } + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL: + param_count=1; + TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); + break; + case BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL: + param_count = 2; + switch(param_index) { + case 0: + TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1); + break; + case 1: + TC_PRT("\nInput param(%d) TTL value\n", param_index + 1); + break; + } + break; + default: + TC_PRT("There is no parameter to set\n"); + break; + } + break; + } + default: + TC_PRT("There is no parameter to set\n"); + need_to_set_params = false; + break; + } + done: + if (need_to_set_params) { + if (param_index == 0) { + g_test_param.param_count = param_count; + g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); + } + + if (param_index > 0) { + int len = strlen(param); + param[len - 1] = '\0'; + g_test_param.params[param_index - 1] = g_strdup(param); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + + param_index++; + } + + return 0; +} + +int test_input_callback(void *data) +{ + int ret = 0; +#ifdef ARCH64 + int test_id = (uintptr_t)data; +#else + int test_id = (int)data; +#endif + + switch (current_tc_table) { + case BT_MESH_UNIT_TEST_TABLE_MAIN: { + switch (test_id) { + case 0x00ff: + TC_PRT("Finished\n"); + g_main_loop_quit(main_loop); + break; + case BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE: + ret = bt_mesh_initialize(); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + case BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE: + ret = bt_mesh_deinitialize(); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + default: + break; + } + break; + } + case BT_MESH_UNIT_TEST_TABLE_NETWORK:{ + switch (test_id) { + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE:{ + bt_mesh_node_features_s features; + features.features = BT_MESH_FEATURE_RELAY; + features.features |= BT_MESH_FEATURE_LOWPOWER; + + ret = bt_mesh_node_create(&features, &local_node); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_node_handle(local_node); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY: { + bt_mesh_node_h node_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameters first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_destroy(node_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK: { + bt_mesh_network_h net_h; + bt_mesh_node_h node_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameters first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_get_network(node_h, &net_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_network_handle(net_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT: { + bt_mesh_element_h elem_h; + bt_mesh_node_h node_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameters first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_create_element(node_h, &elem_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_element_handle(elem_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL: { + bt_mesh_element_h elem_h; + bt_mesh_model_h model_h; + bt_mesh_model_id_s mod_id; + memset(&mod_id, 0x00, sizeof(bt_mesh_model_id_s)); + + if (g_test_param.param_count != 2) { + TC_PRT("Enter parameters first!"); + break; + } + elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + mod_id.model_id = strtoul(g_test_param.params[1], NULL, 16); + mod_id.company_id = 0xFFFF; + TC_PRT("The model_id is [0x%2.2x]\n", mod_id.model_id); + ret = bt_mesh_element_create_model(elem_h, &mod_id, &model_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_model_handle(model_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE: { + bt_mesh_element_h elem_h; + bt_mesh_node_h node_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_element_get_node(elem_h, &node_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + + if (ret == BT_ERROR_NONE) + print_node_handle(node_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID: { + bt_mesh_model_id_s model_id; + memset(&model_id, 0x00, sizeof(bt_mesh_model_id_s)); + bt_mesh_model_h mod_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_model_get_id(mod_h, &model_id); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) { + TC_PRT("The Model ID is [0x%2.2x]", model_id.model_id); + TC_PRT("The Company ID is [0x%2.2x]", model_id.company_id); + } + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY: { + bt_mesh_model_h mod_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_model_destroy(mod_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT: { + bt_mesh_model_h mod_h; + bt_mesh_element_h elem_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + mod_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_model_get_element(mod_h, &elem_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_element_handle(elem_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY: { + bt_mesh_element_h elem_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + elem_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_element_destroy(elem_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS: { + bt_mesh_node_h node_h = 0; + if (g_test_param.param_count != 1){ + TC_PRT("Enter Input parameter first.\n"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_foreach_element(node_h, __bt_mesh_node_foreach_elem_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS: { + bt_mesh_element_h element_h = 0; + if (g_test_param.param_count != 1){ + TC_PRT("Enter Input parameter first.\n"); + break; + } + element_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_element_foreach_models(element_h, __bt_mesh_elem_foreach_model_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE: { + char* network_name = "Mesh Test Network"; + bt_mesh_node_h node_h; + if (g_test_param.param_count != 2) { + TC_PRT("Enter Input parameter first.\n"); + break; + } + network_name = g_strdup(g_test_param.params[0]); + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + ret = bt_mesh_network_create(node_h, (const char*)network_name, &network, &token); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) { + TC_PRT("Network Created, token [%s]", token); + print_network_handle(network); + } + g_free(network_name); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD: { + char *token_str; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + token_str = g_strdup(g_test_param.params[0]); + ret = bt_mesh_network_load(token_str, &network); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_network_handle(network); + g_free(token_str); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: { + char* network_name="tempName"; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!"); + break; + } + network_name = g_strdup(g_test_param.params[0]); + ret = bt_mesh_network_set_name(network,(const char*)network_name); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + g_free(network_name); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME: { + char* network_name; + ret = bt_mesh_network_get_name(network, &network_name); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("network name is [%s]", network_name); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY: { + /* netkey 1*/ + bt_mesh_netkey_h n_h; + ret = bt_mesh_network_add_netkey(network, &n_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_netkey_handle(n_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS: { + ret = bt_mesh_network_foreach_netkeys(network, + __bt_mesh_network_netkey_info_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX: { + uint16_t index = 0xFFFF; + bt_mesh_netkey_h netkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + /* Get index for netkey 1 */ + ret = bt_mesh_netkey_get_index(netkey_h, &index); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("The index of the netkey is: [%d]", index); + + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE: { + bt_mesh_netkey_h netkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_netkey_update(netkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE: { + bt_mesh_netkey_h netkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_netkey_delete(netkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("netkey is deleted"); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY: { + bt_mesh_netkey_h netkey_h; + bt_mesh_appkey_h appkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_netkey_add_appkey(netkey_h, &appkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_appkey_handle(appkey_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS: { + /* Get all appkeys for NetKey 1 */ + bt_mesh_netkey_h netkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_netkey_foreach_appkeys(netkey_h, __bt_mesh_appkey_info_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX: { + uint16_t index = 0xFFFF; + bt_mesh_appkey_h appkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + /* Get appkey index for appkey 1 */ + ret = bt_mesh_appkey_get_index(appkey_h, &index); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("The index of the appkey is: [%d]", index); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE: { + bt_mesh_appkey_h appkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_appkey_update(appkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE: { + bt_mesh_appkey_h appkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set parameter first!"); + break; + } + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_appkey_delete(appkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("appkey is deleted"); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES: { + ret = bt_mesh_network_foreach_devices(network, __bt_mesh_network_device_info_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP: { + uint16_t group_addr = 0xc001; + bt_mesh_group_h group_h; + if (g_test_param.param_count != 1) { + TC_PRT("Enter parameter first!!\n"); + break; + } + group_addr = strtoul(g_test_param.params[0], NULL, 16); + TC_PRT("Group addrrss [0x%2.2x]", group_addr); + ret = bt_mesh_network_create_group(network, group_addr, &group_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_group_handle(group_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP: { + bt_mesh_group_h group_h; + ret = bt_mesh_network_create_virtual_group(network, &group_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_group_handle(group_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP: { + ret = bt_mesh_network_remove_group(group); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS: { + ret = bt_mesh_network_foreach_groups(network, + __bt_mesh_network_group_info_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN: { + bt_mesh_scan_params_s scan_params; + memset(&scan_params, 0x00, sizeof(bt_mesh_scan_params_s)); + if(g_test_param.param_count != 1) { + TC_PRT("Enter Input parameter first.\n"); + break; + } + scan_params.seconds = strtoul(g_test_param.params[0], NULL, 16); + TC_PRT("The scan is set for [%u] seconds", scan_params.seconds); + ret = bt_mesh_network_unprovisioned_device_scan(network, &scan_params, + __bt_mesh_network_scan_unprovisioned_device_result_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN: { + ret = bt_mesh_stop_unprovisioned_device_scan(network); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + TC_PRT("Device SCAN : STOPPED"); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: { + const char *dev_uuid = "abababababababababababababababab"; + if(g_test_param.param_count != 1) { + TC_PRT("Enter Input parameter first.\n"); + break; + } + dev_uuid = g_test_param.params[0]; + TC_PRT("The dev_uuid is [%s]\n",dev_uuid); + ret = bt_mesh_network_provision_device(network, dev_uuid, + __bt_mesh_network_device_provision_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB: { + ret = bt_mesh_authentication_set_request_cb( + __bt_mesh_authentication_request_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: { + char* value; + int len; + bool auth_reply; + if(g_test_param.param_count !=2){ + TC_PRT("Enter Input parameter first.\n"); + break; + } + len = strlen(g_test_param.params[0]); + value = g_malloc0(len+1); + g_strlcpy(value, g_test_param.params[0], len+1); + auth_reply = atoi(g_test_param.params[1]); + TC_PRT("\nauth_value is [%s]\n", value); + TC_PRT("auth_reply is [%d]\n", auth_reply); + TC_PRT("auth_type is [%d]\n", request_type); + ret = bt_mesh_authentication_reply(request_type, (const char*)value, auth_reply); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: { + bt_mesh_provisioner_capabilities_s capabilities; + if(g_test_param.param_count !=4) { + TC_PRT("Enter Input parameter first."); + break; + } + capabilities.public_oob = atoi(g_test_param.params[0]); + capabilities.static_oob = atoi(g_test_param.params[1]); + capabilities.out_oob = (int)strtol(g_test_param.params[2], NULL, 16); + capabilities.in_oob = (int)strtol(g_test_param.params[3], NULL, 16); + TC_PRT("CAP: PUBLIC OOB [%d]", capabilities.public_oob); + TC_PRT("CAP: STATIC OOB [%d]", capabilities.static_oob); + TC_PRT("CAP: OUT OOB [%d]", capabilities.out_oob); + TC_PRT("CAP: IN OOB [%d]", capabilities.in_oob); + ret = bt_mesh_network_set_provisioning_capabilities(network, &capabilities); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES: { + // TODO: need to implement + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: { + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + } + default: + break; + } + __bt_free_test_param(&g_test_param); + break; + } + case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: { + switch (test_id) { + case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE: { + char* dev_uu = "tempName"; + if (g_test_param.param_count > 0) { + dev_uu = g_strdup(g_test_param.params[0]); + } else { + TC_PRT("Set Input parameter first!"); + break; + } + ret = bt_mesh_network_discover_node(network, (const char*)dev_uu, + __bt_mesh_node_discover_status_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET: { + // TODO: need to implement + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES: { + bt_mesh_node_h node_h = 0; + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_get_features(node_h, __bt_mesh_node_features_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS: { + bt_mesh_node_h node_h = 0; + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_foreach_netkeys(node_h, __bt_mesh_node_foreach_netkeys_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS: { + bt_mesh_node_h node_h = 0; + bt_mesh_netkey_h netkey_h = 0; + if (g_test_param.param_count != 2) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + + ret = bt_mesh_node_foreach_appkeys(node_h, netkey_h, + __bt_mesh_node_foreach_appkeys_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL: { + bt_mesh_node_h node_h = 0; + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ret = bt_mesh_node_get_ttl(node_h, __bt_mesh_node_ttl_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL: { + bt_mesh_node_h node_h = 0; + int ttl = 120; + if (g_test_param.param_count != 2) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + ttl = atoi(g_test_param.params[1]); + + ret = bt_mesh_node_set_ttl(node_h, (uint8_t) ttl, __bt_mesh_node_ttl_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY: { + bt_mesh_node_h node_h = 0; + bt_mesh_netkey_h netkey_h = 0; + bt_mesh_node_key_configuration_e config = 0; + if (g_test_param.param_count != 3) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + netkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + config = atoi(g_test_param.params[2]); + + ret = bt_mesh_node_configure_netkey(node_h, config, netkey_h, + __bt_mesh_node_configure_netkey_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY: { + bt_mesh_node_h node_h = 0; + bt_mesh_appkey_h appkey_h = 0; + bt_mesh_node_key_configuration_e config = 0; + if (g_test_param.param_count != 3) { + TC_PRT("Set Input parameter first!"); + break; + } + node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + config = atoi(g_test_param.params[2]); + + ret = bt_mesh_node_configure_appkey(node_h, config, appkey_h, + __bt_mesh_node_configure_appkey_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY: { + bt_mesh_model_h model_h = 0; + bt_mesh_appkey_h appkey_h = 0; + if (g_test_param.param_count != 2) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + + ret = bt_mesh_model_bind_appkey(model_h, appkey_h, __bt_mesh_model_bind_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY: { + bt_mesh_model_h model_h = 0; + bt_mesh_appkey_h appkey_h = 0; + if (g_test_param.param_count != 2) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + + ret = bt_mesh_model_unbind_appkey(model_h, appkey_h, __bt_mesh_model_unbind_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST: { + bt_mesh_model_h model_h = 0; + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + + ret = bt_mesh_model_get_appkey_list(model_h, __bt_mesh_model_appkey_list_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION: { + bt_mesh_model_h model_h = 0; + bt_mesh_group_h group_h = 0; + bt_mesh_model_subscription_op_e op = BT_MESH_MODEL_SUBSCRIPTION_ADD; + + if (g_test_param.param_count != 3) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + op = atoi(g_test_param.params[1]); + group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); + + ret = bt_mesh_model_configure_group_subscription(op, model_h, group_h, + __bt_mesh_model_subscription_op_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION: { + bt_mesh_model_h model_h = 0; + bt_mesh_group_h group_h = 0; + bt_mesh_model_subscription_op_e op = BT_MESH_MODEL_SUBSCRIPTION_ADD; + + if (g_test_param.param_count != 3) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + op = atoi(g_test_param.params[1]); + group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); + + ret = bt_mesh_model_configure_virtual_group_subscription(op, model_h, group_h, + __bt_mesh_model_subscription_op_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST: { + bt_mesh_model_h model_h = 0; + + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + + ret = bt_mesh_model_get_subscription_list(model_h, __bt_mesh_model_subscription_list_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION: { + bt_mesh_model_h model_h = 0; + bt_mesh_model_h appkey_h = 0; + bt_mesh_group_h group_h = 0; + bt_mesh_model_pub_params_s param; + + memset(¶m, 0x00, sizeof(bt_mesh_model_pub_params_s)); + + if (g_test_param.param_count != 3) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16)); + group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[2], NULL, 16)); + + param.ttl = 120; + param.num_steps = 10; + param.per_res = BT_MESH_PUBLICATION_STEP_RES_1_SECOND; + param.retrans_cnt = BT_MESH_MAX_PUBISH_RETRANSMIT_COUNT; + param.retrans_step = BT_MESH_MAX_PUBISH_RETRANSMIT_INTERVAL_STEPS; + + ret = bt_mesh_model_set_publication(model_h, appkey_h, group_h, ¶m, + __bt_mesh_model_publication_status_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION: { + bt_mesh_model_h model_h = 0; + + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + + ret = bt_mesh_model_get_publication(model_h, __bt_mesh_model_publication_status_cb, NULL); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: { + bt_mesh_appkey_h appkey_h = 0; + bt_mesh_netkey_h netkey_h; + + if (g_test_param.param_count != 1) { + TC_PRT("Set Input parameter first!"); + break; + } + appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16)); + + ret = bt_mesh_appkey_get_netkey(appkey_h, &netkey_h); + TC_PRT("return %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + print_network_handle(netkey_h); + break; + } + case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: { + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + } + default: + break; + } + __bt_free_test_param(&g_test_param); + break; + } + default: + break; + } + return 0; +} + + +static gboolean key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[BUFFER_LEN] = { 0 }; + +#ifdef ARCH64 + unsigned long len = 0; +#else + unsigned int len = 0; +#endif + int test_id; + bool is_call_api = false; + + memset(buf, 0, sizeof(buf)); + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + TC_PRT("IO Channel read error"); + return FALSE; + } + + if (need_to_set_params == true) { + if (g_test_id == -1) { + test_id = atoi(buf); + g_test_id = test_id; + } + test_set_params(g_test_id, buf); + return TRUE; + } else { + TC_PRT("%s", buf); + test_id = atoi(buf); + + g_test_id = -1; + need_to_set_params = false; + } + + if (current_tc_table == BT_MESH_UNIT_TEST_TABLE_MAIN) { + if (test_id == 0) + current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; + else if(test_id >= BT_MESH_UNIT_TEST_TABLE_NETWORK + && test_id < BT_MESH_UNIT_TEST_TABLE_FINISH) { + current_tc_table = test_id; + } + else { + is_call_api = true; + } + } + + else { + if (buf[0] == '0' && buf[2] == 0) { + current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; + } +#if 0 + if(test_id == 0) { + current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; + } +#endif + else { + is_call_api = true; + } + } + + tc_usage_print(); + if (test_id && is_call_api) { +#ifdef ARCH64 + g_idle_add(test_input_callback, (void *)(uintptr_t)test_id); +#else + g_idle_add(test_input_callback, (void *)test_id); +#endif + } + return TRUE; +} + +void sig_handler(int signo) +{ + if (signo == SIGINT) { + bt_mesh_deinitialize(); + exit(0); + } +} + +int main() +{ + GIOChannel *key_io; + + current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN; + + key_io = g_io_channel_unix_new(fileno(stdin)); + + g_io_channel_set_encoding(key_io, NULL, NULL); + g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); + + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + key_event_cb, NULL); + + g_io_channel_unref(key_io); + + main_loop = g_main_loop_new(NULL, FALSE); + + if (signal(SIGINT, sig_handler) == SIG_ERR) + TC_PRT("\n can't catch SIGINT\n"); + + g_main_loop_run(main_loop); + + bt_mesh_deinitialize(); + + return 0; +} diff --git a/tests/test/bt_mesh_unit_test.h b/tests/test/bt_mesh_unit_test.h new file mode 100644 index 0000000..10d02b5 --- /dev/null +++ b/tests/test/bt_mesh_unit_test.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * @author: Anupam Roy + * + * 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. + */ + +#define BUFFER_LEN 49 + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define TC_PRT(format, args...) PRT(format"\n", ##args) + +typedef struct { + const char *tc_name; + int tc_code; +} tc_table_t; + +typedef struct { + int param_count; + char **params; +} tc_params_t; + + +typedef enum { + BT_MESH_UNIT_TEST_TABLE_MAIN = 1, + BT_MESH_UNIT_TEST_TABLE_NETWORK = 3, + BT_MESH_UNIT_TEST_TABLE_CONFIGURATION, + BT_MESH_UNIT_TEST_TABLE_FINISH = 0XFF, +} bt_mesh_unit_test_table_e; + +typedef enum { + BT_MESH_UNIT_TEST_FUNCTION_BACK = 0, + BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE = 1, + BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE, + BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE = 1, + BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY, + BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT, + BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK, + BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT, + BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY, + BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE, + BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS, + BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS, + BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX, + BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE, + BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE, + BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY, + BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS, + BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX, + BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE, + BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_DEVICES, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN, + BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB, + BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES, + BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES, + BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE=1, + BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET, + BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_FEATURES, + BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETKEYS, + BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS, + BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL, + BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL, + BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY, + BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION, + BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY, + BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, +} bt_mesh_unit_test_function_e; + +int test_input_callback(void *data); diff --git a/tests/test/bt_onoff.c b/tests/test/bt_onoff.c new file mode 100644 index 0000000..fb593c4 --- /dev/null +++ b/tests/test/bt_onoff.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file bt_onoff.c + * @brief This is the source file for bt activation/deactivation. + */ + +#include +#include + +#include "bluetooth.h" +#include "bluetooth_internal.h" + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define TC_PRT(format, args...) PRT(format"\n", ##args) + +GMainLoop *main_loop = NULL; +static guint onoff_timer = 0; +static int cnt = 0; + +static gboolean __bt_onoff_timeout_cb(gpointer data); + +static void __bt_retry_onoff(bt_adapter_state_e state) +{ + int ret; + + cnt++; + + TC_PRT("Retry cnt: %d", cnt); + + onoff_timer = g_timeout_add(20000, (GSourceFunc)__bt_onoff_timeout_cb, NULL); + + if (state == BT_ADAPTER_DISABLED) + ret = bt_adapter_enable(); + else + ret = bt_adapter_disable(); + + TC_PRT("bt_adapter_%s() error(%d)", + state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); +} + +static void __bt_adapter_state_changed_cb(int result, + bt_adapter_state_e adapter_state, void *user_data) +{ + TC_PRT("state(%d), error(%d)", adapter_state, result); + + if (onoff_timer) + g_source_remove(onoff_timer); + onoff_timer = 0; + + if (result != BT_ERROR_NONE) { + char *argv[] = {NULL}; + execv("all_log_dump.sh", argv); + } + + __bt_retry_onoff(adapter_state); +} + +static gboolean __bt_onoff_timeout_cb(gpointer data) +{ + TC_PRT("Timed out"); + + char *argv[] = {NULL}; + execv("all_log_dump.sh", argv); + + if (main_loop) + g_main_loop_quit(main_loop); + else + exit(0); + + return FALSE; +} + +int main(int argc, char *argv[]) +{ + int ret; + bt_adapter_state_e state; + + if (bt_initialize() != BT_ERROR_NONE) { + TC_PRT("bt_initialize() failed."); + return -1; + } + if (bt_adapter_set_state_changed_cb( + __bt_adapter_state_changed_cb, NULL) != BT_ERROR_NONE) { + TC_PRT("bt_adapter_set_state_changed_cb() failed."); + goto DONE; + } + + main_loop = g_main_loop_new(NULL, FALSE); + + bt_adapter_get_state(&state); + ret = bt_adapter_get_state(&state); + TC_PRT("state(%d), error(%d)", state, ret); + + onoff_timer = g_timeout_add(20000, + (GSourceFunc)__bt_onoff_timeout_cb, + NULL); + + if (argc <= 1) { + if (state == BT_ADAPTER_DISABLED) + ret = bt_adapter_enable(); + else + ret = bt_adapter_disable(); + + TC_PRT("bt_adapter_%s() error(%d)", + state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); + } else { + if (argv[1][0] == '0') { + if (state == BT_ADAPTER_DISABLED) { + TC_PRT("Already disabled"); + goto DONE; + } else { + ret = bt_adapter_disable(); + TC_PRT("bt_adapter_disable() error(%d)", + ret); + if (ret != BT_ERROR_NONE) + goto DONE; + } + } else { + if (state == BT_ADAPTER_ENABLED) { + TC_PRT("Already eabled"); + goto DONE; + } else { + ret = bt_adapter_enable(); + TC_PRT("bt_adapter_enable() error(%d)", ret); + if (ret != BT_ERROR_NONE) + goto DONE; + } + } + } + + g_main_loop_run(main_loop); + +DONE: + if (onoff_timer) + g_source_remove(onoff_timer); + onoff_timer = 0; + bt_adapter_unset_state_changed_cb(); + bt_deinitialize(); + + return 0; +} diff --git a/tests/test/bt_unit_test.c b/tests/test/bt_unit_test.c new file mode 100644 index 0000000..0331d63 --- /dev/null +++ b/tests/test/bt_unit_test.c @@ -0,0 +1,10655 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * @file bt_unit_test.c + * @brief This is the source file for capi unit test. + */ + +#include +#include +#include +#include +#include +#include +#include +#ifdef ARCH64 +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bluetooth.h" +#include "bluetooth_internal.h" +#include "bluetooth_extension.h" +#include "bluetooth_private.h" +#include "bluetooth-telephony-api.h" +#include "bt_unit_test.h" + +const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB"; +const char *hid_uuid = "00001124-0000-1000-8000-00805f9b34fb"; +const char *opp_uuid = "00001105-0000-1000-8000-00805f9b34fb"; +const char *custom_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"; + +/* HPS UUIDs. defined by SIG */ +#define HPS_UUID "1823" +#define HTTP_URI_UUID "2ab6" +#define HTTP_HDR_UUID "2ab7" +#define HTTP_ENTITY_UUID "2ab9" +#define HTTP_CP_UUID "2aba" +#define HTTP_STATUS_UUID "2ab8" +#define HTTP_SECURITY_UUID "2abb" +#define HTTP_STATUS_DESC_UUID "2902" +#define IPSP_PORT 3344 +static bt_unit_test_table_e current_tc_table; +static char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; +static char ipsp_iface_name[17] = ""; +static bool input_automated_test_delay = false; + +/* For HDP profile TEST */ +static char *appid = "/org/bluez/health_app_2"; +static char *data_hdp = "aaa"; +static unsigned channel_hdp = 0; + +static bool need_to_set_params = false; +static int g_test_id = -1; +static tc_params_t g_test_param = {0,}; + +static int server_fd; +static int client_fd; +static int custom_server_fd; +static int custom_client_fd; +static int ipsp_server_sock = 0; +static int ipsp_client_sock = 0; + +static int bt_onoff_cnt = 0; +static int bt_onoff_cnt_success = 0; +static int bt_onoff_cnt_fail = 0; +static int total_time = 0; +static struct timeval check_time = {0,}; + +static int absolute_volume = 0; + +int service_index; +int char_service_index; + +static bt_advertiser_h advertiser = NULL; +static bt_advertiser_h advertiser_list[3] = {NULL, }; +static int advertiser_index = 0; + +bt_gatt_client_h client = NULL; +bt_gatt_client_h hps_client = NULL; + +bt_gatt_server_h server = NULL; +typedef struct { + bt_gatt_h svc; + bt_gatt_h chr; + bt_gatt_h desc; +} gatt_handle_t; +gatt_handle_t battery_h; +gatt_handle_t heart_rate_h; +gatt_handle_t thermometer_h; +gatt_handle_t custom_h; +gatt_handle_t ipsp_h; + +bt_proximity_reporter_h reporter; +bt_proximity_monitor_h monitor; +bt_scan_filter_h pxp_scan_filter; + +bt_tds_provider_h provider; +char *tds_act_address; +bt_tds_seeker_h seeker; + +bt_otp_client_h otp_client; +bt_hrp_collector_h collector; +bool set_notif = true; + + +static unsigned char *hash = NULL; +static unsigned char *randomizer = NULL; +int hash_len; +int rand_len; + +bt_call_list_h call_list; +GMainLoop *main_loop = NULL; + +tc_table_t tc_main[] = { + /* Categories */ + {"SET ADDRESS" + , BT_UNIT_TEST_FUNCTION_SET_ADDRESS}, + {"bt_initialize" + , BT_UNIT_TEST_FUNCTION_INITIALIZE}, + {"bt_deinitialize" + , BT_UNIT_TEST_FUNCTION_DEINITIALIZE}, + {"Adapter" + , BT_UNIT_TEST_TABLE_ADAPTER}, + {"Adapter LE" + , BT_UNIT_TEST_TABLE_ADAPTER_LE}, + {"Device" + , BT_UNIT_TEST_TABLE_DEVICE}, + {"Socket" + , BT_UNIT_TEST_TABLE_SOCKET}, + {"Opp" + , BT_UNIT_TEST_TABLE_OPP}, + {"Audio(ag, a2dp, call)" + , BT_UNIT_TEST_TABLE_AUDIO}, + {"Pan(nap, panu)" + , BT_UNIT_TEST_TABLE_PAN}, + {"Gatt" + , BT_UNIT_TEST_TABLE_GATT}, + {"HPS" + , BT_UNIT_TEST_TABLE_HPS}, + {"Avrcp" + , BT_UNIT_TEST_TABLE_AVRCP}, + {"Hid" + , BT_UNIT_TEST_TABLE_HID}, + {"IPSP" + , BT_UNIT_TEST_TABLE_IPSP}, + {"HDP" + , BT_UNIT_TEST_TABLE_HDP}, + {"DPM" + , BT_UNIT_TEST_TABLE_DPM}, + {"PXP" + , BT_UNIT_TEST_TABLE_PXP}, + {"HF Role" + , BT_UNIT_TEST_TABLE_HF}, + {"PBAP Client" + , BT_UNIT_TEST_TABLE_PBAP_CLIENT}, + {"etc.(Automated test, AppControl)" + , BT_UNIT_TEST_TABLE_ETC}, + {"TDS Provider" + , BT_UNIT_TEST_TABLE_TDS_PROVIDER}, + {"TDS Seeker" + , BT_UNIT_TEST_TABLE_TDS_SEEKER}, + {"OTP" + , BT_UNIT_TEST_TABLE_OTP}, + {"HRS" + , BT_UNIT_TEST_TABLE_HRP_SENSOR}, + {"HRC" + , BT_UNIT_TEST_TABLE_HRP_COLLECTOR}, + {"Initialize All" + , BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL}, + {"FINISH" + , BT_UNIT_TEST_TABLE_FINISH}, + {NULL , 0x0000}, +}; + +tc_table_t tc_adapter[] = { + /* Adapter functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_adapter_get_state" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE}, + {"bt_adapter_enable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE}, + {"bt_adapter_disable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE}, + {"bt_adapter_recover" + , BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER}, + {"bt_adapter_start_device_discovery" + , BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY}, + {"bt_adapter_stop_device_discovery" + , BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY}, + {"bt_adapter_is_discovering" + , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING}, + {"bt_adapter_foreach_bonded_device" + , BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE}, + {"bt_adapter_foreach_profile_connected_devices" + , BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES}, + {"bt_adapter_get_bonded_device_info" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO}, + {"bt_adapter_is_service_used" + , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED}, + {"bt_adapter_get_visibility" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY}, + {"bt_adapter_set_visibility" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY}, + {"bt_adapter_set_device_discovery_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, + {"bt_adapter_unset_device_discovery_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, + {"bt_adapter_get_local_oob_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA}, + {"bt_adapter_set_remote_oob_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA}, + {"bt_adapter_remove_remote_oob_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA}, + {"bt_adapter_get_local_oob_ext_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA}, + {"bt_adapter_set_remote_oob_ext_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA}, + {"bt_adapter_read_battery_info" + , BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO}, + {"bt_adapter_init_battery_monitor" + , BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR}, + {"bt_adapter_deinit_battery_monitor" + , BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR}, + {"bt_adapter_set_visibility_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB}, + {"bt_adapter_unset_visibility_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB}, + {"bt_adapter_set_visibility_duration_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB}, + {"bt_adapter_unset_visibility_duration_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB}, + {"bt_adapter_set_connectable_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB}, + {"bt_adapter_unset_connectable_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB}, + {"bt_adapter_get_connectable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE}, + {"bt_adapter_set_connectable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE}, + {"bt_adapter_get_version" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION}, + {"bt_adapter_get_local_info" + , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO}, + {"bt_adapter_set_manufacturer_data_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB}, + {"bt_adapter_unset_manufacturer_data_changed_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB}, + {"bt_adapter_set_manufacturer_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA}, + {"bt_adapter_set_authentication_req_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB}, + {"bt_adapter_set_authentication_request_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW}, + {"bt_adapter_unset_authentication_req_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB}, + {"bt_adapter_unset_authentication_request_cb" + , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW}, + {"bt_adapter_passkey_reply(passkey, TRUE)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT}, + {"bt_adapter_passkey_reply(passkey, FALSE)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL}, + {"bt_adapter_passkey_confirmation_reply(TRUE)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT}, + {"bt_adapter_passkey_confirmation_reply(FALSE)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_adapter_le[] = { + /* Adapter functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_adapter_le_get_state" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE}, + {"bt_adapter_le_enable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE}, + {"bt_adapter_le_disable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE}, + {"bt_adapter_le_set_scan_mode" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE}, + {"bt_adapter_le_set_scan_type" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE}, + {"bt_adapter_le_set_customized_scan_mode" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED}, + {"bt_adapter_le_start_scan" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN}, + {"bt_adapter_le_stop_scan" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN}, + {"bt_adapter_le_add_advertising_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA}, + {"bt_adapter_le_set_advertising_mode" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE}, + {"bt_adapter_le_set_advertising_filter_policy" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY}, + {"bt_adapter_le_set_advertising_connectable" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE}, + {"bt_adapter_le_set_advertising_custom_tx_power_level" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER}, + {"bt_adapter_le_start_advertising_new" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW}, + {"bt_adapter_le_stop_advertising" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING}, + {"bt_adapter_le_add_white_list" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST}, + {"bt_adapter_le_remove_white_list" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST}, + {"bt_adapter_le_enable_privacy" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY}, + {"bt_adapter_le_get_local_oob_ext_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA}, + {"bt_adapter_le_set_remote_oob_ext_data" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA}, + {"Register scan filter (Device Address)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS}, + {"Register scan filter (Device Name)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME}, + {"Register scan filter (Service UUID)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID}, + {"Register scan filter (Service Solicitation UUID)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID}, + {"Register scan filter (Manufacturer DATA)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA}, + {"Register iBeaconscan filter (Manufacturer DATA)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA}, + {"Unregister all scan filters" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS}, + {"bt_adater_le_read_maximum_data_length" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH}, + {"bt_adater_le_wite_host_suggested_def_data_length" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, + {"bt_adater_le_read_host_suggested_def_data_length" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, + {"bt_adapter_le_is_2m_phy_supported" + , BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT}, + {"bt_adapter_le_is_coded_phy_supported" + , BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_device[] = { + /* Device functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_device_set_authorization (true)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE}, + {"bt_device_set_authorization (false)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE}, + {"bt_device_set_authorization_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB}, + {"bt_device_unset_authorization_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB}, + {"bt_device_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB}, + {"bt_device_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB}, + {"bt_device_foreach_connected_profiles" + , BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES}, + {"bt_device_is_profile_connected" + , BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED}, + {"bt_device_set_bond_created_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB}, + {"bt_device_set_bond_destroyed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB}, + {"bt_device_disconnect" + , BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT}, + {"bt_device_create_bond" + , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND}, + {"bt_device_create_bond_by_type" + , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE}, + {"bt_device_destroy_bond" + , BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND}, + {"bt_device_update_le_connection_mode" + , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE}, + {"bt_device_le_conn_update" + , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION}, + {"bt_device_request_att_mtu" + , BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU}, + {"bt_device_set_att_mtu_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB}, + {"bt_device_unset_att_mtu_changed_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB}, + {"bt_device_get_att_mtu" + , BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU}, + {"bt_device_le_set_data_length" + , BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH}, + {"bt_device_le_data_length_changed_cb" + , BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {"bt_device_set_profile_trusted_A2DP(true)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE}, + {"bt_device_set_profile_trusted_A2DP(false)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE}, + {"bt_device_set_profile_trusted_HFP_HF(true)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE}, + {"bt_device_set_profile_trusted_HFP_HF(false)" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE}, + {"bt_device_set_trusted_profile_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB}, + {"bt_device_unset_trusted_profile_cb" + , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB}, + {NULL , 0x0000}, +}; + +tc_table_t tc_socket[] = { + /* Socket functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_socket_create_rfcomm" + , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM}, + {"bt_socket_destroy_rfcomm" + , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM}, + {"bt_socket_listen_and_accept_rfcomm" + , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM}, + {"bt_socket_listen" + , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN}, + {"bt_socket_accept" + , BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT}, + {"bt_socket_reject" + , BT_UNIT_TEST_FUNCTION_SOCKET_REJECT}, + {"bt_socket_connect_rfcomm" + , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM}, + {"bt_socket_disconnect_rfcomm" + , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM}, + {"bt_socket_send_data" + , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA}, + {"bt_socket_create_rfcomm with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID}, + {"bt_socket_destroy_rfcomm with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID}, + {"bt_socket_listen_and_accept_rfcomm with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID}, + {"bt_socket_connect_rfcomm with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID}, + {"bt_socket_disconnect_rfcomm with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID}, + {"bt_socket_send_data with custom uuid" + , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID}, + {"bt_socket_set_data_received_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB}, + {"bt_socket_unset_data_received_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB}, + {"bt_socket_set_connection_requested_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB}, + {"bt_socket_unset_connection_requested_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB}, + {"bt_socket_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_socket_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_opp[] = { + /* OPP functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_opp_client_initialize" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE}, + {"bt_opp_client_deinitialize" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE}, + {"bt_opp_client_add_file" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE}, + {"bt_opp_client_clear_files" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES}, + {"bt_opp_client_push_files" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES}, + {"bt_opp_client_cancel_push" + , BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_audio[] = { + /* AG functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_audio_initialize" + , BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE}, + {"bt_audio_deinitialize" + , BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE}, + {"bt_audio_connect" + , BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT}, + {"bt_audio_disconnect" + , BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT}, + {"bt_audio_sink_connect" + , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT}, + {"bt_audio_sink_disconnect" + , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT}, + {"bt_audio_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_audio_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"bt_ag_open_sco" + , BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO}, + {"bt_ag_close_sco" + , BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO}, + {"bt_ag_is_sco_opened" + , BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED}, + {"bt_ag_set_sco_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB}, + {"bt_ag_unset_sco_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB}, + {"bt_ag_set_speaker_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB}, + {"bt_ag_unset_speaker_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB}, + {"bt_ag_set_microphone_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB}, + {"bt_ag_unset_microphone_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB}, + {"bt_ag_is_connected" + , BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED}, + {"BT_AG_CALL_EVENT_IDLE" + , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE}, + {"BT_AG_CALL_EVENT_ANSWERED" + , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED}, + {"BT_AG_CALL_EVENT_DIALING" + , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING}, + {"BT_AG_CALL_EVENT_ALERTING" + , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING}, + {"BT_AG_CALL_EVENT_INCOMING" + , BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING}, + {"bt_call_list_create" + , BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE}, + {"bt_call_list_destroy" + , BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY}, + {"bt_call_list_reset" + , BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET}, + {"bt_call_list_add" + , BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD}, + {"bt_ag_notify_call_list" + , BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST}, + {"bt_ag_set_call_handling_event_cb" + , BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB}, + {"bt_ag_is_nrec_enabled" + , BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED}, + {"bt_ag_switch_headset" + , BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET}, + {"bt_audio_select_role(source)" + , BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE}, + {"bt_audio_select_role(sink)" + , BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE}, + {"bt_audio_set_absolute_volume" + , BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME}, + {"bt_audio_get_absolute_volume" + , BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME}, + {"bt_audio_is_avc_activated" + , BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED}, + {"bt_audio_set_absolute_volume_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB}, + {"bt_audio_unset_absolute_volume_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB}, + {"bt_audio_set_avc_status_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB}, + {"bt_audio_unset_avc_status_changed_cb" + , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB}, + /* A2DP SCMS-T functions */ + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_pan[] = { + /* Network functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_nap_activate" + , BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE}, + {"bt_nap_deactivate" + , BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE}, + {"bt_nap_disconnect_all" + , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL}, + {"bt_nap_disconnect" + , BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT}, + {"bt_panu_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_panu_connect" + , BT_UNIT_TEST_FUNCTION_PANU_CONNECT}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_gatt[] = { + /* Gatt functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_gatt_connect" + , BT_UNIT_TEST_FUNCTION_GATT_CONNECT}, + {"bt_gatt_disconnect" + , BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT}, + {"bt_gatt_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB}, + {"bt_gatt_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB}, + {"bt_gatt_client_create" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE}, + {"bt_gatt_client_destroy" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY}, + {"bt_gatt_client_get_remote_address" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS}, + {"bt_gatt_client_print_all" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL}, + {"bt_gatt_client_read_value" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE}, + {"bt_gatt_client_write_value" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE}, + {"bt_gatt_client_set_char_value_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB}, + {"bt_gatt_client_unset_char_value_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB}, + {"bt_gatt_client_foreach_services" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES}, + {"bt_gatt_client_request_att_mtu_change" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU}, + {"bt_gatt_client_get_att_mtu" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU}, + {"bt_gatt_client_set_service_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB}, + {"bt_gatt_client_unset_service_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB}, + {"bt_gatt_client_set_att_mtu_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB}, + {"bt_gatt_client_unset_att_mtu_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB}, + {"bt_gatt_server_initialize" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE}, + {"bt_gatt_server_deinitilaize" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE}, + {"bt_gatt_server_unregister_all_services" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES}, + {"bt_gatt_server_foreach_services" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES}, + {"bt_gatt_server_get_device_mtu" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU}, + {"bt_gatt_server_set_att_mtu_changed_cb" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB}, + {"Register Battery Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC}, + {"Change Battery Level" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL}, + {"Register Heart Rate Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC}, + {"Notify Heart Rate Measurement" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT}, + {"Register Thermometer Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC}, + {"Change Thermometer Measurement" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT}, + {"Register Device Information Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC}, + {"Register Link Loss Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC}, + {"Register HID Over GATT Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC}, + {"Register Custom Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC}, + {"Change Custom Value" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL}, + {"Start Server" + , BT_UNIT_TEST_FUNCTION_GATT_START_SERVER}, + {"Get Specification Name from UUID" + , BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID}, + {"ANCS (Pair)" + , BT_UNIT_TEST_FUNCTION_ANCS_PAIR}, + {"ANCS (Watch notification)" + , BT_UNIT_TEST_FUNCTION_ANCS_WATCH}, + {"ANCS (Positive action)" + , BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION}, + {"ANCS (Negative action)" + , BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION}, + {"ANCS (Get Noti. Attr.)" + , BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR}, + {"bt_gatt_get_available_data_batching_packets" + , BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS}, + {"bt_gatt_enable_data_batching" + , BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING}, + {"bt_gatt_disable_data_batching" + , BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_hps[] = { + /* HPS functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hps_client_create" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE}, + {"bt_hps_client_destroy" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY}, + {"bt_hps_client_print_all" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL}, + {"bt_hps_client_read_value" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE}, + {"bt_hps_client_set_uri" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI}, + {"bt_hps_client_set_hdr" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR}, + {"bt_hps_client_set_entity" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY}, + {"bt_hps_client_set_cp" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP}, + {"bt_hps_client_get_uri" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI}, + {"bt_hps_client_get_hdr" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR}, + {"bt_hps_client_get_entity" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY}, + {"bt_hps_client_get_security" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY}, + {"bt_hps_client_set_status_notification" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION}, + {"bt_hps_client_unset_status_notification" + , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_pxp[] = { + /* HPS functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"Proximity Reporter(Register)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER}, + {"Proximity Reporter(Unregister)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER}, + {"Proximity Reporter(Start Advertising Proximity Reporter)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING}, + {"Proximity Reporter (Set State Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB}, + {"Proximity Reporter (UnSet State Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"Proximity Reporter (Set Property Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB}, + {"Proximity Reporter (UnSet Property Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB}, + {"Proximity Reporter(Read Linkloss Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT}, + {"Proximity Reporter(Read Immediate Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT}, + {"Proximity Monitor(Create)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE}, + {"Proximity Monitor(Destroy)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY}, + {"Proximity Monitor(Connect)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT}, + {"Proximity Monitor(Disconnect)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT}, + {"Proximity Monitor (Set State Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB}, + {"Proximity Monitor (UnSet State Changed callback)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"Proximity Monitor(Set LE Scan Filter for Proximity UUID)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID}, + {"Proximity Monitor(Unet LE Scan Filter for Proximity UUID)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID}, + {"Proximity Monitor(Write Linkloss Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT}, + {"Proximity Monitor(Write Immediate Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT}, + {"Proximity Monitor(Read Linkloss Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT}, + {"Proximity Monitor(Read Immediate Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT}, + {"Proximity Monitor(Read Signal Level)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_avrcp[] = { + /* AVRCP functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_avrcp_target_initialize" + , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE}, + {"bt_avrcp_target_deinitialize" + , BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE}, + {"bt_avrcp_set_equalizer_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB}, + {"bt_avrcp_set_repeat_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB}, + {"bt_avrcp_set_shuffle_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB}, + {"bt_avrcp_set_scan_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB}, + {"bt_avrcp_unset_equalizer_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB}, + {"bt_avrcp_unset_repeat_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB}, + {"bt_avrcp_unset_shuffle_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB}, + {"bt_avrcp_unset_scan_mode_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB}, + {"bt_avrcp_control_initialize" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE}, + {"bt_avrcp_control_deinitialize" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE}, + {"bt_avrcp_control_connect" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT}, + {"bt_avrcp_control_disconnect" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT}, + {"bt_avrcp_control_player_PLAY" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY}, + {"bt_avrcp_control_player_STOP" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP}, + {"bt_avrcp_control_player_PAUSE" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE}, + {"bt_avrcp_control_player_FF" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF}, + {"bt_avrcp_control_player_RW" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW}, + {"bt_avrcp_control_player_NEXT" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT}, + {"bt_avrcp_control_player_PREV" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV}, + {"bt_avrcp_control_player_SET_ABSOLUTE_VOLUME" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME}, + {"bt_avrcp_control_player_VOLUME_UP" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP}, + {"bt_avrcp_control_player_VOLUME_DOWN" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN}, + {"bt_avrcp_control_player_GET_REPEAT" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT}, + {"bt_avrcp_control_player_SET_REPEAT" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT}, + {"bt_avrcp_control_player_GET_SHUFFLE" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE}, + {"bt_avrcp_control_player_SET_SHUFFLE" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE}, + {"bt_avrcp_control_player_GET_POSITION" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION}, + {"bt_avrcp_control_player_GET_PLAY STATUS" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS}, + {"bt_avrcp_control_player_GET_TRACK_INFO" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO}, + {"bt_avrcp_set_position_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB}, + {"bt_avrcp_set_play_status_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB}, + {"bt_avrcp_set_track_info_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB}, + {"bt_avrcp_unset_position_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB}, + {"bt_avrcp_unset_play_status_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB}, + {"bt_avrcp_unset_track_info_changed_cb" + , BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_hid[] = { + /* HID functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hid_host_initialize" + , BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE}, + {"bt_hid_host_deinitialize" + , BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE}, + {"bt_hid_host_connect" + , BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT}, + {"bt_hid_host_disconnect" + , BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT}, + {"bt_hid_device_activate" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE}, + {"bt_hid_device_connect" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT}, + {"bt_hid_device_disconnect" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT}, + {"bt_hid_device_deactivate" + , BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE}, + {"bt_hid_device_send_mouse_event" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT}, + {"bt_hid_device_send_key_event" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT}, + {"bt_hid_device_send_custom_event" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT}, + {"bt_hid_device_set_data_received_cb" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB}, + {"bt_hid_device_unset_data_received_cd" + , BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_ipsp[] = { + /* IPSP functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_ipsp_register[Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_REGISTER}, + {"bt_ipsp_unregister[Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER}, + {"bt_ipsp_initialize[Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE}, + {"bt_ipsp_deinitialize[Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE}, + {"bt_ipsp_connect[Client role]" + , BT_UNIT_TEST_FUNCTION_IPSP_CONNECT}, + {"bt_ipsp_disconnect[Client role]" + , BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT}, + {"bt_ipsp_start_advertising[Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING}, + {"bt_ipsp_set_connection_state_changed_cb[Client/Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_ipsp_unset_connection_state_changed_cb[Client/Server role]" + , BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"bt_ipsp_create_ipsp_app_server_socket[Server App role]" + , BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET}, + {"bt_ipsp_connect_with_ipsp_app_server_socket[Client App role]" + , BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET}, + {"bt_ipsp_send_ipv6_application_data[Client/Server App role][Max 255 bytes]" + , BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA}, + {"bt_ipsp_recv_ipv6_application_data[Client/Server App role]" + , BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA}, + {"bt_ipsp_close_socket[Client/Server App role]" + , BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_HDP[] = { + /* HDP functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hdp_register_sink_app" + , BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP}, + {"bt_hdp_unregister_sink_app" + , BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP}, + {"bt_hdp_connect_to_source" + , BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE}, + {"bt_hdp_disconnect" + , BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT}, + {"bt_hdp_send_data" + , BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA}, + {"bt_hdp_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB}, + {"bt_hdp_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB}, + {"bt_hdp_set_data_received_cb" + , BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB}, + {"bt_hdp_unset_data_received_cb" + , BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_DPM[] = { + /* DPM functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_dpm_Set_default_policies" + , BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES}, + {"bt_dpm_set_allow_bluetooth_mode" + , BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE}, + {"bt_dpm_get_allow_bluetooth_mode" + , BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE}, + {"bt_dpm_activate_device_restriction" + , BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION}, + {"bt_dpm_is_device_restriction_active" + , BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE}, + {"bt_dpm_activate_bluetoooth_uuid_restriction" + , BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION}, + {"bt_dpm_is_uuid_restriction_active" + , BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE}, + {"bt_dpm_add_devices_to_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST}, + {"bt_dpm_add_devices_to_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST}, + {"bt_dpm_add_uuids_to_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST}, + {"bt_dpm_add_uuids_to_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST}, + {"bt_dpm_get_devices_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST}, + {"bt_dpm_get_devices_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST}, + {"bt_dpm_get_uuids_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST}, + {"bt_dpm_get_uuids_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST}, + {"bt_dpm_clear_devices_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST}, + {"bt_dpm_clear_devices_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST}, + {"bt_dpm_clear_uuids_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST}, + {"bt_dpm_clear_uuids_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST}, + {"bt_dpm_remove_device_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST}, + {"bt_dpm_remove_device_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST}, + {"bt_dpm_remove_uuid_from_blacklist" + , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST}, + {"bt_dpm_remove_uuid_from_whitelist" + , BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST}, + {"bt_dpm_set_allow_outgoing_call" + , BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL}, + {"bt_dpm_get_allow_outgoing_call" + , BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL}, + {"bt_dpm_set_pairing_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE}, + {"bt_dpm_get_pairing_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE}, + {"bt_dpm_set_profile_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE}, + {"bt_dpm_get_profile_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE}, + {"bt_dpm_set_desktop_connectivity_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE}, + {"bt_dpm_get_desktop_connectivity_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE}, + {"bt_dpm_set_discoverable_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE}, + {"bt_dpm_get_discoverable_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE}, + {"bt_dpm_set_limited_discoverable_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE}, + {"bt_dpm_get_limited_discoverable_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE}, + {"bt_dpm_set_data_transfer_state" + , BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE}, + {"bt_dpm_get_data_transfer_state" + , BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_hf[] = { + /* Handsfree role functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hf_initialize" + , BT_UNIT_TEST_FUNCTION_HF_INITIALIZE}, + {"bt_hf_deinitialize" + , BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE}, + {"(CALL Handling) bt_hf_notify_call_event(answer)" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER}, + {"(CALL Handling) bt_hf_notify_call_event(initiate)" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT}, + {"(CALL Handling) bt_hf_notify_call_event(terminate)" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM}, + {"(CALL Status) bt_hf_get_call_status_info_list" + , BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST}, + {"(CALL Status) bt_hf_request_call_status_info_list" + , BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST}, + {"(CALL Status) bt_hf_set_call_handling_event_cb()" + , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB}, + {"(CALL Status) bt_hf_unset_call_handling_event_cb" + , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB}, + {"(CALL Status) bt_hf_set_call_status_updated_event_cb" + , BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB}, + {"(CALL Status) bt_hf_unset_call_status_updated_event_cb" + , BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB}, + {"(Volume) bt_hf_notify_speaker_gain" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN}, + {"(Volume) bt_hf_set_speaker_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB}, + {"(Volume) bt_hf_unset_speaker_gain_changed_cb" + , BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB}, + {"(Voice-recog) bt_hf_notify_voice_recognition_state(true)" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE}, + {"(Voice-recog) bt_hf_notify_voice_recognition_state(false)" + , BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE}, + {"(SCO) bt_hf_is_sco_opened" + , BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED}, + {"(SCO) bt_hf_get_codec_id" + , BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID}, + {"(SCO) bt_hf_set_sco_state_changed_cb()" + , BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB}, + {"(SCO) bt_hf_unset_sco_state_changed_cb()" + , BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_pbap_client[] = { + /* PBAP Functions*/ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_pbap_client_initialize()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE}, + {"bt_pbap_client_deinitialize()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE}, + {"bt_pbap_client_set_connection_state_changed_cb()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_pbap_client_unset_connection_state_changed_cb()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"bt_pbap_client_connect()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT}, + {"bt_pbap_client_disconnect()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT}, + {"bt_pbap_client_is_connected()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED}, + {"bt_pbap_client_get_phone_book_size()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE}, + {"bt_pbap_client_get_phone_book()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL}, + {"bt_pbap_client_get_list()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST}, + {"bt_pbap_client_pull_vcard()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL}, + {"bt_pbap_client_search_phone_book()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH}, + {"bt_pbap_client_get_list() Maxlist=0" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO}, + {"Select this menu to set parameters and then select the function again." + , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_tds_provider[] = { + /* TDS provider functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"TDS Provider(Register)" + , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER}, + {"TDS Provider(Unregister)" + , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER}, + {"TDS Provider set activation req callback" + , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB}, + {"TDS Provider unset activation req callback" + , BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB}, + {"TDS CUSTOM Provider(Create)" + , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE}, + {"TDS CUSTOM Provider(Destroy)" + , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY}, + {"TDS CUSTOM Provider(Set transport Data)" + , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA}, + {"TDS CUSTOM Provider(Set manuf Data)" + , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA}, + {"TDS CUSTOM Provider(Send Activation Response)" + , BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP}, + {NULL , 0x0000}, +}; + +tc_table_t tc_tds_seeker[] = { + /* TDS Seeker functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"TDS Seeker Start Discovering Provider" + , BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER}, + {"TDS Seeker Stop Discovering Provider" + , BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER}, + {"TDS Seeker(Create)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE}, + {"TDS Seeker(Destroy)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY}, + {"TDS Set Seeker Connection cb" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK}, + {"TDS Seeker Connect(remote)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT}, + {"TDS Seeker DisConnect(remote)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT}, + {"TDS UnSet Seeker Connection cb" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK}, + {"TDS Read Complete Transport Data (remote)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA}, + {"TDS Activate Control Point (remote)" + , BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT}, + {NULL , 0x0000}, +}; + +tc_table_t tc_otp[] = { + /* OTP functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_otp_server_init" + , BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT}, + {"bt_otp_server_deinit" + , BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT}, + {"bt_otp_set_server_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB}, + {"bt_otp_unset_server_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB}, + {"bt_otp_client_create" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE}, + {"bt_otp_client_destroy" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY}, + {"bt_otp_client_set_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK}, + {"bt_otp_client_unset_connection_state_changed_cb" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK}, + {"bt_otp_client_connect" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT}, + {"bt_otp_client_disconnect" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT}, + {"bt_otp_client_discover_all_objects" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS}, + {"bt_otp_client_select_object" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ}, + {"bt_otp_client_read_object_contents" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS}, + {"bt_otp_client_create_object" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ}, + {"bt_otp_client_write_object" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ}, + {"bt_otp_client_execute_object" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ}, + {"bt_otp_client_delete_object" + , BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ}, + {NULL , 0x0000}, +}; + +tc_table_t tc_hr_sensor[] = { + /* HR Sensor functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"[sensor]Set Location Value" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE}, + {"[sensor]Set Contact Value" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE}, + {"[sensor]Set Device Name" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME}, + {"[sensor] Create Sensor" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE}, + {"[sensor] Notify Collector" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY}, + {"[sensor] Destroy Sensor" + , BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY}, + {NULL , 0x0000}, +}; + +tc_table_t tc_hr_collector[] = { + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"[collector]Set Connection State callback" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK}, + {"[collector]Set/Unset Notification" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION}, + {"[collector]Start Scan" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN}, + {"[collector]Stop Scan" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN}, + {"[collector]Connect Sensor" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT}, + {"[collector]Disconnect Sensor" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT}, + {"[collector]Create Collector" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE}, + {"[collector]Destroy Collector" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY}, + {"[collector]Read Body Sensor Location" + , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC}, + {NULL , 0x0000}, +}; + + +tc_table_t tc_automated_test[] = { + /* Automated test Functions*/ + {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, + {"On/Off repeat test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST}, + {"On/Off repeat(1sec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY}, + {"On/Off repeat(Nsec delay) test()" , BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY}, + {"AppControl default" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT}, + {"AppControl 2.3 BT onoff" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF}, + {"AppControl 2.3 BT Visibility" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY}, + {"AppControl 2.4 BT onoff" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF}, + {"AppControl 2.4 BT Visibility" , BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY}, + {"Check feature(ex.tizen.org/feature/network.bluetooth)" , BT_UNIT_TEST_FUNCTION_CHECK_FEATURE}, + + {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +static void __bt_initialize_all(void); + +void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, + void *user_data); + +void tc_usage_print(void) +{ + int i = 0; + tc_table_t *tc_table = NULL; + + switch (current_tc_table) { + case BT_UNIT_TEST_TABLE_SET_ADDRESS: + TC_PRT("Key 0 : usage BACK"); + TC_PRT("Input the address of remote device." + "(e.g.,F6:FB:8F:D8:C8:7C)\n\n"); + return; + case BT_UNIT_TEST_TABLE_ADAPTER: + tc_table = tc_adapter; + break; + case BT_UNIT_TEST_TABLE_ADAPTER_LE: + tc_table = tc_adapter_le; + break; + case BT_UNIT_TEST_TABLE_DEVICE: + tc_table = tc_device; + break; + case BT_UNIT_TEST_TABLE_SOCKET: + tc_table = tc_socket; + break; + case BT_UNIT_TEST_TABLE_OPP: + tc_table = tc_opp; + break; + case BT_UNIT_TEST_TABLE_AUDIO: + tc_table = tc_audio; + break; + case BT_UNIT_TEST_TABLE_PAN: + tc_table = tc_pan; + break; + case BT_UNIT_TEST_TABLE_GATT: + tc_table = tc_gatt; + break; + case BT_UNIT_TEST_TABLE_HPS: + tc_table = tc_hps; + break; + case BT_UNIT_TEST_TABLE_AVRCP: + tc_table = tc_avrcp; + break; + case BT_UNIT_TEST_TABLE_HID: + tc_table = tc_hid; + break; + case BT_UNIT_TEST_TABLE_IPSP: + tc_table = tc_ipsp; + break; + case BT_UNIT_TEST_TABLE_HDP: + tc_table = tc_HDP; + break; + case BT_UNIT_TEST_TABLE_DPM: + tc_table = tc_DPM; + break; + case BT_UNIT_TEST_TABLE_PXP: + tc_table = tc_pxp; + break; + case BT_UNIT_TEST_TABLE_HF: + if (!TIZEN_PROFILE_WEARABLE_IVI) + goto __default__; + tc_table = tc_hf; + break; + case BT_UNIT_TEST_TABLE_PBAP_CLIENT: + if (!TIZEN_PROFILE_WEARABLE_IVI) + goto __default__; + tc_table = tc_pbap_client; + break; + case BT_UNIT_TEST_TABLE_ETC: + if (input_automated_test_delay == true) { + TC_PRT("Input the delay for automated" + "test.(e.g., 10)\n\n"); + return; + } + tc_table = tc_automated_test; + break; + case BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL: + __bt_initialize_all(); + TC_PRT("Key 0 : usage BACK"); + return; + case BT_UNIT_TEST_TABLE_TDS_PROVIDER: + tc_table = tc_tds_provider; + break; + case BT_UNIT_TEST_TABLE_TDS_SEEKER: + tc_table = tc_tds_seeker; + break; + case BT_UNIT_TEST_TABLE_OTP: + tc_table = tc_otp; + break; + case BT_UNIT_TEST_TABLE_HRP_SENSOR: + tc_table = tc_hr_sensor; + break; + case BT_UNIT_TEST_TABLE_HRP_COLLECTOR: + tc_table = tc_hr_collector; + break; + case BT_UNIT_TEST_TABLE_MAIN: +__default__: + default: + tc_table = tc_main; + break; + } + + while (tc_table[i].tc_name) { + TC_PRT("Key %d : usage %s", tc_table[i].tc_code, + tc_table[i].tc_name); + i++; + } + printf("\n\n"); +} + +static void __bt_free_test_param(tc_params_t *param) +{ + int i = 0; + + for (i = 0; i < param->param_count; i++) + g_free(param->params[i]); + g_free(param->params); + param->params = NULL; + param->param_count = 0; +} + +static const char *__bt_get_error_message(bt_error_e err) +{ + const char *err_str = NULL; + + switch (err) { + case BT_ERROR_NONE: + err_str = "BT_ERROR_NONE"; + break; + case BT_ERROR_CANCELLED: + err_str = "BT_ERROR_CANCELLED"; + break; + case BT_ERROR_INVALID_PARAMETER: + err_str = "BT_ERROR_INVALID_PARAMETER"; + break; + case BT_ERROR_OUT_OF_MEMORY: + err_str = "BT_ERROR_OUT_OF_MEMORY"; + break; + case BT_ERROR_RESOURCE_BUSY: + err_str = "BT_ERROR_RESOURCE_BUSY"; + break; + case BT_ERROR_TIMED_OUT: + err_str = "BT_ERROR_TIMED_OUT"; + break; + case BT_ERROR_NOW_IN_PROGRESS: + err_str = "BT_ERROR_NOW_IN_PROGRESS"; + break; + case BT_ERROR_NOT_INITIALIZED: + err_str = "BT_ERROR_NOT_INITIALIZED"; + break; + case BT_ERROR_NOT_ENABLED: + err_str = "BT_ERROR_NOT_ENABLED"; + break; + case BT_ERROR_ALREADY_DONE: + err_str = "BT_ERROR_ALREADY_DONE"; + break; + case BT_ERROR_OPERATION_FAILED: + err_str = "BT_ERROR_OPERATION_FAILED"; + break; + case BT_ERROR_NOT_IN_PROGRESS: + err_str = "BT_ERROR_NOT_IN_PROGRESS"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; + break; + case BT_ERROR_AUTH_REJECTED: + err_str = "BT_ERROR_AUTH_REJECTED"; + break; + case BT_ERROR_AUTH_FAILED: + err_str = "BT_ERROR_AUTH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; + break; + case BT_ERROR_SERVICE_SEARCH_FAILED: + err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; + break; + case BT_ERROR_PERMISSION_DENIED: + err_str = "BT_ERROR_PERMISSION_DENIED"; + break; + case BT_ERROR_SERVICE_NOT_FOUND: + err_str = "BT_ERROR_SERVICE_NOT_FOUND"; + break; + case BT_ERROR_NO_DATA: + err_str = "BT_ERROR_NO_DATA"; + break; + case BT_ERROR_NOT_SUPPORTED: + err_str = "BT_ERROR_NOT_SUPPORTED"; + break; + case BT_ERROR_DEVICE_POLICY_RESTRICTION: + err_str = "DEVICE_POLICY_RESTRICTION"; + break; + default: + err_str = "NOT Defined"; + break; + } + + return err_str; +} + +void __bt_adapter_state_changed_cb(int result, + bt_adapter_state_e adapter_state, void *user_data) +{ + TC_PRT("__bt_adapter_state_changed_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("state: %s", + (adapter_state == BT_ADAPTER_ENABLED) ? + "ENABLED" : "DISABLED"); +} + +static void __bt_adapter_disable_battery_cb(bt_battery_info_s *data) +{ + TC_PRT("Battery data: %ld %ld %d %d", data->session_start_time, + data->session_end_time, data->session_scan_time, data->session_connected_time); + if (data->atm_list == NULL) { + TC_PRT("No data transaction in this session"); + return; + } + + TC_PRT("Displaying app-wise transaction details"); + for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) { + bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data); + TC_PRT("uid: %ld, pid: %ld, received bytes: %d, sent bytes: %d, time: %u", + (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time); + } +} + +static void __bt_adapter_device_visibility_mode_changed_cb(int result, + bt_adapter_visibility_mode_e visibility_mode, + void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("visibility_mode: %d", visibility_mode); +} + +static void __bt_adapter_device_visibility_duration_changed_cb(int duration, + void *user_data) +{ + TC_PRT("visibility_duration: %d", duration); +} + +static void __bt_adapter_connectable_changed_cb(int result, + bool connectable, void *user_data) +{ + if (result != BT_ERROR_NONE) { + TC_PRT("connectable change is failed : [0x%04x]", result); + return; + } + + TC_PRT("%s", connectable ? "Connectable" : "Non-connectable"); +} + +static void __bt_adapter_manufacturer_data_changed_cb(char *data, + int len, void *user_data) +{ + int i; + + TC_PRT("manufacturer data is changed"); + for (i = 0; i < len; i++) + TC_PRT("[%d] %02x", i, data[i]); +} + +static void __bt_adapter_authentication_req_cb( + int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data) +{ + TC_PRT("__bt_adapter_authentication_req_cb:" + " device name = %s", device_name); + TC_PRT("__bt_adapter_authentication_req_cb:" + " device address = %s", remote_addr); + + if (auth_type == BT_AUTH_PIN_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PIN_REQUEST"); + } else if (auth_type == BT_AUTH_PASSKEY_CONFIRM_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PASSKEY_CONFIRM_REQUEST"); + TC_PRT("Passkey: [%s]", pass_key); + } else if (auth_type == BT_AUTH_KEYBOARD_PASSKEY_DISPLAY) { + TC_PRT("Auth Type = BT_AUTH_KEYBOARD_PASSKEY_DISPLAY"); + TC_PRT("Passkey: [%s]", pass_key); + } +} + +static void __bt_adapter_authentication_request_cb( + bool incoming, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data) +{ + TC_PRT("__bt_adapter_authentication_request_cb:" + " device name = %s", device_name); + TC_PRT("__bt_adapter_authentication_request_cb:" + " device address = %s", remote_addr); + + if (incoming == TRUE) + TC_PRT("It is an incoming request"); + else + TC_PRT("It is not an incoming request"); + + if (auth_type == BT_AUTH_PIN_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PIN_REQUEST"); + } else if (auth_type == BT_AUTH_PASSKEY_CONFIRM_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PASSKEY_CONFIRM_REQUEST"); + TC_PRT("Passkey: [%s]", pass_key); + } else if (auth_type == BT_AUTH_KEYBOARD_PASSKEY_DISPLAY) { + TC_PRT("Auth Type = BT_AUTH_KEYBOARD_PASSKEY_DISPLAY"); + TC_PRT("Passkey: [%s]", pass_key); + } +} + +static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, + void *user_data) +{ + int i; + char *str = NULL; + + TC_PRT("remote_address: %s", device_info->remote_address); + TC_PRT("remote_name: %s", device_info->remote_name); + TC_PRT("is_connected: %d", device_info->is_connected); + TC_PRT("service_count: %d", device_info->service_count); + TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask, + device_info->bt_class.major_device_class, + device_info->bt_class.minor_device_class); + + if (device_info->service_uuid == NULL) { + TC_PRT("No uuids"); + } else { + for (i = 0; i < device_info->service_count; i++) { + bt_get_uuid_name(device_info->service_uuid[i], &str); + + TC_PRT("[%d / %d] %s (%s)", i, device_info->service_count, + str ? str : "Unknown", device_info->service_uuid[i]); + g_free(str); + str = NULL; + } + } + + if (device_info->manufacturer_data_len > 0) { + TC_PRT("manufacturer specific data(len:%d)", + device_info->manufacturer_data_len); + printf("data ["); + for (i = 0; i < device_info->manufacturer_data_len; i++) + printf("%02x ", device_info->manufacturer_data[i]); + printf("]\n"); + } + printf("\n"); + + return true; +} + +static bool __bt_adapter_profile_connected_devices_cb( + const char *remote_address, void *user_data) +{ + TC_PRT("remote_address: %s", remote_address); + + return true; +} + +static void __bt_adapter_device_discovery_state_changed_cb( + int result, bt_adapter_device_discovery_state_e discovery_state, + bt_adapter_device_discovery_info_s *discovery_info, + void *user_data) +{ + int i; + + TC_PRT("discovery_state: %d", discovery_state); + + if (discovery_info == NULL) { + TC_PRT("No discovery_info!"); + return; + } + + TC_PRT("remote_address: %s", discovery_info->remote_address); + TC_PRT("remote_name: %s", discovery_info->remote_name); + TC_PRT("rssi: %d", discovery_info->rssi); + TC_PRT("is_bonded: %d", discovery_info->is_bonded); + TC_PRT("service 0x%x, major 0x%x, minor 0x%x", discovery_info->bt_class.major_service_class_mask, + discovery_info->bt_class.major_device_class, + discovery_info->bt_class.minor_device_class); + TC_PRT("service_count: %d", discovery_info->service_count); + + if (discovery_info->service_uuid == NULL) { + TC_PRT("No uuids"); + } else { + for (i = 0; i < discovery_info->service_count; i++) + TC_PRT("uuid: %s", discovery_info->service_uuid[i]); + } + + if (discovery_info->manufacturer_data_len > 0) { + TC_PRT("manufacturer specific data(len:%d)", + discovery_info->manufacturer_data_len); + printf("data ["); + for (i = 0; i < discovery_info->manufacturer_data_len; i++) + printf("%02x ", discovery_info->manufacturer_data[i]); + printf("]\n"); + } +} + +static GSList *le_scan_list; +gint __bt_compare_address(gpointer *a, gpointer *b) +{ + bt_adapter_le_device_scan_result_info_s *info = (bt_adapter_le_device_scan_result_info_s *)a; + char *address = (char *)b; + return g_strcmp0(info->remote_address, address); +} + +static void __bt_adapter_le_scan_result_cb( + int result, bt_adapter_le_device_scan_result_info_s *info, + void *user_data) +{ + int i; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + bt_adapter_le_device_scan_result_info_s *adv_info; + + if (info == NULL) { + TC_PRT("No discovery_info!"); + return; + } + + TC_PRT(" "); + TC_PRT("%s Adv %d Scan resp %d RSSI %d Addr_type %d", + info->remote_address, info->adv_data_len, + info->scan_data_len, info->rssi, + info->address_type); + + if (info->adv_data_len > 31 || info->scan_data_len > 31) { + TC_PRT("###################"); + bt_adapter_le_stop_scan(); + TC_PRT("###################"); + return; + } + + GSList *l = NULL; + l = g_slist_find_custom(le_scan_list, info->remote_address, + (GCompareFunc)__bt_compare_address); + if (l == NULL) { + adv_info = g_malloc0(sizeof(bt_adapter_le_device_scan_result_info_s)); + adv_info->remote_address= g_strdup(info->remote_address); + adv_info->rssi = info->rssi; + le_scan_list = g_slist_append(le_scan_list, adv_info); + } else { + adv_info = l->data; + adv_info->rssi = info->rssi; + } + + for (i = 0; i < 2; i++) { + char **uuids; + char *device_name; + int tx_power_level; + bt_adapter_le_service_data_s *data_list; + int appearance; + int manufacturer_id; + char *manufacturer_data; + int manufacturer_data_len; + int count; + bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; + + pkt_type += i; + if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING + && info->adv_data == NULL) continue; + if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE + && info->scan_data == NULL) break; + + if (bt_adapter_le_get_scan_result_service_uuids( + info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { + int i; + for (i = 0; i < count; i++) { + TC_PRT("UUID[%d] = %s", i + 1, uuids[i]); + g_free(uuids[i]); + } + g_free(uuids); + } + if (bt_adapter_le_get_scan_result_device_name( + info, pkt_type, &device_name) == BT_ERROR_NONE) { + TC_PRT("Device name = %s", device_name); + if (adv_info->adv_data == NULL) + adv_info->adv_data= g_strdup(device_name); + g_free(device_name); + } + if (bt_adapter_le_get_scan_result_tx_power_level( + info, pkt_type, &tx_power_level) == BT_ERROR_NONE) { + TC_PRT("TX Power level = %d", tx_power_level); + } + if (bt_adapter_le_get_scan_result_service_solicitation_uuids( + info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { + int i; + for (i = 0; i < count; i++) { + TC_PRT("Solicitation UUID[%d] = %s", + i + 1, uuids[i]); + g_free(uuids[i]); + } + g_free(uuids); + } + if (bt_adapter_le_get_scan_result_service_data_list( + info, pkt_type, &data_list, &count) == BT_ERROR_NONE) { + int i; + for (i = 0; i < count; i++) + TC_PRT("Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", + i + 1, data_list[i].service_uuid[0], + data_list[i].service_uuid[1], + data_list[i].service_data[0]); + bt_adapter_le_free_service_data_list(data_list, count); + } + if (bt_adapter_le_get_scan_result_appearance( + info, pkt_type, &appearance) == BT_ERROR_NONE) { + TC_PRT("Appearance = %d", appearance); + } + if (bt_adapter_le_get_scan_result_manufacturer_data( + info, pkt_type, &manufacturer_id, &manufacturer_data, + &manufacturer_data_len) == BT_ERROR_NONE) { + + if (manufacturer_data_len > 1) { + TC_PRT("Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]", + manufacturer_id, manufacturer_data[0], + manufacturer_data[1], manufacturer_data_len); + } else { + TC_PRT("Manufacturer data[ID:%.4X, len:%d]", manufacturer_id, manufacturer_data_len); + } + + g_free(manufacturer_data); + } + if (bt_adapter_le_get_scan_result_ibeacon_report(info, pkt_type, + &ibeacon_info) == BT_ERROR_NONE) { + TC_PRT("APPLE IBEACON"); + TC_PRT("Company_id: %d", ibeacon_info->company_id); + TC_PRT("ibeacon_type: %d", ibeacon_info->ibeacon_type); + TC_PRT("uuid: %s", ibeacon_info->uuid); + TC_PRT("major_id: %d", ibeacon_info->major_id); + TC_PRT("minor_id: %d", ibeacon_info->minor_id); + TC_PRT("measured_power: %d", ibeacon_info->measured_power); + bt_adapter_le_free_ibeacon_report(ibeacon_info); + } + } +} + +static void __print_gatt_handler(bt_gatt_h gatt_handle) +{ + if (!gatt_handle) { + TC_PRT("Invalid handler"); + return; + } + + char *type; + char *role; + bt_gatt_common_s *handle = (bt_gatt_common_s *)gatt_handle; + + if (handle->type == BT_GATT_TYPE_SERVICE) + type = g_strdup("Service"); + else if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) + type = g_strdup("Characteristic"); + else if (handle->type == BT_GATT_TYPE_DESCRIPTOR) + type = g_strdup("Descriptor"); + else + type = g_strdup("Unknown"); + + if (handle->role == BT_GATT_ROLE_SERVER) + role = g_strdup("Server"); + else if (handle->role == BT_GATT_ROLE_CLIENT) + role = g_strdup("Client"); + else + role = g_strdup("Unknown"); + + TC_PRT("GATT %s [%s]", type, role); + TC_PRT("%s [%s]", handle->path, handle->uuid); + + g_free(type); + g_free(role); +} + +void __bt_gatt_server_read_value_requested_cb( + const char *remote_address, int request_id, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, void *user_data) +{ + char char_value_1[3] = {0, 1, 2}; + int resp_status = BT_ATT_ERROR_NONE; + + __print_gatt_handler(gatt_handle); + TC_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset); + printf("\n"); + + /* Get the attribute new values here */ + bt_gatt_server_send_response(request_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, offset, + resp_status, char_value_1, 3 - offset); +} + +void __bt_gatt_server_notification_state_change_cb(bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + void *user_data) +{ + __print_gatt_handler(gatt_handle); + TC_PRT("Notification %s [%d]", notify ? "enabled" : "disabled", notify); + TC_PRT("server %s", (char *)server); + printf("\n\n"); +} + +static void __bt_adapter_le_advertising_state_changed_cb(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, + void *user_data) +{ + TC_PRT("Result : %d", result); + TC_PRT("Advertiser : %p", advertiser); + TC_PRT("Advertising %s [%d]", + adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? + "started" : "stopped", adv_state); +} + +static void __bt_adapter_le_advertising_state_changed_cb_2(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, + void *user_data) +{ + TC_PRT("Result : %d", result); + TC_PRT("Advertiser : %p", advertiser); + TC_PRT("Advertising %s [%d]", + adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? + "started" : "stopped", adv_state); +} + +static void __bt_adapter_le_advertising_state_changed_cb_3(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, + void *user_data) +{ + TC_PRT("Result : %d", result); + TC_PRT("Advertiser : %p", advertiser); + TC_PRT("Advertising %s [%d]", + adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? + "started" : "stopped", adv_state); +} + +static void __bt_socket_data_received_cb(bt_socket_received_data_s *data, + void *user_data) +{ + TC_PRT("+"); + + if (data == NULL) { + TC_PRT("No received data!"); + return; + } + + TC_PRT("Socket fd: %d", data->socket_fd); + TC_PRT("Data: %s", data->data); + TC_PRT("Size: %d", data->data_size); +} + +static void __bt_hid_device_data_received_cb(const bt_hid_device_received_data_s *data, + void *user_data) +{ + TC_PRT("+"); + char val = 0x01; + int ret = 0; + static char hidmode = 0x01; + if (data == NULL) { + TC_PRT("No received data"); + return; + } + TC_PRT("Address: %s", data->address); + TC_PRT("Type: %d", data->header_type); + TC_PRT("Param_type: %d", data->param_type); + + switch (data->header_type) { + case BT_HID_HEADER_HANDSHAKE: + TC_PRT("HANDSHAKE data"); + break; + case BT_HID_HEADER_HID_CONTROL: + TC_PRT("HID Control data"); + ret = bt_hid_device_disconnect(remote_addr); + TC_PRT("ret %d", ret); + break; + case BT_HID_HEADER_GET_REPORT: + TC_PRT("GET_REPORT data"); + TC_PRT("ReportId %d", data->data[1]); + + if (data->data[1] == 0x02) { + bt_hid_key_data_s send_data; + /* Will send character 'a' */ + char pressedkey[8] = { 4, 0, 0, 0, 0, 0, 0, 0 }; + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_GET_REPORT, + BT_HID_PARAM_DATA_RTYPE_INPUT, + (const char *)&send_data, + sizeof(send_data)); + } else if (data->data[1] == 0x01) { + TC_PRT("Send Mouse Event"); + bt_hid_mouse_data_s send_data; + + send_data.buttons = 1; + send_data.padding = BT_HID_MOUSE_BUTTON_NONE; + + send_data.axis_x = 10; + send_data.axis_y = 0; + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_GET_REPORT, + BT_HID_PARAM_DATA_RTYPE_INPUT, + (const char *)&send_data, + sizeof(send_data)); + } else { + TC_PRT("Invalid ReportId"); + val = BT_HID_HANDSHAKE_ERR_INVALID_REPORT_ID; + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_HANDSHAKE, + BT_HID_PARAM_DATA_RTYPE_INPUT, + &val, sizeof(val)); + } + TC_PRT("ret %d", ret); + break; + case BT_HID_HEADER_SET_REPORT: + TC_PRT("SET_REPORT data"); + val = BT_HID_HANDSHAKE_SUCCESSFUL; + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_HANDSHAKE, + BT_HID_PARAM_DATA_RTYPE_INPUT, + &val, sizeof(val)); + TC_PRT("ret %d", ret); + break; + case BT_HID_HEADER_DATA: + TC_PRT("TRANs DATA"); + break; + case BT_HID_HEADER_GET_PROTOCOL: + TC_PRT("GET PROTOCOL %x", hidmode); + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_GET_PROTOCOL, + BT_HID_PARAM_DATA_RTYPE_INPUT, + &hidmode, sizeof(hidmode)); + TC_PRT("ret %d", ret); + break; + case BT_HID_HEADER_SET_PROTOCOL: + TC_PRT("SET PROTOCOL"); + val = BT_HID_HANDSHAKE_SUCCESSFUL; + + if (data->data[0] & 0x01) { + TC_PRT("HID Report mode set"); + hidmode = 0x01; + } else { + TC_PRT("HID Boot mode set"); + hidmode = 0x00; + } + ret = bt_hid_device_reply_to_report(remote_addr, + BT_HID_HEADER_HANDSHAKE, + BT_HID_PARAM_DATA_RTYPE_INPUT, + &val, sizeof(val)); + TC_PRT("ret %d", ret); + break; + default: + TC_PRT("Unkonw"); + break; + } + + switch (data->param_type) { + case BT_HID_PARAM_DATA_RTYPE_INPUT: + TC_PRT("Input Report"); + break; + case BT_HID_PARAM_DATA_RTYPE_OUTPUT: + TC_PRT("Output Report"); + break; + } +} + +static void __bt_socket_connection_requested_cb(int socket_fd, + const char *remote_address, void *user_data) +{ + TC_PRT("Socket fd: %d", socket_fd); + TC_PRT("remote_address: %s", remote_address); +} + +static void __bt_socket_connection_state_changed_cb(int result, + bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection, + void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("connection_state: %d", connection_state); + + if (connection == NULL) { + TC_PRT("No connection data!"); + return; + } + + TC_PRT("socket fd: %d", connection->socket_fd); + TC_PRT("server socket fd: %d", connection->server_fd); + TC_PRT("role: %d", connection->local_role); + TC_PRT("remote address: %s", connection->remote_address); + if (strcmp(spp_uuid, connection->service_uuid) == 0) { + TC_PRT("service_uuid: %s", spp_uuid); + client_fd = connection->socket_fd; + } else { + TC_PRT("service_uuid: %s", connection->service_uuid); + custom_client_fd = connection->socket_fd; + } +} + +static void __bt_adapter_le_state_changed_cb(int result, + bt_adapter_le_state_e adapter_le_state, void *user_data) +{ + TC_PRT("__bt_adapter_le_state_changed_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("state: %s", + (adapter_le_state == BT_ADAPTER_LE_ENABLED) ? + "ENABLED" : "DISABLED"); +} + +static void __bt_le_set_data_length_changed_cb(int result, + const char *remote_address, int max_tx_octets, + int max_tx_time, int max_rx_octets, + int max_rx_time, void *user_data) +{ + TC_PRT("__bt_le_set_data_length_changed_cb \n"); + TC_PRT("max_tx_octets: %d max_tx_time: %d" + "max_rx_octets: %d max_rx_time: %d", + max_tx_octets, max_tx_time, + max_rx_octets, max_rx_time); + TC_PRT("result: %s", __bt_get_error_message(result)); +} + +void __bt_opp_client_push_responded_cb(int result, + const char *remote_address, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); +} + +void __bt_opp_client_push_progress_cb(const char *file, + long long size, int percent, void *user_data) +{ + TC_PRT("size: %ld", (long)size); + TC_PRT("percent: %d", percent); + TC_PRT("file: %s", file); +} + +void __bt_opp_client_push_finished_cb(int result, + const char *remote_address, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); +} + +void __bt_audio_connection_state_changed_cb(int result, + bool connected, const char *remote_address, + bt_audio_profile_type_e type, void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("connected [%d]", connected); + TC_PRT("address [%s]", remote_address); + TC_PRT("type [%d]", type); +} + +void __bt_audio_absolute_volume_changed_cb(unsigned int volume, void *user_data) +{ + TC_PRT("volume [%d]", volume); +} + +void __bt_audio_avc_status_changed_cb(bool activated, void *user_data) +{ + TC_PRT("activated [%d]", activated); +} + +void __bt_ag_sco_state_changed_cb(int result, + bool opened, void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("opened [%s]", opened ? "YES" : "NO"); +} + +void __bt_ag_speaker_gain_changed_cb(int gain, void *user_data) +{ + TC_PRT("gain [%d]", gain); +} + +void __bt_ag_microphone_gain_changed_cb(int gain, void *user_data) +{ + TC_PRT("gain [%d]", gain); +} + +void __bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_e event, + unsigned int call_id, void *user_data) +{ + TC_PRT("event[%d] call_id[%d]", event, call_id); +} + +void __bt_device_authorization_changed_cb(bt_device_authorization_e authorization, + char *remote_address, void *user_data) +{ + TC_PRT("__bt_device_authorization_changed_cb [%d]", authorization); + TC_PRT("address: %s", remote_address); +} + +void __bt_device_profile_trusted_cb(int result, char *remote_address, + int trusted_profile, bool supported, + bool trusted, void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("trusted profile [%d]", trusted_profile); + TC_PRT("Is supported [%d]", supported); + TC_PRT("Is trusted [%d]", trusted); + TC_PRT("address: %s", remote_address); +} + +void __bt_device_connection_state_changed_cb(bool connected, + bt_device_connection_info_s *conn_info, void *user_data) +{ + TC_PRT("__bt_device_connection_state_changed_cb [%d]", connected); + TC_PRT("address [%s]", conn_info->remote_address); + TC_PRT("link type [%d]", conn_info->link); + if (!connected) { + int rssi; + TC_PRT("disconnection reason [%d]", conn_info->disconn_reason); + if (bt_device_get_link_loss_rssi(&rssi) == BT_ERROR_NONE) + TC_PRT("RSSI = %d", rssi); + } +} + +void __bt_device_att_mtu_changed_cb(int result, bt_device_att_mtu_info_s *mtu_info, void *user_data) +{ + TC_PRT("__bt_device_att_mtu_changed_cb"); + + if (result != BT_ERROR_NONE) { + TC_PRT("Callback: Request ATT MTU failed."); + TC_PRT("result: %s", __bt_get_error_message(result)); + } + + if (mtu_info) { + TC_PRT("status [%d]", mtu_info->status); + TC_PRT("address [%s]", mtu_info->remote_address); + TC_PRT("MTU [%d]", mtu_info->mtu); + } +} + +bool __bt_device_connected_profile(bt_profile_e profile, void *user_data) +{ + TC_PRT("__bt_device_connected_profile [0x%04x]", profile); + return true; +} + +void __bt_device_bond_created_cb(int result, + bt_device_info_s *device_info, void *user_data) +{ + if (result == BT_ERROR_NONE) { + TC_PRT("Callback: A bond is created."); + TC_PRT("Callback: The number of service - %d.", + device_info->service_count); + TC_PRT("Callback: class : %d %d %d", (int)device_info->bt_class.major_device_class, device_info->bt_class.minor_device_class, device_info->bt_class.major_service_class_mask); + + int i = 0; + for (i = 0; i < device_info->service_count; i++) { + TC_PRT("Callback: service[%d] - %s", + i+1, device_info->service_uuid[i]); + } + TC_PRT("Callback: is_bonded - %d.", + device_info->is_bonded); + TC_PRT("Callback: is_connected - %d.", + device_info->is_connected); + + if (device_info->manufacturer_data_len > 0) { + TC_PRT("manufacturer specific data(len:%d)", + device_info->manufacturer_data_len); + printf("data ["); + for (i = 0; i < device_info->manufacturer_data_len; i++) + printf("%02x ", device_info->manufacturer_data[i]); + printf("]\n"); + } + } else { + TC_PRT("Callback: Creating a bond is failed."); + TC_PRT("result: %s", __bt_get_error_message(result)); + } +} + +void __bt_device_bond_destroyed_cb(int result, + char *remote_address, void *user_data) +{ + if (result == BT_ERROR_NONE) { + TC_PRT("Callback: A bond is destroyed."); + TC_PRT("Callback: Address - %s.", remote_address); + } else { + TC_PRT("Callback: Destroying a bond is failed."); + TC_PRT("result: %s", __bt_get_error_message(result)); + } +} + +void __bt_print_repeat_test_summary(void) +{ + static struct timeval current_time = {0,}; + static struct timeval diff_time = {0,}; + int time_diff; + + gettimeofday(¤t_time, NULL); + + diff_time.tv_sec = current_time.tv_sec - check_time.tv_sec; + diff_time.tv_usec = current_time.tv_usec - check_time.tv_usec; + if (diff_time.tv_usec < 0) { + diff_time.tv_sec = diff_time.tv_sec - 1; + diff_time.tv_usec = diff_time.tv_usec + 1000000; + } + time_diff = (diff_time.tv_sec * 1000); + time_diff += diff_time.tv_usec / 1000; + + TC_PRT("try: %d, success: %d, fail: %d, time(%d msec)\n", + bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, + time_diff); + + total_time += time_diff; +} + +void __bt_print_repeat_test_final_summary() +{ + TC_PRT("try: %d, success: %d, fail: %d," + "Total_time(%d msec), Average_time(%d msec)\n", + bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, + total_time, total_time / bt_onoff_cnt); +} + +void __bt_gatt_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + if (result != BT_ERROR_NONE) + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (connected) { + TC_PRT("GATT connected [%s]", remote_address); + strncpy(remote_addr, remote_address, strlen(remote_addr)); + + bt_le_conn_update_s param; + + param.interval_min = 90; + param.interval_max = 90; + param.latency = 0; + param.time_out = 2000; + bt_device_le_conn_update(remote_addr, ¶m); + } else { + TC_PRT("GATT DISconnected [%s]", remote_address); + } +} + +void __bt_hps_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + int ret; + if (result != BT_ERROR_NONE) + TC_PRT("result: %s", __bt_get_error_message(result)); + + if (connected) { + TC_PRT("HPS connected [%s]", remote_address); + /* Fix : STRING_OVERFLOW */ + strncpy(remote_addr, remote_address, strlen(remote_addr)); + if (hps_client) { + bt_gatt_client_destroy(hps_client); + hps_client = NULL; + } + ret = bt_gatt_client_create(remote_addr, &hps_client); + TC_PRT("returns bt_gatt_client_create %s\n", + __bt_get_error_message(ret)); + + } else { + TC_PRT("HPS DISconnected [%s]", remote_address); + } +} + +void __bt_gatt_client_service_changed_cb(bt_gatt_client_h c, + bt_gatt_client_service_change_type_e type, + const char *uuid, void *user_data) +{ + char *addr = NULL; + char *svc = NULL; + int ret; + + ret = bt_gatt_client_get_remote_address(client, &addr); + if (ret != BT_ERROR_NONE) + TC_PRT("Cannot get remote address"); + + ret = bt_get_uuid_name(uuid, &svc); + if (ret != BT_ERROR_NONE) + svc = g_strdup(uuid); + + TC_PRT("Remote device [%s] : %s is %s", addr, svc, + type == BT_GATT_CLIENT_SERVICE_ADDED ? + "Added" : "Removed"); + g_free(svc); + g_free(addr); +} + +void __bt_gatt_client_att_mtu_changed_cb(bt_gatt_client_h c, const bt_gatt_client_att_mtu_info_s *mtu_info, void *user_data) +{ + char *addr = NULL; + int ret; + + TC_PRT("__bt_gatt_client_att_mtu_changed_cb"); + + ret = bt_gatt_client_get_remote_address(client, &addr); + if (ret != BT_ERROR_NONE) { + TC_PRT("Cannot get remote address"); + return; + } + + if (mtu_info) { + TC_PRT("status [%d]", mtu_info->status); + TC_PRT("address [%s]", mtu_info->remote_address); + TC_PRT("MTU [%d]", mtu_info->mtu); + } + + g_free(addr); +} + +int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h) +{ + int ret; + int s_val; + unsigned int u_val; + char *buf; + int len; + + if (strcasecmp(type, "int8") == 0) { + s_val = atoi(value); + buf = (char *)&s_val; + len = 1; + } else if (strcasecmp(type, "int16") == 0) { + s_val = atoi(value); + buf = (char *)&s_val; + len = 2; + } else if (strcasecmp(type, "int32") == 0) { + s_val = atoi(value); + buf = (char *)&s_val; + len = 4; + } else if (strcasecmp(type, "uint8") == 0) { + u_val = strtoul(value, NULL, 10); + buf = (char *)&u_val; + len = 1; + } else if (strcasecmp(type, "uint16") == 0) { + u_val = strtoul(value, NULL, 10); + buf = (char *)&u_val; + len = 2; + } else if (strcasecmp(type, "uint32") == 0) { + u_val = strtoul(value, NULL, 10); + buf = (char *)&u_val; + len = 4; + } else if (strcasecmp(type, "str") == 0) { + buf = value; + len = strlen(buf); + } else + return BT_ERROR_INVALID_PARAMETER; + + ret = bt_gatt_set_value(h, buf, len); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_set_value is failed : %d", ret); + + return ret; +} + +void __bt_gatt_client_print_value(bt_gatt_h h) +{ + int ret; + char *str = NULL; + char *value = NULL; + int len = 0; + bool hex_format = false; + int i; + + ret = bt_gatt_get_value(h, &value, &len); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_get_value is failed : %d", ret); + return; + } + + for (i = 0; i < len; i++) + if (isalnum(value[i]) == 0) { + hex_format = true; + break; + } + + if (hex_format) { + str = g_malloc0(len * 5 + 1); + for (i = 0; i < len; i++) { + if (i > 0) + str[i * 5 - 1] = ' '; + + snprintf(&str[i * 5], 5, "0x%02X", value[i]); + } + } else { + str = g_malloc0(len + 1); + memcpy(str, value, len); + } + + TC_PRT("Value : %s", str); + + g_free(str); + g_free(value); +} + +bool __bt_gatt_print_info_cb(int total, + int index, bt_gatt_h gatt_handle, void *user_data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(gatt_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("[%d / %d] %s (%s)", + index, total, + str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + return true; +} + +void __bt_gatt_client_write_complete_cb(int result, + bt_gatt_h gatt_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(gatt_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("Write %s for %s (%s)", + result == BT_ATT_ERROR_NONE ? "Success" : "Fail", + str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + return; +} + +void __bt_gatt_client_read_complete_cb(int result, + bt_gatt_h gatt_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(gatt_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("Read %s for %s (%s)", + result == BT_ATT_ERROR_NONE ? "Success" : "Fail", + str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + if (result != BT_ATT_ERROR_NONE) + return; + + __bt_gatt_client_print_value(gatt_handle); + + return; +} + +bool __bt_gatt_client_foreach_desc_cb(int total, + int index, bt_gatt_h desc_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(desc_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("\t\t[%d / %d] %s (%s)", + index, total, + str ? str : "Unknown", uuid); + __bt_gatt_client_print_value(desc_handle); + + g_free(str); + g_free(uuid); + + return true; +} + +bool __bt_gatt_client_foreach_chr_cb(int total, + int index, bt_gatt_h chr_handle, void *data) +{ + int ret; + char *uuid = NULL; + char *str = NULL; + int properties = 0; + + bt_gatt_get_uuid(chr_handle, &uuid); + bt_get_uuid_name(uuid, &str); + bt_gatt_characteristic_get_properties(chr_handle, &properties); + + TC_PRT("\t[%d / %d] %s (%s) (0x%X)", index, total, str ? str : "Unknown", uuid, properties); + __bt_gatt_client_print_value(chr_handle); + + g_free(str); + g_free(uuid); + + ret = bt_gatt_characteristic_foreach_descriptors(chr_handle, + __bt_gatt_client_foreach_desc_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_characteristic_foreach_descriptors is failed : %d", ret); + + return true; +} + +bool __bt_gatt_client_foreach_svc_cb(int total, + int index, bt_gatt_h svc_handle, void *data) +{ +#ifdef ARCH64 + int test_id = (int)(uintptr_t) data; +#else + int test_id = (int)data; +#endif + int ret; + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(svc_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("[%d / %d] %s (%s)", + index, total, + str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + if (test_id == BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL) { +#ifdef ARCH64 + ret = bt_gatt_service_foreach_characteristics(svc_handle, + __bt_gatt_client_foreach_chr_cb, (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_service_foreach_characteristics(svc_handle, + __bt_gatt_client_foreach_chr_cb, (void *)test_id); +#endif + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret); + } + + return true; +} + +bool __bt_hps_client_svc_cb(int total, + int index, bt_gatt_h svc_handle, void *data) +{ +#ifdef ARCH64 + int test_id = (int) (uintptr_t) data; +#else + int test_id = (int)data; +#endif + int ret; + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(svc_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + if (!g_strcmp0(uuid, HPS_UUID)) { + + TC_PRT("[%d / %d] %s (%s)", + index, total, + str ? str : "Unknown", uuid); + + if (test_id == BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL) { +#ifdef ARCH64 + ret = bt_gatt_service_foreach_characteristics(svc_handle, + __bt_gatt_client_foreach_chr_cb, + (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_service_foreach_characteristics(svc_handle, + __bt_gatt_client_foreach_chr_cb, + (void *)test_id); +#endif + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret); + } + } + + g_free(str); + g_free(uuid); + return true; +} + +static void __ancs_write_completed_cb(int result, + bt_gatt_h request_handle, void *user_data) +{ + if (result != BT_ERROR_NONE) { + TC_PRT("write request is failed : %d", result); + return; + } + + TC_PRT("write request is done"); + + return; +} + +static int __ancs_write_value_to_control_point(bt_gatt_client_h client, + char *value, int len) +{ + bt_gatt_h ancs_svc = NULL; + bt_gatt_h control_point = NULL; + char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; + char *chr_uuid = "69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9"; + int ret; + + ret = bt_gatt_client_get_service(client, + svc_uuid, &ancs_svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + return ret; + } + + ret = bt_gatt_service_get_characteristic(ancs_svc, + chr_uuid, &control_point); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed"); + return ret; + } + + ret = bt_gatt_characteristic_set_write_type(control_point, + BT_GATT_WRITE_TYPE_WRITE); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_characteristic_set_write_type is failed : %d", ret); + return ret; + } + + ret = bt_gatt_set_value(control_point, value, len); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + return ret; + } + + ret = bt_gatt_client_write_value(control_point, + __ancs_write_completed_cb, NULL); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + return ret; + } + + return ret; +} + +void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, + char *value, int len, void *user_data) +{ + char *uuid = NULL; + int i; + + bt_gatt_get_uuid(chr, &uuid); + + TC_PRT("Value changed for [%s]", uuid); + TC_PRT("len [%d]", len); + for (i = 0; i < len; i++) + TC_PRT("value %u", value[i]); + + g_free(uuid); + + return; +} +void __bt_hrp_heart_rate_value_changed_cb(bt_gatt_h chr, + unsigned short hr_value, void *user_data) +{ + char *uuid = NULL; + + bt_gatt_get_uuid(chr, &uuid); + + TC_PRT("Value changed for [%s]", uuid); + TC_PRT("Value [%d]", hr_value); + + g_free(uuid); + + return; +} + +void __bt_HP_client_cp_req_status_changed_cb(bt_gatt_h chr, + char *value, int len, void *user_data) +{ + char *uuid = NULL; + int i; + + bt_gatt_get_uuid(chr, &uuid); + + TC_PRT("Value changed for [%s]", uuid); + TC_PRT("len [%d]", len); + for (i = 0; i < len; i++) + TC_PRT("value %u", value[i]); + + g_free(uuid); + + return; +} + +void __bt_proximity_reporter_property_changed_cb(int result, const char *remote_address, + int service_type, int prop_value, void *user_data) +{ + TC_PRT("reporter_property result [%s]", __bt_get_error_message(result)); + TC_PRT("remote_address : %s", remote_address); + TC_PRT("service_type : %d", service_type); + TC_PRT("prop_value : %d", prop_value); +} + +void __bt_proximity_monitor_connection_state_changed_cb(int result, const char *remote_address, + bt_proximity_monitor_h monitor_s, bool connected, int supported_service, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + if (connected) { + TC_PRT("PXP connected(address = %s)", remote_address); + TC_PRT("PXP Reporter supported Service\n"); + if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT) + TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n"); + if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT) + TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n"); + if (supported_service & BT_PROXIMITY_TX_POWER) + TC_PRT("BT_PROXIMITY_TX_POWER"); + } else { + TC_PRT("PXP DISconnected"); + } + } +} + +void __bt_proximity_reporter_connection_state_changed_cb(int result, const char *remote_address, + bt_proximity_reporter_h reporter_s, bool connected, int supported_service, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + if (connected) { + TC_PRT("PXP connected(address = %s)", remote_address); + TC_PRT("PXP Reporter supported Service\n"); + if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT) + TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n"); + if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT) + TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n"); + if (supported_service & BT_PROXIMITY_TX_POWER) + TC_PRT("BT_PROXIMITY_TX_POWER"); + } else { + TC_PRT("PXP DISconnected"); + } + } +} + +void __tds_activation_req_cb(char *rem_bd_addr, + bt_tds_transport_e transport, unsigned char *buf, int len, void *user_data) +{ + int i; + + TC_PRT("remote_address : %s", rem_bd_addr); + TC_PRT("transport : %d", transport); + for (i = 0; i < len; i++) + TC_PRT("Act req data[%d] : %.2x", i, buf[i]); + + g_free(tds_act_address); + tds_act_address = g_strdup(rem_bd_addr); +} + +void __bt_gatt_server_att_mtu_changed_cb(bt_gatt_server_h s, const bt_gatt_server_att_mtu_info_s *mtu_info, void *user_data) +{ + TC_PRT("__bt_gatt_server_att_mtu_changed_cb"); + + if (mtu_info) { + TC_PRT("status [%d]", mtu_info->status); + TC_PRT("address [%s]", mtu_info->remote_address); + TC_PRT("MTU [%d]", mtu_info->mtu); + } + +} + +void __bt_gatt_server_notification_sent_cb(int result, + const char *remote_address, bt_gatt_server_h server, + bt_gatt_h characteristic, bool completed, void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("remote_address : %s", remote_address); + TC_PRT("completed : %d", completed); + TC_PRT("characteristic : %p", characteristic); +} + +void __bt_gatt_server_write_value_requested_cb(const char *remote_address, + int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, bool response_needed, int offset, + const char *value, int len, void *user_data) +{ + int i, resp_status = BT_ATT_ERROR_NONE; + + __print_gatt_handler(gatt_handle); + TC_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", + remote_address, request_id, response_needed, offset, len); + + for (i = 0; i < len; i++) + printf("%d ", value[i]); + + bt_gatt_server_send_response(request_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE, offset, + resp_status, NULL, 0); + + printf("\n"); +} + +bool __bt_gatt_server_foreach_svc_cb(int total, + int index, bt_gatt_h svc_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(svc_handle, &uuid); + bt_get_uuid_name(uuid, &str); + + TC_PRT("[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + return true; +} + +void __bt_gatt_char_write_cb(void *user_data) +{ + TC_PRT("__bt_gatt_char_write_cb"); + return; +} + +void __bt_gatt_char_read_cb(unsigned char *value, + int value_length, void *user_data) +{ + int i; + + TC_PRT("__bt_gatt_char_read_cb"); + + TC_PRT("value_length %d", value_length); + + for (i = 0; i < value_length; i++) + TC_PRT("value %u", value[i]); + + return; +} + +void __bt_avrcp_target_connection_state_changed_cb(bool connected, + const char *remote_address, void *user_data) +{ + TC_PRT("__bt_avrcp_target_connection_state_changed_cb"); + TC_PRT("connected %d", connected); + TC_PRT("remote_address %s", remote_address); +} + +void __bt_avrcp_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, + void *user_data) +{ + TC_PRT("__bt_avrcp_equalizer_state_changed_cb"); + TC_PRT("equalizer %d (1: OFF, 2: ON)", equalizer); +} + +void __bt_avrcp_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, + void *user_data) +{ + TC_PRT("__bt_avrcp_repeat_mode_changed_cb"); + TC_PRT("repeat %d (1: OFF, 2: SINGLE, 3: All, 4:GROUP)", repeat); +} + +void __bt_avrcp_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, + void *user_data) +{ + TC_PRT("__bt_avrcp_shuffle_mode_changed_cb"); + TC_PRT("shuffle -> %d (1: OFF, 2: All TRACK, 3:GROUP)", shuffle); +} + +void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, + void *user_data) +{ + TC_PRT("__bt_avrcp_scan_mode_changed_cb"); + TC_PRT("scan -> %d", scan); +} + +void __bt_avrcp_control_connection_state_changed_cb(bool connected, + const char *remote_address, void *user_data) +{ + TC_PRT("__bt_avrcp_target_connection_state_changed_cb"); + TC_PRT("connected %d", connected); + TC_PRT("remote_address %s", remote_address); +} + +void __bt_avrcp_song_position_changed_cb(unsigned int postion, + void *user_data) +{ + TC_PRT("__bt_avrcp_song_position_changed_cb"); + TC_PRT("Position %d", postion); +} + +void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, + void *user_data) +{ + TC_PRT("__bt_avrcp_player_state_changed_cb"); + TC_PRT("Player state -> %d (0: stopped, 1: Playing, 2:Paused, 3:FF, 4:REW)", state); +} + +void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, + void *user_data) +{ + TC_PRT("__bt_avrcp_track_info_changed_cb"); + TC_PRT("title %s", metadata->title); + TC_PRT("artist %s", metadata->artist); + TC_PRT("album %s", metadata->album); + TC_PRT("genre %s", metadata->genre); + TC_PRT("total_tracks %d", metadata->total_tracks); + TC_PRT("number %d", metadata->number); + TC_PRT("duration %d", metadata->duration); +} + +void panu_conn_state_changed(int result, bool connected, + const char *remote_address, bt_panu_service_type_e type, + void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("connected [%d]", connected); + TC_PRT("address [%s]", remote_address); + TC_PRT("type [%d]", type); + +} + +void __bt_hid_host_connection_state_changed_cb(int result, + bool connected, const char *remote_address, + void *user_data) +{ + TC_PRT("__bt_hid_host_connection_state_changed_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); +} + +void __bt_hdp_connected_cb(int result, const char *remote_address, + const char *app_id, bt_hdp_channel_type_e type, + unsigned int channel, void *user_data) +{ + TC_PRT("__bt_hdp_connected_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); + TC_PRT("app_id: %s", app_id); + TC_PRT("type: %x", type); + TC_PRT("channel: %d", channel); + + channel_hdp = channel; +} + +void __bt_hdp_disconnected_cb(int result, const char *remote_address, + unsigned int channel, void *user_data) +{ + TC_PRT("__bt_hdp_connected_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); + TC_PRT("channel: %d", channel); + + channel_hdp = channel; +} + +void __bt_hdp_data_received_cb(unsigned int channel, const char *data, + unsigned int size, void *user_data) +{ + TC_PRT("__bt_hdp_data_received_cb: called"); + TC_PRT("data: %s", data); + TC_PRT("size: %d", size); + TC_PRT("channel: %d", channel); +} + +void __bt_hid_device_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + TC_PRT("__bt_hid_device_connection_state_changed_cb:"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("Remote Address %s", remote_address); + TC_PRT("Connected %d", connected); +} + +void __bt_ipsp_init_state_changed_cb(int result, + bool ipsp_initialized, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + if (ipsp_initialized) { + TC_PRT("IPSP Init state: INITIALIZED"); + } else { + TC_PRT("IPSP Init state: UN-INITIALIZED"); + _bt_unset_cb(BT_EVENT_IPSP_INIT_STATE_CHANGED); + } +} + +void __bt_ipsp_connection_state_changed_cb(int result, + bool connected, const char *remote_address, const char *iface_name, void *user_data) +{ + TC_PRT("__bt_le_ipsp_connection_state_changed_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("Connected: %d", connected); + TC_PRT("Remote BT address : %s", remote_address); + if (connected) + TC_PRT("Local BT Interface : %s is Up", iface_name); + else + TC_PRT("Local BT Interface : %s is Down", iface_name); + strncpy(ipsp_iface_name, iface_name, sizeof(ipsp_iface_name)); + ipsp_iface_name[sizeof(ipsp_iface_name) - 1] = '\0'; +} + +void __bt_hf_sco_state_changed_cb(int result, + bool opened, void *user_data) +{ + TC_PRT("opened [%s]", opened ? "YES" : "NO"); +} + +void __bt_hf_set_call_handling_event_cb(bt_hf_call_handling_event_e event, + char *phone_number, void *user_data) +{ + switch (event) { + case BT_HF_CALL_HANDLING_EVENT_ANSWER: + TC_PRT("[call_handling_event_cb] event [ANSWER]"); + break; + case BT_HF_CALL_HANDLING_EVENT_RELEASE: + TC_PRT("[call_handling_event_cb] event [RELEASE]"); + break; + case BT_HF_CALL_HANDLING_EVENT_REJECT: + TC_PRT("[call_handling_event_cb] event [REJECT]"); + break; + case BT_HF_CALL_HANDLING_EVENT_RING: + TC_PRT("[call_handling_event_cb] event [RING]"); + break; + case BT_HF_CALL_HANDLING_EVENT_CALL_STARTED: + TC_PRT("[call_handling_event_cb] event [CALL_STARTED]"); + break; + case BT_HF_CALL_HANDLING_EVENT_CALL_ENDED: + TC_PRT("[call_handling_event_cb] event [CALL_ENDED]"); + break; + case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_ENABLED: + TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_ENABLED]"); + break; + case BT_HF_CALL_HANDLING_EVENT_VOICE_RECOGNITION_DISABLED: + TC_PRT("[call_handling_event_cb] event [VOICE_RECOGNITION_DISABLED]"); + break; + case BT_HF_CALL_HANDLING_EVENT_WAITING: + TC_PRT("[call_handling_event_cb] event [WAITING]"); + break; + case BT_HF_CALL_HANDLING_EVENT_HELD: + TC_PRT("[call_handling_event_cb] event [HELD]"); + break; + case BT_HF_CALL_HANDLING_EVENT_UNHELD: + TC_PRT("[call_handling_event_cb] event [UNHELD]"); + break; + case BT_HF_CALL_HANDLING_EVENT_SWAPPED: + TC_PRT("[call_handling_event_cb] event [SWAPPED]"); + break; + default: + TC_PRT("[call_handling_event_cb] event [UNKNOWN]"); + } + + TC_PRT("[call_handling_event_cb] phone_number [%s]", + phone_number); +} + +void __bt_hf_call_status_updated_event_cb(GSList *call_info_list, + void *user_data) +{ + TC_PRT("[call_status_updated_event_cb]"); + for (; call_info_list; call_info_list = g_slist_next(call_info_list)) { + bt_hf_call_status_info_s *call_info = call_info_list->data; + TC_PRT(" > Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]", + call_info->number, call_info->direction, + call_info->status, call_info->multi_party, + call_info->index); + } + + bt_hf_free_call_status_info_list(call_info_list); +} + +void __bt_hf_speaker_gain_changed_cb(int gain, + void *user_data) +{ + TC_PRT("__bt_hf_speaker_gain_changed_cb"); + TC_PRT("Gain= %d", gain); +} + +void __bt_pbap_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) +{ + TC_PRT("__bt_pbap_connection_state_changed_cb"); + TC_PRT("Result: %d", result); + TC_PRT("Remote Device: %s", remote_address); + TC_PRT("Connected Status: %d", connected); +} + +void __bt_pbap_phonebook_size_cb(int result, const char *remote_address, + int size, void *user_data) +{ + TC_PRT("__bt_pbap_phonebook_size_cb"); + TC_PRT("Result: %d", result); + TC_PRT("Remote Device: %s", remote_address); + TC_PRT("Phonebook Size: %d", size); +} + +void __bt_pbap_phonebook_pull_cb(int result, const char *remote_address, + const char *vcf_file, void *user_data) +{ + TC_PRT("__bt_pbap_phonebook_pull_cb"); + TC_PRT("Result: %d", result); + TC_PRT("Remote Device: %s", remote_address); + TC_PRT("Phonebook Download File: %s", vcf_file); + TC_PRT("Phonebook Download Status: %s", + (result == BT_ERROR_NONE) ? "Successful" : "Unsuccessful"); +} + +void __bt_pbap_vcard_list_cb(int result, const char *remote_address, + const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data) +{ + int i; + + TC_PRT("__bt_pbap_vcard_list_cb"); + TC_PRT("Result: %d", result); + TC_PRT("Remote Device: %s", remote_address); + TC_PRT("vCard Count: %d", count); + + for (i = 0; i < count; i++) + TC_PRT("vCard[%d]: %s", vcard_info[i].index, vcard_info[i].contact_name); + + TC_PRT("Listing Status: %s", + (result == BT_ERROR_NONE) ? "Successful" : "Unsuccessful"); +} + +void __bt_repeat_test_adapter_state_changed_cb(int result, + bt_adapter_state_e adapter_state, void *user_data) +{ + unsigned int delay = *(unsigned int *)user_data; + + TC_PRT("__bt_repeat_test_adapter_state_changed_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("state: %s, delay(%dsec)", + (adapter_state == BT_ADAPTER_ENABLED) ? + "ENABLED" : "DISABLED", delay); + + __bt_print_repeat_test_summary(); + + if (result != BT_ERROR_NONE) { + char *argv[] = {NULL}; + + TC_PRT("make dump\n"); + execv("all_log_dump.sh", argv); + + bt_onoff_cnt_fail++; + } else { + bt_onoff_cnt_success++; + + if (delay) + sleep(delay); + } + + gettimeofday(&check_time, NULL); + if (adapter_state == BT_ADAPTER_DISABLED) + bt_adapter_enable(); + else + bt_adapter_disable(); + + bt_onoff_cnt++; +} + +/* TDS Seeker Callbacks */ +static void __bt_tds_provider_scan_result_cb(int result, const char *remote_address, + bt_tds_transport_block_list_s *info, bt_adapter_le_device_scan_result_info_s *scan_info, + void *user_data) +{ + int k; + int l; + TC_PRT("__bt_tds_provider_scan_result_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + TC_PRT("Number of Transport Block [%d]", info->num_transport_block); + + if (result == BT_ERROR_NONE) { + for (k = 0; k < info->num_transport_block; k++) { + TC_PRT("Block Num[%d] Transport Name [%d]", k+1, info->data[k]->transport); + TC_PRT("Block Num[%d] Transport state [%d]", k+1, info->data[k]->state); + TC_PRT("Block Num[%d] Is Data complete [%d]", k+1, info->data[k]->is_data_complete); + TC_PRT("Block Num[%d] Length of TDS Block data [%d]", k+1, info->data[k]->length); + + for (l = 0; l < info->data[k]->length; l++) + TC_PRT("Transport Specific data [%d] = [0x%x]", l, info->data[k]->data[l]); + } + } +} + +static void __bt_tds_seeker_connection_state_changed_cb(int result, const char *remote_address, + bt_tds_seeker_h seeker, bool connected, void *user_data) +{ + TC_PRT("Result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + if (connected) + TC_PRT("TDS Seeker connected(address = %s)", remote_address); + else + TC_PRT("TDS Seeker Disconnected (address = %s)", remote_address); + } else + BT_ERR("TDS Connection failed!"); +} + +static void __bt_hrp_collector_connection_state_changed_cb(int result, const char *remote_address, + bt_hrp_collector_h seeker, bool connected, void *user_data) +{ + TC_PRT("Result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + if (connected) + TC_PRT("HRP Collector connected(address = %s)", remote_address); + else + TC_PRT("HRP Collector Disconnected (address = %s)", remote_address); + } else + BT_ERR("HRP Collection Connection failed!"); +} + + +static void __bt_tds_seeker_complete_transport_data_cb(int result, const char *remote_address, + bt_tds_transport_block_list_s *info, void *user_data) +{ + int k; + int l; + TC_PRT("__bt_tds_seeker_complete_transport_data_cb"); + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + + if (result == BT_ERROR_NONE) { + TC_PRT("Number of Transport Block [%d]", info->num_transport_block); + for (k = 0; k < info->num_transport_block; k++) { + TC_PRT("Block Num[%d] Transport Name [%d]", k+1, info->data[k]->transport); + TC_PRT("Block Num[%d] Transport state [%d]", k+1, info->data[k]->state); + TC_PRT("Block Num[%d] Is Data complete [%d]", k+1, info->data[k]->is_data_complete); + TC_PRT("Block Num[%d] Length of TDS Block data [%d]", k+1, info->data[k]->length); + + for (l = 0; l < info->data[k]->length; l++) + TC_PRT("Transport Specific data [%d] = [0x%x]", l, info->data[k]->data[l]); + } + } else + BT_ERR("TDS Data receive request failed!"); +} + +static void __bt_tds_control_point_activation_result_cb(int result, const char *remote_address, + unsigned char *data, int length, void *user_data) +{ + int k; + TC_PRT("__bt_tds_control_point_activation_result_cb"); + TC_PRT("Result [%d]", result); + TC_PRT("Address[%s]", remote_address); + + if (result == BT_ERROR_NONE) { + TC_PRT("Data length [%d]", length); + for (k = 0; k < length; k++) + TC_PRT("Data[%d] [0x%x]", k, data[k]); + } +} + +void __bt_otp_server_state_changed_cb(int result, bool status) +{ + TC_PRT("__bt_otp_server_state_changed_cb"); + TC_PRT("Result: %d", result); + TC_PRT("Server Status: %s", status ? "enabled" : "disabled"); +} + +static void __bt_otp_client_connection_state_changed_cb(int result, const char *remote_address, + bt_otp_client_h otp_client, bool connected, void *user_data) +{ + TC_PRT("Result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + if (connected) + TC_PRT("OTP Client connected(address = %s)", remote_address); + else + TC_PRT("OTP Client Disconnected (address = %s)", remote_address); + } else + BT_ERR("OTP Connection failed!"); +} + +static void __bt_otp_client_object_discovery_cb(int result, const char *remote_address, + bt_otp_object_list_s *obj_list, void *user_data) +{ + int k; + TC_PRT("__bt_otp_client_object_discovery_cb"); + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + + if (result == BT_ERROR_NONE) { + TC_PRT("Number of Objects [%d]", obj_list->num_objects); + + for (k = 0; k < obj_list->num_objects; k++) + TC_PRT("Object[%d] Id: [%llu] Name: [%s]", k+1, obj_list->data[k]->id, obj_list->data[k]->name); + + } else { + BT_ERR("Object discovery failed!"); + } +} + +static void __bt_otp_client_object_select_cb(int result, const char *remote_address, + unsigned long long obj_id, void *user_data) +{ + TC_PRT("__bt_otp_client_object_select_cb"); + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + + if (result == BT_ERROR_NONE) + TC_PRT("Object selected successfully! Current object[%llu]", obj_id); + else + BT_ERR("Object selection failed! Current object[%llu]", obj_id); +} + +static void __bt_otp_client_read_object_complete_cb(int result, const char *remote_address, + char *file_path, void *user_data) +{ + if (result == BT_ERROR_NONE) + TC_PRT("Read object success!, File location [%s]", file_path); + else + BT_ERR("Read object failed!"); +} + +static void __bt_otp_client_object_create_cb(int result, const char *remote_address, + unsigned long long obj_id, void *user_data) +{ + if (result == BT_ERROR_NONE) + TC_PRT("Object[%llu] created successfully in remote server!", obj_id); + else + BT_ERR("Object creation failed!"); +} + +static void __bt_otp_client_object_write_cb(int result, const char *remote_address, + unsigned int length, void *user_data) +{ + if (result == BT_ERROR_NONE) + TC_PRT("Object write success!, [%u] bytes written", length); + else + BT_ERR("Object write failed!, [%u] bytes written", length); +} + +static void __bt_otp_client_object_execute_cb(int result, const char *remote_address, + unsigned long long obj_id, void *user_data) +{ + TC_PRT("__bt_otp_client_object_execute_cb"); + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + + if (result == BT_ERROR_NONE) + TC_PRT("Object[%llu] launched successfully!", obj_id); + else + BT_ERR("Object[%llu] launch failed!", obj_id); +} + +static void __bt_otp_client_object_delete_cb(int result, const char *remote_address, + unsigned long long obj_id, void *user_data) +{ + TC_PRT("__bt_otp_client_object_delete_cb"); + TC_PRT("Result: %s", __bt_get_error_message(result)); + TC_PRT("Remote addr [%s]", remote_address); + + if (result == BT_ERROR_NONE) + TC_PRT("Object[%llu] deleted successfully!", obj_id); + else + BT_ERR("Object[%llu] delete failed!", obj_id); +} + +void __bt_gatt_client_read_request_completed_cb(int result, + bt_gatt_h request_handle, void *user_data) +{ + TC_PRT("[HR]Result : %d", result); +} + +void __bt_gatt_client_write_request_completed_cb(int result, + bt_gatt_h request_handle, void *user_data) +{ + TC_PRT("[HR]Result : %d", result); +} + +void _bt_hrp_collector_bsl_read_completed_cb(int result, + bt_hrp_collector_h request_handle, bt_body_sensor_location_e location, void *user_data) +{ + TC_PRT("[HR]Result : %d", result); + TC_PRT("[HR]request_handle : %p", request_handle); + TC_PRT("[HR]location [%d]", location); + +} + +static void __bt_initialize_all(void) +{ + int ret; + TC_PRT("Initialize and set callback functions"); + + ret = bt_initialize(); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_set_state_changed_cb( + __bt_adapter_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_set_connectable_changed_cb( + __bt_adapter_connectable_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_device_set_bond_created_cb( + __bt_device_bond_created_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_device_set_bond_destroyed_cb( + __bt_device_bond_destroyed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_device_set_connection_state_changed_cb( + __bt_device_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_device_set_att_mtu_changed_cb( + __bt_device_att_mtu_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_gatt_set_connection_state_changed_cb( + __bt_gatt_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_set_device_discovery_state_changed_cb( + __bt_adapter_device_discovery_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + if (TIZEN_PROFILE_WEARABLE_IVI) { + ret = bt_pbap_client_set_connection_state_changed_cb(__bt_pbap_connection_state_changed_cb, + NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + ret = bt_socket_set_connection_state_changed_cb( + __bt_socket_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_le_set_state_changed_cb( + __bt_adapter_le_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + return; +} + +int test_set_params(int test_id, char *param) +{ + static int param_index = 0; + const char *param_type = NULL; + int param_count = 0; + + if (param_index > 0 && param_index == g_test_param.param_count) + goto done; + + switch (current_tc_table) { + case BT_UNIT_TEST_TABLE_ADAPTER: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: + param_count = 1; + TC_PRT("Input param(%d) (non-discoverable: -1, always: 0, limited-discoverable(time): N)", param_index + 1); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: + param_count = 5; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_ADAPTER_LE: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: + param_count = 1; + TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE: + param_count = 1; + TC_PRT("Scan type\n (0 : Passive, 1: Active)"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED: + param_count = 2; + switch (param_index) { + case 0: + TC_PRT("Input Scan Interval (Unit : ms)"); + break; + case 1: + TC_PRT("Input Scan Window (Unit : ms)"); + break; + } + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS: + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME: + param_count = 1; + TC_PRT("Input data for LE scan filter"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: + param_count = 1; + TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS"); + TC_PRT("\t (Default scan response : Service Data &Local name & Manufacturer data)"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: + param_count = 1; + TC_PRT("Input mode \n (0 : Balanced(500 ms), 1 : Low Latency(150 ms), 2 : Low Energy (1000 ms))"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: + param_count = 1; + TC_PRT("Input filter_policy \n (0 : No use White List, 1 : Allow scan, 2 : Allow conneciton, 3 : Allow scan & conneciton)"); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: + param_count = 1; + TC_PRT("Input adv type \n (0 : Non-connectable (ADV_SCAN_IND), 1 : Connectable (ADV_IND) "); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER: + param_count = 1; + TC_PRT("Input adv Tx power level \n ( 1 ~ -127 dBm) "); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: + param_count = 1; + TC_PRT("Input adv slot id \n (Default is 0, Maximum is 2) "); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA: + param_count = 4; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + switch (param_index) { + case 0: + TC_PRT("Remote address"); + break; + case 1: + TC_PRT("Address type (0 : Public, 1 : Random"); + break; + case 2: + TC_PRT("confirmation"); + break; + case 3: + TC_PRT("random"); + break; + } + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_DEVICE: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: + case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: + param_count = 1; + TC_PRT("Input param(%d) mode (0 : balanced, 1 : low latency, 2 : low power) ", param_index + 1); + break; + case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION: + param_count = 4; + switch (param_index) { + case 0: + TC_PRT("Input interval min (8 ~ 4000)"); + break; + case 1: + TC_PRT("Input interval max (8 ~ 4000)"); + break; + case 2: + TC_PRT("Input slave latency ( 0 ~ 499)"); + break; + case 3: + TC_PRT("Input supervision timeout ( 100 ~ 32000)"); + break; + } + break; + case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: + param_count = 1; + param_type = "int(1, 2, 10, ...., 512)"; + TC_PRT("Input param(%d) : %s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: + param_count = 2; + switch (param_index) { + case 0: + TC_PRT("Input max octets (27 ~ 251)"); + break; + case 1: + TC_PRT("Input max time (328 ~ 2120)"); + break; + } + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_SOCKET: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: + case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: + case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_OPP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_AUDIO: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: + case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: + case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: + case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_PAN: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_GATT: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { + param_count = 3; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + case 2: + TC_PRT("Input write_type (0 : no response, 1 : with reponse, 2 : signed)"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { + param_count = 3; + + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + case 2: + TC_PRT("Input Descriptor UUID or nothing"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: { + param_count = 5; + + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + case 2: + TC_PRT("Input Descriptor UUID or nothing"); + break; + case 3: + TC_PRT("Input Value Type (avail. : uint8, uint16, uint32, int8, int16, int32, str)"); + break; + case 4: + TC_PRT("Input Value"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: { + param_count = 2; + + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: { + param_count = 2; + + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: + case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: + case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING: { + param_count = 2; + switch (param_index) { + case 0: + TC_PRT("Input buffer_threshold (1 ~ 32767)"); + break; + case 1: + TC_PRT("Input timeout (1 ~ 32767)"); + break; + } + break; + } + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_HPS: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { + param_count = 1; + TC_PRT("Input Value Type (avail. : \n1.HTTP_GET, \n2.HTTP_HEAD, \ + \n3.HTTP_POST, \n4.HTTP_PUT, \n5.HTTP_DELETE, \ + \n6.HTTPS_GET, \n7.HTTPS_HEAD, \n8.HTTPS_POST, \ + \n9.HTTPS_PUT, \n10.HTTPS_DELETE, \n11.HTTP_CANCEL"); + break; + } + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_DPM: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_HANDSFREE_ONLY, \n2.BT_DPM_BT_RESTRICTED"); + break; + + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: + case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); + break; + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: + param_count = 1; + TC_PRT("Input device Address"); + break; + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: + param_count = 1; + TC_PRT("Input UUID"); + break; + case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: + param_count = 2; + switch (param_index) { + case 0: + TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ + \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ + \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ + \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ + \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ + \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ + \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ + \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ + \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ + \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); + break; + case 1: + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); + break; + } + break; + case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: + param_count = 1; + TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ + \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ + \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ + \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ + \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ + \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ + \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ + \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ + \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ + \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); + + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_PXP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH"); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_AVRCP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_HID: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: + param_count = 1; + TC_PRT("Select TV control mode (1 : Vol Up, 2 : Vol Down, 3 : CH Up, 4 : CH Down) : "); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_IPSP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: + param_count = 1; + TC_PRT("IPSP Client : Input IPSP App server's IPv6 address to connect :"); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA: { + param_count = 2; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + + switch (param_index) { + case 0: + TC_PRT("IPSP : Input current role of Application[Server[0] / Client[1] :"); + break; + case 1: + TC_PRT("IPSP : input data to send :"); + break; + } + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: + param_count = 1; + TC_PRT("IPSP : Input current role of Application[Server[0]/Client[1] :"); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_HDP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_HF: + { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_PBAP_CLIENT: + if (!TIZEN_PROFILE_WEARABLE_IVI) + goto __default__; + { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_ETC: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input launch-type string(ex. setting, headset, hid)"); + break; + case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: + param_count = 1; + TC_PRT("Input feature string(ex. tizen.org/feature/network.bluetooth)"); + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_OTP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: + param_count = 1; + TC_PRT("Input Value in string"); + break; + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: + param_count = 1; + TC_PRT("Input Value in uint64_t"); + break; + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: + param_count = 4; + + switch (param_index) { + case 0: + TC_PRT("Input file path"); + break; + case 1: + TC_PRT("Input offset"); + break; + case 2: + TC_PRT("Input Length"); + break; + case 3: + TC_PRT("Input mode"); + break; + } + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } +__default__: + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + +done: + if (need_to_set_params) { + if (param_index == 0) { + g_test_param.param_count = param_count; + g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); + } + + if (param_index > 0) { + int len = strlen(param); + /* Remove new line character */ + param[len - 1] = '\0'; + g_test_param.params[param_index - 1] = g_strdup(param); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + + param_index++; + } + + return 0; +} + +int test_input_callback(void *data) +{ + int ret = 0; +#ifdef ARCH64 + int test_id = (uintptr_t)data; +#else + int test_id = (int)data; +#endif + + switch (current_tc_table) { + case BT_UNIT_TEST_TABLE_MAIN: { + switch (test_id) { + case 0x00ff: + TC_PRT("Finished"); + g_main_loop_quit(main_loop); + break; + + case BT_UNIT_TEST_FUNCTION_INITIALIZE: + ret = bt_initialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DEINITIALIZE: + ret = bt_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_ADAPTER: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE: { + bt_adapter_state_e state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&state); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("state: %d", state); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE: + ret = bt_adapter_enable(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE: + ret = bt_adapter_disable(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER: + ret = bt_adapter_recover(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY: + ret = bt_adapter_start_device_discovery(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY: + ret = bt_adapter_stop_device_discovery(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING: { + bool is_discovering = FALSE; + ret = bt_adapter_is_discovering(&is_discovering); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + else + TC_PRT("is_discovering: %d", is_discovering); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE: { + ret = bt_adapter_foreach_bonded_device( + __bt_adapter_bonded_device_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES: { + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_SPP, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("SPP connected devices returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_HFP_HF, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("HFP HF connected devices returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SOURCE, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("A2DP Source connected devices returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SINK, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("A2DP Sink connected devices returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_AVRCP_CONTROL, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("AVRCP Control connected devices returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_AVRCP_TARGET, + __bt_adapter_profile_connected_devices_cb, NULL); + TC_PRT("AVRCP Target connected devices returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO: { + bt_device_info_s *device_info = NULL; + int i; + char *str = NULL; + + ret = bt_adapter_get_bonded_device_info(remote_addr, + &device_info); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + if (device_info) { + TC_PRT("address: %s", device_info->remote_address); + TC_PRT("name: %s", device_info->remote_name); + TC_PRT("is_connected: %d", device_info->is_connected); + TC_PRT("is_authorized: %d", device_info->is_authorized); + TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask, + device_info->bt_class.major_device_class, + device_info->bt_class.minor_device_class); + + TC_PRT("service_count: %d", device_info->service_count); + if (device_info->service_uuid == NULL) { + TC_PRT("No uuids"); + } else { + for (i = 0; i < device_info->service_count; i++) { + bt_get_uuid_name(device_info->service_uuid[i], &str); + + TC_PRT("[%d / %d] %s (%s)", i, device_info->service_count, + str ? str : "Unknown", device_info->service_uuid[i]); + g_free(str); + } + } + + if (device_info->manufacturer_data_len > 0) { + TC_PRT("manufacturer specific data(len:%d)", + device_info->manufacturer_data_len); + printf("data ["); + for (i = 0; i < device_info->manufacturer_data_len; i++) + printf("%02x ", device_info->manufacturer_data[i]); + printf("]\n"); + } + printf("\n"); + } + + bt_adapter_free_device_info(device_info); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED: { + bool used = FALSE; + + ret = bt_adapter_is_service_used(opp_uuid, &used); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("used: %d", used); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY: { + bt_adapter_visibility_mode_e visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + int time = 0; + + ret = bt_adapter_get_visibility(&visibility_mode, &time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("mode: %d", visibility_mode); + TC_PRT("time: %d", time); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: { + int mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; + int timeout_sec = 0; + + if (g_test_param.param_count > 0) { + if (g_test_param.params[0][0] == '-') + mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + else if (g_test_param.params[0][0] == '0') + mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; + else { + mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE; + timeout_sec = atoi(g_test_param.params[0]); + } + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_set_visibility(mode, timeout_sec); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB: + ret = bt_adapter_set_device_discovery_state_changed_cb( + __bt_adapter_device_discovery_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB: + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA: { + ret = bt_adapter_get_local_oob_data(&hash, &randomizer, + &hash_len, &rand_len); + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("hash = [%s]", hash); + TC_PRT("randomizer = [%s]", randomizer); + } + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA: { + ret = bt_adapter_set_remote_oob_data(remote_addr, hash, + randomizer, hash_len, rand_len); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA: { + unsigned char *data[4]; + int len[4]; + int i; + + ret = bt_adapter_get_local_oob_ext_data( + &data[0], &data[1], &len[0], &len[1], + &data[2], &data[3], &len[2], &len[3]); + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + for (i = 0; i < 4; i++) { + int j; + + printf("Data[%d] : ", i); + + for (j = 0; j < len[i]; j++) + printf("%02x", data[i][j]); + + printf("\n"); + + g_free(data[i]); + } + } + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO: { + bt_battery_info_s battery_data; + memset(&battery_data, 0, sizeof(bt_battery_info_s)); + ret = bt_adapter_read_battery_info(&battery_data); + if (ret < 0) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("Battery data: %ld %ld %d %d", battery_data.session_start_time, + battery_data.session_end_time, battery_data.session_scan_time, battery_data.session_connected_time); + + TC_PRT("Tx time [%d], Rx time [%d], Idle time [%d]", battery_data.tx_time, + battery_data.rx_time, battery_data.idle_time); + + if(battery_data.atm_list == NULL) { + TC_PRT("No data transaction in this session"); + break; + } + + TC_PRT("Displaying app-wise transaction details"); + for (GSList *l = battery_data.atm_list; l != NULL; l = g_slist_next(l)) { + bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data); + TC_PRT("uid: %ld, pid: %ld, received bytes: %d, sent bytes: %d, time: %u", + (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time); + } + } + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR: { + int ret = bt_adapter_init_battery_monitor(__bt_adapter_disable_battery_cb, NULL); + if (ret == BLUETOOTH_ERROR_NONE) + TC_PRT("Battery monitor initialized and activated"); + else + TC_PRT("Battery monitor could not be initialized and activated"); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR: { + int ret = bt_adapter_deinit_battery_monitor(); + if (ret == BLUETOOTH_ERROR_NONE) + TC_PRT("Battery monitor deinitialized successfully"); + else + TC_PRT("Battery monitor could not be deinitialized"); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: { + char remote_addr[18]; + unsigned char *param_data[4]; + int len[4]; + int i; + char tmp[3]; + long val; + + if (g_test_param.param_count != 5) { + TC_PRT("Input parameter first!"); + break; + } + + g_strlcpy(remote_addr, g_test_param.params[0], + sizeof(remote_addr)); + + for (i = 0; i < 4; i++) { + len[i] = strlen(g_test_param.params[i + 1]) / 2; + param_data[i] = g_malloc0(len[i]); + } + + for (i = 0; i < 4; i++) { + int j; + + printf("param_data[%d] : ", i); + for (j = 0; j < len[i]; j++) { + g_strlcpy(tmp, g_test_param.params[i + 1] + 2 * j, sizeof(tmp)); + val = strtol(tmp, NULL, 16); + param_data[i][j] = val; + printf("%02x", param_data[i][j]); + } + printf("\n"); + } + + ret = bt_adapter_set_remote_oob_ext_data(remote_addr, + param_data[0], param_data[1], len[0], len[1], + param_data[2], param_data[3], len[2], len[3]); + + __bt_free_test_param(&g_test_param); + + for (i = 0; i < 4; i++) + g_free(param_data[i]); + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA: { + ret = bt_adapter_remove_remote_oob_data(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB: + ret = bt_adapter_set_visibility_mode_changed_cb( + __bt_adapter_device_visibility_mode_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB: + ret = bt_adapter_unset_visibility_mode_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB: + ret = bt_adapter_set_visibility_duration_changed_cb( + __bt_adapter_device_visibility_duration_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB: + ret = bt_adapter_unset_visibility_duration_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB: { + ret = bt_adapter_set_connectable_changed_cb( + __bt_adapter_connectable_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB: { + ret = bt_adapter_unset_connectable_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE: { + bool connectable = false; + + ret = bt_adapter_get_connectable(&connectable); + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + TC_PRT("%s", connectable ? "Connectable" : "Non-connectable"); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: { + bool connectable = false; + + bt_adapter_get_connectable(&connectable); + + if (g_test_param.param_count > 0) { + if (g_strrstr(g_test_param.params[0], "true")) + connectable = true; + else + connectable = false; + + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_set_connectable(!connectable); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION: { + char *version = NULL; + + ret = bt_adapter_get_version(&version); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + else { + TC_PRT("Version: [%s]", version); + g_free(version); + } + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO: { + char *chipset = NULL; + char *firmware = NULL; + char *stack_version = NULL; + char *profiles = NULL; + + ret = bt_adapter_get_local_info(&chipset, &firmware, + &stack_version, &profiles); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + else { + TC_PRT("Local info: [%s, %s, %s]", chipset, firmware, stack_version); + TC_PRT("Local info(Profiles):\n%s", profiles); + g_free(chipset); + g_free(firmware); + g_free(stack_version); + g_free(profiles); + } + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB: + { + ret = bt_adapter_set_manufacturer_data_changed_cb( + __bt_adapter_manufacturer_data_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB: + ret = bt_adapter_unset_manufacturer_data_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA: + { + char param_data[20] = {0x03, 0xFF, 0x01, 0x02}; + int len = 4; + int i = 0; + + if (g_test_param.param_count > 0) { + len = 0; + for (i = 0; i < (strlen(g_test_param.params[0]) - 1); i += 2) { + if (g_test_param.params[0][i] >= 'A' && g_test_param.params[0][i] <= 'F') + param_data[i/2] = (g_test_param.params[0][i] - 'A' + 0X0A) << 4; + else + param_data[i/2] = (g_test_param.params[0][i] - '0') << 4; + + if (g_test_param.params[0][i+1] >= 'A' && g_test_param.params[0][i+1] <= 'F') + param_data[i/2] += (g_test_param.params[0][i+1] - 'A' + 0X0A); + else + param_data[i/2] += (g_test_param.params[0][i+1] - '0'); + len++; + } + + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_set_manufacturer_data(param_data, len); + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB: + { + ret = bt_adapter_set_authentication_req_cb( + __bt_adapter_authentication_req_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW: + { + ret = bt_adapter_set_authentication_request_cb( + __bt_adapter_authentication_request_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB: + { + ret = bt_adapter_unset_authentication_req_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW: + { + ret = bt_adapter_unset_authentication_request_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT: + { + char *passkey = NULL; + TC_PRT("bt_adapter_passkey_reply: Authenticate Logitech Mouse: reply = Accept"); + passkey = g_strdup("0000"); /* Passkey - "0000" for mouse */ + ret = bt_adapter_passkey_reply(passkey, TRUE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_adapter_passkey_reply: accept authentication result = %d", ret); + g_free(passkey); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL: + { + char *passkey = NULL; + TC_PRT("bt_adapter_passkey_reply: cancel authentication reply"); + passkey = g_strdup("0000"); /* Passkey - "0000" */ + ret = bt_adapter_passkey_reply(passkey, FALSE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_adapter_passkey_reply: Logitech Mouse cancel authentication result = %d", ret); + g_free(passkey); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT: + { + ret = bt_adapter_passkey_confirmation_reply(TRUE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_adapter_passkey_confirmation_reply accept, result = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT: + { + ret = bt_adapter_passkey_confirmation_reply(FALSE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_adapter_passkey_confirmation_reply reject, result = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_ADAPTER_LE: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE: { + bt_adapter_le_state_e le_state = BT_ADAPTER_LE_DISABLED; + + ret = bt_adapter_le_get_state(&le_state); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("le_state: %d", le_state); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE: { + ret = bt_adapter_le_enable(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE: { + ret = bt_adapter_le_disable(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: { + int mode = BT_ADAPTER_LE_SCAN_MODE_BALANCED; + + if (g_test_param.param_count > 0) { + mode = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_scan_mode(mode); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE: { + int type = BT_ADAPTER_LE_PASSIVE_SCAN; + + if (g_test_param.param_count > 0) { + type = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_scan_type(type); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN: { + ret = bt_adapter_le_start_scan( + __bt_adapter_le_scan_result_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN: { + ret = bt_adapter_le_stop_scan(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + GSList *l = NULL; + int cnt = 0; + bt_adapter_le_device_scan_result_info_s *info; + printf("LE scan result :\n"); + for (l = le_scan_list; l != NULL; l = g_slist_next(l)) { + info = l->data; + if (info) { + printf("[%d] %s, %d dBm", ++cnt, info->remote_address, info->rssi); + if (info->adv_data) + printf(", %s", info->adv_data); + printf("\n"); + g_free(info->remote_address); + g_free(info->adv_data); + g_free(info); + } + } + g_slist_free(le_scan_list); + le_scan_list = NULL; + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: { + int adv_data_type = 3; /* default all */ + int manufacturer_id = 117; + char *manufacture = NULL; + char manufacture_0[] = {0x0, 0x0, 0x0, 0x0}; + char manufacture_1[] = {0x01, 0x01, 0x01, 0x01}; + char manufacture_2[] = {0x02, 0x02, 0x02, 0x02}; + char manufacture_3[] = {0x03, 0x03, 0x03, 0x03}; + char service_data[] = {0x01, 0x02, 0x03}; + const char *time_svc_uuid_16 = "1805"; + const char *battery_svc_uuid_16 = "180f"; + const char *heart_rate_svc_uuid_16 = "180d"; + const char *lmmediate_alert_svc_uuid_16 = "1802"; + const char *ancs_uuid_128 = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; + const char *ams_uuid_128 = "89D3502B-0F36-433A-8EF4-C502AD55F8DC"; + int appearance = 192; /* 192 is generic watch */ + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } else { + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING); + if (ret != BT_ERROR_NONE) + TC_PRT("clear advertising data [0x%04x]", ret); + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); + if (ret != BT_ERROR_NONE) + TC_PRT("clear scan response data [0x%04x]", ret); + } + + if (g_test_param.param_count > 0) { + adv_data_type = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + switch (adv_data_type) { + case 0: /* service uuid */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + manufacture = manufacture_0; + break; + + case 1: /* service solicitation */ + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + manufacture = manufacture_1; + break; + + case 2: /* appearance & tx power level */ + ret = bt_adapter_le_set_advertising_appearance(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); + if (ret != BT_ERROR_NONE) + TC_PRT("add appearance data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, true); + if (ret != BT_ERROR_NONE) + TC_PRT("add appearance data [0x%04x]", ret); + manufacture = manufacture_2; + break; + + case 3: /* All */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, heart_rate_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, lmmediate_alert_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); + if (ret != BT_ERROR_NONE) + TC_PRT("add appearance data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, true); + if (ret != BT_ERROR_NONE) + TC_PRT("add tx_power_level [0x%04x]", ret); + + manufacture = manufacture_3; + break; + + case 4: /* ANCS */ + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, ancs_uuid_128); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + TC_PRT("set device name [0x%04x]", ret); + + return 0; + + case 5: /* AMS */ + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, ams_uuid_128); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + TC_PRT("set device name [0x%04x]", ret); + + return 0; + + default: + TC_PRT("No adv data"); + break; + } + + /* Default scsn response data */ + ret = bt_adapter_le_add_advertising_service_data(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, + service_data, sizeof(service_data)); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + TC_PRT("set device name [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, + manufacturer_id, + manufacture, sizeof(manufacture_0)); + if (ret != BT_ERROR_NONE) + TC_PRT("add manufacturer data [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA: { + const char *battery_svc_uuid_16 = "180f"; + const char *hid_svc_uuid_16 = "1812"; + const char *gatt_svc_uuid_16 = "1801"; + int appearance = 192; /* 192 is generic watch */ + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } else { + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING); + if (ret != BT_ERROR_NONE) + TC_PRT("clear advertising data [0x%04x]", ret); + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); + if (ret != BT_ERROR_NONE) + TC_PRT("clear scan response data [0x%04x]", ret); + } + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, hid_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, gatt_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); + if (ret != BT_ERROR_NONE) + TC_PRT("add appearance data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, true); + if (ret != BT_ERROR_NONE) + TC_PRT("add tx_power_level [0x%04x]", ret); + + /* Default scsn response data */ + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + TC_PRT("set device name [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: { + int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } + + if (g_test_param.param_count > 0) { + mode = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_advertising_mode(advertiser, mode); + if (ret != BT_ERROR_NONE) + TC_PRT("add scan response data [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: { + int filter_policy = BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_CONN_WL; + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } + + if (g_test_param.param_count > 0) { + filter_policy = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_advertising_filter_policy(advertiser, filter_policy); + if (ret != BT_ERROR_NONE) + TC_PRT("add scan response data [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: { + int type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE; + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } + + if (g_test_param.param_count > 0) { + type = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_advertising_connectable(advertiser, type); + if (ret != BT_ERROR_NONE) + TC_PRT("add scan response data [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER: { + int tx_power_level = 0; + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } + + if (g_test_param.param_count > 0) { + tx_power_level = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_set_advertising_custom_tx_power_level(advertiser, tx_power_level); + if (ret != BT_ERROR_NONE) + TC_PRT("set Tx power level [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW: { + bt_adapter_le_advertising_state_changed_cb cb; + + if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; + else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; + else cb = __bt_adapter_le_advertising_state_changed_cb_3; + + advertiser = advertiser_list[advertiser_index]; + advertiser_index++; + advertiser_index %= 3; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } + + TC_PRT("advertiser: %p", advertiser); + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: { + int slot_id = 0; + + if (g_test_param.param_count > 0) { + slot_id = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + if (slot_id < 0 || + slot_id >= (sizeof(advertiser_list) / sizeof(advertiser_list[0]))) { + TC_PRT("wrong slot_id: %d", slot_id); + break; + } + + advertiser = advertiser_list[slot_id]; + + ret = bt_adapter_le_stop_advertising(advertiser); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST: { + ret = bt_adapter_le_add_white_list(remote_addr, + BT_DEVICE_PUBLIC_ADDRESS); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST: { + ret = bt_adapter_le_remove_white_list(remote_addr, + BT_DEVICE_PUBLIC_ADDRESS); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: { + static bool enable_privacy = false; + + if (enable_privacy == false) + enable_privacy = true; + else + enable_privacy = false; + + if (g_test_param.param_count > 0) { + if (g_strrstr(g_test_param.params[0], "true")) + enable_privacy = true; + else + enable_privacy = false; + + __bt_free_test_param(&g_test_param); + } + + ret = bt_adapter_le_enable_privacy(enable_privacy); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA: { + char *local_address; + bt_device_address_type_e address_type = 0; + unsigned char *confirm; + unsigned char *random; + int confirm_len; + int random_len; + int i; + + bt_adapter_le_get_local_oob_ext_data(&local_address, &address_type, + &confirm, &random, + &confirm_len, &random_len); + + printf("local address : %s\n", local_address); + printf("address type : %d\n", address_type); + printf("confirm : "); + for (i=0; i 0) { + ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } else { + ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, remote_addr); + } + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME: { + bt_scan_filter_h scan_filter; + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + if (g_test_param.param_count > 0) { + ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } else { + ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, "Galaxy"); + } + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID: { + bt_scan_filter_h scan_filter; + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_set_service_uuid(scan_filter, "1805"); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID: { + bt_scan_filter_h scan_filter; + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(scan_filter, "1805"); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA: { + bt_scan_filter_h scan_filter = NULL; + int manufacturer_id = 117; /* samsung */ + char param_data[] = {0x42, 0x04}; + /* Use "appearance & tx power level" of bt_adapter_le_add_XXX_advertising_data */ + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data(scan_filter, + manufacturer_id, param_data, sizeof(param_data)); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA: { + bt_scan_filter_h scan_filter; + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS: { + ret = bt_adapter_le_scan_filter_unregister_all(); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { + + TC_PRT("Testing: Write Host suggested default LE Data length"); + + unsigned int def_tx_octects = 30; + unsigned int def_tx_time = 330; + ret = bt_adapter_le_write_host_suggested_default_data_length( + def_tx_octects, def_tx_time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { + + TC_PRT("Read host suggested default LE Data length"); + + unsigned int def_tx_octets = 0; + unsigned int def_tx_time = 0; + ret = bt_adapter_le_read_suggested_default_data_length( + &def_tx_octets, &def_tx_time); + TC_PRT("host suggested default le data length values are %d %d", + def_tx_octets, def_tx_time); + break; + } + case BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT: { + + TC_PRT("Check LE 2M PHY Feature support"); + bool is_2m_phy_supported = FALSE; + + ret = bt_adapter_le_is_2m_phy_supported(&is_2m_phy_supported); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("LE 2M PHY Support [%s]", is_2m_phy_supported ? "YES" : "NO"); + break; + } + case BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT: { + + TC_PRT("Check LE CODED PHY Feature support"); + bool is_coded_phy_supported = FALSE; + + ret = bt_adapter_le_is_coded_phy_supported(&is_coded_phy_supported); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("LE CODED PHY Support [%s]", is_coded_phy_supported ? "YES" : "NO"); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_DEVICE: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE: { + ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, TRUE); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE: { + ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, FALSE); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE: { + ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, TRUE); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE: { + ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, FALSE); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB: + ret = bt_device_set_trusted_profile_cb( + __bt_device_profile_trusted_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB: + ret = bt_device_unset_trusted_profile_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE: { + ret = bt_device_set_authorization(remote_addr, BT_DEVICE_AUTHORIZED); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE: { + ret = bt_device_set_authorization(remote_addr, BT_DEVICE_UNAUTHORIZED); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB: + ret = bt_device_set_authorization_changed_cb( + __bt_device_authorization_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB: + ret = bt_device_unset_authorization_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB: + ret = bt_device_set_connection_state_changed_cb( + __bt_device_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB: + ret = bt_device_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES: { + ret = bt_device_foreach_connected_profiles(remote_addr, + __bt_device_connected_profile, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: { + bool connected_status = false; + bt_profile_e profile = BT_PROFILE_HSP; + + if (g_test_param.param_count > 0) { + profile = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_device_is_profile_connected(remote_addr, + profile, &connected_status); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + TC_PRT("Profile [%s]", + connected_status ? "Connected" : "Disconnected"); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB: { + ret = bt_device_set_bond_created_cb( + __bt_device_bond_created_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB: { + ret = bt_device_set_bond_destroyed_cb( + __bt_device_bond_destroyed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT: { + ret = bt_device_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND: { + ret = bt_device_create_bond(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: { + bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE; + + if (g_test_param.param_count > 0) { + link_type = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_device_create_bond_by_type(remote_addr, + link_type); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND: { + ret = bt_device_destroy_bond(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE: { + bool bredr_connected = false; + bool le_connected = false; + + ret = bt_device_get_connection_state(remote_addr, + BT_DEVICE_CONNECTION_LINK_BREDR, + &bredr_connected); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_device_get_connection_state(remote_addr, + BT_DEVICE_CONNECTION_LINK_LE, + &le_connected); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + TC_PRT("BR/EDR [%s], LE [%s]", + bredr_connected ? "Connected" : "Disconnected", + le_connected ? "Connected" : "Disconnected"); + + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: { + unsigned int mtu = 512; /* MAX MTU Value */ + + if (g_test_param.param_count > 0) { + mtu = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_device_request_att_mtu(remote_addr, mtu); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU: { + unsigned int mtu = 0; + ret = bt_device_get_att_mtu(remote_addr, &mtu); + TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB: { + ret = bt_device_set_att_mtu_changed_cb(__bt_device_att_mtu_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB: { + ret = bt_device_unset_att_mtu_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION: { + bt_le_conn_update_s param; + + if (g_test_param.param_count == 0) + break; + + param.interval_min = atof(g_test_param.params[0]); + param.interval_max = atof(g_test_param.params[1]); + param.latency = atoi(g_test_param.params[2]); + param.time_out = atoi(g_test_param.params[3]); + + __bt_free_test_param(&g_test_param); + + ret = bt_device_le_conn_update(remote_addr, ¶m); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: { + + TC_PRT("Set LE Data length paramters cmd"); + + unsigned int tx_octets = 50; + unsigned int tx_time = 500; + + if (g_test_param.param_count > 0) { + tx_octets = atoi(g_test_param.params[0]); + tx_time = atoi(g_test_param.params[1]); + + __bt_free_test_param(&g_test_param); + } + + TC_PRT("settting le data length values tx octects: %d tx time: %d", + tx_octets, tx_time); + ret = bt_device_le_set_data_length(remote_addr, + tx_octets, tx_time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB: { + + TC_PRT("Setting LE Data length change callback"); + + ret = bt_device_le_set_data_length_change_cb( + __bt_le_set_data_length_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: { + int mode = BT_DEVICE_LE_CONNECTION_MODE_BALANCED; + + if (g_test_param.param_count > 0) { + mode = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + ret = bt_device_update_le_connection_mode(remote_addr, mode); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_SOCKET: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM: { + int socket_fd = 0; + + ret = bt_socket_create_rfcomm(spp_uuid, &socket_fd); + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("socket_fd: %d", socket_fd); + server_fd = socket_fd; + } + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM: + ret = bt_socket_destroy_rfcomm(server_fd); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM: + ret = bt_socket_listen_and_accept_rfcomm(server_fd, 1); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN: + ret = bt_socket_listen(server_fd, 1); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT: { + int socket_fd = 0; + + ret = bt_socket_accept(server_fd); + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("socket_fd: %d", socket_fd); + client_fd = socket_fd; + } + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_REJECT: + ret = bt_socket_reject(server_fd); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM: { + ret = bt_socket_connect_rfcomm(remote_addr, spp_uuid); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM: + ret = bt_socket_disconnect_rfcomm(client_fd); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: { + char data[] = "Sending test"; + + if (g_test_param.param_count > 0) { + ret = bt_socket_send_data(client_fd, + g_test_param.params[0], + strlen(g_test_param.params[0]) + 1); + + __bt_free_test_param(&g_test_param); + } else { + ret = bt_socket_send_data(client_fd, + data, sizeof(data)); + } + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: { + int socket_fd = 0; + + if (g_test_param.param_count > 0) { + ret = bt_socket_create_rfcomm(g_test_param.params[0], &socket_fd); + + __bt_free_test_param(&g_test_param); + } else { + ret = bt_socket_create_rfcomm(custom_uuid, &socket_fd); + } + + if (ret < BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("socket_fd: %d", socket_fd); + custom_server_fd = socket_fd; + } + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID: + ret = bt_socket_destroy_rfcomm(custom_server_fd); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID: + ret = bt_socket_listen_and_accept_rfcomm(custom_server_fd, 1); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: { + if (g_test_param.param_count > 0) { + ret = bt_socket_connect_rfcomm(remote_addr, g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } else { + ret = bt_socket_connect_rfcomm(remote_addr, custom_uuid); + } + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID: + ret = bt_socket_disconnect_rfcomm(custom_client_fd); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID: { + char param_data[] = "Sending test"; + + if (g_test_param.param_count > 0) { + ret = bt_socket_send_data(custom_client_fd, + g_test_param.params[0], + strlen(g_test_param.params[0]) + 1); + + __bt_free_test_param(&g_test_param); + } else { + ret = bt_socket_send_data(custom_client_fd, + param_data, sizeof(param_data)); + } + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB: + ret = bt_socket_set_data_received_cb( + __bt_socket_data_received_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB: + ret = bt_socket_unset_data_received_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB: + ret = bt_socket_set_connection_requested_cb( + __bt_socket_connection_requested_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB: + ret = bt_socket_unset_connection_requested_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB: + ret = bt_socket_set_connection_state_changed_cb( + __bt_socket_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB: + ret = bt_socket_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_OPP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE: + ret = bt_opp_client_initialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE: + ret = bt_opp_client_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE: + ret = bt_opp_client_add_file("/opt/media/Images/image1.jpg"); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES: + ret = bt_opp_client_clear_files(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES: { + ret = bt_opp_client_push_files(remote_addr, + __bt_opp_client_push_responded_cb, + __bt_opp_client_push_progress_cb, + __bt_opp_client_push_finished_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH: + ret = bt_opp_client_cancel_push(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_AUDIO: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE: + ret = bt_audio_initialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE: + ret = bt_audio_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: { + bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL; + + if (g_test_param.param_count > 0) { + audio_profile = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_audio_connect(remote_addr, audio_profile); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: { + bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_ALL; + + if (g_test_param.param_count > 0) { + audio_profile = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_audio_disconnect(remote_addr, audio_profile); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT: { + bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK; + + if (g_test_param.param_count > 0) { + audio_profile = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_audio_connect(remote_addr, audio_profile); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT: { + bt_audio_profile_type_e audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK; + + if (g_test_param.param_count > 0) { + audio_profile = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_audio_disconnect(remote_addr, audio_profile); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB: + ret = bt_audio_set_connection_state_changed_cb( + __bt_audio_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB: + ret = bt_audio_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO: + ret = bt_ag_open_sco(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO: + ret = bt_ag_close_sco(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED: { + bool opened = false; + ret = bt_ag_is_sco_opened(&opened); + TC_PRT("opend[%s]", opened ? "YES" : "NO"); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB: + ret = bt_ag_set_sco_state_changed_cb( + __bt_ag_sco_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB: + ret = bt_ag_unset_sco_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB: + ret = bt_ag_set_speaker_gain_changed_cb( + __bt_ag_speaker_gain_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB: + ret = bt_ag_unset_speaker_gain_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB: + ret = bt_ag_set_microphone_gain_changed_cb( + __bt_ag_microphone_gain_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB: + ret = bt_ag_unset_microphone_gain_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED: { + bool connected = false; + ret = bt_ag_is_connected(&connected); + TC_PRT("returns %s\n", + connected ? "Connected" : "Disconnected"); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE: { + unsigned int call_id = 1; + + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_IDLE, + call_id, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED: { + unsigned int call_id = 1; + bool sco_required = true; + + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_ANSWERED, + call_id, NULL); + if (sco_required) + bt_ag_open_sco(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: { + unsigned int call_id = 1; + bool sco_required = TRUE; + const char *phone_number; + + if (g_test_param.param_count > 0) { + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_DIALING, + call_id, g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } else { + phone_number = g_strdup("01012345678"); + + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_DIALING, + call_id, phone_number); + } + + if (sco_required) + bt_ag_open_sco(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING: { + unsigned int call_id = 1; + + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_ALERTING, + call_id, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: { + unsigned int call_id = 1; + const char *phone_number; + + if (g_test_param.param_count > 0) { + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_INCOMING, + call_id, g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } else { + phone_number = g_strdup("01012345678"); + + ret = bt_ag_notify_call_event( + BT_AG_CALL_EVENT_INCOMING, + call_id, phone_number); + } + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE: + ret = bt_call_list_create(&call_list); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY: + ret = bt_call_list_destroy(call_list); + call_list = NULL; + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET: + ret = bt_call_list_reset(call_list); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: { + const char *phone_number; + + if (g_test_param.param_count > 0) { + ret = bt_call_list_add(call_list, 1, + BT_AG_CALL_STATE_ACTIVE, + g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } else { + phone_number = g_strdup("01012345678"); + + ret = bt_call_list_add(call_list, 1, + BT_AG_CALL_STATE_ACTIVE, + phone_number); + } + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST: + ret = bt_ag_notify_call_list(call_list); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB: + ret = bt_ag_set_call_handling_event_cb( + __bt_ag_set_call_handling_event_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED: { + bool enabled = false; + ret = bt_ag_is_nrec_enabled(&enabled); + TC_PRT("opend[%s]", enabled ? "YES" : "NO"); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: { + if (g_test_param.param_count < 0) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_ag_switch_headset(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + case BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE: { + bt_audio_role_e role = BT_A2DP_SOURCE; + ret = bt_audio_select_role(role); + TC_PRT("Asdp Source set change ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE: { + bt_audio_role_e role = BT_A2DP_SINK; + ret = bt_audio_select_role(role); + TC_PRT("Asdp Sink set change ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME: { + if (absolute_volume > 150) + absolute_volume = 0; + + ret = bt_audio_set_absolute_volume(absolute_volume); + TC_PRT("ret = %d", ret); + + if (ret == BT_ERROR_NONE) + absolute_volume = absolute_volume + 50; + + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME: { + unsigned int volume = 0; + ret = bt_audio_get_absolute_volume(&volume); + TC_PRT("ret = %d, volume: %d", ret, volume); + + if (ret == BT_ERROR_NONE) + absolute_volume = volume; + + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED: { + bool activated = false; + ret = bt_audio_is_avc_activated(&activated); + TC_PRT("ret = %d, activated = %d", ret, activated); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB: { + ret = bt_audio_set_absolute_volume_changed_cb(__bt_audio_absolute_volume_changed_cb, NULL); + TC_PRT("ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB: { + ret = bt_audio_unset_absolute_volume_changed_cb(); + TC_PRT("ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB: { + ret = bt_audio_set_avc_status_changed_cb(__bt_audio_avc_status_changed_cb, NULL); + TC_PRT("ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB: { + ret = bt_audio_unset_avc_status_changed_cb(); + TC_PRT("ret = %d", ret); + break; + } + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_PAN: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE: + ret = bt_nap_activate(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE: + ret = bt_nap_deactivate(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL: + ret = bt_nap_disconnect_all(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT: { + ret = bt_nap_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_panu_set_connection_state_changed_cb( + panu_conn_state_changed, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PANU_CONNECT: { + ret = bt_panu_connect(remote_addr, + BT_PANU_SERVICE_TYPE_NAP); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_GATT: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: { + bool auto_connect = false; + + if (g_test_param.param_count > 0) { + if (g_strrstr(g_test_param.params[0], "true")) + auto_connect = true; + else + auto_connect = false; + + __bt_free_test_param(&g_test_param); + } + + ret = bt_gatt_connect(remote_addr, auto_connect); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT: { + ret = bt_gatt_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB: { + ret = bt_gatt_set_connection_state_changed_cb( + __bt_gatt_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB: { + ret = bt_gatt_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { + char *svc_uuid = NULL; + char *chr_uuid = NULL; + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + bt_gatt_write_type_e write_type; + + if (g_test_param.param_count < 3) { + TC_PRT("Input parameters first"); + break; + } + + svc_uuid = g_test_param.params[0]; + chr_uuid = g_test_param.params[1]; + + ret = bt_gatt_client_get_service(client, svc_uuid, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + write_type = atoi(g_test_param.params[2]); + ret = bt_gatt_characteristic_set_write_type(chr, write_type); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_characteristic_set_write_type is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE: { + if (client) { + bt_gatt_client_destroy(client); + client = NULL; + } + ret = bt_gatt_client_create(remote_addr, &client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY: { + if (!client) + break; + + ret = bt_gatt_client_destroy(client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + client = NULL; + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS: { + char *addr = NULL; + + ret = bt_gatt_client_get_remote_address(client, &addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + if (addr) { + TC_PRT("remote addr : %s\n", addr); + g_free(addr); + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL: { +#ifdef ARCH64 + ret = bt_gatt_client_foreach_services(client, + __bt_gatt_client_foreach_svc_cb, + (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_client_foreach_services(client, + __bt_gatt_client_foreach_svc_cb, + (void *)test_id); +#endif + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { + char *svc_uuid = NULL; + char *chr_uuid = NULL; + char *desc_uuid = NULL; + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + bt_gatt_h desc = NULL; + + if (g_test_param.param_count < 3) { + TC_PRT("Input parameters first"); + break; + } + + svc_uuid = g_test_param.params[0]; + chr_uuid = g_test_param.params[1]; + + ret = bt_gatt_client_get_service(client, + svc_uuid, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + chr_uuid, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + if (strlen(g_test_param.params[2]) > 0) { + desc_uuid = g_test_param.params[2]; + ret = bt_gatt_characteristic_get_descriptor(chr, + desc_uuid, &desc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + ret = bt_gatt_client_read_value(desc, + __bt_gatt_client_read_complete_cb, NULL); + } else { + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + } + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: { + char *svc_uuid = NULL; + char *chr_uuid = NULL; + char *desc_uuid = NULL; + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + bt_gatt_h desc = NULL; + + if (g_test_param.param_count < 5) { + TC_PRT("Input parameters first"); + break; + } + + svc_uuid = g_test_param.params[0]; + chr_uuid = g_test_param.params[1]; + + ret = bt_gatt_client_get_service(client, + svc_uuid, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + chr_uuid, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + if (strlen(g_test_param.params[2]) > 0) { + desc_uuid = g_test_param.params[2]; + ret = bt_gatt_characteristic_get_descriptor(chr, + desc_uuid, &desc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_characteristic_get_descriptor is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value(g_test_param.params[3], + g_test_param.params[4], desc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(desc, + __bt_gatt_client_write_complete_cb, NULL); + } else { + ret = __bt_gatt_client_set_value(g_test_param.params[3], + g_test_param.params[4], chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + } + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: { + char *svc_uuid = NULL; + char *chr_uuid = NULL; + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + if (g_test_param.param_count < 2) { + TC_PRT("Input parameters first"); + break; + } + + svc_uuid = g_test_param.params[0]; + chr_uuid = g_test_param.params[1]; + + ret = bt_gatt_client_get_service(client, + svc_uuid, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + chr_uuid, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, + __bt_gatt_client_value_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: { + char *svc_uuid = NULL; + char *chr_uuid = NULL; + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + if (g_test_param.param_count < 2) { + TC_PRT("Input parameters first"); + break; + } + + svc_uuid = g_test_param.params[0]; + chr_uuid = g_test_param.params[1]; + + ret = bt_gatt_client_get_service(client, + svc_uuid, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + chr_uuid, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES: { +#ifdef ARCH64 + ret = bt_gatt_client_foreach_services(client, + __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_client_foreach_services(client, + __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id); +#endif + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed"); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU: { + unsigned int mtu = 512; /* MAX MTU Value */ + + if (g_test_param.param_count > 0) { + mtu = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_gatt_client_request_att_mtu_change(client, mtu); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU: { + unsigned int mtu = 0; + ret = bt_gatt_client_get_att_mtu(client, &mtu); + TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB: { + ret = bt_gatt_client_set_service_changed_cb(client, + __bt_gatt_client_service_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_service_changed_cb is failed"); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB: { + ret = bt_gatt_client_unset_service_changed_cb(client); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_unset_service_changed_cb is failed"); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB: { + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB: { + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE: { + + ret = bt_gatt_server_initialize(); + + TC_PRT("returns %s \n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE: { + + ret = bt_gatt_server_deinitialize(); + + server = NULL; + + TC_PRT("returns %s \n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES: { + ret = bt_gatt_server_unregister_all_services(server); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB: { + ret = bt_gatt_server_set_att_mtu_changed_cb(server, __bt_gatt_server_att_mtu_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *service_uuid = "180f"; /* Battery Service */ + char *char_uuid = "2a19"; /* Battery Level */ + char *desc_uuid = "2902"; /* CCCD */ + char char_value[1] = {80}; /* 80% */ + char desc_value[2] = {0, 0}; /* Notification & Indication */ + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, + char_value, sizeof(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, + __bt_gatt_server_notification_state_change_cb, NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + ret = bt_gatt_descriptor_create(desc_uuid, permissions, + desc_value, sizeof(desc_value), &descriptor); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + battery_h.svc = service; + battery_h.chr = characteristic; + battery_h.desc = descriptor; + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL: { + char char_value[1] = {1 + (rand()%100)}; + if (!server) { + TC_PRT("bt gatt server is not created"); + break; + } + ret = bt_gatt_set_value(battery_h.chr, char_value, 1); + TC_PRT("Value[%d], returns %s\n", char_value[0], __bt_get_error_message(ret)); + + /* notify only client remote_addr */ + ret = bt_gatt_server_notify_characteristic_changed_value(battery_h.chr, + __bt_gatt_server_notification_sent_cb, + remote_addr, NULL); + TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *service_uuid = "180d"; /* Heart Rate Service */ + char *char_uuid = "2a37"; /* Heart Rate Measurement */ + char *desc_uuid = "2902"; /* CCCD */ + char char_value_1[3] = {1, 0x38, 0}; /* Flag + Measurement value (56) */ + char desc_value[2] = {1, 0}; /* Notification enabled */ + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; /* READ property added for testing */ + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, + char_value_1, sizeof(char_value_1), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + heart_rate_h.chr = characteristic; + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, + __bt_gatt_server_notification_state_change_cb, NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + ret = bt_gatt_descriptor_create(desc_uuid, permissions, + desc_value, sizeof(desc_value), &descriptor); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + char_uuid = "2a38"; /* Body Sensor Location */ + permissions = BT_GATT_PERMISSION_READ; + properties = BT_GATT_PROPERTY_READ; + char char_value_2 = 4; /* Hand */ + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, + &char_value_2, sizeof(char_value_2), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + heart_rate_h.svc = service; + heart_rate_h.desc = descriptor; + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT: { + int char_value = 60 + (rand()%60); + if (!server) { + TC_PRT("bt gatt server is not created"); + break; + } + ret = bt_gatt_set_int_value(heart_rate_h.chr, + BT_DATA_TYPE_UINT16, char_value, 1); + TC_PRT("bt_gatt_set_value(value : %d) : %s\n", + char_value, __bt_get_error_message(ret)); + + /* Notify all client devices */ + ret = bt_gatt_server_notify_characteristic_changed_value(heart_rate_h.chr, + __bt_gatt_server_notification_sent_cb, + NULL, NULL); + TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *service_uuid = "1809"; /* Health Thermometer Service */ + char *char_uuid = "2a1c"; /* Temperature Measurement */ + char *desc_uuid = "2902"; /* CCCD */ + char char_value[5] = {0, 0x85, 0xff, 0xff, 0xfe}; /* Flag + Temperature Measurement Value (Celsius, -1.23) */ + char desc_value[2] = {2, 0}; /* Indication enabled */ + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_INDICATE | BT_GATT_PROPERTY_READ; /* READ property added for testing */ + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, + BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, + char_value, sizeof(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, + __bt_gatt_server_notification_state_change_cb, NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + ret = bt_gatt_descriptor_create(desc_uuid, permissions, + desc_value, sizeof(desc_value), &descriptor); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + thermometer_h.chr = characteristic; + thermometer_h.svc = service; + thermometer_h.desc = descriptor; + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT: { + if (!server) { + TC_PRT("bt gatt server is not created"); + break; + } + ret = bt_gatt_set_float_value(thermometer_h.chr, BT_DATA_TYPE_FLOAT, 123, -2, 1); + TC_PRT("bt_gatt_set_value(value : 1.23) : %s\n", __bt_get_error_message(ret)); + + /* notify only client remote_addr */ + ret = bt_gatt_server_notify_characteristic_changed_value(thermometer_h.chr, + __bt_gatt_server_notification_sent_cb, remote_addr, NULL); + TC_PRT("bt_gatt_server_notify : %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + char *service_uuid = "180a"; /* Device Infromation Service */ + char *char_uuid = NULL; + char *char_value; + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_READ; + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, + BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + char_uuid = "2a29"; /* Manufacturer Name String */ + char_value = g_strdup("Samsung"); + ret = bt_gatt_characteristic_create(char_uuid, permissions, + properties, char_value, + strlen(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + g_free(char_value); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, + NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + char_uuid = "2a24"; /* Model Number String */ + char_value = g_strdup("TIZEN_HR 0408"); + ret = bt_gatt_characteristic_create(char_uuid, permissions, + properties, char_value, + strlen(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + g_free(char_value); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, + NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + char_uuid = "2a28"; /* S/W Revision String */ + char_value = g_strdup("NC2"); + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, + char_value, strlen(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + g_free(char_value); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, + NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + char_uuid = "2a26"; /* Firmware Revision Name String */ + char_value = g_strdup("Firmware Ver 04"); + ret = bt_gatt_characteristic_create(char_uuid, permissions, + properties, char_value, + strlen(char_value), &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + g_free(char_value); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, + NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + char *service_uuid = "1803"; /* Link Loss Service */ + char *char_uuid = "2a06"; /* Alert Level */ + char char_value[1] = {2}; /* high alert */ + int value_length = 1; + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, + properties, char_value, + value_length, &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, + __bt_gatt_server_write_value_requested_cb, + NULL); + TC_PRT("bt_gatt_server_set_write_value_requested_cb : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC: { + bt_gatt_h service1 = NULL; + bt_gatt_h service2 = NULL; + bt_gatt_h service3 = NULL; + bt_gatt_h characteristic1_1 = NULL; + bt_gatt_h characteristic2_1 = NULL; + bt_gatt_h characteristic2_2 = NULL; + bt_gatt_h characteristic2_3 = NULL; + bt_gatt_h characteristic2_4 = NULL; + bt_gatt_h characteristic2_5 = NULL; + bt_gatt_h characteristic2_6 = NULL; + bt_gatt_h characteristic2_7 = NULL; + bt_gatt_h descriptor1_1 = NULL; + bt_gatt_h descriptor2_3 = NULL; + bt_gatt_h descriptor2_4_1 = NULL; + bt_gatt_h descriptor2_4_2 = NULL; + bt_gatt_h descriptor2_5_1 = NULL; + bt_gatt_h descriptor2_5_2 = NULL; + char *service_uuid1 = "180f"; /* Battery Service */ + char *service_uuid2 = "1812"; /* HID Service */ + char *service_uuid3 = "1801"; /* Generic Attribute Service */ + char *char_uuid1 = "2a19"; /* Battery Level */ + char *char_uuid2_1 = "2a4a"; /* HID information */ + char *char_uuid2_2 = "2a4b"; + char *char_uuid2_3 = "2a33"; + char *char_uuid2_4 = "2a4d"; + char *char_uuid2_5 = "2a4d"; + char *char_uuid2_6 = "2a4c"; + char *char_uuid2_7 = "2a4e"; + char *desc_uuid1_1 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_3 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_4_1 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_4_2 = "2908"; /* Report Reference */ + char *desc_uuid2_5_1 = "2908"; /* Report Reference */ + char *desc_uuid2_5_2 = "2901"; /* Characteristic User Description */ + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; + + char char_value[1] = {80}; /* 80% */ + char char_value_unknown[4] = {10, 20, 30, 40}; + char desc_value_configration[2] = {0, 0}; /* Notification & Indication */ + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + /* Battery Service */ + ret = bt_gatt_service_create(service_uuid1, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service1); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1, permissions, + properties, char_value, + 1, &characteristic1_1); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_1); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_1, permissions, + desc_value_configration, 2, &descriptor1_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_1, descriptor1_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service1); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + /* HID Service */ + ret = bt_gatt_service_create(service_uuid2, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service2); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_1, permissions, + properties, char_value_unknown, + 4, &characteristic2_1); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_1); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_2, permissions, + properties, char_value_unknown, + 4, &characteristic2_2); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_2); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_3, permissions, + properties, char_value_unknown, + 4, &characteristic2_3); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_3); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_3, permissions, + desc_value_configration, 2, &descriptor2_3); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_3, descriptor2_3); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_4, permissions, + properties, char_value_unknown, + 4, &characteristic2_4); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_4); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_4_1, permissions, + desc_value_configration, 2, &descriptor2_4_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_4_2, permissions, + desc_value_configration, 2, &descriptor2_4_2); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_2); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_5, permissions, + properties, char_value_unknown, + 4, &characteristic2_5); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_5); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_5_1, permissions, + desc_value_configration, 2, &descriptor2_5_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_5_2, permissions, + desc_value_configration, 2, &descriptor2_5_2); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_2); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_6, permissions, + properties, char_value_unknown, + 4, &characteristic2_6); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_6); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_7, permissions, + properties, char_value_unknown, + 4, &characteristic2_7); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_7); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service2); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + /* Generic Attribute Service */ + ret = bt_gatt_service_create(service_uuid3, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service3); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service3); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC: { + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *service_uuid = "000018f2-0000-1000-8000-00805f9b34fb"; + char *char_uuid = "00002af6-0000-1000-8000-00805f9b34fb"; + char *desc_uuid = "2902"; // CCCD + char char_value[4] = {10, 20, 30, 40}; + char desc_value[2] = {0, 0}; // Notification disabled + int value_length = 4; + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties = BT_GATT_PROPERTY_BROADCAST | BT_GATT_PROPERTY_READ | + BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_NOTIFY; + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + /* Read & Write & Notify characteristics UUID */ + ret = bt_gatt_characteristic_create(char_uuid, permissions, + properties, char_value, + value_length, &characteristic); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, + __bt_gatt_server_read_value_requested_cb, NULL); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, + __bt_gatt_server_write_value_requested_cb, NULL); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, + __bt_gatt_server_notification_state_change_cb, NULL); + + ret = bt_gatt_service_add_characteristic(service, characteristic); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + /* CCCD for Notify characteristics */ + ret = bt_gatt_descriptor_create(desc_uuid, permissions, + desc_value, value_length, &descriptor); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + custom_h.svc = service; + custom_h.chr = characteristic; + custom_h.desc = descriptor; + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL: { + char char_value[4] = {50, 60, 70, 80}; + if (!server) { + TC_PRT("bt gatt server is not created"); + break; + } + ret = bt_gatt_set_value(custom_h.chr, char_value, 4); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + /* notify only client remote_addr */ + ret = bt_gatt_server_notify_characteristic_changed_value(custom_h.chr, + __bt_gatt_server_notification_sent_cb, remote_addr, NULL); + TC_PRT("bt_gatt_server_notify_characteristic_changed_value : %s\n", + __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_START_SERVER: { + ret = bt_gatt_server_start(); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID: { + char *name = NULL; + char *uuid = "0000180F-0000-1000-8000-00805F9B34FB"; + ret = bt_gatt_get_uuid_specification_name(uuid, &name); + TC_PRT("bt_gatt_get_uuid_specification_name : %s\n", __bt_get_error_message(ret)); + if (BT_ERROR_NONE == ret) { + TC_PRT("UUID [%s] Specification Name [%s]", uuid, name); + free(name); + } + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES: { +#ifdef ARCH64 + ret = bt_gatt_server_foreach_services(server, + __bt_gatt_server_foreach_svc_cb, (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_server_foreach_services(server, + __bt_gatt_server_foreach_svc_cb, (void *)test_id); +#endif + TC_PRT("bt_gatt_server_foreach_services: %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU: { + unsigned int mtu = 0; + ret = bt_gatt_server_get_device_mtu(remote_addr, &mtu); + TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu); + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_PAIR: { + bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE; + + if (g_test_param.param_count > 0) { + link_type = atoi(g_test_param.params[0]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_device_create_bond_by_type(remote_addr, link_type); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_WATCH: { + bt_gatt_h ancs_svc = NULL; + bt_gatt_h noti_source = NULL;; + char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; + char *chr_uuid = "9FBF120D-6301-42D9-8C58-25E699A21DBD"; + + ret = bt_gatt_client_get_service(client, svc_uuid, &ancs_svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(ancs_svc, + chr_uuid, ¬i_source); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(noti_source, + __bt_gatt_client_value_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: { + char value[6]; + char *noti_id = NULL; + int id; + + if (g_test_param.param_count == 0) { + TC_PRT("Input parameters first"); + break; + } + + noti_id = g_test_param.params[0]; + id = atoi(noti_id); + + value[0] = 0x02; + memcpy(&value[1], &id, sizeof(int)); + value[5] = 0x00; + + __ancs_write_value_to_control_point(client, + value, sizeof(value)); + + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: { + char value[6]; + char *noti_id = NULL; + int id; + + if (g_test_param.param_count == 0) { + TC_PRT("Input parameters first"); + break; + } + + noti_id = g_test_param.params[0]; + id = atoi(noti_id); + + value[0] = 0x02; + memcpy(&value[1], &id, sizeof(int)); + value[5] = 0x01; + + __ancs_write_value_to_control_point(client, + value, sizeof(value)); + + break; + } + case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: { + bt_gatt_h ancs_svc = NULL; + bt_gatt_h data_source = NULL;; + char *svc_uuid = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; + char *chr_uuid = "22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB"; + + char value[19]; + char *noti_id = NULL; + int id; + + if (g_test_param.param_count == 0) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_gatt_client_get_service(client, + svc_uuid, &ancs_svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(ancs_svc, + chr_uuid, &data_source); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(data_source, + __bt_gatt_client_value_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); + + noti_id = g_test_param.params[0]; + id = atoi(noti_id); + + value[0] = 0x00; + memcpy(&value[1], &id, sizeof(int)); + value[5] = 0x00; + value[6] = 0x01; + value[7] = 0xff; + value[8] = 0x00; + value[9] = 0x02; + value[10] = 0xff; + value[11] = 0x00; + value[12] = 0x03; + value[13] = 0xff; + value[14] = 0x00; + value[15] = 0x04; + value[16] = 0x05; + value[17] = 0x06; + value[18] = 0x07; + + __ancs_write_value_to_control_point(client, + value, sizeof(value)); + + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS: { + int available = 0; + ret = bt_gatt_get_data_batching_available_packets(&available); + TC_PRT("returns %s, (available:%d)\n", __bt_get_error_message(ret), available); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING: { + int packet_threshold = 30; + int timeout = 20; + + if (g_test_param.param_count > 0) { + packet_threshold = atoi(g_test_param.params[0]); + timeout = atoi(g_test_param.params[1]); + + __bt_free_test_param(&g_test_param); + } + + ret = bt_gatt_enable_data_batching(remote_addr, packet_threshold, timeout); + TC_PRT("returns %s, (packet_threshold:%d, timeout:%d)\n", __bt_get_error_message(ret), packet_threshold, timeout); + break; + } + case BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING: { + ret = bt_gatt_disable_data_batching(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_HPS: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: { + bool auto_connect = false; + + if (g_test_param.param_count > 0) { + if (g_strrstr(g_test_param.params[0], "true")) + auto_connect = true; + else + auto_connect = false; + + __bt_free_test_param(&g_test_param); + } + + ret = bt_gatt_connect(remote_addr, auto_connect); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_gatt_set_connection_state_changed_cb( + __bt_hps_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY: { + if (!hps_client) + break; + + ret = bt_gatt_client_destroy(hps_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + hps_client = NULL; + ret = bt_gatt_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL: { +#ifdef ARCH64 + ret = bt_gatt_client_foreach_services(hps_client, + __bt_hps_client_svc_cb, (void *)(uintptr_t)test_id); +#else + ret = bt_gatt_client_foreach_services(hps_client, + __bt_hps_client_svc_cb, (void *)test_id); +#endif + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *uri = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + uri = g_test_param.params[0]; + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_URI_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", uri, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *hdr = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + hdr = g_test_param.params[0]; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_HDR_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", hdr, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *entity = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + entity = g_test_param.params[0]; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_ENTITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", + entity, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, + __bt_HP_client_cp_req_status_changed_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_CP_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("uint8", + g_test_param.params[0], chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + + __bt_free_test_param(&g_test_param); + break; + } + + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_URI_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + break; + } + + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_HDR_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_ENTITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_SECURITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_STATUS_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, + __bt_gatt_client_value_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, + HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, + HTTP_STATUS_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + + case BT_UNIT_TEST_TABLE_AVRCP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE: + ret = bt_avrcp_target_initialize( + __bt_avrcp_target_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE: + ret = bt_avrcp_target_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB: + ret = bt_avrcp_set_equalizer_state_changed_cb( + __bt_avrcp_equalizer_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB: + ret = bt_avrcp_set_repeat_mode_changed_cb( + __bt_avrcp_repeat_mode_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB: + ret = bt_avrcp_set_shuffle_mode_changed_cb( + __bt_avrcp_shuffle_mode_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB: + ret = bt_avrcp_set_scan_mode_changed_cb( + __bt_avrcp_scan_mode_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB: + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB: + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB: + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB: + ret = bt_avrcp_unset_scan_mode_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE: + ret = bt_avrcp_control_initialize( + __bt_avrcp_control_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE: + ret = bt_avrcp_control_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT: + ret = bt_avrcp_control_connect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT: + ret = bt_avrcp_control_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_STOP); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PAUSE); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_FAST_FORWARD); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_REWIND); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT: + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_NEXT); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV: { + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PREVIOUS); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME: { + static unsigned int volume_level = 1; + ret = bt_avrcp_control_set_absolute_volume(volume_level++); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP: { + ret = bt_avrcp_control_increase_volume(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN: { + ret = bt_avrcp_control_decrease_volume(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SEND_DELAY_REPORT: { + static unsigned int delay_level = 1; + ret = bt_avrcp_control_send_delay_report(delay_level++); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT: { + bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_GROUP; + ret = bt_avrcp_control_get_repeat_mode(&mode); + TC_PRT("Repet mode : %d returns %s\n", mode, + __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT: { + ret = bt_avrcp_control_set_repeat_mode(2); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE: { + bt_avrcp_shuffle_mode_e mode = BT_AVRCP_SHUFFLE_MODE_ALL_TRACK; + ret = bt_avrcp_control_get_shuffle_mode(&mode); + TC_PRT("Shuffle mode %d returns %s\n", mode, __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE: { + ret = bt_avrcp_control_set_shuffle_mode(1); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION: { + unsigned int position = 0; + ret = bt_avrcp_control_get_position(&position); + TC_PRT("position %d returns %s\n", position, __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS: { + unsigned int status = 0; + ret = bt_avrcp_control_get_play_status(&status); + TC_PRT("status %d returns %s\n", status, __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO: { + bt_avrcp_metadata_attributes_info_s *track; + ret = bt_avrcp_control_get_track_info(&track); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) { + TC_PRT("Title. %s\n", track->title); + TC_PRT("Artist %s\n", track->artist); + TC_PRT("Album %s\n", track->album); + TC_PRT("Genre %s\n", track->genre); + TC_PRT("Total tracks %d\n", track->total_tracks); + TC_PRT("Number %d\n", track->number); + TC_PRT("Duration %d\n", track->duration); + bt_avrcp_control_free_track_info(track); + } + break; + } + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB: + ret = bt_avrcp_set_position_changed_cb( + __bt_avrcp_song_position_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB: + ret = bt_avrcp_set_play_status_changed_cb( + __bt_avrcp_player_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB: + ret = bt_avrcp_set_track_info_changed_cb( + __bt_avrcp_track_info_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB: + ret = bt_avrcp_unset_position_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB: + ret = bt_avrcp_unset_play_status_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB: + ret = bt_avrcp_unset_track_info_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_HID: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE: + ret = bt_hid_host_initialize( + __bt_hid_host_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE: + ret = bt_hid_host_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT: { + ret = bt_hid_host_connect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT: { + ret = bt_hid_host_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE: { + ret = bt_hid_device_activate( + __bt_hid_device_connection_state_changed_cb, + NULL); + TC_PRT("returns %s", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT: { + ret = bt_hid_device_connect(remote_addr); + TC_PRT("returns %s", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE: { + ret = bt_hid_device_deactivate(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT: { + ret = bt_hid_device_disconnect(remote_addr); + TC_PRT("return %s", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT: { + bt_hid_mouse_data_s send_data; + int i; + + send_data.buttons = 1; + send_data.padding = BT_HID_MOUSE_BUTTON_LEFT; + + send_data.axis_x = 10; + send_data.axis_y = 0; + for (i = 0; i < 30; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = 0; + send_data.axis_y = 10; + for (i = 0; i < 30; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = -10; + send_data.axis_y = 0; + for (i = 0; i < 60; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = 0; + send_data.axis_y = -10; + for (i = 0; i < 60; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = 10; + send_data.axis_y = 0; + for (i = 0; i < 60; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = 0; + send_data.axis_y = 10; + for (i = 0; i < 30; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + send_data.axis_x = -10; + send_data.axis_y = 0; + for (i = 0; i < 30; i++) { + usleep(30000); + ret = bt_hid_device_send_mouse_event( + remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + } + TC_PRT("Completed"); + + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL: { + bt_hid_mouse_data_s send_data; + + send_data.buttons = BT_HID_MOUSE_BUTTON_NONE; + send_data.padding = 0x01; + + send_data.axis_x = 0; + send_data.axis_y = 0; + TC_PRT("Scroll UP"); + ret = bt_hid_device_send_mouse_event(remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL_DOWN: { + bt_hid_mouse_data_s send_data; + send_data.buttons = BT_HID_MOUSE_BUTTON_NONE; + send_data.padding = 0xff; + send_data.axis_x = 0; + send_data.axis_y = 0; + TC_PRT("Scroll Down"); + ret = bt_hid_device_send_mouse_event(remote_addr, &send_data); + if (ret < 0) + TC_PRT("returns %d\n", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT: { + bt_hid_key_data_s send_data; + /* Will send character 'a' */ + char pressedkey[8] = { 4, 0, 0, 0, 0, 0, 0, 0 }; + char pressedkey1[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + ret = bt_hid_device_send_key_event( + remote_addr, &send_data); + TC_PRT("returns %d\n", ret); + memcpy(send_data.key, pressedkey1, 8); + ret = bt_hid_device_send_key_event( + remote_addr, &send_data); + TC_PRT("returns %d\n", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: { + unsigned char report_id = 0xF7; + char pressed_data[6] = {0x07, 0x00, 0x00, 0x00, 0x00, 0x00}; + char released_data[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static int mode = 1; + + if (g_test_param.param_count > 0) { + mode = atoi(g_test_param.params[0]); + __bt_free_test_param(&g_test_param); + } + + if (mode == 1) + pressed_data[0] = 0x07; /* Vol up */ + else if (mode == 2) + pressed_data[0] = 0x0B; /* Vol down */ + else if (mode == 3) + pressed_data[0] = 0x12; /* CH up */ + else if (mode == 4) + pressed_data[0] = 0x10; /* CH down */ + + ret = bt_hid_device_send_custom_event(remote_addr, + report_id, pressed_data, 6); + TC_PRT("returns %d\n", ret); + + ret = bt_hid_device_send_custom_event(remote_addr, + report_id, released_data, 6); + TC_PRT("returns %d\n", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB: { + ret = bt_hid_device_set_data_received_cb( + __bt_hid_device_data_received_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB: { + ret = bt_hid_device_unset_data_received_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_IPSP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_IPSP_REGISTER: { + bt_gatt_h service = NULL; + char *service_uuid = "1820"; /* IPSP Service */ + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + ipsp_h.svc = service; + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER: + if (server != NULL && ipsp_h.svc != NULL) { + ret = bt_gatt_server_unregister_service(server, + ipsp_h.svc); + TC_PRT("bt_gatt_server_unregister_service : returns %s\n", + __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + ipsp_h.svc = NULL; + } else { + TC_PRT("Gatt Server or IPSP not registered !"); + } + break; + case BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE: + /* Initialize IPSP server */ + if (server != NULL && ipsp_h.svc != NULL) { + ret = bt_ipsp_initialize( + &__bt_ipsp_init_state_changed_cb, + NULL); + TC_PRT("bt_le_ipsp_initialize : returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("Gatt Server or IPSP not registered !"); + } + break; + case BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE: + /* De-Initialize IPSP server */ + ret = bt_ipsp_deinitialize(); + TC_PRT("bt_le_ipsp_deinitialize : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT: + ret = bt_ipsp_connect(remote_addr); + TC_PRT("returns %s", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT: + ret = bt_ipsp_disconnect(remote_addr); + TC_PRT("returns %s", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING: { + const char *ipsp_svc_uuid_16 = "1820"; + + /* Add IPSP service in advertising data */ + advertiser = advertiser_list[advertiser_index]; + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + if (ret != BT_ERROR_NONE) { + TC_PRT("created le advertiser(%d)", ret); + break; + } + + advertiser_list[advertiser_index] = advertiser; + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) { + TC_PRT("set device name [0x%04x]", ret); + break; + } + } + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, ipsp_svc_uuid_16); + if (ret != BT_ERROR_NONE) { + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + break; + } + + /* Start advertising IPSP service */ + bt_adapter_le_advertising_state_changed_cb cb; + + if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; + else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; + else cb = __bt_adapter_le_advertising_state_changed_cb_3; + + advertiser = advertiser_list[advertiser_index]; + + advertiser_index++; + advertiser_index %= 3; + + TC_PRT("advertiser: %p", advertiser); + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB: + ret = bt_ipsp_set_connection_state_changed_cb( + __bt_ipsp_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB: + ret = bt_ipsp_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET: { + int serverSocket = 0; + struct ifaddrs *ifap, *ifa; + struct sockaddr_in6 serverAddr, clientAddr; + socklen_t clilen; + char host[NI_MAXHOST]; + char client_ipv6[100] = {0, }; + char *addr = NULL; + + TC_PRT("\n****** IPSP Application Server Started ******\n"); + + getifaddrs(&ifap); + + for (ifa = ifap; ifa; ifa = ifa->ifa_next) { + if (ifa->ifa_addr->sa_family == AF_INET6) { + if (!memcmp(ifa->ifa_name, ipsp_iface_name, IFNAMSIZ)) { + getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), host, NI_MAXHOST, + NULL, 0, NI_NUMERICHOST); + TC_PRT("[IPV6]Host : %s \n", host); + addr = strchr(host, '%'); + if (addr != NULL) { + addr = g_strndup(host, (addr - host)); + TC_PRT("Found match Interface: %s and addr : %s\n", ifa->ifa_name, addr); + } + } + } + } + + freeifaddrs(ifap); + + if (addr != NULL) { + bzero((char *) &serverAddr, sizeof(serverAddr)); + + serverAddr.sin6_flowinfo = 0; + serverAddr.sin6_family = AF_INET6; + serverAddr.sin6_addr = in6addr_any; + serverAddr.sin6_port = htons(IPSP_PORT); + serverAddr.sin6_scope_id = if_nametoindex(ipsp_iface_name); + inet_pton(AF_INET6, addr, &(serverAddr.sin6_addr.s6_addr)); + + g_free(addr); + + /* Create the IPSP APP server socket */ + serverSocket = socket(AF_INET6, SOCK_STREAM, 0); + if (serverSocket < 0) { + TC_PRT("\nIPSP server Error : In socket creation !"); + break; + } + else + TC_PRT("\nIPSP Server : Socket created.."); + + + /* Bind the address struct to the socket */ + if (bind(serverSocket, (struct sockaddr *) &serverAddr, sizeof(serverAddr)) < 0) { + TC_PRT("\nIPSP server Error : In socket binding !"); + close(serverSocket); + break; + } + else + TC_PRT("\nIPSP Server : Socket binding done.."); + + + /* Listen on the socket, with 1 max connection requests queued */ + if (listen(serverSocket, 1) < 0) { + TC_PRT("\nIPSP server Error : In socket listening !"); + close(serverSocket); + break; + } + else + TC_PRT("\nIPSP server : Socket listening, waiting for connection...\n"); + + /* Accept call creates a new socket for the incoming connection */ + clilen = sizeof(clientAddr); + ipsp_server_sock = accept(serverSocket, (struct sockaddr *) &clientAddr, &clilen); + if (ipsp_server_sock < 0) { + TC_PRT("\nIPSP server Error : While accepting incoming connection !"); + close(serverSocket); + break; + } + + inet_ntop(AF_INET6, &(clientAddr.sin6_addr), client_ipv6, 100); + TC_PRT("\n****** IPSP server : Incoming connection from client... %s successful, ready to send/receive IPV6 data ******", client_ipv6); + + close(serverSocket); + } else { + TC_PRT("Matching Address is Not Found , Wait till the Connected Event is recieved from STACK"); + } + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: { + char *saddr = NULL; + struct sockaddr_in6 serverAddr; + struct hostent *server; + + if (g_test_param.param_count < 1) { + TC_PRT("Input IPSP Application's server IPv6 address first !"); + break; + } + saddr = g_test_param.params[0]; + + TC_PRT("\n****** IPSP Application Client Started ******\n"); + + /* Create the IPSP APP Client socket */ + ipsp_client_sock = socket(AF_INET6, SOCK_STREAM, 0); + if (ipsp_client_sock < 0) + TC_PRT("\nIPSP Client Error : In socket creation !"); + else + TC_PRT("\nIPSP Client : Socket created.."); + + /* Sockets Layer Call: gethostbyname2() */ + server = gethostbyname2(saddr, AF_INET6); + + if (server == NULL) + TC_PRT("\nIPSP Client Error : No such host !"); + else { + + TC_PRT("\nIPSP Client GetHostbyName Success!"); + memset((char *) &serverAddr, 0, sizeof(serverAddr)); + serverAddr.sin6_flowinfo = 0; + serverAddr.sin6_family = AF_INET6; + serverAddr.sin6_addr = in6addr_any; + serverAddr.sin6_port = htons(IPSP_PORT); + serverAddr.sin6_scope_id = if_nametoindex(ipsp_iface_name); + + memmove((char *) &serverAddr.sin6_addr.s6_addr, (char *) server->h_addr, server->h_length); + + TC_PRT("\nIPSP Client Attempt To Connect to server %s!", serverAddr.sin6_addr.s6_addr); + /* Connect with IPSP APP Server socket */ + if (connect(ipsp_client_sock, (struct sockaddr *) &serverAddr, sizeof(serverAddr)) < 0) + TC_PRT("\nIPSP Client Error : %d while connecting with server !", errno); + else + TC_PRT("\n****** IPSP Client : Connection with : %s successful, ready to send/receive IPV6 data ******\n", saddr); + + __bt_free_test_param(&g_test_param); + } + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA: { + int role = -1, n = 0; + char *param_data = NULL; + + if (g_test_param.param_count < 2) { + TC_PRT("IPSP Error : Input IPSP Application's role and data to send first !"); + break; + } + + role = atoi(g_test_param.params[0]); + param_data = g_test_param.params[1]; + + if (role == 0) { + if (ipsp_server_sock) { + TC_PRT("IPSP : Current role is IPSP Sever !"); + + /* Sockets Layer Call: send() */ + n = send(ipsp_server_sock, param_data, strlen(param_data) + 1, 0); + if (n < 0) + TC_PRT("\nIPSP Error : While sending data !"); + } else { + TC_PRT("IPSP Error: There is no connected server socket !"); + } + } else if (role == 1) { + if (ipsp_client_sock) { + /* Sockets Layer Call: send() */ + n = send(ipsp_client_sock, param_data, strlen(param_data) + 1, 0); + if (n < 0) + TC_PRT("\nIPSP Error : While sending data !"); + } else { + TC_PRT("IPSP Error: There is no connected client socket !"); + } + } else { + TC_PRT("IPSP Error: Please input the proper role !"); + } + __bt_free_test_param(&g_test_param); + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: { + int role = -1, n; + char buffer[256] = {0}; + + if (g_test_param.param_count < 1) { + TC_PRT("IPSP Error : Input IPSP Application's role first !"); + break; + } + + role = atoi(g_test_param.params[0]); + + if (role == 0) { + if (ipsp_server_sock) { + TC_PRT("IPSP : Current role is IPSP Sever, ready to receive data !"); + + /* Sockets Layer Call: recv() */ + n = recv(ipsp_server_sock, buffer, 255, 0); + if (n < 0) + TC_PRT("\nIPSP Server Error : While receiving data from client !"); + + TC_PRT("\nIPSP Server : Message received from client: %s\n", buffer); + } else { + TC_PRT("IPSP Error: There is no connected or active server socket !"); + } + } else if (role == 1) { + if (ipsp_client_sock) { + TC_PRT("IPSP : Current role is IPSP Client, ready to receive data !"); + + /* Sockets Layer Call: recv() */ + n = recv(ipsp_client_sock, buffer, 255, 0); + if (n < 0) + TC_PRT("\nIPSP Client Error : %d while receiving data from server!", errno); + + TC_PRT("\nIPSP Client : Message received from server: %s\n", buffer); + } else { + TC_PRT("IPSP Error: There is no connected or active client socket !"); + } + } else { + TC_PRT("IPSP Error: Please input the proper role !"); + } + + __bt_free_test_param(&g_test_param); + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET: { + if (ipsp_server_sock) { + TC_PRT("IPSP server : Closing server socket.."); + close(ipsp_server_sock); + ipsp_server_sock = 0; + } + + if (ipsp_client_sock) { + TC_PRT("IPSP Client : Closing client socket.."); + close(ipsp_client_sock); + ipsp_client_sock = 0; + } + + break; + } + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_HDP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP: + ret = bt_hdp_register_sink_app(0x1007, &appid); + TC_PRT("bt_hdp_register_sink_app : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP: + ret = bt_hdp_unregister_sink_app(appid); + TC_PRT("bt_hdp_unregister_sink_app : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE: + ret = bt_hdp_connect_to_source(remote_addr, + appid); + TC_PRT("bt_hdp_connect_to_source : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT: + ret = bt_hdp_disconnect(remote_addr, + channel_hdp); + TC_PRT("bt_hdp_disconnect : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA: + ret = bt_hdp_send_data(channel_hdp, + data_hdp, strlen(data_hdp)); + TC_PRT("bt_hdp_send_data : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB: + ret = bt_hdp_set_connection_state_changed_cb( + __bt_hdp_connected_cb, + __bt_hdp_disconnected_cb, NULL); + TC_PRT("bt_hdp_set_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB: + ret = bt_hdp_unset_connection_state_changed_cb(); + TC_PRT("bt_hdp_unset_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB: + ret = bt_hdp_set_data_received_cb( + __bt_hdp_data_received_cb, + NULL); + TC_PRT("bt_hdp_set_data_received_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB: + ret = bt_hdp_unset_data_received_cb(); + TC_PRT("bt_hdp_unset_data_received_cb : returns %s\n", __bt_get_error_message(ret)); + break; + default: + break; + } + break; + } + case BT_UNIT_TEST_TABLE_DPM: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES: { + const char *hfp_uuid = "0000111f-0000-1000-8000-00805f9b34fb"; + const char *hsp_uuid = "00001112-0000-1000-8000-00805f9b34fb"; + const char *a2dp_uuid = "0000110D-0000-1000-8000-00805F9B34FB"; + const char *avrcp_target_uuid = "0000110c-0000-1000-8000-00805f9b34fb"; + + ret = bt_dpm_set_allow_bluetooth_mode(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_allow_bluetooth_mode : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_activate_device_restriction(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_activate_device_restriction : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_activate_uuid_restriction(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_activate_uuid_restriction : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_allow_outgoing_call(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_allow_outgoing_call : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_pairing_state(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_pairing_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_profile_state(BT_DPM_POLICY_HFP_PROFILE_STATE, + BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_profile_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_desktop_connectivity_state(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_desktop_connectivity_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_discoverable_state(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_discoverable_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_limited_discoverable_state(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_limited_discoverable_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_set_data_transfer_state(BT_DPM_BT_ALLOWED); + + TC_PRT("bt_dpm_set_data_transfer_state : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(spp_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(opp_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(hid_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(hfp_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(hsp_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(a2dp_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + ret = bt_dpm_add_uuids_to_whitelist(avrcp_target_uuid); + + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + ret = bt_dpm_set_allow_bluetooth_mode(value); + + TC_PRT("bt_dpm_set_allow_bluetooth_mode : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE: { + bt_dpm_allow_e value = BT_DPM_ERROR; + ret = bt_dpm_get_allow_bluetooth_mode(&value); + TC_PRT("bt_dpm_get_allow_bluetooth_mode : allow: %d, returns %s\n", + value , __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_activate_device_restriction(value); + TC_PRT("bt_dpm_activate_device_restriction : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_is_device_restriction_active(&value); + TC_PRT("bt_dpm_is_device_restriction_active : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_activate_uuid_restriction(value); + TC_PRT("bt_dpm_activate_uuid_restriction : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_is_uuid_restriction_active(&value); + TC_PRT("bt_dpm_is_uuid_restriction_active : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_add_devices_to_blacklist(g_test_param.params[0]); + TC_PRT("bt_dpm_add_devices_to_blacklist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_add_devices_to_whitelist(g_test_param.params[0]); + TC_PRT("bt_dpm_add_devices_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_add_uuids_to_blacklist(g_test_param.params[0]); + TC_PRT("bt_dpm_add_uuids_to_blacklist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_add_uuids_to_whitelist(g_test_param.params[0]); + TC_PRT("bt_dpm_add_uuids_to_whitelist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST: { + bt_dpm_device_list_s *device_list = NULL; + int i = 0; + char *str = NULL; + ret = bt_dpm_get_devices_from_blacklist(&device_list); + TC_PRT("bt_dpm_get_devices_from_blacklist : returns %s\n", + __bt_get_error_message(ret)); + if (device_list) { + TC_PRT("list len %d", device_list->count); + for (i = 0; i < device_list->count; i++) { + str = g_strdup((const gchar*)device_list->devices[i]); + TC_PRT("%d: %s\n", i, str); + g_free(str); + free(device_list->devices[i]); + } + free(device_list); + } + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST: { + bt_dpm_device_list_s *device_list = NULL; + int i = 0; + char *str = NULL; + ret = bt_dpm_get_devices_from_whitelist(&device_list); + TC_PRT("bt_dpm_get_devices_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + if (device_list) { + TC_PRT("list len %d", device_list->count); + for (i = 0; i < device_list->count; i++) { + str = g_strdup((const gchar*)device_list->devices[i]); + TC_PRT("%d: %s\n", i, str); + g_free(str); + free(device_list->devices[i]); + } + free(device_list); + } + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST: { + bt_dpm_uuids_list_s *uuids_list = NULL; + int i = 0; + char *str = NULL; + ret = bt_dpm_get_uuids_from_blacklist(&uuids_list); + TC_PRT("bt_dpm_get_uuids_from_blacklist : returns %s\n", + __bt_get_error_message(ret)); + + if (uuids_list) { + TC_PRT("list len %d", uuids_list->count); + for (i = 0; i < uuids_list->count; i++) { + str = g_strdup(uuids_list->uuids[i]); + TC_PRT("%d: %s\n", i, str); + g_free(str); + free(uuids_list->uuids[i]); + } + free(uuids_list); + } + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST: { + bt_dpm_uuids_list_s *uuids_list = NULL; + int i = 0; + char *str = NULL; + ret = bt_dpm_get_uuids_from_whitelist(&uuids_list); + TC_PRT("bt_dpm_get_uuids_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + + if (uuids_list) { + TC_PRT("list len %d", uuids_list->count); + for (i = 0; i < uuids_list->count; i++) { + str = g_strdup(uuids_list->uuids[i]); + TC_PRT("%d: %s\n", i, str); + g_free(str); + free(uuids_list->uuids[i]); + } + free(uuids_list); + } + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST: + ret = bt_dpm_clear_devices_from_blacklist(); + TC_PRT("bt_dpm_clear_devices_from_blacklist : returns %s\n", + __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST: + ret = bt_dpm_clear_devices_from_whitelist(); + TC_PRT("bt_dpm_clear_devices_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST: + ret = bt_dpm_clear_uuids_from_blacklist(); + TC_PRT("bt_dpm_clear_uuids_from_blacklist : returns %s\n", + __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST: + ret = bt_dpm_clear_uuids_from_whitelist(); + TC_PRT("bt_dpm_clear_uuids_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_remove_device_from_blacklist(g_test_param.params[0]); + TC_PRT("bt_dpm_add_devices_to_blacklist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_remove_device_from_whitelist(g_test_param.params[0]); + TC_PRT("bt_dpm_remove_device_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_remove_uuid_from_blacklist(g_test_param.params[0]); + TC_PRT("bt_dpm_remove_device_from_blacklist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_dpm_remove_uuid_from_whitelist(g_test_param.params[0]); + TC_PRT("bt_dpm_remove_uuid_from_whitelist : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_set_allow_outgoing_call(value); + TC_PRT("bt_dpm_set_allow_outgoing_call : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_allow_outgoing_call(&value); + TC_PRT("bt_dpm_get_allow_outgoing_call : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_set_pairing_state(value); + TC_PRT("bt_dpm_set_pairing_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_pairing_state(&value); + TC_PRT("bt_dpm_get_pairing_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: { + int profile, value; + if (g_test_param.param_count < 2) { + TC_PRT("Input parameters first"); + break; + } + profile = atoi(g_test_param.params[0]); + value = atoi(g_test_param.params[1]); + + ret = bt_dpm_set_profile_state(profile, value); + TC_PRT("bt_dpm_set_profile_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + int profile; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + profile = atoi(g_test_param.params[0]); + + ret = bt_dpm_get_profile_state(profile, &value); + TC_PRT("bt_dpm_get_profile_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_set_desktop_connectivity_state(value); + TC_PRT("bt_dpm_set_desktop_connectivity_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_desktop_connectivity_state(&value); + TC_PRT("bt_dpm_get_desktop_connectivity_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + ret = bt_dpm_set_discoverable_state(value); + TC_PRT("bt_dpm_set_discoverable_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_discoverable_state(&value); + TC_PRT("bt_dpm_get_discoverable_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_set_limited_discoverable_state(value); + TC_PRT("bt_dpm_set_limited_discoverable_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_limited_discoverable_state(&value); + TC_PRT("bt_dpm_get_limited_discoverable_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: { + int value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + value = atoi(g_test_param.params[0]); + + ret = bt_dpm_set_data_transfer_state(value); + TC_PRT("bt_dpm_set_data_transfer_state : returns %s\n", + __bt_get_error_message(ret)); + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE: { + bt_dpm_status_e value = BT_DPM_STATUS_ERROR; + ret = bt_dpm_get_data_transfer_state(&value); + TC_PRT("bt_dpm_get_data_transfer_state : allow: %d, returns %s\n", + value, __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_PXP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER: { + if (reporter) { + ret = bt_proximity_reporter_destroy(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_reporter_unset_property_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + reporter = NULL; + } + ret = bt_proximity_reporter_create(&reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER: { + ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_reporter_unset_property_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + + ret = bt_proximity_reporter_destroy(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + reporter = NULL; + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE: { + if (monitor) { + ret = bt_proximity_monitor_disconnect(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_monitor_destroy(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + monitor = NULL; + } + ret = bt_proximity_monitor_create(remote_addr, &monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY: { + ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_proximity_monitor_destroy(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + monitor = NULL; + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: { + ret = bt_proximity_monitor_connect(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: { + ret = bt_proximity_monitor_disconnect(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_proximity_monitor_set_connection_state_changed_cb(monitor, + __bt_proximity_monitor_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_proximity_reporter_set_connection_state_changed_cb(reporter, + __bt_proximity_reporter_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB: { + ret = bt_proximity_reporter_set_property_changed_cb(reporter, + __bt_proximity_reporter_property_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB: { + ret = bt_proximity_reporter_unset_property_changed_cb(reporter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID: { + if (pxp_scan_filter) { + ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + pxp_scan_filter = NULL; + } + ret = bt_adapter_le_scan_filter_create(&pxp_scan_filter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_le_scan_filter_set_type(pxp_scan_filter, + BT_ADAPTER_LE_SCAN_FILTER_TYPE_PROXIMITY_UUID); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_le_scan_filter_register(pxp_scan_filter); + if (ret != BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID: { + ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_le_scan_filter_destroy(pxp_scan_filter); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + pxp_scan_filter = NULL; + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING: { + /* Add Reporter service in advertising data */ + advertiser = advertiser_list[advertiser_index]; + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + if (ret != BT_ERROR_NONE) { + TC_PRT("created le advertiser(%d)", ret); + break; + } + + advertiser_list[advertiser_index] = advertiser; + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) { + TC_PRT("set device name [0x%04x]", ret); + break; + } + } + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_IMMEDIATE_ALERT_SVC_UUID); + if (ret != BT_ERROR_NONE) { + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + break; + } + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_LINK_LOSS_SVC_UUID); + if (ret != BT_ERROR_NONE) { + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + break; + } + + /* Start advertising PXP Reporter service */ + bt_adapter_le_advertising_state_changed_cb cb; + + if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; + else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; + else cb = __bt_adapter_le_advertising_state_changed_cb_3; + + advertiser = advertiser_list[advertiser_index]; + + advertiser_index++; + advertiser_index %= 3; + + TC_PRT("advertiser: %p", advertiser); + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: { + int alert_value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + alert_value = atoi(g_test_param.params[0]); + ret = bt_proximity_monitor_set_linkloss_alert(monitor, alert_value); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: { + int alert_value; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + alert_value = atoi(g_test_param.params[0]); + ret = bt_proximity_monitor_set_immediate_alert(monitor, alert_value); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT: { + int alert_level = 0; + ret = bt_proximity_monitor_get_linkloss_alert(monitor, &alert_level); + TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT: { + int alert_level = 0; + ret = bt_proximity_monitor_get_immediate_alert(monitor, &alert_level); + TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL: { + int alert_level = 0; + ret = bt_proximity_monitor_get_signal_level(monitor, &alert_level); + TC_PRT("returns %s, signal_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT: { + int alert_level = 0; + ret = bt_proximity_reporter_get_linkloss_alert(remote_addr, &alert_level); + TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT: { + int alert_level = 0; + ret = bt_proximity_reporter_get_immediate_alert(remote_addr, &alert_level); + TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_HF: { + if (!TIZEN_PROFILE_WEARABLE_IVI) + break; + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HF_INITIALIZE: + ret = bt_hf_initialize(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE: + ret = bt_hf_deinitialize(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER: + ret = bt_hf_notify_call_event( + BT_HF_CALL_EVENT_ANSWER, + "9663868998"); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN: + ret = bt_hf_notify_speaker_gain(10); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB: + ret = bt_hf_set_speaker_gain_changed_cb( + __bt_hf_speaker_gain_changed_cb, + NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB: + ret = bt_hf_unset_speaker_gain_changed_cb(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE: + ret = bt_hf_notify_voice_recognition_state(true); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM: + ret = bt_hf_notify_call_event( + BT_HF_CALL_EVENT_IDLE, + "9663868998"); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT: + ret = bt_hf_notify_call_event( + BT_HF_CALL_EVENT_DIAL, + "9663868998"); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE: + ret = bt_hf_notify_voice_recognition_state(false); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED: { + bool is_opened = false; + ret = bt_hf_is_sco_opened(&is_opened); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("Sco is opened [%s]", is_opened ? "YES" : "NO"); + break; + } + case BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID: { + unsigned int codec_id = 0; + ret = bt_hf_get_codec_id(&codec_id); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("Codec ID [%d]", codec_id); + break; + } + case BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST: { + GSList *list; + ret = bt_hf_get_call_status_info_list(&list); + + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else { + for (; list; list = g_slist_next(list)) { + bt_hf_call_status_info_s *call_info = list->data; + TC_PRT("Call info [No:%s, Dir:%d, Stat:%d, Mpt:%d, Idx:%d]", + call_info->number, call_info->direction, + call_info->status, call_info->multi_party, + call_info->index); + } + bt_hf_free_call_status_info_list(list); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST: { + ret = bt_hf_request_call_status_info_list(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB: + ret = bt_hf_set_sco_state_changed_cb( + __bt_hf_sco_state_changed_cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB: + ret = bt_hf_unset_sco_state_changed_cb(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB: + ret = bt_hf_set_call_handling_event_cb( + __bt_hf_set_call_handling_event_cb, + NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB: + ret = bt_hf_unset_call_handling_event_cb(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB: + ret = bt_hf_set_call_status_updated_event_cb( + __bt_hf_call_status_updated_event_cb, + NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB: + ret = bt_hf_unset_call_status_updated_event_cb(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_PBAP_CLIENT: { + if (!TIZEN_PROFILE_WEARABLE_IVI) + break; + switch (test_id) { + + /*PBAP Test Cases */ + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE: + ret = bt_pbap_client_initialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE: + ret = bt_pbap_client_deinitialize(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_pbap_client_set_connection_state_changed_cb(__bt_pbap_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB: { + ret = bt_pbap_client_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT: { + ret = bt_pbap_client_connect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT: { + ret = bt_pbap_client_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED: { + bool connected_status = false; + + ret = bt_pbap_client_is_connected(remote_addr, &connected_status); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + TC_PRT("PBAP Profile [%s]", + connected_status ? "Connected" : "Disconnected"); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE: { + ret = bt_pbap_client_get_phone_book_size(remote_addr, + 0, 0, + __bt_pbap_phonebook_size_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL: { + unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG | BT_PBAP_FIELD_X_IRMC_CALL_DATETIME; + + ret = bt_pbap_client_get_phone_book(remote_addr, + 0, 0, 0, 0, 0, 100, + fields, __bt_pbap_phonebook_pull_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST: { + ret = bt_pbap_client_get_list(remote_addr, + 0, 0, 0, 0, 100, + __bt_pbap_vcard_list_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL: { + long long unsigned fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL | BT_PBAP_FIELD_ORG; + ret = bt_pbap_client_pull_vcard(remote_addr, + 0, 0, 0, 0, fields, + __bt_pbap_phonebook_pull_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH: { + ret = bt_pbap_client_search_phone_book(remote_addr, + 0, 0, + 0, "ff", + 0, 0, 100, + __bt_pbap_vcard_list_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO: { + ret = bt_pbap_client_get_list(remote_addr, + 0, 0, 0, 0, 0, + __bt_pbap_vcard_list_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + case BT_UNIT_TEST_TABLE_TDS_PROVIDER: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER: { + ret = bt_tds_provider_register(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER: { + ret = bt_tds_provider_unregister(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + provider = NULL; + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB: { + ret = bt_tds_set_transport_activation_requested_cb(__tds_activation_req_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB: { + ret = bt_tds_unset_transport_activation_requested_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE: { + if (provider) { + ret = bt_tds_provider_destroy(provider); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + provider = NULL; + } + ret = bt_tds_provider_create(&provider, BT_TDS_TRANSPORT_CUSTOM); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY: { + ret = bt_tds_provider_destroy(provider); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + provider = NULL; + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA: { + unsigned char buf[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Mac */ + 0x20, 0xFA, /* Operating Channel */ + 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; /* Hash */ + + ret = bt_tds_provider_set_transport_data(provider, + BT_TDS_TRANSPORT_STATE_OFF, buf, sizeof(buf)); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA: { + unsigned char buf[] = {0x00, 0x75, 0x4E, 0x24, 0x36, 0x28, 0x01, 0x13}; + + ret = bt_tds_provider_set_manufacturer_data(buf, sizeof(buf)); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP: { + ret = bt_tds_provider_send_activation_resp( + tds_act_address, BLUETOOTH_ERROR_NONE, provider); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + default: + break; + } + break; + } + case BT_UNIT_TEST_TABLE_TDS_SEEKER: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER: { + ret = bt_tds_start_seeking_providers(__bt_tds_provider_scan_result_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER: { + ret = bt_tds_stop_seeking_providers(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE: { + if (seeker) + seeker = NULL; + ret = bt_tds_seeker_create(remote_addr, &seeker); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY: { + if (seeker) { + ret = bt_tds_seeker_destroy(seeker); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK: { + if (seeker) { + ret = bt_tds_seeker_set_connection_state_changed_cb(seeker, + __bt_tds_seeker_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT: { + if (seeker) { + ret = bt_tds_seeker_connect(seeker); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT: { + if (seeker) { + ret = bt_tds_seeker_disconnect(seeker); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK: { + if (seeker) { + ret = bt_tds_seeker_unset_connection_state_changed_cb(seeker); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA: { + if (seeker) { + ret = bt_tds_seeker_get_complete_transport_blocks(seeker, + __bt_tds_seeker_complete_transport_data_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT: { + if (seeker) { + unsigned char buf[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, /* Mac */ + 0x0A, 0x0B}; /* Channel Info */ + bt_tds_transport_e transport = BT_TDS_TRANSPORT_CUSTOM; + ret = bt_tds_seeker_activate_control_point(seeker, transport, buf, sizeof(buf), + __bt_tds_control_point_activation_result_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + default: + break; + } + break; + } + case BT_UNIT_TEST_TABLE_OTP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: { + char *directory = NULL; + + if (g_test_param.param_count < 1) + TC_PRT("No relative path set"); + else + directory = g_test_param.params[0]; + + TC_PRT("%s", directory); + + ret = bt_otp_server_initialize(directory); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + /* __bt_free_test_param(&g_test_param); */ + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT: { + ret = bt_otp_server_deinitialize(); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB: { + ret = bt_otp_set_server_state_changed_cb( + __bt_otp_server_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB: { + ret = bt_otp_unset_server_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE: { + if (otp_client) + otp_client = NULL; + ret = bt_otp_client_create(remote_addr, &otp_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY: { + if (otp_client) { + ret = bt_otp_client_destroy(otp_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK: { + if (otp_client) { + ret = bt_otp_client_set_connection_state_changed_cb(otp_client, + __bt_otp_client_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT: { + if (otp_client) { + ret = bt_otp_client_connect(otp_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT: { + if (otp_client) { + ret = bt_otp_client_disconnect(otp_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK: { + if (otp_client) { + ret = bt_otp_client_unset_connection_state_changed_cb(otp_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS: { + if (otp_client) { + ret = bt_otp_client_discover_all_objects(otp_client, + __bt_otp_client_object_discovery_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: { + if (otp_client) { + unsigned long long id; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + id = (unsigned long long)atoi(g_test_param.params[0]); + TC_PRT("Object ID[%llu]", id); + ret = bt_otp_client_select_object(otp_client, id, + __bt_otp_client_object_select_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS: { + if (otp_client) { + ret = bt_otp_client_read_object_contents(otp_client, + __bt_otp_client_read_object_complete_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: { + char *file_path = NULL; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + file_path = g_test_param.params[0]; + TC_PRT("%s", file_path); + + if (otp_client) { + ret = bt_otp_client_create_object(otp_client, + file_path, __bt_otp_client_object_create_cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + } + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: { + char *file_path = NULL; + int offset, length, mode; + + if (g_test_param.param_count < 4) { + TC_PRT("Input parameters first"); + break; + } + + file_path = g_test_param.params[0]; + TC_PRT("%s", file_path); + + offset = strtoul(g_test_param.params[1], NULL, 10); + length = strtoul(g_test_param.params[2], NULL, 10); + mode = strtoul(g_test_param.params[3], NULL, 10); + + if (otp_client) { + ret = bt_otp_client_write_object(otp_client, + file_path, offset, length, mode, + __bt_otp_client_object_write_cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else if (ret == BT_ERROR_NONE) + TC_PRT("Success"); + } + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ: { + if (otp_client) { + ret = bt_otp_client_execute_object(otp_client, + __bt_otp_client_object_execute_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ: { + if (otp_client) { + ret = bt_otp_client_delete_object(otp_client, + __bt_otp_client_object_delete_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + default: + break; + } + break; + } + case BT_UNIT_TEST_TABLE_HRP_SENSOR: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE: { + TC_PRT("HR SENSOR SET LOC VALUE\n"); + bt_body_sensor_location_e location = BT_BSL_WRIST; + bt_hrp_sensor_set_location_value(location); + + break; + } + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE: { + TC_PRT("HR SENSOR SET CONTACT VALUE\n"); + bool iscontact = true; + bt_hrp_sensor_set_contact_value(iscontact); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME: { + TC_PRT("HR SENSOR SET DEVICE NAME\n"); + char *name = g_strdup("SAMSUNG HR"); + bt_hrp_sensor_set_device_manufacturer_name(name); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE: { + TC_PRT("HR SENSOR CREATE\n"); + ret = bt_hrp_sensor_create(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY: { + TC_PRT("HR SENSOR UPDATE HR value\n"); + bt_hrp_sensor_set_heartrate_value(60 + (rand()%60)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY: { + TC_PRT("HR SENSOR DESTROY\n"); + ret = bt_hrp_sensor_destroy(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + default: + break; + } + break; + } + case BT_UNIT_TEST_TABLE_HRP_COLLECTOR: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK: { + TC_PRT("HR COLLECTOR CONNECTION STATE CALLBACK\n"); + if (collector) { + ret = bt_hrp_collector_set_connection_state_changed_cb(collector, + __bt_hrp_collector_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION: { + TC_PRT("HR COLLECTOR SET NOTIFICATION\n"); + if (set_notif == true) { + set_notif = false; + ret = bt_hrp_collector_set_notification(collector, + __bt_hrp_heart_rate_value_changed_cb, true); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } else { + set_notif = true; + ret = bt_hrp_collector_set_notification(collector, + __bt_hrp_heart_rate_value_changed_cb, false); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE: { + TC_PRT("HR COLLECTOR CREATE\n"); + ret = bt_hrp_collector_create(remote_addr, &collector); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN: { + TC_PRT("HR COLLECTOR START SCAN\n"); + ret = bt_hrp_collector_start_scan(__bt_adapter_le_scan_result_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN: { + TC_PRT("HR COLLECTOR STOP SCAN\n"); + ret = bt_hrp_collector_stop_scan(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT: { + TC_PRT("HR COLLECTOR CONNECT\n"); + ret = bt_hrp_collector_connect(collector); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT: { + TC_PRT("HR COLLECTOR DISCONNECT\n"); + ret = bt_hrp_collector_disconnect(collector); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC: { + TC_PRT("HR COLLECTOR GET BSL LOCATION\n"); + if (collector) { + ret = bt_hrp_collector_get_body_sensor_location(collector, _bt_hrp_collector_bsl_read_completed_cb); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY: { + TC_PRT("HR COLLECTOR DESTROY\n"); + ret = bt_hrp_collector_destory(collector); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + collector = NULL; + break; + } + default: + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_ETC: { + static unsigned int delay = 0; + bt_onoff_cnt = 0; + bt_onoff_cnt_success = 0; + bt_onoff_cnt_fail = 0; + + total_time = 0; + gettimeofday(&check_time, NULL); + + if (input_automated_test_delay == true) { + delay = test_id; + test_id = BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY; + } + + switch (test_id) { + /*Automated Test Cases */ + case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST: { + bt_adapter_state_e state = BT_ADAPTER_DISABLED; + delay = 0; + + ret = bt_adapter_set_state_changed_cb( + __bt_repeat_test_adapter_state_changed_cb, + &delay); + TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_get_state(&state); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("Current state: %d", state); + + if (state == BT_ADAPTER_DISABLED) + bt_adapter_enable(); + else + bt_adapter_disable(); + break; + } + case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY: { + bt_adapter_state_e state = BT_ADAPTER_DISABLED; + delay = 1; + + ret = bt_adapter_set_state_changed_cb( + __bt_repeat_test_adapter_state_changed_cb, + &delay); + TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_get_state(&state); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("Current state: %d", state); + + if (state == BT_ADAPTER_DISABLED) + bt_adapter_enable(); + else + bt_adapter_disable(); + break; + } + case BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY: { + bt_adapter_state_e state = BT_ADAPTER_DISABLED; + + input_automated_test_delay = false; + + ret = bt_adapter_set_state_changed_cb( + __bt_repeat_test_adapter_state_changed_cb, + &delay); + TC_PRT("set_cb returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_get_state(&state); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + TC_PRT("Current state: %d", state); + + if (state == BT_ADAPTER_DISABLED) + bt_adapter_enable(); + else + bt_adapter_disable(); + break; + } + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT: { + char *mode = "setting"; + + if (g_test_param.param_count > 0) + mode = g_test_param.params[0]; + + app_control_h service = NULL; + + app_control_create(&service); + app_control_set_app_id(service, "com.samsung.bluetooth-single"); + app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); + app_control_add_extra_data(service, "launch-type", mode); + ret = app_control_send_launch_request(service, NULL, NULL); + TC_PRT("returns %d", ret); + + app_control_destroy(service); + break; + } + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF: { + app_control_h service = NULL; + + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_EDIT); + app_control_set_mime(service, "application/x-bluetooth-on-off"); + + ret = app_control_send_launch_request(service, NULL, NULL); + TC_PRT("returns %d", ret); + + app_control_destroy(service); + + break; + } + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY: { + app_control_h service = NULL; + + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_EDIT); + app_control_set_mime(service, "application/x-bluetooth-visibility"); + + ret = app_control_send_launch_request(service, NULL, NULL); + TC_PRT("returns %d", ret); + + app_control_destroy(service); + + break; + } + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF: { + app_control_h service = NULL; + + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_ENABLE); + + ret = app_control_send_launch_request(service, NULL, NULL); + TC_PRT("returns %d", ret); + + app_control_destroy(service); + + break; + } + case BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY: { + app_control_h service = NULL; + + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY); + + ret = app_control_send_launch_request(service, NULL, NULL); + TC_PRT("returns %d", ret); + + app_control_destroy(service); + + break; + } + case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: { + int ret; + bool is_supported = false; + + if (g_test_param.param_count > 0) { + ret = system_info_get_custom_bool( + g_test_param.params[0], &is_supported); + if (ret != 0) + TC_PRT("returns %d", ret); + TC_PRT("%s is %s", g_test_param.params[0], + is_supported ? "true" : "false"); + __bt_free_test_param(&g_test_param); + } else { + ret = system_info_get_custom_bool( + "tizen.org/feature/network.bluetooth", &is_supported); + if (ret != 0) + TC_PRT("returns %d", ret); + TC_PRT("tizen.org/feature/network.bluetooth is %s", + is_supported ? "true" : "false"); + } + + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + default: + break; + } + + break; + } + default: + break; + } + + return 0; +} + +static gboolean key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[BUFFER_LEN] = { 0 }; + +#ifdef ARCH64 + unsigned long len = 0; +#else + unsigned int len = 0; +#endif + int test_id; + bool is_call_api = false; + + memset(buf, 0, sizeof(buf)); + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + TC_PRT("IO Channel read error"); + return FALSE; + } + + if (need_to_set_params == true) { + if (g_test_id == -1) { + test_id = atoi(buf); + g_test_id = test_id; + } + test_set_params(g_test_id, buf); + return TRUE; + } else { + TC_PRT("%s", buf); + test_id = atoi(buf); + + g_test_id = -1; + need_to_set_params = false; + } + + if (current_tc_table == BT_UNIT_TEST_TABLE_MAIN) { + if (buf[0] == '0' && buf[2] == 0) + current_tc_table = BT_UNIT_TEST_TABLE_SET_ADDRESS; + else if (test_id >= BT_UNIT_TEST_TABLE_ADAPTER + && test_id < BT_UNIT_TEST_TABLE_FINISH) + current_tc_table = test_id; + else + is_call_api = true; + } else { + if (buf[0] == '0' && buf[2] == 0) { + current_tc_table = BT_UNIT_TEST_TABLE_MAIN; + } else if (current_tc_table == BT_UNIT_TEST_TABLE_ETC + && test_id == BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY + && input_automated_test_delay == false) { + input_automated_test_delay = true; + } else { + is_call_api = true; + } + } + + tc_usage_print(); + + if (current_tc_table == BT_UNIT_TEST_TABLE_SET_ADDRESS + && is_call_api == true) { + memcpy(remote_addr, buf, 17); + remote_addr[17] = 0; + } else if (test_id && is_call_api) +#ifdef ARCH64 + g_idle_add(test_input_callback, (void *)(uintptr_t)test_id); +#else + g_idle_add(test_input_callback, (void *)test_id); +#endif + return TRUE; +} + +void sig_handler(int signo) +{ + if (signo == SIGINT) { + if (bt_onoff_cnt > 0) + __bt_print_repeat_test_final_summary(); + + bt_deinitialize(); + exit(0); + } +} + +int main() +{ + GIOChannel *key_io; + + current_tc_table = BT_UNIT_TEST_TABLE_MAIN; + + key_io = g_io_channel_unix_new(fileno(stdin)); + + g_io_channel_set_encoding(key_io, NULL, NULL); + g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); + + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + key_event_cb, NULL); + + g_io_channel_unref(key_io); + + main_loop = g_main_loop_new(NULL, FALSE); + + if (signal(SIGINT, sig_handler) == SIG_ERR) + TC_PRT("\n can't catch SIGINT\n"); + + g_main_loop_run(main_loop); + + bt_deinitialize(); + + return 0; +} diff --git a/tests/test/bt_unit_test.h b/tests/test/bt_unit_test.h new file mode 100644 index 0000000..375a497 --- /dev/null +++ b/tests/test/bt_unit_test.h @@ -0,0 +1,639 @@ +/* + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ +#define __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BUFFER_LEN 49 +#define MAX_SERVICES 10 +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define TC_PRT(format, args...) PRT(format"\n", ##args) + +typedef enum { + BT_UNIT_TEST_TABLE_MAIN = 1, + BT_UNIT_TEST_TABLE_SET_ADDRESS, + BT_UNIT_TEST_TABLE_ADAPTER, + BT_UNIT_TEST_TABLE_ADAPTER_LE, + BT_UNIT_TEST_TABLE_DEVICE, + BT_UNIT_TEST_TABLE_SOCKET, + BT_UNIT_TEST_TABLE_OPP, + BT_UNIT_TEST_TABLE_AUDIO, + BT_UNIT_TEST_TABLE_PAN, + BT_UNIT_TEST_TABLE_GATT, + BT_UNIT_TEST_TABLE_HPS, + BT_UNIT_TEST_TABLE_AVRCP, + BT_UNIT_TEST_TABLE_HID, + BT_UNIT_TEST_TABLE_IPSP, + BT_UNIT_TEST_TABLE_HDP, + BT_UNIT_TEST_TABLE_DPM, + BT_UNIT_TEST_TABLE_PXP, + BT_UNIT_TEST_TABLE_HF, + BT_UNIT_TEST_TABLE_PBAP_CLIENT, + BT_UNIT_TEST_TABLE_ETC, + BT_UNIT_TEST_FUNCTION_INITIALIZE_ALL, + BT_UNIT_TEST_TABLE_TDS_PROVIDER, + BT_UNIT_TEST_TABLE_TDS_SEEKER, + BT_UNIT_TEST_TABLE_OTP, + BT_UNIT_TEST_TABLE_HRP_SENSOR, + BT_UNIT_TEST_TABLE_HRP_COLLECTOR, + BT_UNIT_TEST_TABLE_FINISH = 0xFF, +} bt_unit_test_table_e; + +typedef enum { + BT_UNIT_TEST_FUNCTION_BACK = 0, + BT_UNIT_TEST_FUNCTION_SET_ADDRESS = 0, + BT_UNIT_TEST_FUNCTION_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_STATE = 1, + BT_UNIT_TEST_FUNCTION_ADAPTER_ENABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_DISABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_RECOVER, + BT_UNIT_TEST_FUNCTION_ADAPTER_START_DEVICE_DISCOVERY, + BT_UNIT_TEST_FUNCTION_ADAPTER_STOP_DEVICE_DISCOVERY, + BT_UNIT_TEST_FUNCTION_ADAPTER_IS_DISCOVERING, + BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_BONDED_DEVICE, + BT_UNIT_TEST_FUNCTION_ADAPTER_FOREACH_PROFILE_CONNECTED_DEVICES, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO, + BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO, + BT_UNIT_TEST_FUNCTION_ADAPTER_INIT_BATTERY_MONITOR, + BT_UNIT_TEST_FUNCTION_ADAPTER_DEINIT_BATTERY_MONITOR, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_DURATION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_DURATION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_CONNECTABLE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_CONNECTABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VERSION, + BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_INFO, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUEST_CB_NEW, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUEST_CB_NEW, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE = 1, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_WHITE_LIST, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_WHITE_LIST, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_CLEAR_WHITE_LIST, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_LE_2M_PHY_SUPPORT, + BT_UNIT_TEST_FUNCTION_LE_CODED_PHY_SUPPORT, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_AUTHORIZATION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_CONNECTION_STAET_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_CONNECTION_STAET_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_FOREACH_CONNECTED_PROFILES, + BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_CREATED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_BOND_DESTROYED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_DISCONNECT, + BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND, + BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE, + BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND, + BT_UNIT_TEST_FUNCTION_DEVICE_ENABLE_RSSI_MONITOR, + BT_UNIT_TEST_FUNCTION_DEVICE_DISABLE_RSSI_MONITOR, + BT_UNIT_TEST_FUNCTION_DEVICE_GET_RSSI_STRENGTH, + BT_UNIT_TEST_FUNCTION_DEVICE_GET_CONNECTION_STATE, + BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE, + BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION, + BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_REQUEST_ATT_MTU_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_REQUEST_ATT_MTU_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU, + BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE, + BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB, + BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM = 1, + BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM, + BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM, + BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN, + BT_UNIT_TEST_FUNCTION_SOCKET_ACCEPT, + BT_UNIT_TEST_FUNCTION_SOCKET_REJECT, + BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM, + BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM, + BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA, + BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_RFCOMM_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_CUSTOM_UUID, + BT_UNIT_TEST_FUNCTION_SOCKET_SET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_REQUESTED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_REQUESTED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_ADD_FILE, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CLEAR_FILES, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_PUSH_FILES, + BT_UNIT_TEST_FUNCTION_OPP_CLIENT_CANCEL_PUSH, + BT_UNIT_TEST_FUNCTION_AUDIO_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT, + BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT, + BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT, + BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT, + BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO, + BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO, + BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED, + BT_UNIT_TEST_FUNCTION_AG_SET_SCO_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_UNSET_SCO_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_SET_SPEAKER_GAIN_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_UNSET_SPEAKER_GAIN_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_SET_MICRO_GAIN_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_UNSET_MICRO_GAIN_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_IS_CONNECTED, + BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_IDLE, + BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ANSWERED, + BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING, + BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_ALERTING, + BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING, + BT_UNIT_TEST_FUNCTION_CALL_LIST_CREATE, + BT_UNIT_TEST_FUNCTION_CALL_LIST_DESTROY, + BT_UNIT_TEST_FUNCTION_CALL_LIST_RESET, + BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD, + BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST, + BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB, + BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED, + BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET, + BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE, + BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE, + BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME, + BT_UNIT_TEST_FUNCTION_AUDIO_GET_ABSOLUTE_VOLUME, + BT_UNIT_TEST_FUNCTION_AUDIO_IS_AVC_ACTIVATED, + BT_UNIT_TEST_FUNCTION_AUDIO_SET_ABSOLUTE_VOLUME_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_ABSOLUTE_VOLUME_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AUDIO_SET_AVC_STATUE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_AVC_STATUE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AG_IS_WBS_MODE, + BT_UNIT_TEST_FUNCTION_AG_SET_VENDOR_CMD_CB, + BT_UNIT_TEST_FUNCTION_AG_UNSET_VENDOR_CMD_CB, + BT_UNIT_TEST_FUNCTION_AG_NOTIFY_VENDOR_CMD, + BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_ENABLE, + BT_UNIT_TEST_FUNCTION_A2DP_SET_CONTENT_PROTECTION_DISABLE, + BT_UNIT_TEST_FUNCTION_NAP_ACTIVATE = 1, + BT_UNIT_TEST_FUNCTION_NAP_DEACTIVATE, + BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT_ALL, + BT_UNIT_TEST_FUNCTION_NAP_DISCONNECT, + BT_UNIT_TEST_FUNCTION_PANU_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PANU_CONNECT, + BT_UNIT_TEST_FUNCTION_GATT_CONNECT = 1, + BT_UNIT_TEST_FUNCTION_GATT_DISCONNECT, + BT_UNIT_TEST_FUNCTION_SET_GATT_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_UNSET_GATT_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_CREATE, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_DESTROY, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_REMOTE_ADDRESS, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_SET_MTU_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_NOTIFY_HEART_RATE_MEASUREMENT, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_THERMOMETER_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL, + BT_UNIT_TEST_FUNCTION_GATT_START_SERVER, + BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID, + BT_UNIT_TEST_FUNCTION_ANCS_PAIR, + BT_UNIT_TEST_FUNCTION_ANCS_WATCH, + BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION, + BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION, + BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR, + BT_UNIT_TEST_FUNCTION_GATT_FOREACH_PRIMARY_SERVICES, + BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTICS, + BT_UNIT_TEST_FUNCTION_GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS, + BT_UNIT_TEST_FUNCTION_GATT_GET_SERVICE_UUID, + BT_UNIT_TEST_FUNCTION_GATT_FOREACH_INCLUDED_SERVICES, + BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_UNSET_CHARACTERISTIC_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_GATT_GET_CHARACTERISTIC_DECLARATION, + BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE, + BT_UNIT_TEST_FUNCTION_GATT_SET_CHARACTERISTIC_VALUE_REQUEST, + BT_UNIT_TEST_FUNCTION_GATT_READ_CHARACTERISTIC_VALUE, + BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES, + BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES, + BT_UNIT_TEST_FUNCTION_GATT_GET_DATA_BATCHING_AVAILABLE_PACKETS, + BT_UNIT_TEST_FUNCTION_GATT_ENABLE_DATA_BATCHING, + BT_UNIT_TEST_FUNCTION_GATT_DISABLE_DATA_BATCHING, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE = 1, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION, + BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_REPEAT_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_SHUFFLE_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_SCAN_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_EQUALIZER_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_REPEAT_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SHUFFLE_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SCAN_MODE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_INITIALIZE, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_CONNECT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_DISCONNECT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PLAY, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_STOP, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PAUSE, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_FF, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SEND_DELAY_REPORT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_SHUFFLE, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_POSITION, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_PLAY_STATUS, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_TRACK_INFO, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_SONG_POSITION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_PLAY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_SET_TRACK_INFO_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_SONG_POSITION_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_PLAY_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_AVRCP_UNSET_TRACK_INFO_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_HID_HOST_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT, + BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT, + BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT_SCROLL_DOWN, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_IPSP_REGISTER = 1, + BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER, + BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE, + BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_IPSP_CONNECT, + BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT, + BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING, + BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_IPSP_CREATE_APP_SERVER_SOCKET, + BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET, + BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA, + BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA, + BT_UNIT_TEST_FUNCTION_IPSP_CLOSE_SOCKET, + BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP = 1, + BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP, + BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE, + BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT, + BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA, + BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB, + BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB, + BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_DPM_SET_DEFAULT_POLICIES = 1, + BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE, + BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_BLUETOOTH_MODE, + BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION, + BT_UNIT_TEST_FUNCTION_DPM_IS_DEVICE_RESTRICTIO_ACTIVATE, + BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION, + BT_UNIT_TEST_FUNCTION_DPM_IS_UUID_RESTRICTIO_ACTIVATE, + BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_GET_DEVICES_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_GET_UUIDS_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_CLEAR_DEVICES_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_CLEAR_UUIDS_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST, + BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST, + BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL, + BT_UNIT_TEST_FUNCTION_DPM_GET_ALLOW_OUTGOING_CALL, + BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_PAIRING_STATE, + BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_DESKTOP_CONNECTIVITY_STATE, + BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_DISCOVERABLE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_LIMITED_DISCOVERABLE_STATE, + BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE, + BT_UNIT_TEST_FUNCTION_DPM_GET_DATA_TRANSFER_STATE, + BT_UNIT_TEST_FUNCTION_HF_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_ANSWER, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_INIT, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_TERM, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM, + BT_UNIT_TEST_FUNCTION_HF_GET_CALL_STATUS_INFO_LIST, + BT_UNIT_TEST_FUNCTION_HF_REQUEST_CALL_STATUS_INFO_LIST, + BT_UNIT_TEST_FUNCTION_HF_SET_CALL_EVENT_CB, + BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_EVENT_CB, + BT_UNIT_TEST_FUNCTION_HF_SET_CALL_STATUS_UPDATED_EVENT_CB, + BT_UNIT_TEST_FUNCTION_HF_UNSET_CALL_STATUS_UPDATED_EVENT_CB, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_SPEAKER_GAIN, + BT_UNIT_TEST_FUNCTION_HF_SET_SPEAKER_GAIN_CB, + BT_UNIT_TEST_FUNCTION_HF_UNSET_SPEAKER_GAIN_CB, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_TRUE, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VOICE_REC_FALSE, + BT_UNIT_TEST_FUNCTION_HF_IS_SCO_OPENED, + BT_UNIT_TEST_FUNCTION_HF_GET_CODEC_ID, + BT_UNIT_TEST_FUNCTION_HF_SET_SCO_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_HF_UNSET_SCO_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_HF_NOTIFY_VENDOR_CMD, + BT_UNIT_TEST_FUNCTION_HF_SET_VENDOR_CMD_EVENT_CB, + BT_UNIT_TEST_FUNCTION_HF_UNSET_VENDOR_CMD_EVENT_CB, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_INITIALIZE = 1, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDPULL, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKSEARCH, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST_MAXLIST_ZERO, + BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST = 1, + BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_1_SEC_DELAY, + BT_UNIT_TEST_FUNCTION_ON_OFF_REPEAT_TEST_N_SEC_DELAY, + BT_UNIT_TEST_FUNCTION_APP_CONTROL_DEFAULT, + BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_ONOFF, + BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_3_BT_VISIBILITY, + BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF, + BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY, + BT_UNIT_TEST_FUNCTION_CHECK_FEATURE, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER = 1, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL, + + /* TDS Provider */ + BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_REGISTER = 1, + BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNREGISTER, + BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_SET_ACT_REQ_CB, + BT_UNIT_TEST_FUNCTION_TDS_PROVIDER_UNSET_ACT_REQ_CB, + BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_CREATE, + BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_DESTROY, + BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_TRANSPORT_DATA, + BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SET_MANUF_DATA, + BT_UNIT_TEST_FUNCTION_TDS_CUSTOM_PROVIDER_SEND_ACTIVATION_RESP, + + /* TDS Seeker */ + BT_UNIT_TEST_FUNCTION_TDS_START_DISCOVERING_PROVIDER = 1, + BT_UNIT_TEST_FUNCTION_TDS_STOP_DISCOVERING_PROVIDER, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CREATE, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DESTROY, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_SET_CONNECTION_CALLBACK, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_CONNECT, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_DISCONNECT, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_UNSET_CONNECTION_CALLBACK, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_GET_COMPLETE_DATA, + BT_UNIT_TEST_FUNCTION_TDS_SEEKER_ACTIVATE_CONTROL_POINT, + + /* OTP */ + BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT = 1, + BT_UNIT_TEST_FUNCTION_OTP_SERVER_DEINIT, + BT_UNIT_TEST_FUNCTION_OTP_SET_SERVER_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_OTP_UNSET_SERVER_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DESTROY, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SET_CONNECTION_CALLBACK, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_UNSET_CONNECTION_CALLBACK, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CONNECT, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCONNECT, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DISCOVER_ALL_OBJECTS, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_READ_OBJ_CONTENTS, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_EXECUTE_OBJ, + BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ, + + /*HR-Sensor*/ + BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE = 1, + BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE, + BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME, + BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE, + BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY, + BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY, + /*HR-Collector*/ + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK = 1, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY, + BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC, + + BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, +} bt_unit_test_function_e; + +/** + * AMS EntityID type. + */ +typedef enum { + BT_AMS_ENTITY_ID_PLAYER = 0x00, /**< Player */ + BT_AMS_ENTITY_ID_QUEUE = 0x01, /**< Queue */ + BT_AMS_ENTITY_ID_TRACK = 0x02 /**< Track */ +} bt_ams_entity_id_type_e; + +/** + * AMS Entity Player's Attribute IDs type. + */ +typedef enum { + BT_AMS_PLAYER_ATTR_ID_NAME = 0x00, /**< PlayerAttributeIDName */ + BT_AMS_PLAYER_ATTR_ID_PLAYBACK_INFO = 0x01, /**< PlayerAttributeIDPlaybackInfo */ + BT_AMS_PLAYER_ATTR_ID_VOLUME = 0x02 /**< PlayerAttributeIDVolume */ +} bt_ams_player_attr_id_type_e; + +/** + * AMS Entity Queue's Attribute IDs type. + */ +typedef enum { + BT_AMS_QUEUE_ATTR_ID_INDEX = 0x00, /**< QueueAttributeIDIndex */ + BT_AMS_QUEUE_ATTR_ID_COUNT = 0x01, /**< QueueAttributeIDCount */ + BT_AMS_QUEUE_ATTR_ID_SHUFFLE_MODE = 0x02, /**< QueueAttributeIDShuffleMode */ + BT_AMS_QUEUE_ATTR_ID_REPEAT_MODE = 0x03 /**< QueueAttributeIDRepeatMode */ +} bt_ams_queue_attr_id_type_e; + +/** + * AMS Entity Track's Attribute IDs type. + */ +typedef enum { + BT_AMS_TRACK_ATTR_ID_ARTIST = 0x00, /**< TrackAttributeIDArtist */ + BT_AMS_TRACK_ATTR_ID_ALBUM = 0x01, /**< TrackAttributeIDAlbum */ + BT_AMS_TRACK_ATTR_ID_TITLE = 0x02, /**< TrackAttributeIDTitle */ + BT_AMS_TRACK_ATTR_ID_DURATION = 0x03 /**< TrackAttributeIDDuration */ +} bt_ams_track_attr_id_type_e; + +typedef struct { + const char *tc_name; + int tc_code; +} tc_table_t; + +typedef struct { + int param_count; + char **params; +} tc_params_t; + +#define BT_UNIT_TEST_PARAM_TYPE_BOOL "bool(true, false)" +#define BT_UNIT_TEST_PARAM_TYPE_INT "int(1, 2, 10, 777...)" +#define BT_UNIT_TEST_PARAM_TYPE_FLOAT "float(1.5, 0.625...)" +#define BT_UNIT_TEST_PARAM_TYPE_STRING "string(abc, HAHA..)" +#define BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY "byte array(03FF0102, 0015836CF7B2...)" + +int test_input_callback(void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_BLUETOOTH_UNIT_TEST_H__ */ diff --git a/tests/test/hid_keyboard.c b/tests/test/hid_keyboard.c new file mode 100644 index 0000000..5dca9db --- /dev/null +++ b/tests/test/hid_keyboard.c @@ -0,0 +1,863 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "HID_KEYBOARD" + +#define INIT_BOND 0 + +#define KEYBOARD_RETURN 0x28 // Enter +#define KEYBOARD_ESCAPE 0x29 // Back +#define KEYBOARD_F5 0x3e // Smart Hub +#define KEYBOARD_F6 0x3f // Source +#define KEYBOARD_F7 0x40 // Channel List +#define KEYBOARD_F8 0x41 // Volume Mute +#define KEYBOARD_F9 0x42 // Volume Down +#define KEYBOARD_F10 0x43 // Volume Up +#define KEYBOARD_F11 0x44 // Channel Down +#define KEYBOARD_F12 0x45 // Channel Up +#define KEYBOARD_RIGHT 0x4f // Arrow Right +#define KEYBOARD_LEFT 0x50 // Arrow Left +#define KEYBOARD_DOWN 0x51 // Arrow Down +#define KEYBOARD_UP 0x52 // Arrow Up + +/** + * Variables + **/ +static GMainLoop *g_mainloop = NULL; +static bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; +static char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; +static bool address_input = false; +#if INIT_BOND +static bool scanning = false; +static bool setup_in_progress = false; +static GSList *le_scan_list; +static bool g_wait_flag; +static int g_wait_count; +#endif + +static bool device_bonded = false; +static bool hid_connected = false; +static bool audio_connected = false; + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define HID_PRT(format, args...) PRT(format"\n", ##args) + +#if INIT_BOND +#define WAIT_FOR_SYNC {\ + g_wait_flag = true;\ + g_wait_count = 0;\ + while (g_wait_flag == true && g_wait_count < 50) {\ + usleep(1000);\ + HID_PRT("Initial Setup...");\ + g_main_context_iteration(NULL, true);\ + g_wait_count++;\ + }\ +} +#endif + +typedef struct { + const char *tc_name; + int tc_code; +} tc_table_t; + +typedef enum { + BT_HID_DEVICE_SET_ADDRESS = 1, +#if INIT_BOND + BT_HID_DEVICE_TEST_SETUP, +#endif + BT_HID_DEVICE_TEST_VOLUME_UP, + BT_HID_DEVICE_TEST_VOLUME_DOWN, + BT_HID_DEVICE_TEST_CHANNEL_UP, + BT_HID_DEVICE_TEST_CHANNEL_DOWN, + BT_HID_DEVICE_TEST_CONNECT_HID, + BT_HID_DEVICE_TEST_DISCONNECT_HID, + BT_HID_DEVICE_TEST_CONNECT_AUDIO, + BT_HID_DEVICE_TEST_DISCONNECT_AUDIO, +#if INIT_BOND + BT_HID_DEVICE_TEST_SEARCH, + BT_HID_DEVICE_TEST_STOP_SEARCH, +#endif + BT_HID_DEVICE_TEST_FINISH = 0xFF, +} bt_hid_test_type_e; + +tc_table_t tc_hid_device[] = { + {"SET ADDRESS" + , BT_HID_DEVICE_SET_ADDRESS}, +#if INIT_BOND + {"Initial Setup (Bond & Connects)" + , BT_HID_DEVICE_TEST_SETUP}, +#endif + {"Volume Up" + , BT_HID_DEVICE_TEST_VOLUME_UP}, + {"Volume Down" + , BT_HID_DEVICE_TEST_VOLUME_DOWN}, + {"Channel Up" + , BT_HID_DEVICE_TEST_CHANNEL_UP}, + {"Channel Down" + , BT_HID_DEVICE_TEST_CHANNEL_DOWN}, + {"HID Connect only" + , BT_HID_DEVICE_TEST_CONNECT_HID}, + {"HID Disconnect only" + , BT_HID_DEVICE_TEST_DISCONNECT_HID}, + {"AUDIO Connect only" + , BT_HID_DEVICE_TEST_CONNECT_AUDIO}, + {"AUDIO Disconnect only" + , BT_HID_DEVICE_TEST_DISCONNECT_AUDIO}, +#if INIT_BOND + {"Search TV" + , BT_HID_DEVICE_TEST_SEARCH}, + {"Stop to search" + , BT_HID_DEVICE_TEST_STOP_SEARCH}, +#endif + {"Finish" + , BT_HID_DEVICE_TEST_FINISH}, + {NULL, 0x0000}, +}; + +static const char *__bt_get_error_message(bt_error_e err) +{ + const char *err_str = NULL; + + switch (err) { + case BT_ERROR_NONE: + err_str = "BT_ERROR_NONE"; + break; + case BT_ERROR_CANCELLED: + err_str = "BT_ERROR_CANCELLED"; + break; + case BT_ERROR_INVALID_PARAMETER: + err_str = "BT_ERROR_INVALID_PARAMETER"; + break; + case BT_ERROR_OUT_OF_MEMORY: + err_str = "BT_ERROR_OUT_OF_MEMORY"; + break; + case BT_ERROR_RESOURCE_BUSY: + err_str = "BT_ERROR_RESOURCE_BUSY"; + break; + case BT_ERROR_TIMED_OUT: + err_str = "BT_ERROR_TIMED_OUT"; + break; + case BT_ERROR_NOW_IN_PROGRESS: + err_str = "BT_ERROR_NOW_IN_PROGRESS"; + break; + case BT_ERROR_NOT_INITIALIZED: + err_str = "BT_ERROR_NOT_INITIALIZED"; + break; + case BT_ERROR_NOT_ENABLED: + err_str = "BT_ERROR_NOT_ENABLED"; + break; + case BT_ERROR_ALREADY_DONE: + err_str = "BT_ERROR_ALREADY_DONE"; + break; + case BT_ERROR_OPERATION_FAILED: + err_str = "BT_ERROR_OPERATION_FAILED"; + break; + case BT_ERROR_NOT_IN_PROGRESS: + err_str = "BT_ERROR_NOT_IN_PROGRESS"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; + break; + case BT_ERROR_AUTH_REJECTED: + err_str = "BT_ERROR_AUTH_REJECTED"; + break; + case BT_ERROR_AUTH_FAILED: + err_str = "BT_ERROR_AUTH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; + break; + case BT_ERROR_SERVICE_SEARCH_FAILED: + err_str = "BT_ERROR_SERVICE_SEARCH_FAILED"; + break; + case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: + err_str = "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; + break; + case BT_ERROR_PERMISSION_DENIED: + err_str = "BT_ERROR_PERMISSION_DENIED"; + break; + case BT_ERROR_SERVICE_NOT_FOUND: + err_str = "BT_ERROR_SERVICE_NOT_FOUND"; + break; + case BT_ERROR_NO_DATA: + err_str = "BT_ERROR_NO_DATA"; + break; + case BT_ERROR_NOT_SUPPORTED: + err_str = "BT_ERROR_NOT_SUPPORTED"; + break; + case BT_ERROR_DEVICE_POLICY_RESTRICTION: + err_str = "DEVICE_POLICY_RESTRICTION"; + break; + default: + err_str = "NOT Defined"; + break; + } + + return err_str; +} + +/** + * Callback functions + **/ +static gboolean __bt_timeout_func(gpointer data) +{ + HID_PRT("Timeout."); + if (g_mainloop) + g_main_loop_quit((GMainLoop *)data); + + return FALSE; +} + +static gboolean __bt_audio_connect_cb(gpointer user_data) +{ + int ret; + + if (audio_connected == true) + return FALSE; + + HID_PRT("Try to connect audio.."); + ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); + HID_PRT("returns %s", __bt_get_error_message(ret)); + + return TRUE; +} + +static void __bt_hid_device_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + HID_PRT("result: %s", __bt_get_error_message(result)); + HID_PRT("Remote Address: %s", remote_address); + HID_PRT("Connected [%d]", connected); + +#if INIT_BOND + g_wait_flag = false; +#endif + + if (connected == true && result == BT_ERROR_NONE) { + g_strlcpy(remote_addr, remote_address, 18); + hid_connected = true; + + /* Try to connect Audio */ + if (audio_connected == false) + g_timeout_add(2000, __bt_audio_connect_cb, NULL); + } else { + hid_connected = false; + } +} + +void __bt_audio_connection_state_changed_cb(int result, + bool connected, const char *remote_address, + bt_audio_profile_type_e type, void *user_data) +{ + HID_PRT("result [%s]", __bt_get_error_message(result)); + HID_PRT("connected [%d]", connected); + HID_PRT("address [%s]", remote_address); + HID_PRT("type [%d]", type); + +#if INIT_BOND + g_wait_flag = false; +#endif + + if (connected == true && result == BT_ERROR_NONE) { + g_strlcpy(remote_addr, remote_address, 18); + audio_connected = true; + } else { + audio_connected = false; + } +} + +static bool __bt_adapter_hid_profile_connected_devices_cb( + const char *remote_address, void *user_data) +{ + HID_PRT("remote_address: %s", remote_address); + + g_strlcpy(remote_addr, remote_address, 18); + + hid_connected = true; + + return true; +} + +static bool __bt_adapter_a2dp_profile_connected_devices_cb( + const char *remote_address, void *user_data) +{ + HID_PRT("remote_address: %s", remote_address); + + g_strlcpy(remote_addr, remote_address, 18); + + audio_connected = true; + + return true; +} + +void __bt_device_bond_created_cb(int result, + bt_device_info_s *device_info, void *user_data) +{ + if (result == BT_ERROR_NONE) { + HID_PRT("Callback: A bond is created."); + HID_PRT("Callback: is_bonded - %d.", device_info->is_bonded); + device_bonded = true; + } else { + HID_PRT("Callback: Creating a bond is failed."); + HID_PRT("result: %s", __bt_get_error_message(result)); + } + +#if INIT_BOND + g_wait_flag = false; +#endif +} + +static void __bt_state_changed_impl(int result, + bt_adapter_state_e adapter_state, + void *user_data) +{ + if (adapter_state == BT_ADAPTER_ENABLED) { + if (result == BT_ERROR_NONE) { + HID_PRT("Callback: BT was enabled successfully."); + bt_state = BT_ADAPTER_ENABLED; + } else { + HID_PRT("Callback: Failed to enable BT."); + } + } + + if (g_mainloop) + g_main_loop_quit(g_mainloop); +} + +#if INIT_BOND +gint __bt_compare_address(gpointer *a, gpointer *b) +{ + bt_adapter_le_device_scan_result_info_s *info = (bt_adapter_le_device_scan_result_info_s *)a; + char *address = (char *)b; + return g_strcmp0(info->remote_address, address); +} + +static void __bt_adapter_le_scan_result_cb( + int result, bt_adapter_le_device_scan_result_info_s *info, + void *user_data) +{ + int i; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + bt_adapter_le_device_scan_result_info_s *adv_info; + + if (info == NULL) { + HID_PRT("No discovery_info!"); + return; + } + + if (info->adv_data_len > 31 || info->scan_data_len > 31) { + HID_PRT("###################"); + bt_adapter_le_stop_scan(); + HID_PRT("###################"); + return; + } + + GSList *l = NULL; + l = g_slist_find_custom(le_scan_list, info->remote_address, + (GCompareFunc)__bt_compare_address); + + if (l != NULL) { + adv_info = l->data; + adv_info->rssi = info->rssi; + return; + } + + adv_info = g_malloc0(sizeof(bt_adapter_le_device_scan_result_info_s)); + adv_info->remote_address= g_strdup(info->remote_address); + adv_info->rssi = info->rssi; + le_scan_list = g_slist_append(le_scan_list, adv_info); + + for (i = 0; i < 2; i++) { + char *device_name; + + pkt_type += i; + if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING + && info->adv_data == NULL) continue; + if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE + && info->scan_data == NULL) break; + + if (bt_adapter_le_get_scan_result_device_name( + info, pkt_type, &device_name) == BT_ERROR_NONE) { + + HID_PRT("\n%s Adv %d Scan resp %d RSSI %d Addr_type %d", + info->remote_address, info->adv_data_len, + info->scan_data_len, info->rssi, + info->address_type); + + HID_PRT("Device name = %s", device_name); + if (adv_info->adv_data == NULL) + adv_info->adv_data= g_strdup(device_name); + g_free(device_name); + return; + } + } +} + +static void __bt_find_remote_tv(void) +{ + int ret = BT_ERROR_NONE; + bt_scan_filter_h scan_filter = NULL; + int manufacturer_id = 117; /* samsung */ + + scanning = true; + + ret = bt_adapter_le_scan_filter_unregister_all(); + if (ret != BT_ERROR_NONE) + HID_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_create(&scan_filter); + if (ret != BT_ERROR_NONE) + HID_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data(scan_filter, + manufacturer_id, NULL, 0); + if (ret != BT_ERROR_NONE) + HID_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_register(scan_filter); + if (ret != BT_ERROR_NONE) + HID_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_scan_filter_destroy(scan_filter); + if (ret != BT_ERROR_NONE) + HID_PRT("failed with [0x%04x]", ret); + + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + HID_PRT("returns %s\n", __bt_get_error_message(ret)); + + if (ret == BT_ERROR_NONE) + scanning = true; +} +#else +static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) +{ + if (device_info != NULL) { + if (g_strrstr(device_info->remote_name, "[TV]")) { + HID_PRT("TV is boned : %s [%s]", device_info->remote_name, device_info->remote_address); + g_strlcpy(remote_addr, device_info->remote_address, 18); + return false; + } + } + + return true; +} +#endif + +static gboolean __bt_start_service(gpointer user_data) +{ + int ret = BT_ERROR_NONE; + + ret = bt_audio_initialize(); + + ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0); + + ret = bt_adapter_set_name("Tizen Keyboard"); + + ret = bt_audio_select_role(BT_A2DP_SINK); + + ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb, NULL); + + ret = bt_audio_set_connection_state_changed_cb( + __bt_audio_connection_state_changed_cb, NULL); + + ret = bt_hid_device_activate( + __bt_hid_device_connection_state_changed_cb, + NULL); + HID_PRT("returns %s", __bt_get_error_message(ret)); + + if (ret != BT_ERROR_NONE && ret != BT_ERROR_NOW_IN_PROGRESS) { + HID_PRT("bt_hid_device_activate() failed."); + g_main_loop_quit(g_mainloop); + return FALSE; + } + + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_HID, + __bt_adapter_hid_profile_connected_devices_cb, NULL); + HID_PRT("HID connected devices returns %s\n", __bt_get_error_message(ret)); + + ret = bt_adapter_foreach_profile_connected_devices(BT_PROFILE_SERVICE_UUID_A2DP_SOURCE, + __bt_adapter_a2dp_profile_connected_devices_cb, NULL); + HID_PRT("A2DP connected devices returns %s\n", __bt_get_error_message(ret)); + + if (hid_connected == false && audio_connected == false) { +#if INIT_BOND + HID_PRT("No TV is connected, try to search..."); + + __bt_find_remote_tv(); +#else + ret = bt_adapter_foreach_bonded_device(__bt_adapter_bonded_device_cb, NULL); +#endif + } + return FALSE; +} + +#if INIT_BOND +static void __bt_stop_setup(void) +{ + setup_in_progress = false; +} + +static int __bt_initial_setup(void) +{ + int ret = BT_ERROR_NONE; + bt_device_info_s *device_info = NULL; + + setup_in_progress = true; + + ret = bt_adapter_get_bonded_device_info(remote_addr, &device_info); + HID_PRT("returns %s\n", __bt_get_error_message(ret)); + + if (ret == BT_ERROR_NONE) { + /* Already bond */ + HID_PRT("Device is already paired"); + device_bonded = true; + } else { + /* Create Bond */ + ret = bt_device_create_bond(remote_addr); + HID_PRT("returns %s\n", __bt_get_error_message(ret)); + + if (ret != BT_ERROR_NONE) + return ret; + + WAIT_FOR_SYNC; + } + + if (device_bonded == false) + return BT_ERROR_OPERATION_FAILED; + + /* Connect HID first */ + ret = bt_hid_device_connect(remote_addr); + HID_PRT("HID connect for %s: returns %s", remote_addr, __bt_get_error_message(ret)); + + if (ret == BT_ERROR_NONE) + WAIT_FOR_SYNC; + + /* Connect Audio */ + ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); + HID_PRT("Audio connect for %s: returns %s", remote_addr, __bt_get_error_message(ret)); + + if (ret == BT_ERROR_NONE) + WAIT_FOR_SYNC; + + if (hid_connected == false || audio_connected == false) + ret = BT_ERROR_OPERATION_FAILED; + + setup_in_progress = false; + + return ret; +} +#endif + +static void __bt_tc_usage_print(void) +{ + int i = 0; + tc_table_t *tc_table = tc_hid_device; + + + while (tc_table[i].tc_name) { + HID_PRT("Key %d : usage %s", tc_table[i].tc_code, + tc_table[i].tc_name); + i++; + } + HID_PRT("\n"); +} + +static int __bt_test_input_callback(void *data) +{ + int ret = 0; +#ifdef ARCH64 + int test_id = (uintptr_t)data; +#else + int test_id = (int)data; +#endif + bt_hid_key_data_s send_data; + char pressedkey[8] = { KEYBOARD_F10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + char pressedkey1[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +#if INIT_BOND + int cnt = 0; + GSList *l = NULL; + bt_adapter_le_device_scan_result_info_s *info; + + if (setup_in_progress == true && + test_id != BT_HID_DEVICE_TEST_SETUP && + test_id != BT_HID_DEVICE_TEST_FINISH) { + HID_PRT("Initial Setup is in progress,,"); + HID_PRT("Wait to finish setup"); + return 0; + } +#endif + + switch (test_id) { + case BT_HID_DEVICE_SET_ADDRESS: + HID_PRT("Input the address of remote device." + "(e.g.,F6:FB:8F:D8:C8:7C)\n\n"); + + address_input = true; + + break; +#if INIT_BOND + case BT_HID_DEVICE_TEST_SETUP: + if (setup_in_progress == true) { + HID_PRT("Stop the initial setup"); + __bt_stop_setup(); + } else { + if (__bt_initial_setup() != BT_ERROR_NONE) { + HID_PRT("Fail to setup: %s", __bt_get_error_message(ret)); + } + } + break; +#endif + case BT_HID_DEVICE_TEST_VOLUME_UP: + pressedkey[0] = KEYBOARD_F10; /* Vol up */ + + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + HID_PRT("returns %d\n", ret); + + memcpy(send_data.key, pressedkey1, 8); + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + + break; + case BT_HID_DEVICE_TEST_VOLUME_DOWN: + pressedkey[0] = KEYBOARD_F9; /* Vol down */ + + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + HID_PRT("returns %d\n", ret); + + memcpy(send_data.key, pressedkey1, 8); + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + + break; + case BT_HID_DEVICE_TEST_CHANNEL_UP: + pressedkey[0] = KEYBOARD_F12; /* CH up */ + + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + HID_PRT("returns %d\n", ret); + + memcpy(send_data.key, pressedkey1, 8); + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + + break; + case BT_HID_DEVICE_TEST_CHANNEL_DOWN: + pressedkey[0] = KEYBOARD_F11; /* CH down */ + + memcpy(send_data.key, pressedkey, 8); + send_data.modifier = 0; + + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + HID_PRT("returns %d\n", ret); + + memcpy(send_data.key, pressedkey1, 8); + ret = bt_hid_device_send_key_event(remote_addr, &send_data); + + break; + case BT_HID_DEVICE_TEST_CONNECT_AUDIO: + ret = bt_audio_connect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); + HID_PRT("returns %s", __bt_get_error_message(ret)); + break; + case BT_HID_DEVICE_TEST_DISCONNECT_AUDIO: + ret = bt_audio_disconnect(remote_addr, BT_AUDIO_PROFILE_TYPE_A2DP_SINK); + HID_PRT("returns %s", __bt_get_error_message(ret)); + break; + case BT_HID_DEVICE_TEST_CONNECT_HID: + ret = bt_hid_device_connect(remote_addr); + HID_PRT("returns %s", __bt_get_error_message(ret)); + break; + case BT_HID_DEVICE_TEST_DISCONNECT_HID: + ret = bt_hid_device_disconnect(remote_addr); + HID_PRT("returns %s", __bt_get_error_message(ret)); + break; +#if INIT_BOND + case BT_HID_DEVICE_TEST_SEARCH: + __bt_find_remote_tv(); + break; + case BT_HID_DEVICE_TEST_STOP_SEARCH: + scanning = false; + + ret = bt_adapter_le_stop_scan(); + HID_PRT("returns %s\n", __bt_get_error_message(ret)); + + HID_PRT("LE scan result :\n"); + for (l = le_scan_list; l != NULL; l = g_slist_next(l)) { + info = l->data; + if (info) { + if (info->adv_data) + HID_PRT("[%d] %s, %d dBm, %s", ++cnt, info->remote_address, info->rssi, info->adv_data); + + g_free(info->remote_address); + g_free(info->adv_data); + g_free(info); + } + } + g_slist_free(le_scan_list); + le_scan_list = NULL; + + break; +#endif + case BT_HID_DEVICE_TEST_FINISH: + HID_PRT("Finished"); + g_main_loop_quit(g_mainloop); + break; + default: + break; + } + + return 0; +} + + +static gboolean __bt_key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[49] = { 0 }; + +#ifdef ARCH64 + unsigned long len = 0; +#else + unsigned int len = 0; +#endif + int test_id; + + memset(buf, 0, sizeof(buf)); + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + HID_PRT("IO Channel read error"); + return FALSE; + } + + HID_PRT("%s", buf); + + if (address_input == true) { + memcpy(remote_addr, buf, 17); + remote_addr[17] = 0; + address_input = false; + } + +#if INIT_BOND + if (scanning == true) { + test_id = BT_HID_DEVICE_TEST_STOP_SEARCH; +#ifdef ARCH64 + g_idle_add(__bt_test_input_callback, (void *)(uintptr_t)test_id); +#else + g_idle_add(__bt_test_input_callback, (void *)test_id); +#endif + return TRUE; + } +#endif + + test_id = atoi(buf); + + __bt_tc_usage_print(); + +#ifdef ARCH64 + g_idle_add(__bt_test_input_callback, (void *)(uintptr_t)test_id); +#else + g_idle_add(__bt_test_input_callback, (void *)test_id); +#endif + return TRUE; +} + +int main() +{ + int timeout_id = -1; + int ret = BT_ERROR_NONE; + GIOChannel *key_io; + + g_mainloop = g_main_loop_new(NULL, FALSE); + + HID_PRT("HID Keyboard starts"); + + if (bt_initialize() != BT_ERROR_NONE) { + HID_PRT("bt_initialize() failed."); + return -1; + } + + if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) { + HID_PRT("bt_adapter_get_state() failed."); + return -1; + } + + /* Enable BT */ + if (bt_state == BT_ADAPTER_DISABLED) { + if (bt_adapter_set_state_changed_cb( + __bt_state_changed_impl, NULL) != BT_ERROR_NONE) { + HID_PRT("bt_adapter_set_state_changed_cb() failed."); + return -1; + } + + if (bt_adapter_enable() == BT_ERROR_NONE) { + HID_PRT("bt_adapter_state_changed_cb will be called."); + timeout_id = g_timeout_add(60000, + __bt_timeout_func, g_mainloop); + g_main_loop_run(g_mainloop); + g_source_remove(timeout_id); + } else { + HID_PRT("bt_adapter_enable() failed."); + return -1; + } + } else { + HID_PRT("BT was already enabled."); + } + + if (bt_state != BT_ADAPTER_ENABLED) { + HID_PRT("BT is not enabled."); + return -1; + } + + g_idle_add(__bt_start_service, NULL); + + key_io = g_io_channel_unix_new(fileno(stdin)); + + g_io_channel_set_encoding(key_io, NULL, NULL); + g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); + + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + __bt_key_event_cb, NULL); + + g_io_channel_unref(key_io); + + g_main_loop_run(g_mainloop); + + ret = bt_hid_device_deactivate(); + HID_PRT("returns %s\n", __bt_get_error_message(ret)); + + bt_deinitialize(); + + HID_PRT("HID Keyboard ends."); + return 0; +} diff --git a/tests/test/spp_test_addr b/tests/test/spp_test_addr new file mode 100644 index 0000000..5dd70bf --- /dev/null +++ b/tests/test/spp_test_addr @@ -0,0 +1 @@ +E4:FA:ED:75:D7:11 diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt new file mode 100644 index 0000000..cc88149 --- /dev/null +++ b/tests/unittest/CMakeLists.txt @@ -0,0 +1,21 @@ +SET(UNITTEST_NAME "tct-bluetooth-core") + +FILE(GLOB TEST_SRCS *.c) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/tests/unittest/include +) + +ADD_DEFINITIONS(-DMOBILE) + +SET(BLUETOOTH_MOCK "bluetooth-mock") +SET(BLUETOOTH_MOCK_SRCS + mock/bluetooth-mock.c) +ADD_LIBRARY(${BLUETOOTH_MOCK} SHARED ${BLUETOOTH_MOCK_SRCS}) + +ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TEST_SRCS}) +TARGET_LINK_LIBRARIES(${UNITTEST_NAME} + gtest + ${fw_name} +) diff --git a/tests/unittest/include/assert_local.h b/tests/unittest/include/assert_local.h new file mode 100644 index 0000000..492224a --- /dev/null +++ b/tests/unittest/include/assert_local.h @@ -0,0 +1,118 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 _ASSERT_H_ +#define _ASSERT_H_ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define assert(exp) \ + do { \ + if (!(exp)) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert Fail; Following expression is not true: %s\n", \ + __FILE__, __LINE__, #exp); \ + return 1; \ + } \ + } while (0) + +#define assert_eq(var, ref) \ + do { \ + if (var != ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_eq_no_return(var, ref) \ + do { \ + if (var != ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + +#define assert_neq_no_return(var, ref) \ + do { \ + if (var == ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + +#define assert_neq(var, ref) \ + do { \ + if (var == ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_gt(var, ref) \ + do { \ + if (var <= ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_geq(var, ref) \ + do { \ + if (var < ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than or equal to (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_lt(var, ref) \ + do { \ + if (var >= ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_leq(var, ref) \ + do { \ + if (var > ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than or equal to (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#ifdef __cplusplus +} +#endif +#endif // _ASSERT_H_ diff --git a/tests/unittest/include/tct_common.h b/tests/unittest/include/tct_common.h new file mode 100644 index 0000000..a8a7b4e --- /dev/null +++ b/tests/unittest/include/tct_common.h @@ -0,0 +1,219 @@ +// +// Copyright (c) 2020 Samsung Electronics Co., Ltd. +// +// 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 _TCT_COMMON_H_ +#define _TCT_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "assert_local.h" + +#include +#include +#include +#include +#include +#include +#include + +#define CONFIG_LINE_LEN_MAX 2048 +#define CONFIG_VALUE_LEN_MAX 1024 + +#define UTC_LOG "utc.log" +#define ERR_UTC_LOG "utc_error.log" +#define TC_RESULT "tc_result.log" + +FILE *g_fpLog; +FILE *g_fpLogDump; +int g_Serr; + +int old_Serr; + +#define FPRINTF(...) {\ + g_fpLog = fopen(ERR_LOG, "a");\ + fprintf(g_fpLog, __VA_ARGS__);\ + fclose(g_fpLog);\ +} + +#define DUMP_UTC_ERRLOG() {\ + g_Serr = dup(fileno(stderr));\ + g_fpLogDump = freopen(ERR_UTC_LOG, "w", stderr);\ + fflush(stderr);\ +} + +#define CLOSE_UTC_ERRLOG() {\ + if(g_fpLogDump) \ + {\ + if (g_Serr != -1)\ + {\ + old_Serr = fileno(stderr);\ + if(old_Serr != -1)\ + {\ + dup2(g_Serr, old_Serr);\ + }\ + close(g_Serr);\ + }\ + fclose(g_fpLogDump);\ + }\ +} + +#define PRINT_TC_RESULT(...) {\ + g_fpLog = fopen(TC_RESULT, "w");\ + fprintf(g_fpLog, __VA_ARGS__);\ + fclose(g_fpLog);\ +} + +#define FREE_MEMORY_TC(buffer) {\ + if ( buffer != NULL )\ +{\ + free(buffer);\ + buffer = NULL;\ +}\ +} + +#define IS_FEATURE_SUPPORTED(feature_name, featureFlag, ModuleName)\ +{\ + if ( !(TCTCheckSystemInfoFeatureSupported(feature_name, ModuleName)) )\ +{\ + featureFlag = false;\ +}\ + else\ +{\ + featureFlag = true;\ +}\ +} + +#define PRINT_RESULT(eCompare, eRetVal, API, Error) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ + else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ + return 1;\ +}\ +} + +#define PRINT_RESULT_NORETURN(eCompare, eRetVal, API, Error) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ + else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ +}\ +} + +#define PRINT_RESULT_CLEANUP(eCompare, eRetVal, API, Error, FreeResource) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ +else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ + FreeResource;\ + return 1;\ +}\ +} + +#define CHECK_VALUE_STRING(StringVariable, API) {\ + if ( StringVariable == NULL )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = value returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ + else if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] value returned = %s\\n", __LINE__, API_NAMESPACE, StringVariable);\ +}\ + free(StringVariable);\ + StringVariable = NULL;\ +} + +#define CHECK_VALUE_INT(Variable, API) {\ + if ( Variable == 0 )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = value returned is Zero\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ + else if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] value returned = %d\\n", __LINE__, API_NAMESPACE, Variable);\ +}\ +} + +#define CHECK_HANDLE(Handle, API) {\ + if ( Handle == NULL )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = Handle returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ +} + +#define FREE_MEMORY(buffer) {\ + if ( buffer != NULL )\ +{\ + free(buffer);\ + buffer = NULL;\ +}\ +} + +bool TCTCheckSystemInfoFeatureSupported(char* pszKey, char* pszModuleName){ + return false; +} +char* TCTSystemInfoGetError(int nRet){ + return NULL; +} +bool GetValueFromConfigFile(char* pstrKeyString, char* pstrValue, char* pstrModule){ + return false; +} +bool GetValueForTCTSetting(char* pstrKeyString, char* pstrValue, char* pstrModule){ + return false; +} + +//======================================================================================= +// changed logging macro +//======================================================================================= +#define dlog_print( type, tag, ...) do{ \ + fprintf(stdout, ##__VA_ARGS__ ); \ + fprintf(stdout, "\n" ); \ +} while(0) + +#define PRINT_UTC_LOG(...) do{ \ + fprintf(stdout, ##__VA_ARGS__ ); \ + fprintf(stdout, "\n" ); \ +} while(0) +//======================================================================================= + + +#ifdef __cplusplus +} +#endif + +#endif // _TCT_COMMON_H_ diff --git a/tests/unittest/include/testcase.h b/tests/unittest/include/testcase.h new file mode 100644 index 0000000..d828c90 --- /dev/null +++ b/tests/unittest/include/testcase.h @@ -0,0 +1,40 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 _TESTCASE_H_ +#define _TESTCASE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* pointer to startup/cleanup functions */ +typedef void (*void_fun_ptr)(void); + +/* pointer to testcase functions */ +typedef int (*tc_fun_ptr)(void); + +/* struct describing specific testcase */ +typedef struct testcase_s { + const char* name; + tc_fun_ptr function; + void_fun_ptr startup; + void_fun_ptr cleanup; +} testcase; + +#ifdef __cplusplus +} +#endif +#endif // _TESTCASE_H_ diff --git a/tests/unittest/mock/bluetooth-mock.c b/tests/unittest/mock/bluetooth-mock.c new file mode 100644 index 0000000..df900d8 --- /dev/null +++ b/tests/unittest/mock/bluetooth-mock.c @@ -0,0 +1,760 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + +static const char g_remote_addr[BLUETOOTH_ADDRESS_LENGTH] = {0x00, 0x02, 0x33, 0xA9, 0xE7, 0xF6}; +static const char g_uuid1[BLUETOOTH_UUID_STRING_MAX] = "00001105-0000-1000-8000-00805F9B34FB"; +static const char g_uuid2[BLUETOOTH_UUID_STRING_MAX] = "0000110A-0000-1000-8000-00805F9B34FB"; +static bluetooth_device_info_t g_device_info; +static bluetooth_le_device_info_t g_le_device_info; +static int g_adv_handle; +static guint g_adv_ind_data[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX] = {0x01, 0x02, 0x03}; +static guint g_scan_resp_data[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX] = {0x04, 0x05, 0x06}; + +static bluetooth_cb_func_ptr adapter_event_cb; +static bluetooth_cb_func_ptr le_adapter_event_cb; + +static gboolean __adapter_event_cb(gpointer user_data) +{ + bluetooth_event_param_t *bt_event = user_data; + adapter_event_cb(bt_event->event, bt_event, NULL); + g_free(bt_event); + return FALSE; +} + +static gboolean __adapter_le_event_cb(gpointer user_data) +{ + bluetooth_event_param_t *bt_event = user_data; + le_adapter_event_cb(bt_event->event, bt_event, NULL); + g_free(bt_event); + return FALSE; +} + +API int system_info_get_platform_bool(const char *key, bool *value) +{ + *value = true; + return SYSTEM_INFO_ERROR_NONE; +} + +API int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data) +{ + adapter_event_cb = callback_ptr; + + /* Initialize device info */ + memcpy(g_device_info.device_address.addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + strncpy(g_device_info.device_name.name, "Tizen", BLUETOOTH_DEVICE_NAME_LENGTH_MAX); + g_device_info.device_class.major_class = BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE; + g_device_info.device_class.minor_class = BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION; + g_device_info.device_class.service_class = BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER; + g_device_info.paired = TRUE; + g_device_info.connected = FALSE; + g_device_info.service_index = 2; + strncpy(g_device_info.uuids[0], g_uuid1, BLUETOOTH_UUID_STRING_MAX); + strncpy(g_device_info.uuids[1], g_uuid2, BLUETOOTH_UUID_STRING_MAX); + + /* Initialize le device info */ + memcpy(g_le_device_info.device_address.addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + g_le_device_info.addr_type = BLUETOOTH_BDADDR_LE_PUBLIC; + g_le_device_info.rssi = -70; + g_le_device_info.adv_ind_data.data_len = 3; + memcpy(g_le_device_info.adv_ind_data.data.data, g_adv_ind_data, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX); + g_le_device_info.scan_resp_data.data_len = 3; + memcpy(g_le_device_info.scan_resp_data.data.data, g_scan_resp_data, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX); + + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_unregister_callback(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_le_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data) +{ + le_adapter_event_cb = callback_ptr; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_le_unregister_callback(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_check_adapter(void) +{ + return BLUETOOTH_ADAPTER_ENABLED; +} + +API int bluetooth_get_local_address(bluetooth_device_address_t *local_address) +{ + memcpy(local_address->addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_local_name(bluetooth_device_name_t *local_name) +{ + memset(local_name->name, 0x00, sizeof(local_name->name)); + strncpy(local_name->name, "Tizen", sizeof(local_name->name)); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_local_name(const bluetooth_device_name_t *local_name) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_LOCAL_NAME_CHANGED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)local_name; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_start_le_discovery(void) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_le_device_info; + + g_timeout_add(500, __adapter_le_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_start_discovery(unsigned short max_response, + unsigned short discovery_duration, + unsigned int classOfDeviceMask) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_device_info; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr) +{ + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_service_used(const char *service_uuid, gboolean *used) +{ + *used = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data) +{ + char buf[] = {0x01, 0x02, 0x03, 0x04}; + memset(local_oob_data, 0x00, sizeof(bt_oob_data_t)); + + memcpy(local_oob_data->hash, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->hash_len = sizeof(buf); + memcpy(local_oob_data->randomizer, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->randomizer_len = sizeof(buf); + + memcpy(local_oob_data->hash256, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->hash256_len = sizeof(buf); + memcpy(local_oob_data->randomizer256, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->randomizer256_len = sizeof(buf); + + memcpy(local_oob_data->eir, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->eir_len = sizeof(buf); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_scan_parameters(bluetooth_le_scan_params_t *params) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_custom_advertising(int handle, gboolean enable, bluetooth_advertising_params_t *params) +{ + g_adv_handle = handle; + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_ADVERTISING_STARTED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)&g_adv_handle; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_scan_response_data(int handle, const bluetooth_scan_resp_data_t *value, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_advertising(int handle, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_advertising(gboolean *is_advertising) +{ + *is_advertising = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_stop_le_discovery(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_le_2m_phy_supported(gboolean *is_supported) +{ + *is_supported = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_le_coded_phy_supported(gboolean *is_supported) +{ + *is_supported = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_av_connect(bluetooth_device_address_t *remote_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_audio_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hf_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_telephony_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_media_player_change_property( + media_player_property_type type, + unsigned int value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_media_player_change_track( + media_metadata_attributes_t *metadata) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_telephony_init(bt_telephony_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_bond_device(const bluetooth_device_address_t *device_address) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_BONDING_FINISHED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_device_info; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_cancel_bonding(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_unbond_device(const bluetooth_device_address_t *device_address) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)&g_remote_addr; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_bonded_device_list(GPtrArray **dev_list) +{ +// g_ptr_array_add(*dev_list, &g_device_info); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_alias(const bluetooth_device_address_t *device_address, + const char *alias) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_authorize_device(const bluetooth_device_address_t *device_address, + gboolean authorized) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address, + bluetooth_service_type_t type, gboolean *is_connected) +{ + *is_connected = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_update_le_connection_mode(const bluetooth_device_address_t *address, + const bluetooth_le_connection_mode_t mode) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_discovering(void) +{ + return TRUE; +} + +API int bluetooth_cancel_discovery(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_connect_le(const bluetooth_device_address_t *device_address, + gboolean auto_connect, int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address, + int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_update_characteristic(int instance_id, + const bluetooth_gatt_server_update_value_t *value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_get_characteristics_property( + const char *address, + bt_gatt_handle_property_t *service_handle, + bt_gatt_handle_property_t *char_handle, + bt_gatt_char_property_t *char_property) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_get_char_descriptor_property( + const char *address, + bt_gatt_handle_property_t *service_handle, + bt_gatt_handle_property_t *char_handle, + bt_gatt_handle_property_t *descriptor_handle, + bt_gatt_char_descriptor_property_t *desc_prop) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_set_service_change_watcher( + const bluetooth_device_address_t *address, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_set_service_change_watcher( + const bluetooth_device_address_t *address, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_deinit(int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_init(int *instance_id, gatt_server_cb_func_ptr callback_ptr, + void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_service(const char *svc_uuid, int type, int numhandles, + int instance_id, int *service_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_new_characteristic(const char *char_uuid, + const bluetooth_gatt_server_attribute_params_t *param, + int *char_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_descriptor(const char *desc_uuid, bt_gatt_permission_t permissions, + int service_handle, int instance_id, int *descriptor_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_register_application(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_unregister_application(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_start_service(int service_handle, int instance_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_send_response(const bluetooth_gatt_server_response_params_t *param, + const bluetooth_gatt_att_data_t *value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_connect(const ipsp_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_disconnect(const ipsp_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_request_att_mtu(const bluetooth_device_address_t *device_address, unsigned int mtu) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_att_mtu(const bluetooth_device_address_t *device_address, + unsigned int *mtu) +{ + *mtu = 512; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_init( + int *client_id, + const bluetooth_device_address_t *address, + gatt_client_cb_func_ptr callback_ptr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_disconnect(unsigned int channel_id, + const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_connect(const char *app_handle, + bt_hdp_qos_type_t channel_type, + const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_activate(unsigned short data_type, + bt_hdp_role_type_t role, + bt_hdp_qos_type_t channel_type, + char **app_handle) +{ + *app_handle = g_strdup("1234"); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_deactivate(const char *app_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_send_data(unsigned int channel_id, + const char *buffer, + unsigned int size) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_connect(hid_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_disconnect(hid_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_activate(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_deactivate(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_connect(const char *remote_addr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_disconnect(const char *remote_addr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_send_mouse_event(const char *remote_addr, + hid_send_mouse_event_t send_event) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_send_key_event(const char *remote_addr, + hid_send_key_event_t send_event) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_reply_to_report(const char *remote_addr, + bt_hid_header_type_t htype, + bt_hid_param_type_t ptype, + const char *data, + unsigned int data_len) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address, + char **file_name_array) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_cancel_push(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_connect(const bluetooth_device_address_t *address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_disconnect(const bluetooth_device_address_t *address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_phonebook_size(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_phonebook(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_pull_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_list(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_list_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_pull_vcard(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_pull_vcard_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_phonebook_search(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_search_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_search_service(const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_create_socket(const char *uuid) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_remove_socket(int id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_listen_and_accept(int id, int max_pending_connection) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_connect( + const bluetooth_device_address_t *remote_bt_address, + const char *remote_uuid) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_disconnect(int socket_fd) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_write(int fd, const char *buf, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_init_without_agent(const char *dst_path) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_set_destination_path(const char *dst_path) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_cancel_transfer(int transfer_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_deinit_without_agent(void) +{ + return BLUETOOTH_ERROR_NONE; +} diff --git a/tests/unittest/tct-bluetooth-core.cpp b/tests/unittest/tct-bluetooth-core.cpp new file mode 100644 index 0000000..aff0030 --- /dev/null +++ b/tests/unittest/tct-bluetooth-core.cpp @@ -0,0 +1,89 @@ +// +// Copyright (c) 2020 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include +#include +#include "tct_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MOBILE +#include "tct-bluetooth-core_mobile.h" +#endif + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include +#include +#include + +#include + +TEST(bluetooth, bluetooth) +{ + char *pszGetTCName = NULL; + pszGetTCName = (char *)malloc(256); + memset(pszGetTCName, 0x00, 256); + strcpy(pszGetTCName, "utc_bluetooth"); + int i = 0, result = 0; + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName); + + int successCnt = 0; + int errorCnt = 0; + for (i = 0; tc_array[i].name; i++) { + if (0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName))) { + if (tc_array[i].startup) + tc_array[i].startup(); + + result = tc_array[i].function(); + if (result == 0) { + successCnt++; + } else { + dlog_print(DLOG_INFO, "NativeTCT", "[Error][%d] %s returns value = %d", i, tc_array[i].name, result); + errorCnt++; + } + + EXPECT_EQ(result, 0); + // ASSERT_EQ(result, 0); + if (tc_array[i].cleanup) + tc_array[i].cleanup(); + } else { + dlog_print(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name); + ASSERT_EQ(0, 1); + } + } + + dlog_print(DLOG_INFO, "NativeTCT", "=========================="); + dlog_print(DLOG_INFO, "NativeTCT", "Success [%4d / %4d]", successCnt, successCnt + errorCnt); + dlog_print(DLOG_INFO, "NativeTCT", "Error [%4d / %4d]", errorCnt, successCnt + errorCnt); + dlog_print(DLOG_INFO, "NativeTCT", "=========================="); + + FREE_MEMORY_TC(pszGetTCName); + return; +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/unittest/tct-bluetooth-core_mobile.h b/tests/unittest/tct-bluetooth-core_mobile.h new file mode 100644 index 0000000..dbcdae8 --- /dev/null +++ b/tests/unittest/tct-bluetooth-core_mobile.h @@ -0,0 +1,946 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 __TCT_BLUETOOTH_NATIVE_H__ +#define __TCT_BLUETOOTH_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_bluetooth_adapter_negative_startup(void); +extern void utc_bluetooth_adapter_negative_cleanup(void); +extern void utc_bluetooth_adapter_positive_startup(void); +extern void utc_bluetooth_adapter_positive_cleanup(void); +extern void utc_bluetooth_bt_audio_negative_startup(void); +extern void utc_bluetooth_bt_audio_negative_cleanup(void); +extern void utc_bluetooth_audio_positive_startup(void); +extern void utc_bluetooth_audio_positive_cleanup(void); +extern void utc_bluetooth_avrcp_callback_positive_startup(void); +extern void utc_bluetooth_avrcp_callback_positive_cleanup(void); +extern void utc_bluetooth_common_startup(void); +extern void utc_bluetooth_common_cleanup(void); +extern void utc_bluetooth_device_discovery_negative_startup(void); +extern void utc_bluetooth_device_discovery_negative_cleanup(void); +extern void utc_bluetooth_device_discovery_positive_startup(void); +extern void utc_bluetooth_device_discovery_positive_cleanup(void); +extern void utc_bluetooth_device_negative_startup(void); +extern void utc_bluetooth_device_negative_cleanup(void); +extern void utc_bluetooth_device_positive_startup(void); +extern void utc_bluetooth_device_positive_cleanup(void); +extern void utc_bluetooth_gatt_negative_startup(void); +extern void utc_bluetooth_gatt_negative_cleanup(void); +extern void utc_bluetooth_gatt_positive_startup(void); +extern void utc_bluetooth_gatt_positive_cleanup(void); +extern void utc_bluetooth_hdp_negative_startup(void); +extern void utc_bluetooth_hdp_negative_cleanup(void); +extern void utc_bluetooth_hdp_positive_startup(void); +extern void utc_bluetooth_hdp_positive_cleanup(void); +extern void utc_bluetooth_hid_negative_startup(void); +extern void utc_bluetooth_hid_negative_cleanup(void); +extern void utc_bluetooth_hid_positive_startup(void); +extern void utc_bluetooth_hid_positive_cleanup(void); +extern void utc_bluetooth_opp_client_negative_startup(void); +extern void utc_bluetooth_opp_client_negative_cleanup(void); +extern void utc_bluetooth_opp_client_positive_startup(void); +extern void utc_bluetooth_opp_client_positive_cleanup(void); +extern void utc_bluetooth_bt_opp_server_negative_startup(void); +extern void utc_bluetooth_bt_opp_server_negative_cleanup(void); +extern void utc_bluetooth_opp_server_positive_startup(void); +extern void utc_bluetooth_opp_server_positive_cleanup(void); +extern void utc_bluetooth_service_search_negative_startup(void); +extern void utc_bluetooth_service_search_negative_cleanup(void); +extern void utc_bluetooth_service_search_positive_startup(void); +extern void utc_bluetooth_service_search_positive_cleanup(void); +extern void utc_bluetooth_socket_negative_startup(void); +extern void utc_bluetooth_socket_negative_cleanup(void); +extern void utc_bluetooth_bt_socket_positive_startup(void); +extern void utc_bluetooth_bt_socket_positive_cleanup(void); +extern void utc_bluetooth_avrcp_control_positive_startup(void); +extern void utc_bluetooth_avrcp_control_positive_cleanup(void); +extern void utc_bluetooth_avrcp_control_negative_startup(void); +extern void utc_bluetooth_avrcp_control_negative_cleanup(void); + +extern int utc_bluetooth_bt_deinitialize_n(void); +extern int utc_bluetooth_bt_adapter_le_is_discovering_n(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_get_state_n(void); +extern int utc_bluetooth_bt_adapter_get_state_n1(void); +extern int utc_bluetooth_bt_adapter_get_address_n(void); +extern int utc_bluetooth_bt_adapter_get_address_n1(void); +extern int utc_bluetooth_bt_adapter_get_name_n(void); +extern int utc_bluetooth_bt_adapter_get_name_n1(void); +extern int utc_bluetooth_bt_adapter_get_visibility_n(void); +extern int utc_bluetooth_bt_adapter_get_visibility_n1(void); +extern int utc_bluetooth_bt_adapter_set_name_n(void); +extern int utc_bluetooth_bt_adapter_set_name_n1(void); +extern int utc_bluetooth_bt_adapter_unset_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_unset_name_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_is_service_used_n(void); +extern int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_le_create_advertiser_n(void); +extern int utc_bluetooth_bt_adapter_le_destroy_advertiser_n(void); +extern int utc_bluetooth_bt_adapter_le_stop_advertising_n(void); +extern int utc_bluetooth_bt_adapter_le_clear_advertising_data_n(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_get_bonded_device_info_n(void); +extern int utc_bluetooth_bt_adapter_free_device_info_n(void); +extern int utc_bluetooth_bt_adapter_set_remote_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_remove_remote_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_le_start_scan_n(void); +extern int utc_bluetooth_bt_adapter_le_stop_scan_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n(void); +extern int utc_bluetooth_bt_adapter_le_free_service_data_list_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n(void); +extern int utc_bluetooth_bt_adapter_le_start_advertising_new_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_connectable_n(void); +extern int utc_bluetooth_bt_get_uuid_name_n(void); +extern int utc_bluetooth_bt_adapter_le_set_scan_mode_n(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_ext_data_n(void); +extern int utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_create_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_destroy_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_register_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_unregister_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_type_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n(void); +extern int utc_bluetooth_bt_adapter_le_free_ibeacon_report_n(void); +extern int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n(void); +extern int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n(void); +extern int utc_bluetooth_bt_adapter_le_is_discovering_p(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_p1(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1(void); +extern int utc_bluetooth_bt_adapter_get_state_p(void); +extern int utc_bluetooth_bt_adapter_get_address_p(void); +extern int utc_bluetooth_bt_adapter_get_name_p(void); +extern int utc_bluetooth_bt_adapter_get_visibility_p(void); +extern int utc_bluetooth_bt_adapter_set_name_p(void); +extern int utc_bluetooth_bt_adapter_unset_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_unset_name_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_data_p(void); +extern int utc_bluetooth_bt_adapter_is_service_used_p(void); +extern int utc_bluetooth_bt_adapter_le_clear_advertising_data_p(void); +extern int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_le_create_advertiser_p(void); +extern int utc_bluetooth_bt_adapter_le_destroy_advertiser_p(void); +extern int utc_bluetooth_bt_adapter_le_stop_advertising_p(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_le_start_scan_p(void); +extern int utc_bluetooth_bt_adapter_le_stop_scan_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p(void); +extern int utc_bluetooth_bt_adapter_le_start_advertising_new_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_connectable_p(void); +extern int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p(void); +extern int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p(void); +extern int utc_bluetooth_bt_get_uuid_name_p(void); +extern int utc_bluetooth_bt_adapter_le_set_scan_mode_p(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_ext_data_p(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_type_p(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p(void); +extern int utc_bluetooth_bt_adapter_le_free_ibeacon_report_p(void); +extern int utc_bluetooth_bt_audio_connect_n(void); +extern int utc_bluetooth_bt_audio_disconnect_n(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_audio_deinitialize_n(void); +extern int utc_bluetooth_bt_audio_initialize_n(void); +extern int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_position_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_target_deinitialize_n(void); +extern int utc_bluetooth_bt_avrcp_target_initialize_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_player_state_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_position_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_track_n(void); +extern int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_position_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n(void); +extern int utc_bluetooth_bt_audio_initialize_p(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_audio_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_initialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_scan_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_player_state_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_position_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_track_p(void); +extern int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_scan_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_position_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_position_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p(void); +extern int utc_bluetooth_bt_initialize_p(void); +extern int utc_bluetooth_bt_deinitialize_p(void); +extern int utc_bluetooth_bt_adapter_stop_device_discovery_n1(void); +extern int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_start_device_discovery_n1(void); +extern int utc_bluetooth_bt_adapter_is_discovering_n1(void); +extern int utc_bluetooth_bt_adapter_is_discovering_n2(void); +extern int utc_bluetooth_bt_adapter_is_discovering_p(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_start_device_discovery_p(void); +extern int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_stop_device_discovery_p(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_n(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_n1(void); +extern int utc_bluetooth_bt_device_set_bond_destroyed_cb_n(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_n(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_n1(void); +extern int utc_bluetooth_bt_device_unset_bond_created_cb_n(void); +extern int utc_bluetooth_bt_device_unset_bond_destroyed_cb_n(void); +extern int utc_bluetooth_bt_device_unset_authorization_changed_cb_n(void); +extern int utc_bluetooth_bt_device_create_bond_n(void); +extern int utc_bluetooth_bt_device_create_bond_n1(void); +extern int utc_bluetooth_bt_device_cancel_bonding_n(void); +extern int utc_bluetooth_bt_device_destroy_bond_n(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_n1(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_n2(void); +extern int utc_bluetooth_bt_device_set_alias_n(void); +extern int utc_bluetooth_bt_device_set_alias_n2(void); +extern int utc_bluetooth_bt_device_set_authorization_n(void); +extern int utc_bluetooth_bt_device_set_authorization_n2(void); +extern int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n(void); +extern int utc_bluetooth_bt_device_is_profile_connected_n(void); +extern int utc_bluetooth_bt_device_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_device_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_device_foreach_connected_profiles_n(void); +extern int utc_bluetooth_bt_device_update_le_connection_mode_n(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_p(void); +extern int utc_bluetooth_bt_device_set_bond_destroyed_cb_p(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_p(void); +extern int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p(void); +extern int utc_bluetooth_bt_device_is_profile_connected_p(void); +extern int utc_bluetooth_bt_device_unset_bond_created_cb_p(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_p(void); +extern int utc_bluetooth_bt_device_unset_bond_destroyed_cb_p(void); +extern int utc_bluetooth_bt_device_unset_authorization_changed_cb_p(void); +extern int utc_bluetooth_bt_device_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_device_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_connect_n(void); +extern int utc_bluetooth_bt_gatt_disconnect_n(void); +extern int utc_bluetooth_bt_gatt_connect_n1(void); +extern int utc_bluetooth_bt_gatt_disconnect_n1(void); +extern int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_get_value_n(void); +extern int utc_bluetooth_bt_gatt_get_int_value_n(void); +extern int utc_bluetooth_bt_gatt_get_float_value_n(void); +extern int utc_bluetooth_bt_gatt_set_value_n(void); +extern int utc_bluetooth_bt_gatt_set_int_value_n(void); +extern int utc_bluetooth_bt_gatt_set_float_value_n(void); +extern int utc_bluetooth_bt_gatt_get_uuid_n(void); +extern int utc_bluetooth_bt_gatt_get_type_n(void); +extern int utc_bluetooth_bt_gatt_service_get_client_n(void); +extern int utc_bluetooth_bt_gatt_service_get_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_service_foreach_characteristics_n(void); +extern int utc_bluetooth_bt_gatt_service_get_included_service_n(void); +extern int utc_bluetooth_bt_gatt_service_foreach_included_services_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_service_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_properties_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_write_type_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_set_write_type_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_descriptor_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_client_create_n(void); +extern int utc_bluetooth_bt_gatt_client_destroy_n(void); +extern int utc_bluetooth_bt_gatt_client_get_remote_address_n(void); +extern int utc_bluetooth_bt_gatt_client_read_value_n(void); +extern int utc_bluetooth_bt_gatt_client_write_value_n(void); +extern int utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_get_service_n(void); +extern int utc_bluetooth_bt_gatt_client_foreach_services_n(void); +extern int utc_bluetooth_bt_gatt_service_destroy_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_destroy_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_destroy_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_permissions_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_permissions_n(void); +extern int utc_bluetooth_bt_gatt_service_create_n(void); +extern int utc_bluetooth_bt_gatt_service_add_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_service_add_included_service_n(void); +extern int utc_bluetooth_bt_gatt_service_get_server_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_create_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_add_descriptor_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_create_n(void); +extern int utc_bluetooth_bt_gatt_server_initialize_n(void); +extern int utc_bluetooth_bt_gatt_server_deinitialize_n(void); +extern int utc_bluetooth_bt_gatt_server_create_n(void); +extern int utc_bluetooth_bt_gatt_server_destroy_n(void); +extern int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n(void); +extern int utc_bluetooth_bt_gatt_server_get_service_n(void); +extern int utc_bluetooth_bt_gatt_server_get_device_mtu_n(void); +extern int utc_bluetooth_bt_gatt_server_foreach_services_n(void); +extern int utc_bluetooth_bt_gatt_server_register_service_n(void); +extern int utc_bluetooth_bt_gatt_server_unregister_service_n(void); +extern int utc_bluetooth_bt_gatt_server_unregister_all_services_n(void); +extern int utc_bluetooth_bt_gatt_server_start_n(void); +extern int utc_bluetooth_bt_gatt_server_send_response_n(void); +extern int utc_bluetooth_bt_gatt_client_set_service_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n(void); +extern int utc_bluetooth_bt_ipsp_initialize_n(void); +extern int utc_bluetooth_bt_ipsp_deinitialize_n(void); +extern int utc_bluetooth_bt_ipsp_connect_n(void); +extern int utc_bluetooth_bt_ipsp_disconnect_n(void); +extern int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_request_att_mtu_change_n(void); +extern int utc_bluetooth_bt_gatt_client_get_att_mtu_n(void); +extern int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_service_destroy_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_destroy_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_destroy_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_permissions_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_permissions_p(void); +extern int utc_bluetooth_bt_gatt_service_create_p(void); +extern int utc_bluetooth_bt_gatt_service_add_characteristic_p(void); +extern int utc_bluetooth_bt_gatt_service_add_included_service_p(void); +extern int utc_bluetooth_bt_gatt_service_get_server_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_create_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_add_descriptor_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_create_p(void); +extern int utc_bluetooth_bt_gatt_server_initialize_p(void); +extern int utc_bluetooth_bt_gatt_server_deinitialize_p(void); +extern int utc_bluetooth_bt_gatt_server_create_p(void); +extern int utc_bluetooth_bt_gatt_server_destroy_p(void); +extern int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_get_service_p(void); +extern int utc_bluetooth_bt_gatt_server_foreach_services_p(void); +extern int utc_bluetooth_bt_gatt_server_register_service_p(void); +extern int utc_bluetooth_bt_gatt_server_unregister_service_p(void); +extern int utc_bluetooth_bt_gatt_server_unregister_all_services_p(void); +extern int utc_bluetooth_bt_gatt_server_start_p(void); +extern int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_n1(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_hdp_disconnect_n(void); +extern int utc_bluetooth_bt_hdp_connect_to_source_n(void); +extern int utc_bluetooth_bt_hdp_connect_to_source_n2(void); +extern int utc_bluetooth_bt_hdp_register_sink_app_n(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_n(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_n1(void); +extern int utc_bluetooth_bt_hdp_send_data_n(void); +extern int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_hdp_unset_data_received_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_p(void); +extern int utc_bluetooth_bt_hdp_unset_data_received_cb_p(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_p(void); +extern int utc_bluetooth_bt_hdp_register_sink_app_p(void); +extern int utc_bluetooth_bt_hid_host_initialize_n(void); +extern int utc_bluetooth_bt_hid_host_initialize_n1(void); +extern int utc_bluetooth_bt_hid_host_connect_n(void); +extern int utc_bluetooth_bt_hid_host_disconnect_n(void); +extern int utc_bluetooth_bt_hid_host_deinitialize_n(void); +extern int utc_bluetooth_bt_hid_host_initialize_p(void); +extern int utc_bluetooth_bt_hid_host_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_client_initialize_n(void); +extern int utc_bluetooth_bt_opp_client_deinitialize_n(void); +extern int utc_bluetooth_bt_opp_client_add_file_n(void); +extern int utc_bluetooth_bt_opp_client_add_file_n1(void); +extern int utc_bluetooth_bt_opp_client_clear_files_n(void); +extern int utc_bluetooth_bt_opp_client_push_files_n(void); +extern int utc_bluetooth_bt_opp_client_cancel_push_n(void); +extern int utc_bluetooth_bt_opp_client_initialize_p(void); +extern int utc_bluetooth_bt_opp_client_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_client_clear_files_p(void); +extern int utc_bluetooth_bt_opp_server_accept_n(void); +extern int utc_bluetooth_bt_opp_server_accept_n1(void); +extern int utc_bluetooth_bt_opp_server_accept_n2(void); +extern int utc_bluetooth_bt_opp_server_reject_n(void); +extern int utc_bluetooth_bt_opp_server_reject_n1(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n1(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n2(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_n(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_n1(void); +extern int utc_bluetooth_bt_opp_server_cancel_transfer_n(void); +extern int utc_bluetooth_bt_opp_server_cancel_transfer_n1(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_p(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_server_set_destination_p(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_n(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_n1(void); +extern int utc_bluetooth_bt_device_unset_service_searched_cb_n(void); +extern int utc_bluetooth_bt_device_start_service_search_n(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_p(void); +extern int utc_bluetooth_bt_device_unset_service_searched_cb_p(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_n(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_n1(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_socket_unset_data_received_cb_n(void); +extern int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_n1(void); +extern int utc_bluetooth_bt_socket_destroy_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_connect_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_disconnect_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_send_data_n(void); +extern int utc_bluetooth_bt_socket_set_connection_requested_cb_n(void); +extern int utc_bluetooth_bt_socket_unset_connection_requested_cb_n(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_p(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_destroy_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_unset_data_received_cb_p(void); +extern int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_socket_set_connection_requested_cb_p(void); +extern int utc_bluetooth_bt_socket_unset_connection_requested_cb_p(void); +extern int utc_bluetooth_bt_avrcp_control_initialize_p(void); +extern int utc_bluetooth_bt_avrcp_control_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_control_connect_n(void); +extern int utc_bluetooth_bt_avrcp_control_disconnect_n(void); +extern int utc_bluetooth_bt_avrcp_control_send_player_command_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_position_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_play_status_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_track_info_n(void); +extern int utc_bluetooth_bt_avrcp_control_free_track_info_n(void); +extern int utc_bluetooth_bt_device_create_bond_p(void); +extern int utc_bluetooth_bt_device_destroy_bond_p(void); + +testcase tc_array[] = { + {"utc_bluetooth_bt_deinitialize_n",utc_bluetooth_bt_deinitialize_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_discovering_n",utc_bluetooth_bt_adapter_le_is_discovering_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_n",utc_bluetooth_bt_adapter_set_state_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_n1",utc_bluetooth_bt_adapter_set_state_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_n",utc_bluetooth_bt_adapter_set_name_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_n1",utc_bluetooth_bt_adapter_set_name_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_n",utc_bluetooth_bt_adapter_get_state_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_n1",utc_bluetooth_bt_adapter_get_state_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_n",utc_bluetooth_bt_adapter_get_address_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_n1",utc_bluetooth_bt_adapter_get_address_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_n",utc_bluetooth_bt_adapter_get_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_n1",utc_bluetooth_bt_adapter_get_name_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_n",utc_bluetooth_bt_adapter_get_visibility_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_n1",utc_bluetooth_bt_adapter_get_visibility_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_n",utc_bluetooth_bt_adapter_set_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_n1",utc_bluetooth_bt_adapter_set_name_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_state_changed_cb_n",utc_bluetooth_bt_adapter_unset_state_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_name_changed_cb_n",utc_bluetooth_bt_adapter_unset_name_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n",utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_data_n",utc_bluetooth_bt_adapter_get_local_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_service_used_n",utc_bluetooth_bt_adapter_is_service_used_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n",utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_create_advertiser_n",utc_bluetooth_bt_adapter_le_create_advertiser_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_destroy_advertiser_n",utc_bluetooth_bt_adapter_le_destroy_advertiser_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_advertising_n",utc_bluetooth_bt_adapter_le_stop_advertising_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_clear_advertising_data_n",utc_bluetooth_bt_adapter_le_clear_advertising_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n",utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_bonded_device_info_n",utc_bluetooth_bt_adapter_get_bonded_device_info_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_free_device_info_n",utc_bluetooth_bt_adapter_free_device_info_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_remote_oob_data_n",utc_bluetooth_bt_adapter_set_remote_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_remove_remote_oob_data_n",utc_bluetooth_bt_adapter_remove_remote_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_scan_n",utc_bluetooth_bt_adapter_le_start_scan_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_scan_n",utc_bluetooth_bt_adapter_le_stop_scan_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n",utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n",utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_service_data_list_n",utc_bluetooth_bt_adapter_le_free_service_data_list_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n",utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n",utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_n",utc_bluetooth_bt_adapter_le_add_advertising_service_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_n",utc_bluetooth_bt_adapter_le_set_advertising_appearance_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_n",utc_bluetooth_bt_adapter_le_set_advertising_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_advertising_new_n",utc_bluetooth_bt_adapter_le_start_advertising_new_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_mode_n",utc_bluetooth_bt_adapter_le_set_advertising_mode_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_connectable_n",utc_bluetooth_bt_adapter_le_set_advertising_connectable_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_get_uuid_name_n",utc_bluetooth_bt_get_uuid_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_scan_mode_n",utc_bluetooth_bt_adapter_le_set_scan_mode_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_ext_data_n",utc_bluetooth_bt_adapter_get_local_oob_ext_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n",utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_create_n",utc_bluetooth_bt_adapter_le_scan_filter_create_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_destroy_n",utc_bluetooth_bt_adapter_le_scan_filter_destroy_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n",utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n",utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n",utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_register_n",utc_bluetooth_bt_adapter_le_scan_filter_register_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_unregister_n",utc_bluetooth_bt_adapter_le_scan_filter_unregister_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n",utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_type_n",utc_bluetooth_bt_adapter_le_scan_filter_set_type_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n",utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_ibeacon_report_n",utc_bluetooth_bt_adapter_le_free_ibeacon_report_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n",utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n",utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_discovering_p",utc_bluetooth_bt_adapter_le_is_discovering_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_p",utc_bluetooth_bt_adapter_set_state_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_p",utc_bluetooth_bt_adapter_set_name_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_p1",utc_bluetooth_bt_adapter_set_name_changed_cb_p1,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_p",utc_bluetooth_bt_adapter_get_state_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_p",utc_bluetooth_bt_adapter_get_address_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_p",utc_bluetooth_bt_adapter_get_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_p",utc_bluetooth_bt_adapter_get_visibility_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_p",utc_bluetooth_bt_adapter_set_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_state_changed_cb_p",utc_bluetooth_bt_adapter_unset_state_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_name_changed_cb_p",utc_bluetooth_bt_adapter_unset_name_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p",utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_data_p",utc_bluetooth_bt_adapter_get_local_oob_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_is_service_used_p",utc_bluetooth_bt_adapter_is_service_used_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_clear_advertising_data_p",utc_bluetooth_bt_adapter_le_clear_advertising_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p",utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_create_advertiser_p",utc_bluetooth_bt_adapter_le_create_advertiser_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_destroy_advertiser_p",utc_bluetooth_bt_adapter_le_destroy_advertiser_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_advertising_p",utc_bluetooth_bt_adapter_le_stop_advertising_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p",utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_scan_p",utc_bluetooth_bt_adapter_le_start_scan_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_scan_p",utc_bluetooth_bt_adapter_le_stop_scan_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_p",utc_bluetooth_bt_adapter_le_add_advertising_service_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_p",utc_bluetooth_bt_adapter_le_set_advertising_appearance_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_p",utc_bluetooth_bt_adapter_le_set_advertising_device_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_advertising_new_p",utc_bluetooth_bt_adapter_le_start_advertising_new_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_mode_p",utc_bluetooth_bt_adapter_le_set_advertising_mode_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_connectable_p",utc_bluetooth_bt_adapter_le_set_advertising_connectable_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p",utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p",utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_get_uuid_name_p",utc_bluetooth_bt_get_uuid_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_scan_mode_p",utc_bluetooth_bt_adapter_le_set_scan_mode_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_ext_data_p",utc_bluetooth_bt_adapter_get_local_oob_ext_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_type_p",utc_bluetooth_bt_adapter_le_scan_filter_set_type_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p",utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_ibeacon_report_p",utc_bluetooth_bt_adapter_le_free_ibeacon_report_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_audio_connect_n",utc_bluetooth_bt_audio_connect_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_disconnect_n",utc_bluetooth_bt_audio_disconnect_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_n",utc_bluetooth_bt_audio_set_connection_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1",utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_deinitialize_n",utc_bluetooth_bt_audio_deinitialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_initialize_n",utc_bluetooth_bt_audio_initialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n",utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n",utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_position_changed_cb_n",utc_bluetooth_bt_avrcp_set_position_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n",utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n",utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_deinitialize_n",utc_bluetooth_bt_avrcp_target_deinitialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_initialize_n",utc_bluetooth_bt_avrcp_target_initialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n",utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_player_state_n",utc_bluetooth_bt_avrcp_target_notify_player_state_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_position_n",utc_bluetooth_bt_avrcp_target_notify_position_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n",utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_scan_mode_n",utc_bluetooth_bt_avrcp_target_notify_scan_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n",utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_track_n",utc_bluetooth_bt_avrcp_target_notify_track_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n",utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_position_changed_cb_n",utc_bluetooth_bt_avrcp_unset_position_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n",utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n",utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_initialize_p",utc_bluetooth_bt_audio_initialize_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_p",utc_bluetooth_bt_audio_set_connection_state_changed_cb_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p",utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_deinitialize_p",utc_bluetooth_bt_audio_deinitialize_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_initialize_p",utc_bluetooth_bt_avrcp_target_initialize_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_deinitialize_p",utc_bluetooth_bt_avrcp_target_deinitialize_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p",utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p",utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p",utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_scan_mode_p",utc_bluetooth_bt_avrcp_target_notify_scan_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_player_state_p",utc_bluetooth_bt_avrcp_target_notify_player_state_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_position_p",utc_bluetooth_bt_avrcp_target_notify_position_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_track_p",utc_bluetooth_bt_avrcp_target_notify_track_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p",utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p",utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p",utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p",utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p",utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p",utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_scan_mode_changed_p",utc_bluetooth_bt_avrcp_set_scan_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p",utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_position_changed_cb_p",utc_bluetooth_bt_avrcp_set_position_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_position_changed_cb_p",utc_bluetooth_bt_avrcp_unset_position_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p",utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p",utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p",utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p",utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_initialize_p",utc_bluetooth_bt_initialize_p,utc_bluetooth_common_startup,utc_bluetooth_common_cleanup}, + {"utc_bluetooth_bt_deinitialize_p",utc_bluetooth_bt_deinitialize_p,utc_bluetooth_common_startup,utc_bluetooth_common_cleanup}, + {"utc_bluetooth_bt_adapter_stop_device_discovery_n1",utc_bluetooth_bt_adapter_stop_device_discovery_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1",utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_start_device_discovery_n1",utc_bluetooth_bt_adapter_start_device_discovery_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_n1",utc_bluetooth_bt_adapter_is_discovering_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_n2",utc_bluetooth_bt_adapter_is_discovering_n2,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_p",utc_bluetooth_bt_adapter_is_discovering_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_start_device_discovery_p",utc_bluetooth_bt_adapter_start_device_discovery_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p",utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_stop_device_discovery_p",utc_bluetooth_bt_adapter_stop_device_discovery_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_n",utc_bluetooth_bt_device_set_bond_created_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_n1",utc_bluetooth_bt_device_set_bond_created_cb_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_destroyed_cb_n",utc_bluetooth_bt_device_set_bond_destroyed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_n",utc_bluetooth_bt_device_set_authorization_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_n1",utc_bluetooth_bt_device_set_authorization_changed_cb_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_created_cb_n",utc_bluetooth_bt_device_unset_bond_created_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_destroyed_cb_n",utc_bluetooth_bt_device_unset_bond_destroyed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_authorization_changed_cb_n",utc_bluetooth_bt_device_unset_authorization_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_n",utc_bluetooth_bt_device_create_bond_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_n1",utc_bluetooth_bt_device_create_bond_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_cancel_bonding_n",utc_bluetooth_bt_device_cancel_bonding_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_destroy_bond_n",utc_bluetooth_bt_device_destroy_bond_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_n1",utc_bluetooth_bt_adapter_foreach_bonded_device_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_n2",utc_bluetooth_bt_adapter_foreach_bonded_device_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_alias_n",utc_bluetooth_bt_device_set_alias_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_alias_n2",utc_bluetooth_bt_device_set_alias_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_n",utc_bluetooth_bt_device_set_authorization_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_n2",utc_bluetooth_bt_device_set_authorization_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n",utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_is_profile_connected_n",utc_bluetooth_bt_device_is_profile_connected_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_connection_state_changed_cb_n",utc_bluetooth_bt_device_set_connection_state_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_connection_state_changed_cb_n",utc_bluetooth_bt_device_unset_connection_state_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_foreach_connected_profiles_n",utc_bluetooth_bt_device_foreach_connected_profiles_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_update_le_connection_mode_n",utc_bluetooth_bt_device_update_le_connection_mode_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_p",utc_bluetooth_bt_device_set_bond_created_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_bond_destroyed_cb_p",utc_bluetooth_bt_device_set_bond_destroyed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_p",utc_bluetooth_bt_device_set_authorization_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p",utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_is_profile_connected_p",utc_bluetooth_bt_device_is_profile_connected_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_created_cb_p",utc_bluetooth_bt_device_unset_bond_created_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_p",utc_bluetooth_bt_adapter_foreach_bonded_device_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_destroyed_cb_p",utc_bluetooth_bt_device_unset_bond_destroyed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_authorization_changed_cb_p",utc_bluetooth_bt_device_unset_authorization_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_connection_state_changed_cb_p",utc_bluetooth_bt_device_set_connection_state_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_connection_state_changed_cb_p",utc_bluetooth_bt_device_unset_connection_state_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_gatt_connect_n",utc_bluetooth_bt_gatt_connect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_disconnect_n",utc_bluetooth_bt_gatt_disconnect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_connect_n1",utc_bluetooth_bt_gatt_connect_n1,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_disconnect_n1",utc_bluetooth_bt_gatt_disconnect_n1,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n",utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n",utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_value_n",utc_bluetooth_bt_gatt_get_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_int_value_n",utc_bluetooth_bt_gatt_get_int_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_float_value_n",utc_bluetooth_bt_gatt_get_float_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_value_n",utc_bluetooth_bt_gatt_set_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_int_value_n",utc_bluetooth_bt_gatt_set_int_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_float_value_n",utc_bluetooth_bt_gatt_set_float_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_uuid_n",utc_bluetooth_bt_gatt_get_uuid_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_type_n",utc_bluetooth_bt_gatt_get_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_client_n",utc_bluetooth_bt_gatt_service_get_client_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_characteristic_n",utc_bluetooth_bt_gatt_service_get_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_foreach_characteristics_n",utc_bluetooth_bt_gatt_service_foreach_characteristics_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_included_service_n",utc_bluetooth_bt_gatt_service_get_included_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_foreach_included_services_n",utc_bluetooth_bt_gatt_service_foreach_included_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_service_n",utc_bluetooth_bt_gatt_characteristic_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_properties_n",utc_bluetooth_bt_gatt_characteristic_get_properties_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_write_type_n",utc_bluetooth_bt_gatt_characteristic_get_write_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_set_write_type_n",utc_bluetooth_bt_gatt_characteristic_set_write_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_descriptor_n",utc_bluetooth_bt_gatt_characteristic_get_descriptor_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n",utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_characteristic_n",utc_bluetooth_bt_gatt_descriptor_get_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_create_n",utc_bluetooth_bt_gatt_client_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_destroy_n",utc_bluetooth_bt_gatt_client_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_remote_address_n",utc_bluetooth_bt_gatt_client_get_remote_address_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_read_value_n",utc_bluetooth_bt_gatt_client_read_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_write_value_n",utc_bluetooth_bt_gatt_client_write_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n",utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_service_n",utc_bluetooth_bt_gatt_client_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_foreach_services_n",utc_bluetooth_bt_gatt_client_foreach_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_destroy_n",utc_bluetooth_bt_gatt_service_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_destroy_n",utc_bluetooth_bt_gatt_characteristic_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_destroy_n",utc_bluetooth_bt_gatt_descriptor_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_permissions_n",utc_bluetooth_bt_gatt_characteristic_get_permissions_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_permissions_n",utc_bluetooth_bt_gatt_descriptor_get_permissions_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_create_n",utc_bluetooth_bt_gatt_service_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_characteristic_n",utc_bluetooth_bt_gatt_service_add_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_included_service_n",utc_bluetooth_bt_gatt_service_add_included_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_server_n",utc_bluetooth_bt_gatt_service_get_server_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_create_n",utc_bluetooth_bt_gatt_characteristic_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_add_descriptor_n",utc_bluetooth_bt_gatt_characteristic_add_descriptor_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_create_n",utc_bluetooth_bt_gatt_descriptor_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_initialize_n",utc_bluetooth_bt_gatt_server_initialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_deinitialize_n",utc_bluetooth_bt_gatt_server_deinitialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_create_n",utc_bluetooth_bt_gatt_server_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_destroy_n",utc_bluetooth_bt_gatt_server_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n",utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n",utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n",utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n",utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_service_n",utc_bluetooth_bt_gatt_server_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_device_mtu_n",utc_bluetooth_bt_gatt_server_get_device_mtu_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_foreach_services_n",utc_bluetooth_bt_gatt_server_foreach_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_register_service_n",utc_bluetooth_bt_gatt_server_register_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_service_n",utc_bluetooth_bt_gatt_server_unregister_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_all_services_n",utc_bluetooth_bt_gatt_server_unregister_all_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_start_n",utc_bluetooth_bt_gatt_server_start_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_send_response_n",utc_bluetooth_bt_gatt_server_send_response_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_service_changed_cb_n",utc_bluetooth_bt_gatt_client_set_service_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_initialize_n",utc_bluetooth_bt_ipsp_initialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_deinitialize_n",utc_bluetooth_bt_ipsp_deinitialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_connect_n",utc_bluetooth_bt_ipsp_connect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_disconnect_n",utc_bluetooth_bt_ipsp_disconnect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n",utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n",utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_request_att_mtu_change_n",utc_bluetooth_bt_gatt_client_request_att_mtu_change_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_att_mtu_n",utc_bluetooth_bt_gatt_client_get_att_mtu_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n",utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p",utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p",utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_destroy_p",utc_bluetooth_bt_gatt_service_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_destroy_p",utc_bluetooth_bt_gatt_characteristic_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_destroy_p",utc_bluetooth_bt_gatt_descriptor_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_permissions_p",utc_bluetooth_bt_gatt_characteristic_get_permissions_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_permissions_p",utc_bluetooth_bt_gatt_descriptor_get_permissions_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_create_p",utc_bluetooth_bt_gatt_service_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_characteristic_p",utc_bluetooth_bt_gatt_service_add_characteristic_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_included_service_p",utc_bluetooth_bt_gatt_service_add_included_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_server_p",utc_bluetooth_bt_gatt_service_get_server_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_create_p",utc_bluetooth_bt_gatt_characteristic_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_add_descriptor_p",utc_bluetooth_bt_gatt_characteristic_add_descriptor_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_create_p",utc_bluetooth_bt_gatt_descriptor_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_initialize_p",utc_bluetooth_bt_gatt_server_initialize_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_deinitialize_p",utc_bluetooth_bt_gatt_server_deinitialize_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_create_p",utc_bluetooth_bt_gatt_server_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_destroy_p",utc_bluetooth_bt_gatt_server_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p",utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p",utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p",utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_service_p",utc_bluetooth_bt_gatt_server_get_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_foreach_services_p",utc_bluetooth_bt_gatt_server_foreach_services_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_register_service_p",utc_bluetooth_bt_gatt_server_register_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_service_p",utc_bluetooth_bt_gatt_server_unregister_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_all_services_p",utc_bluetooth_bt_gatt_server_unregister_all_services_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_start_p",utc_bluetooth_bt_gatt_server_start_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p",utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p",utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p",utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p",utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_n",utc_bluetooth_bt_hdp_set_data_received_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_n1",utc_bluetooth_bt_hdp_set_data_received_cb_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_disconnect_n",utc_bluetooth_bt_hdp_disconnect_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_connect_to_source_n",utc_bluetooth_bt_hdp_connect_to_source_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_connect_to_source_n2",utc_bluetooth_bt_hdp_connect_to_source_n2,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_register_sink_app_n",utc_bluetooth_bt_hdp_register_sink_app_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_n",utc_bluetooth_bt_hdp_unregister_sink_app_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_n1",utc_bluetooth_bt_hdp_unregister_sink_app_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_send_data_n",utc_bluetooth_bt_hdp_send_data_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n",utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unset_data_received_cb_n",utc_bluetooth_bt_hdp_unset_data_received_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_p",utc_bluetooth_bt_hdp_set_data_received_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unset_data_received_cb_p",utc_bluetooth_bt_hdp_unset_data_received_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p",utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_p",utc_bluetooth_bt_hdp_unregister_sink_app_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_register_sink_app_p",utc_bluetooth_bt_hdp_register_sink_app_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_n",utc_bluetooth_bt_hid_host_initialize_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_n1",utc_bluetooth_bt_hid_host_initialize_n1,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_connect_n",utc_bluetooth_bt_hid_host_connect_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_disconnect_n",utc_bluetooth_bt_hid_host_disconnect_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_deinitialize_n",utc_bluetooth_bt_hid_host_deinitialize_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_p",utc_bluetooth_bt_hid_host_initialize_p,utc_bluetooth_hid_positive_startup,utc_bluetooth_hid_positive_cleanup}, + {"utc_bluetooth_bt_hid_host_deinitialize_p",utc_bluetooth_bt_hid_host_deinitialize_p,utc_bluetooth_hid_positive_startup,utc_bluetooth_hid_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_initialize_n",utc_bluetooth_bt_opp_client_initialize_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_deinitialize_n",utc_bluetooth_bt_opp_client_deinitialize_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_add_file_n",utc_bluetooth_bt_opp_client_add_file_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_add_file_n1",utc_bluetooth_bt_opp_client_add_file_n1,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_clear_files_n",utc_bluetooth_bt_opp_client_clear_files_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_push_files_n",utc_bluetooth_bt_opp_client_push_files_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_cancel_push_n",utc_bluetooth_bt_opp_client_cancel_push_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_initialize_p",utc_bluetooth_bt_opp_client_initialize_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_deinitialize_p",utc_bluetooth_bt_opp_client_deinitialize_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_clear_files_p",utc_bluetooth_bt_opp_client_clear_files_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n",utc_bluetooth_bt_opp_server_accept_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n1",utc_bluetooth_bt_opp_server_accept_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n2",utc_bluetooth_bt_opp_server_accept_n2,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_reject_n",utc_bluetooth_bt_opp_server_reject_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_reject_n1",utc_bluetooth_bt_opp_server_reject_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n",utc_bluetooth_bt_opp_server_set_destination_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n1",utc_bluetooth_bt_opp_server_set_destination_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n2",utc_bluetooth_bt_opp_server_set_destination_n2,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_n",utc_bluetooth_bt_opp_server_initialize_by_connection_request_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1",utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_n",utc_bluetooth_bt_opp_server_deinitialize_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_n1",utc_bluetooth_bt_opp_server_deinitialize_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_cancel_transfer_n",utc_bluetooth_bt_opp_server_cancel_transfer_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_cancel_transfer_n1",utc_bluetooth_bt_opp_server_cancel_transfer_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_p",utc_bluetooth_bt_opp_server_initialize_by_connection_request_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_p",utc_bluetooth_bt_opp_server_deinitialize_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_p",utc_bluetooth_bt_opp_server_set_destination_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_n",utc_bluetooth_bt_device_set_service_searched_cb_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_n1",utc_bluetooth_bt_device_set_service_searched_cb_n1,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_service_searched_cb_n",utc_bluetooth_bt_device_unset_service_searched_cb_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_start_service_search_n",utc_bluetooth_bt_device_start_service_search_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_p",utc_bluetooth_bt_device_set_service_searched_cb_p,utc_bluetooth_service_search_positive_startup,utc_bluetooth_service_search_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_service_searched_cb_p",utc_bluetooth_bt_device_unset_service_searched_cb_p,utc_bluetooth_service_search_positive_startup,utc_bluetooth_service_search_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_n",utc_bluetooth_bt_socket_set_data_received_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_n1",utc_bluetooth_bt_socket_set_data_received_cb_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_n",utc_bluetooth_bt_socket_set_connection_state_changed_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1",utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_data_received_cb_n",utc_bluetooth_bt_socket_unset_data_received_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n",utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_n",utc_bluetooth_bt_socket_create_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_n1",utc_bluetooth_bt_socket_create_rfcomm_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_destroy_rfcomm_n",utc_bluetooth_bt_socket_destroy_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n",utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_connect_rfcomm_n",utc_bluetooth_bt_socket_connect_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_disconnect_rfcomm_n",utc_bluetooth_bt_socket_disconnect_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_send_data_n",utc_bluetooth_bt_socket_send_data_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_requested_cb_n",utc_bluetooth_bt_socket_set_connection_requested_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_requested_cb_n",utc_bluetooth_bt_socket_unset_connection_requested_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_p",utc_bluetooth_bt_socket_set_data_received_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_p",utc_bluetooth_bt_socket_set_connection_state_changed_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_p",utc_bluetooth_bt_socket_create_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p",utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_destroy_rfcomm_p",utc_bluetooth_bt_socket_destroy_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_data_received_cb_p",utc_bluetooth_bt_socket_unset_data_received_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p",utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_requested_cb_p",utc_bluetooth_bt_socket_set_connection_requested_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_requested_cb_p",utc_bluetooth_bt_socket_unset_connection_requested_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_initialize_p",utc_bluetooth_bt_avrcp_control_initialize_p,utc_bluetooth_avrcp_control_positive_startup,utc_bluetooth_avrcp_control_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_deinitialize_p",utc_bluetooth_bt_avrcp_control_deinitialize_p,utc_bluetooth_avrcp_control_positive_startup,utc_bluetooth_avrcp_control_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_connect_n",utc_bluetooth_bt_avrcp_control_connect_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_disconnect_n",utc_bluetooth_bt_avrcp_control_disconnect_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_send_player_command_n",utc_bluetooth_bt_avrcp_control_send_player_command_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_equalizer_state_n",utc_bluetooth_bt_avrcp_control_set_equalizer_state_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_equalizer_state_n",utc_bluetooth_bt_avrcp_control_get_equalizer_state_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_repeat_mode_n",utc_bluetooth_bt_avrcp_control_set_repeat_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_repeat_mode_n",utc_bluetooth_bt_avrcp_control_get_repeat_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n",utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n",utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_scan_mode_n",utc_bluetooth_bt_avrcp_control_set_scan_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_scan_mode_n",utc_bluetooth_bt_avrcp_control_get_scan_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_position_n",utc_bluetooth_bt_avrcp_control_get_position_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_play_status_n",utc_bluetooth_bt_avrcp_control_get_play_status_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_track_info_n",utc_bluetooth_bt_avrcp_control_get_track_info_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_free_track_info_n",utc_bluetooth_bt_avrcp_control_free_track_info_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_p",utc_bluetooth_bt_device_create_bond_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_destroy_bond_p",utc_bluetooth_bt_device_destroy_bond_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_BLUETOOTH_NATIVE_H__ diff --git a/tests/unittest/utc_bluetooth_adapter_negative.c b/tests/unittest/utc_bluetooth_adapter_negative.c new file mode 100644 index 0000000..a1b18d3 --- /dev/null +++ b/tests/unittest/utc_bluetooth_adapter_negative.c @@ -0,0 +1,1792 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include +#include + +//& set: BluetoothAdapterNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool le_supported = false; +static bool bt_supported = false; +static bool oob_supported = false; +static bool le_50_supported = false; + +/** + * @function utc_bluetooth_adapter_negative_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV + bt_supported = true; + le_supported = true; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + oob_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.oob", &oob_supported); + + le_50_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.5_0", &le_50_supported); +#endif + if (bt_supported) { + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_adapter_negative_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** +* @testcase utc_bluetooth_bt_deinitialize_n +* @since_tizen 2.3 +* @description Call to de-initialize Bluetooth and related resources twice if BT is supported +* otherwise just call to de-initialize Bluetooth once. check the "ret" flag with BT_ERROR_NOT_INITIALIZED +* if BT is already supported otherwise check with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to de-Initialize Bluetooth and to release related resources. +*/ +int utc_bluetooth_bt_deinitialize_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#if defined(MOBILE) || defined(TV) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_is_discovering_n +* @since_tizen 2.3 +* @description Call to check whether LE device discovery is in progress or not. check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if LE is supported otherwise check with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to check whether LE device discovery is in progress. +*/ +int utc_bluetooth_bt_adapter_le_is_discovering_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_is_discovering(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_discovering(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_n +* @since_tizen 2.3 +* @description Call to register callback as "NULL"; to be invoked when bluetooth adapter's state changes and check the "ret" +* flag with BT_ERROR_INVALID_PARAMETER if LE is supported otherwise just call to register the adapter's state +* change callback as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's state change callback with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to register callback as "NULL"; to be invoked when bluetooth adapter's state +* changes after de-initializing Bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED +* if LE is supported otherwise just call to register the callback with "NULL" and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's state change callback with "NULL" after deinitializng Bluetooth. +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name changed callback as "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's friendly name with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name changed callback as "NULL" after de-initializing +* Bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's friendly name with "NULL" after de-initializing BT(if supported). +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's visibility mode changed callback as "NULL" and +* check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's visibility mode changed callback with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's visibility mode changed callback as "NULL" after de-initializing +* bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's visibility mode changed callback with "NULL" after de-initializing BT. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's current state and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise call to get +* local bluetooth adapter's current state and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get current state of local Bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_get_state_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's current state after de-initializing Bluetooth and check the "ret" flag +* with BT_ERROR_NOT_INITIALIZED if le is supported otherwise call to get +* local bluetooth adapter's current state and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get current state of local Bluetooth adapter after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_state_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's address and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise call to get the adapter's address +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's address. +*/ +int utc_bluetooth_bt_adapter_get_address_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_address(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_address(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's address after de-initializing Bluetooth and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to get the adapter's address +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's address after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_address_n1(void) +{ + char *address = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's friendly name associated with and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to get the adapter's friendly name +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's friendly name. +*/ +int utc_bluetooth_bt_adapter_get_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_name(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_name(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's friendly name associated with after de-initializing Bluetooth +* and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call +* to get the adapter's friendly name and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's friendly name after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_name_n1(void) +{ + char *name = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_n +* @since_tizen 2.3 +* @description Call to get local Bluetooth adapter's current visibility mode and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to get the +* adapter's current visibility mode and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's current visibility mode. +*/ +int utc_bluetooth_bt_adapter_get_visibility_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_visibility(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_n1 +* @since_tizen 2.3 +* @description Call to get local Bluetooth adapter's current visibility mode after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to get the +* adapter's current visibility mode and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's current visibility mode after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_visibility_n1(void) +{ + int dur = 10; + bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name with "NULL" and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to set local bluetooth adapter's +* friendly name with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set local bluetooth adapter's friendly name with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_name(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name with "NULL" after de-initializing bluetooth and check +* the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to set local +* bluetooth adapter's friendly name with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set local bluetooth adapter's friendly name with "NULL" after de-initializing bluetooth. +*/ +int utc_bluetooth_bt_adapter_set_name_n1(void) +{ + char *name = "Test name"; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name(name); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_name(name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_state_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's state changed callback and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just unset local bluetooth adapter's +* state changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's state change callback. +*/ +int utc_bluetooth_bt_adapter_unset_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_name_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's name changed callback after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to unset local +* bluetooth adapter's name changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's name change callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_name_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's visibility mode changed callback after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to unset local +* bluetooth adapter's visibility mode changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's visibility changed callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_data_n +* @since_tizen 2.3 +* @description Call to get the Hash and Randmoizer value, synchronously by setting out param as "NULL" and +* check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to +* get the Hash and Randmoizer value, synchronously by setting out param as "NULL" and check the +* "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the Hash and Randmoizer value, synchronously by setting out param as "NULL". +*/ +int utc_bluetooth_bt_adapter_get_local_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_local_oob_data(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_local_oob_data(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; + +} + +/** +* @testcase utc_bluetooth_bt_adapter_is_service_used_n +* @since_tizen 2.3 +* @description Call to check whether the UUID of service is used or not setting service_uuid as "NULL" and check the "ret" +* flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to check whether the +* UUID of service is used by setting service_uuid as "NULL" check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to check whether the UUID of service is used by setting the service_uuid as "NULL". +*/ +int utc_bluetooth_bt_adapter_is_service_used_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_service_used(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_is_service_used(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n +* @since_tizen 2.3 +* @description Call to set visibility duration changed callback as "NULL" and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to set visibility duration +* changed callback as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set visibility duration changed callback as "NULL". +*/ +int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_visibility_duration_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_create_advertiser_n +* @since_tizen 2.3 +* @description Call to create advertiser to advertise device's existence after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try +* to create advertiser to advertise device's existence and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to create advertiser to advertise device's existence or respond to LE scanning reqeust. +*/ +int utc_bluetooth_bt_adapter_le_create_advertiser_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_destroy_advertiser_n +* @since_tizen 2.3 +* @description Call to destroy advertiser after de-initializing Bluetooth after de-initializing bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try +* to destroy advertiser and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to destroy advertiser. +*/ +int utc_bluetooth_bt_adapter_le_destroy_advertiser_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_destroy_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_destroy_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_advertising_n +* @since_tizen 2.3 +* @description Call to to stop advertising after de-initializing bluetooth and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try to stop advertising +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to stop advertising after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_le_stop_advertising_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_clear_advertising_data_n +* @since_tizen 2.3 +* @description Call to clear all data to be advertised or responded to scan request from LE scanning device after +* de-initializing bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported +* otherwise just try clear the advertising data and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to clear all advertising data after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_le_clear_advertising_data_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void bt_adapter_vd_changed_cb(int duration, void *user_data) +{ + +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset visibility duration changed callback after setting the callback and de-initializing bluetooth +* and then check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported +* otherwise just try to unsetthe callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset the visibility duration changed callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_bonded_device_info_n +* @since_tizen 2.3 +* @description Call to get device information of a bonded device with "NULL" params and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get the device info with "NULL" +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get device information of a bonded device by setting the input device info param as "NULL". +*/ +int utc_bluetooth_bt_adapter_get_bonded_device_info_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_bonded_device_info(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_bonded_device_info(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_free_device_info_n +* @since_tizen 2.3 +* @description Call to free device information by setting the device info param as "NULL" and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free device information +* by setting the device info param as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to free device information with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_free_device_info_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_free_device_info(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_free_device_info(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_remote_oob_data_n +* @since_tizen 2.3 +* @description Call to set the Hash and Randmoizer value, synchronously by setting the input parameters "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try +* set the value with "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the Hash and Randmoizer value, synchronously with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_set_remote_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_remote_oob_data(NULL, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_remote_oob_data(NULL, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_remove_remote_oob_data_n +* @since_tizen 2.3 +* @description Call to delete the Hash and Randmoizer value, synchronously by setting the input parameter "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try +* to delete the value with "NULL" parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to delete the Hash and Randmoizer value, synchronously with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_remove_remote_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_remove_remote_oob_data(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_remove_remote_oob_data(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_scan_n +* @since_tizen 2.3 +* @description Call to start scanning to find LE advertisement with "NULL" parameters and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to start scanning with +* "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to start scanning with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_scan_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_scan(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_start_scan(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_scan_n +* @since_tizen 2.3 +* @description Call to stop scanning after de-initializing Bluetooth and check the "ret" flag +* with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try to stop scanning +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to stop scanning. +*/ +int utc_bluetooth_bt_adapter_le_stop_scan_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n +* @since_tizen 2.3 +* @description Call to get the service UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service UUID list from the scan result with "NULL" parameters and check the +* "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service UUID list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n +* @since_tizen 2.3 +* @description Call to get the device name from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the device name from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the device name from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n +* @since_tizen 2.3 +* @description Call to get the transmission power level from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the transmission power level from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the transmission power level from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } else { + ret = bt_adapter_le_get_scan_result_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n +* @since_tizen 2.3 +* @description Call to get the service solicitation UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service solicitation UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service solicitation UUID list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_solicitation_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_solicitation_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n +* @since_tizen 2.3 +* @description Call to get the service data list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service data list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service data list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_data_list(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_data_list(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_free_service_data_list_n +* @since_tizen 2.3 +* @description Call to free service data list with "NULL" data_list parameter and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free service data list +* with "NULL" data_list parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to free service data list with "NULL" data_list parameter. +*/ +int utc_bluetooth_bt_adapter_le_free_service_data_list_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_free_service_data_list(NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_free_service_data_list(NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n +* @since_tizen 2.3 +* @description Call to get the appearance from the scan result information with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get +* the appearance from the scan result information with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the appearance from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_appearance(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_appearance(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n +* @since_tizen 2.3 +* @description Call to get the manufacturer data from the scan result information with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get +* the manufacturer data from the scan result information with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the manufacturer data from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n +* @since_tizen 2.3 +* @description Call to add a service UUID to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add a service UUID to advertise or scan response data with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add a service UUID to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n +* @since_tizen 2.3 +* @description Call to add a service solicitation UUID to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add a service solicitation UUID to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add a service solicitation UUID to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_data_n +* @since_tizen 2.3 +* @description Call to add service data to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add service data to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add service data to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_appearance_n +* @since_tizen 2.3 +* @description Call to set the external appearance of local device to advertise or scan response data with +* "NULL" advertiser parameter and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is +* supported otherwise just try to set the external appearance of this device to advertise or scan response +* data with "NULL"advertiser parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the external appearance of local device to advertise with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_appearance_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_appearance(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_appearance(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n +* @since_tizen 2.3 +* @description Call to add manufacturer specific data to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add manufacturer specific data to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add manufacturer specific data to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_device_name_n +* @since_tizen 2.3 +* @description Call to set the device name in advertising data or scan response data with "NULL" and "FALSE" +* parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported +* otherwise just try to set the device name in advertising data or scan response data with +* "NULL" and "FALSE" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the device name in advertising data or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n +* @since_tizen 2.3 +* @description Call to set whether the transmission power level should be included in advertise or scan response data +* with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported +* otherwise just try to set transmission power level data in advertise or scan response data with "NULL" +* parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set whether the transmission power level should be included in advertise data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_advertising_new_n +* @since_tizen 2.3 +* @description Call to start advertising with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to start advertising with "NULL" parameters with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to start advertising with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_advertising_new_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_advertising_new(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_start_advertising_new(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_mode_n +* @since_tizen 2.3 +* @description Call to set advertising mode to control the advertising power and latency with "NULL" advertiser parameter +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* set advertising mode to control the advertising power and latency with "NULL" parameter and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set advertising mode to control the advertising power and latency with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_mode_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_mode(NULL, BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_mode(NULL, BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_connectable_n +* @since_tizen 2.3 +* @description Call to set whether the advertising type should be connectable or non-connectable with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* set whether the advertising type should be connectable or non-connectable with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set whether the advertising type should be connectable or +* non-connectable with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_connectable_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_connectable(NULL, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_connectable(NULL, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_get_uuid_name_n +* @since_tizen 3.0 +* @description Call to get uuid name with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get uuid name "NULL" parameters. +*/ +int utc_bluetooth_bt_get_uuid_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_get_uuid_name(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_get_uuid_name(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_scan_mode_n +* @since_tizen 3.0 +* @description Call to set LE scan mode after deinitializing Bluetooth and check the "ret" +* flag with BT_ERROR_NOT_INITIALIZED if LE is supported otherwise just try to set LE scan mode +* check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set LE scan mode. + +*/ +int utc_bluetooth_bt_adapter_le_set_scan_mode_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_ext_data_n +* @since_tizen 3.0 +* @description Call to get local oob ext data with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local oob ext data "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_ext_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_get_local_oob_ext_data(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_local_oob_ext_data(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n +* @since_tizen 3.0 +* @description Call to set remotel oob ext data with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set remote oob ext data "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_remote_oob_ext_data(NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_remote_oob_ext_data(NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_create_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_create(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_create(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_destroy_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_device_address(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_device_address(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_device_name(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_device_name(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_data(NULL, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_data(NULL, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_data_with_mask(NULL, NULL, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_data_with_mask(NULL, NULL, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data(NULL, 0, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_manufacturer_data(NULL, 0, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data_with_mask(NULL, 0, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_manufacturer_data_with_mask(NULL, 0, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_register_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_register(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_register(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_unregister_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_unregister(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_unregister(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_unregister_all(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_scan_filter_unregister_all(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_type_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_type(NULL, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_type(NULL, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_ibeacon_report(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_ibeacon_report(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_free_ibeacon_report_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_free_ibeacon_report(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_free_ibeacon_report(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n(void) +{ + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_2m_phy_supported(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_2m_phy_supported(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n(void) +{ + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_coded_phy_supported(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_coded_phy_supported(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_adapter_positive.c b/tests/unittest/utc_bluetooth_adapter_positive.c new file mode 100644 index 0000000..23b41f4 --- /dev/null +++ b/tests/unittest/utc_bluetooth_adapter_positive.c @@ -0,0 +1,1484 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include +#include + +//& set: BluetoothAdapterPositive + +static int startup_flag = BT_ERROR_NONE; +static GMainLoop *mainloop = NULL; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static char adapter_name[128] = "dts_test"; +static bool le_supported = false; +static bool bt_supported = false; +static bool oob_supported = false; +static bool le_50_supported = false; + +static int manufacturer_id = 117; +static char *manufacture = NULL; +static char manufacture_0[] = { 0x0, 0x0, 0x0, 0x0 }; +static char manufacture_3[] = { 0x03, 0x03, 0x03, 0x03 }; +static char service_data[] = { 0x01, 0x02, 0x03 }; + +static const char *time_svc_uuid_16 = "1805"; +static const char *battery_svc_uuid_16 = "180f"; +static const char *heart_rate_svc_uuid_16 = "180d"; + +static void adapter_state_changed_cb_for_adapter_p(int result, bt_adapter_state_e adapter_state, void *user_data) +{ + if (user_data != NULL) { + if (!strcmp((char *)user_data, "enable")) { + if (BT_ADAPTER_ENABLED == adapter_state) { + callback_result = true; + } + } else if (!strcmp((char *)user_data, "disable")) { + if (BT_ADAPTER_DISABLED == adapter_state) { + callback_result = true; + } + } + } + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void adapter_name_changed_cb_for_adapter_p(char *device_name, void *user_data) +{ + if (user_data != NULL && !strcmp((char *)user_data, "set_name")) { + if (!strcmp(device_name, adapter_name)) { + callback_result = true; + } else { + fprintf(stderr, "device_name: %s \n", device_name); + fprintf(stderr, "adapter_name: %s \n", adapter_name); + } + } + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void adapter_visibility_mode_changed_cb_for_adpater_p(int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data) +{ + fprintf(stderr, "adapter_visibility_mode_changed_cb_for_adpater_p was called.\n"); + + callback_result = true; + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +/** + * @function utc_bluetooth_adapter_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + +#ifdef TV + bt_supported = true; + le_supported = true; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + oob_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.oob", &oob_supported); + + le_50_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.5_0", &le_50_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_adapter_positive_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +#if defined(MOBILE) || defined(TV) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_is_discovering_p +* @since_tizen 2.3 +* @description Does assert check for startup_flag before checking LE device discovery +* (is in progress or not) when le is supported otherwise just check for the +* LE device discovery status. +* @scenario Checks for the LE device discovery status; is in progress or not. +*/ +int utc_bluetooth_bt_adapter_le_is_discovering_p(void) +{ + bool is_discovery = FALSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_is_discovering(&is_discovery); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_discovering(&is_discovery); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then set the callback function to be invoked +* when Bluetooth adapter state changes if le is supported otherwise just set the +* callback. +* @scenario Registers a callback function to be invoked when the Bluetooth adapter state changes. +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the name of Bluetooth adapter changes; then unset the callback +* if le is supported otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when the name of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_p1 +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the name of Bluetooth adapter changes if le is supported otherwise +* just registers the callback function. +* @scenario Set a callback function to be invoked when the name of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_p1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + +#if defined(MOBILE) || defined(TIZENIOT) + char name[128] = "test"; + snprintf(name, 128, "%s", adapter_name); + strncpy(adapter_name, name, 128); +#endif + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, "set_name"); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, "set_name"); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the visibility mode of Bluetooth adapter changes and unset the +* callback if le is supported otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when visibility mode of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1 +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the visibility mode of Bluetooth adapter changes if le is supported +* otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when visibility mode of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then get the current state of Adapter +* if le is supported otherwise just get the current state of Adapter. +* @scenario Call to get the current state of adapter. +*/ +int utc_bluetooth_bt_adapter_get_state_p(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_state(&adapter_state); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_state(&adapter_state); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the address of local Bluetooth adapter +* if le is supported otherwise just gets the address of local Bluetooth adapter. +* @scenario Call to get the bluetooth address of local adapter. +*/ +int utc_bluetooth_bt_adapter_get_address_p(void) +{ + char *address = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NONE); + + free(address); + address = NULL; + } else { + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the friendly name +* of local Bluetooth Adapter if le is supported otherwise just gets the +* name of local Bluetooth adapter. +* @scenario Call to get the friendly name associated with local adapter. +*/ +int utc_bluetooth_bt_adapter_get_name_p(void) +{ + char *name = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the visibility mode +* of local Bluetooth Adapter if le is supported otherwise just gets the +* the visibility mode of local Bluetooth adapter. +* @scenario Call to get the visibility mode of local bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_get_visibility_p(void) +{ + int dur = 1; + bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then sets the name of local Bluetooth adapter +* if le is supported otherwise just sets the name of local Bluetooth adapter. +* @scenario Call to set the friendly name for local bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_set_name_p(void) +{ + if (bt_supported) { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name("Test name"); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_adapter_set_name(adapter_name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; + +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_state_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the adapter state change callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's state changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_name_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the name changed callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's name changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_name_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the visibility mode changed callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's visibility mode changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag". Gets the Hash and Randmoizer value, +* synchronously when le is supported or not supported. +* @scenario Call to get the Hash and Randmoizer value, synchronously. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_data_p(void) +{ + assert_eq(startup_flag, BT_ERROR_NONE); + + unsigned char *hash = NULL; + unsigned char *randomizer = NULL; + int hash_len = 0; + int randomizer_len = 0; + + if (bt_supported && oob_supported) { + ret = bt_adapter_get_local_oob_data(&hash, &randomizer, &hash_len, &randomizer_len); + + free(hash); + hash = NULL; + + free(randomizer); + randomizer = NULL; + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_local_oob_data(&hash, &randomizer, &hash_len, &randomizer_len); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_is_service_used_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag". Checks whether the UUID of service is +* used or not when le is supported or not supported. +* @scenario Call to check whether the UUID of service is used or not. +*/ +int utc_bluetooth_bt_adapter_is_service_used_p(void) +{ + assert_eq(startup_flag, BT_ERROR_NONE); + + bool used = false; + const char *service_uuid = "00001105-0000-1000-8000-00805f9b34fb"; + + if (bt_supported) { + ret = bt_adapter_is_service_used(service_uuid, &used); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_is_service_used(service_uuid, &used); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_clear_advertising_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then clear all data to be advertised +* or responded to scan request from LE scanning device and then destroy the advertiser +* if le is supported otherwise just create advertiser to advertise device's +* existence or respond to LE scanning reqeust. +* @scenario Call to clear all data to be advertised or responded to scan request from LE scanning device. +*/ +int utc_bluetooth_bt_adapter_le_clear_advertising_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + + bt_adapter_le_destroy_advertiser(advertiser); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void bt_adapter_vd_changed_cb(int duration, void *user_data) +{ + +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", registers a callback function to be invoked +* every second untill the visibility mode is changed and then unregister the callback +* if le is supported otherwise just registers the callback function. +* @scenario Call to set visibility duration changed callback for local adapter. +*/ +int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_unset_visibility_duration_changed_cb(); + } else { + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_create_advertiser_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then destroy the advertiser +* if le is supported otherwise just create the advertiser. +* @scenario Call to create advertiser to advertise device's existence for local adapter. +*/ +int utc_bluetooth_bt_adapter_le_create_advertiser_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_le_destroy_advertiser(advertiser); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_destroy_advertiser_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then destroy the advertiser +* if le is supported otherwise just destroy the advertiser. +* @scenario Call to destroy advertiser for local adapter. +*/ +int utc_bluetooth_bt_adapter_le_destroy_advertiser_p(void) +{ + bt_advertiser_h second_advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&second_advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_destroy_advertiser(second_advertiser); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_destroy_advertiser(second_advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_adapter_le_advertising_state_changed_cb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +#if defined(MOBILE) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_advertising_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then start advertising then +* stop advertsing and then destroy the advertiser if le is supported otherwise +* just stop advertising. +* @scenario Call to stop advertising for the remote BLE scanning devices. +*/ +int utc_bluetooth_bt_adapter_le_stop_advertising_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + /* add advertising data start */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, service_data, sizeof(service_data)); + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + + assert_eq(ret, BT_ERROR_NONE); + + manufacture = manufacture_0; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, manufacturer_id, manufacture, sizeof(manufacture_0)); + + assert_eq(ret, BT_ERROR_NONE); + /* add advertising data end */ + + ret = bt_adapter_le_start_advertising_new(advertiser, __bt_adapter_le_advertising_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_advertising(advertiser); + if (ret != BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_le_destroy_advertiser(advertiser); + } else { + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", set the visibility duration changed +* callback then unset the callback if le is supported otherwise +* just unset the visibility duration changed callback. +* @scenario Call to unregister visibility duration changed callback for local adapter. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_adapter_le_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_scan_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", start scanning the advertising devices +* if le is supported otherwise just start scanning the advertising devices. +* Stop the scanning process. +* @scenario Call to start LE scan to find LE advertisement of remote advertising devices. +*/ +int utc_bluetooth_bt_adapter_le_start_scan_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_scan_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", start scanning the advertising devices +* then stop scanning if le is supported otherwise just stop scanning. +* @scenario Call to stop LE scan. +*/ +int utc_bluetooth_bt_adapter_le_stop_scan_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add a service UUID to advertise or scan response data (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* just add a service UUID to advertise or scan response data and clear the adv data. +* @scenario Call to add a service UUID to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, pkt_type, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, pkt_type, time_svc_uuid_16); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add a service solicitation UUID to advertise data (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* add a service solicitation UUID to advertise data and clear the adv data. +* @scenario Call to add a service solicitation UUID to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, pkt_type, heart_rate_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, pkt_type, heart_rate_svc_uuid_16); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add service data to advertise (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* add service data to advertise and clear the advertising data. +* @scenario Call to add the service data to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, pkt_type, time_svc_uuid_16, service_data, sizeof(service_data)); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_data(advertiser, pkt_type, time_svc_uuid_16, service_data, sizeof(service_data)); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_appearance_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then sets the external appearance of local device to advertise +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* sets the external appearance of local device to advertise and clear the advertising data. +* @scenario Call to add the external appearance of local device to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_appearance_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, pkt_type, 4); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_appearance(advertiser, pkt_type, 4); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add manufacturer specific data to advertise +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* just add manufacturer specific data to advertise and clear the advertising data. +* @scenario Call to add manufacturer specific data to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + bt_adapter_le_create_advertiser(&advertiser); + manufacture = manufacture_3; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, pkt_type, manufacturer_id, manufacture, sizeof(manufacture_0)); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + manufacture = NULL; + } else { + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, pkt_type, manufacturer_id, manufacture, sizeof(manufacture_0)); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_device_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add local device name to advertise (The maximum advertised +* or responded data size is 31 bytes including data type and system wide data) +* and then destroy the advertiser if le is supported otherwise +* just add add device name to advertising data. +* @scenario Call to add device advertise name to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_device_name(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add transmission power level to advertise then destroy the advertiser +* if le is supported otherwise just add transmission power level to advertsing data. +* @scenario Call to add transmission power level to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_advertising_new_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then start advertising with passed advertiser and advertising parameters +* then destroy the advertiser if le is supported otherwise just Start and stop advertising. +* @scenario Call to start advertising with passed advertiser and advertising parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_advertising_new_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_advertising_state_changed_cb cb; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + bt_adapter_le_create_advertiser(&advertiser); + + cb = __bt_adapter_le_advertising_state_changed_cb; + + /* add advertising data start */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, service_data, sizeof(service_data)); + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + + assert_eq(ret, BT_ERROR_NONE); + + manufacture = manufacture_0; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, manufacturer_id, manufacture, sizeof(manufacture_0)); + + assert_eq(ret, BT_ERROR_NONE); + /* add advertising data end */ + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + cb = __bt_adapter_le_advertising_state_changed_cb; + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_stop_advertising(advertiser); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_mode_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then set advertising mode to control the advertising power and latency +* then destroy the advertiser if le is supported otherwise just Set advertising mode +* to control the advertising power and latency. +* @scenario Call to set advertising mode to control the advertising power and latency. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_mode_p(void) +{ + bt_advertiser_h advertiser = NULL; + int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_mode(advertiser, mode); + assert_eq(ret, BT_ERROR_NONE); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_mode(advertiser, mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_connectable_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then set whether the advertising type should be connectable or non-connectable +* then destroy the advertiser if le is supported otherwise just set whether the advertising +* type should be connectable or non-connectable. +* @scenario Call to set whether the advertising type should be connectable or non-connectable. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_connectable_p(void) +{ + bt_advertiser_h advertiser = NULL; + int type = 0x00; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_connectable(advertiser, type); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_connectable(advertiser, type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_get_uuid_name_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then gets the uuid name if bt is supported +* otherwise just gets the uuid name. +* @scenario Call to get the uuid name. +*/ +int utc_bluetooth_bt_get_uuid_name_p(void) +{ + char *uuid = NULL; + char *name = NULL; + + uuid = g_strdup("00001101-0000-1000-8000-00805F9B7777"); + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_get_uuid_name(uuid, &name); + g_free(uuid); + g_free(name); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_get_uuid_name(uuid, &name); + g_free(uuid); + g_free(name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_scan_mode_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then set the scan mode if bt is supported +* otherwise just sets the scan mode. +* @scenario Call to set the scan mode. +*/ +int utc_bluetooth_bt_adapter_le_set_scan_mode_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_ext_data_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then gets the uuid name if bt is supported +* otherwise just gets the uuid name. +* @scenario Call to get the uuid name. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_ext_data_p(void) +{ + unsigned char *data[4]; + int len[4]; + int i; + + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_get_local_oob_ext_data(&data[0], &data[1], &len[0], &len[1], &data[2], &data[3], &len[2], &len[3]); + + for (i = 0; i < 4; i++) { + g_free(data[i]); + } + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_local_oob_ext_data(&data[0], &data[1], &len[0], &len[1], &data[2], &data[3], &len[2], &len[3]); + + if (ret == BT_ERROR_NONE) { + for (i = 0; i < 4; i++) { + g_free(data[i]); + } + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_type_p(void) +{ + bt_scan_filter_h scan_filter = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + result = bt_adapter_le_scan_filter_create(&scan_filter); + + result = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + + result = bt_adapter_le_scan_filter_destroy(scan_filter); + assert_eq(ret, BT_ERROR_NONE); + } else { + result = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bt_adapter_le_device_scan_result_info_s *__bt_create_le_device_scan_info_s(void) +{ + bt_adapter_le_device_scan_result_info_s *scan_info = NULL; + + scan_info = (bt_adapter_le_device_scan_result_info_s *)malloc(sizeof(bt_adapter_le_device_scan_result_info_s)); + if (scan_info == NULL) { + return NULL; + } + + memset(scan_info, 0x00, sizeof(bt_adapter_le_device_scan_result_info_s)); + + scan_info->remote_address = g_strdup("00:1B:66:01:23:1C"); + scan_info->address_type = BT_DEVICE_PUBLIC_ADDRESS; + scan_info->rssi = -31; + scan_info->adv_data_len = 31; + scan_info->adv_data = malloc(scan_info->adv_data_len); + if (scan_info->adv_data) { + + scan_info->adv_data[0] = 28; + scan_info->adv_data[1] = 0xff; + + /* Company ID 0x004C */ + scan_info->adv_data[2] = 0x4c; + scan_info->adv_data[3] = 0x00; + + /* UUID */ + scan_info->adv_data[4] = 0x01; + scan_info->adv_data[5] = 0x01; + scan_info->adv_data[6] = 0x01; + scan_info->adv_data[7] = 0x01; + scan_info->adv_data[8] = 0x01; + scan_info->adv_data[9] = 0x01; + scan_info->adv_data[10] = 0x01; + scan_info->adv_data[11] = 0x01; + scan_info->adv_data[12] = 0x01; + scan_info->adv_data[13] = 0x01; + scan_info->adv_data[14] = 0x01; + scan_info->adv_data[15] = 0x01; + scan_info->adv_data[16] = 0x01; + scan_info->adv_data[17] = 0x01; + scan_info->adv_data[18] = 0x01; + scan_info->adv_data[19] = 0x01; + + /* Major ID */ + scan_info->adv_data[20] = 0x02; + scan_info->adv_data[21] = 0x01; + + /* Minor ID */ + scan_info->adv_data[22] = 0x02; + scan_info->adv_data[23] = 0x01; + + /* Power */ + scan_info->adv_data[24] = -31; + } + + return scan_info; +} + +static void __bt_free_le_device_scan_info_s(bt_adapter_le_device_scan_result_info_s *scan_info) +{ + if (scan_info == NULL) { + return; + } + + if (scan_info->remote_address != NULL) { + free(scan_info->remote_address); + } + + if (scan_info->adv_data != NULL) { + free(scan_info->adv_data); + } + + free(scan_info); + scan_info = NULL; +} + +int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p(void) +{ + bt_adapter_le_device_scan_result_info_s *info = NULL; + bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + info = __bt_create_le_device_scan_info_s(); + + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + + __bt_free_le_device_scan_info_s(info); + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NONE); + } else { + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_free_ibeacon_report_p(void) +{ + bt_adapter_le_device_scan_result_info_s *info = NULL; + bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + info = __bt_create_le_device_scan_info_s(); + + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + + __bt_free_le_device_scan_info_s(info); + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NONE); + } else { + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p(void) +{ + bool is_supported = false; + + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_2m_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_2m_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p(void) +{ + bool is_supported = false; + + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_coded_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_coded_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_audio_negative.c b/tests/unittest/utc_bluetooth_audio_negative.c new file mode 100644 index 0000000..5784dec --- /dev/null +++ b/tests/unittest/utc_bluetooth_audio_negative.c @@ -0,0 +1,872 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAudioNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; +static bool media_supported = false; +static bool call_supported = false; +static bool control_supported = false; + +/** + * @function utc_bluetooth_bt_audio_negative_startup + * @description check if bluetooth is supported, initialize bluetooth. + * check if media or call feature is supported, then initialize the audio profiles. + * @scenario initializes the bluetooth API and audio profiles, this needs to be called before each test. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_audio_negative_startup(void) +{ +#ifdef TV + bt_supported = true; + media_supported = true; + call_supported = false; + control_supported = false; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported || call_supported) { + ret = bt_audio_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_audio_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_bt_audio_negative_cleanup + * @description check if media or call feature is supported, then de-initialize the audio profiles + * check if bluetooth is supported, de-initialize bluetooth. + * @scenario de-initializes the audio profiles and Rrelease all resources of bluetooth, this needs to be called after each test. + + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_audio_negative_cleanup(void) +{ + if (media_supported || call_supported) { + bt_audio_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_audio_connect_n + * @since_tizen 2.3 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given audio profile and check for errors. + * @scenario Try to connect the remote device with the given audio profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_connect_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_connect("DummyAddress", BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_connect("DummyAddress", BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_disconnect_n + * @since_tizen 2.3 + * @description check if audio profile are supported and startup_flag is asserted, then deinitialize the bluetooth and + * disconnect to the remote device with given audio profile and check for errors. + * @scenario Try to disconnect the remote device with the given audio profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_disconnect_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_disconnect(NULL, BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_disconnect(NULL, BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted, then register a callback for change + * in connection state by using invalid parameters and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed by using invalid parameters. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_deinitialize_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the audio profiles and check for errors. + * scenario Try to deinitialize the Bluetooth profiles related with audio. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_deinitialize_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_initialize_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the audio profiles and check for errors. + * scenario Try to initialize the Bluetooth profiles related with audio. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_initialize_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback set for connection state changes and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the equalizer state is changed by the remote control device + * and check for errors. + * scenario Try to register a callback function that will be invoked when the equalizer state is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the repeat mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when repeat mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the scan mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when scan mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the shuffle mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when shuffle mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +static void __bt_avrcp_song_position_changed_cb(unsigned int postion, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_position_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the position is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when position is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_position_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the play status is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when play status is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the track info is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when track info is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#endif + +/** + * @testcase utc_bluetooth_bt_avrcp_target_deinitialize_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the AVRCP(Audio/Video Remote Control Profile) service and check for errors. + * scenario Try to deinitialize the Bluetooth AVRCP(Audio/Video Remote Control Profile) service after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_deinitialize_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_target_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_initialize_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the AVRCP(Audio/Video Remote Control Profile) service and check for errors. + * scenario Try to initialize the Bluetooth AVRCP(Audio/Video Remote Control Profile) service after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_initialize_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send equalizer notification to the remote device and check for errors. + * @scenario Try to notify the equalize state to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_equalizer_state(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_equalizer_state(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_player_state_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send player state notification to the remote device and check for errors. + * @scenario Try to notify the player state to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_player_state_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_player_state(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_player_state(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_position_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send song's current position notification to the remote device and check for errors. + * @scenario Try to notify the current position of song to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_position_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_position(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_position(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send repeat mode notification to the remote device and check for errors. + * @scenario Try to notify the repeat mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_repeat_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_repeat_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_scan_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send scan mode notification to the remote device and check for errors. + * @scenario Try to notify the scan mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_scan_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_scan_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_scan_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send shuffle mode notification to the remote device and check for errors. + * @scenario Try to notify the shuffle mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_shuffle_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_shuffle_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_track_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send track notification to the remote device and check for errors. + * @scenario Try to notify the track details to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_track_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for equalizer state changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the equalizer state is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for repeat mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the repeat mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for scan mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the scan mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for shuffle mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the shuffle mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +/** + * @testcase utc_bluetooth_bt_avrcp_unset_position_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for position changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the position is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_position_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for play status changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the play status is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for track info changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the track info is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_audio_positive.c b/tests/unittest/utc_bluetooth_audio_positive.c new file mode 100644 index 0000000..bff233b --- /dev/null +++ b/tests/unittest/utc_bluetooth_audio_positive.c @@ -0,0 +1,960 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAudioPositive + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool media_supported = false; +static bool call_supported = false; +static bool control_supported = false; + +static void __bt_avrcp_target_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_audio_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_audio_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + +#ifndef TV + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); +#else + bt_supported = true; + media_supported = true; + call_supported = false; +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported || call_supported) { + ret = bt_audio_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_audio_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_audio_positive_cleanup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_audio_positive_cleanup(void) +{ + if (media_supported || call_supported) { + bt_audio_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @function utc_bluetooth_avrcp_callback_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_callback_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + +#ifndef TV + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); +#else + bt_supported = true; + media_supported = true; + call_supported = false; + control_supported = false; +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported) { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_target_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +#ifndef TV + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +#endif + } +} + +/** + * @function utc_bluetooth_avrcp_callback_positive_cleanup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_callback_positive_cleanup(void) +{ + if (media_supported) { + bt_avrcp_target_deinitialize(); + } + +#ifndef TV + if (control_supported) { + bt_avrcp_control_deinitialize(); + } +#endif + + if (bt_supported) { + bt_deinitialize(); + } +} + +static void connection_state_changed_cb_for_audio_p(int result, bool connected, const char *remote_address, bt_audio_profile_type_e type, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_audio_initialize_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, deinitialize audio and initialize audio and ensure there is no error. + * Else, initialize bt audio and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then call bt_audio_initialize on the device and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_deinitialize(); + + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, set audio connection state change callback and ensure there is no error. + * Else, set audio connection state change callback and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then call bt_audio_set_connection_state_changed_cb and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, set and unset audio connection state change callback and ensure there is no error. + * Else, unset audio connection state change callback and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then set and unset audio connection state changed cb. Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_deinitialize_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, deinitialize audio and ensure there is no error. + * Else, deinitialize audio and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Positive case to check for audio deinitialize. Check if BT and media/call is supported and then deinitialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_initialize_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Then deinitialize avrcp target. + * @senario Positive case to check for audio initialize. Check if BT and media/call is supported and then initialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_deinitialize_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Then deinitialize avrcp target. + * @senario Positive case to check for audio deinitialize. Check if BT and media/call is supported and then deinitialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_equalizer_state + * with BT_AVRCP_EQUALIZER_STATE_ON as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_equalizer_state(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_repeat_mode + * with BT_AVRCP_REPEAT_MODE_SINGLE_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_repeat_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_shuffle_mode + * with BT_AVRCP_SHUFFLE_MODE_ALL_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_shuffle_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_scan_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_scan_mode + * with BT_AVRCP_SCAN_MODE_ALL_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_scan_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_scan_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_scan_mode(BT_AVRCP_SCAN_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_scan_mode(BT_AVRCP_SCAN_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_player_state_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_player_state + * with BT_AVRCP_PLAYER_STATE_STOPPED as parameter and check there is no error. Then deinitialize avrcp target + * @senario Positive case to check for bt_avrcp_target_notify_player_state(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_player_state_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_player_state(BT_AVRCP_PLAYER_STATE_STOPPED); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_player_state(BT_AVRCP_PLAYER_STATE_STOPPED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_position_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_position + * and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_position(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_position_p(void) +{ + int ret = BT_ERROR_NONE; + unsigned int position = 0; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_position(position); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_position(position); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_track_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_track + * with valid input details and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_track(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_track_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp equalizer state changed callback + * with valid input details and check there is no error. Then unset the avrcp equalizer state changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_equalizer_state_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + } else { + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp equalizer state changed callback + * with valid input details and check there is no error. Then unset the avrcp equalizer state changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_equalizer_state_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp repeat mode changed callback + * with valid input details and check there is no error. Then unset the avrcp repeat mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_repeat_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + } else { + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp repeat mode changed callback + * with valid input details and check there is no error. Then unset the avrcp repeat mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_repeat_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp shuffle mode changed callback + * with valid input details and check there is no error. Then unset the avrcp shuffle mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_shuffle_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + } else { + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp shuffle mode changed callback + * with valid input details and check there is no error. Then unset the avrcp shuffle mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_shuffle_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_scan_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp scan mode changed callback + * with valid input details and check there is no error. Then unset the avrcp scan mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_scan_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_scan_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_scan_mode_changed_cb(); + } else { + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp scan mode changed callback + * with valid input details and check there is no error. Then unset the avrcp scan mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_scan_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +static void __bt_avrcp_song_position_changed_cb(unsigned int postion, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_position_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp position changed callback + * with valid input details and check there is no error. Then unset the avrcp position changed callback. + * @senario Positive case to check for bt_avrcp_set_position_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_position_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_position_changed_cb(); + } else { + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_position_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp position changed callback + * with valid input details and check there is no error. Then unset the avrcp position changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_position_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_position_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback. + * @senario Positive case to check for bt_avrcp_set_play_status_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_play_status_changed_cb(); + } else { + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_play_status_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp track info changed callback + * with valid input details and check there is no error. Then unset the avrcp track info changed callback. + * @senario Positive case to check for bt_avrcp_set_track_info_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_track_info_changed_cb(); + } else { + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_track_info_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#endif diff --git a/tests/unittest/utc_bluetooth_avrcp_control_negative.c b/tests/unittest/utc_bluetooth_avrcp_control_negative.c new file mode 100644 index 0000000..0f9b5df --- /dev/null +++ b/tests/unittest/utc_bluetooth_avrcp_control_negative.c @@ -0,0 +1,508 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAVRCPControlNegative + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool control_supported = false; + +#ifndef TV +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_avrcp_control_negative_startup + * @description check if bluetooth is supported, initialize bluetooth. + * check if media or call feature is supported, then initialize the avrcp control profiles. + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_negative_startup(void) +{ + int ret = BT_ERROR_NONE; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_avrcp_control_negative_cleanup + * @description check if audio controller feature is supported, then de-initialize the avrcp control profiles + * check if bluetooth is supported, de-initialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_negative_cleanup(void) +{ + if (control_supported) { + bt_avrcp_control_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_connect_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given avrcp control profile and check for errors. + * @scenario Try to connect the remote device with the given avrcp control profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_connect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_disconnect_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given avrcp control profile and check for errors. + * @scenario Try to disconnect the remote device with the given avrcp control profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_disconnect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_send_player_command_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_send_player_command_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_equalizer_state_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_equalizer_state_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_equalizer_state_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_equalizer_state_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_equalizer_state_e state = BT_AVRCP_EQUALIZER_STATE_ON; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_equalizer_state(&state); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_equalizer_state(&state); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_repeat_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_repeat_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_repeat_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_repeat_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_SINGLE_TRACK; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_repeat_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_repeat_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_shuffle_mode_e mode = BT_AVRCP_SHUFFLE_MODE_ALL_TRACK; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_shuffle_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_shuffle_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_scan_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_scan_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_scan_mode(BT_AVRCP_SCAN_MODE_GROUP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_scan_mode(BT_AVRCP_SCAN_MODE_GROUP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_scan_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_scan_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_scan_mode_e mode = BT_AVRCP_SCAN_MODE_GROUP; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_scan_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_scan_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_position_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_position_n(void) +{ + int ret = BT_ERROR_NONE; + unsigned int position = 0; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_position(&position); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_position(&position); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_play_status_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_play_status_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_player_state_e status = BT_AVRCP_PLAYER_STATE_STOPPED; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_play_status(&status); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_play_status(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_track_info_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_track_info_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_metadata_attributes_info_s *track_info = NULL; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_track_info(&track_info); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_track_info(&track_info); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + if (track_info) { + ret = bt_avrcp_control_free_track_info(track_info); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_free_track_info_n + * @since_tizen 3.0 + * @description Call to free track information by setting the track info param as "NULL" and check the "ret" flag + * with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free device information + * by setting the device info param as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. + * @scenario Negative scenario to free device information with "NULL" parameter. + */ +int utc_bluetooth_bt_avrcp_control_free_track_info_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_free_track_info(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_avrcp_control_free_track_info(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_avrcp_control_positive.c b/tests/unittest/utc_bluetooth_avrcp_control_positive.c new file mode 100644 index 0000000..8773c19 --- /dev/null +++ b/tests/unittest/utc_bluetooth_avrcp_control_positive.c @@ -0,0 +1,140 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAVRCPControlPositive + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool control_supported = false; + +#ifndef TV +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_avrcp_control_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_avrcp_control_positive_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_positive_cleanup(void) +{ + if (control_supported) { + bt_avrcp_control_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_initialize_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Initialize avrcp control and check for BT_ERROR_NONE. Then deinitialize avrcp control. + * @senario Positive case to check for avrcp control initialize. Check if BT and controller is supported and then initialize avrcp control. + * Check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_avrcp_control_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_deinitialize_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Initialize avrcp control and check for BT_ERROR_NONE. Then deinitialize avrcp control. + * @senario Positive case to check for avrcp control deinitialize. Check if BT and controller is supported and then deinitialize avrcp control. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_control_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_control_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_common_positive.c b/tests/unittest/utc_bluetooth_common_positive.c new file mode 100644 index 0000000..bd50538 --- /dev/null +++ b/tests/unittest/utc_bluetooth_common_positive.c @@ -0,0 +1,96 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "bluetooth.h" +#include "assert_local.h" +#include +#include + +//& set: BluetoothCommonPositive + +static int ret = BT_ERROR_NONE; +static bool supported = false; + +/** + * @function utc_bluetooth_common_startup + * @description initialize bluetooth and check the adapter state and store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_common_startup(void) +{ + ret = bt_initialize(); + supported = false; + +#ifdef TV +#ifndef TV_PRODUCT + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &supported); +#else + supported = true; +#endif +#else + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &supported); +#endif +} + +/** + * @function utc_bluetooth_common_cleanup + * @description release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_common_cleanup(void) +{ + bt_deinitialize(); +} + +/** + * @testcase utc_bluetooth_bt_initialize_p + * @since_tizen 2.3 + * @description check if bluetooth is supported or not and check for errors. + * @scenario Check if bluetooth is supported or not. + */ +int utc_bluetooth_bt_initialize_p(void) +{ + ret = bt_initialize(); + + if (!supported) { + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_deinitialize_p + * @since_tizen 2.3 + * @description de-initialize the bluetooth and check if bluetooth is supported or not and check for errors. + * @scenario Releases all resources of the Bluetooth API, after bluetooth de-initialization. + + */ +int utc_bluetooth_bt_deinitialize_p(void) +{ + ret = bt_deinitialize(); + + if (!supported) { + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_discovery_negative.c b/tests/unittest/utc_bluetooth_device_discovery_negative.c new file mode 100644 index 0000000..2f08fb3 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_discovery_negative.c @@ -0,0 +1,251 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceDiscoveryNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_device_discovery_negative_startup + * @description check if bluetooth is supported, Initialialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_device_discovery_negative_cleanup + * @description check if bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_adapter_stop_device_discovery_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * stop the device discovery and check for errors. + * @scenario Try to stop the device discovery, asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_stop_device_discovery_n1(void) +{ + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * unregister the callback set for device discovery state changes and check for errors. + * @scenario Try to unregister a callback function to be invoked when the device discovery state changes, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void device_discovery_state_changed_cb_for_discovery_p(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * register a callback that will be invoked when device discovery state changes and check for errors. + * @scenario Try to register a callback function, to be invoked when the device discovery state changes, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then register a callback that will be + * invoked when device discovery state changes, by using invalid parameters and check for errors. + * @scenario Try to register a callback function, to be invoked when the device discovery state changes, by using invalid parameters. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_start_device_discovery_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * start the device discovery and check for errors. + * @scenario Try to start the device discovery, asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_start_device_discovery_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * check the satuts of device discovery and check for errors. + * @scenario Try to check for the device discovery is in progress or not after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_is_discovering_n1(void) +{ + bool status = false; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then check the satuts of + * device discovery by using invalid parameters and check for errors. + * @scenario Try to check for the device discovery is in progress or not after bluetooth de-initialization, by using invalid parameters. + */ +int utc_bluetooth_bt_adapter_is_discovering_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_is_discovering(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_discovery_positive.c b/tests/unittest/utc_bluetooth_device_discovery_positive.c new file mode 100644 index 0000000..68ec835 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_discovery_positive.c @@ -0,0 +1,229 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceDiscoveryPositive + +static int startup_flag = BT_ERROR_NONE; +static GMainLoop *mainloop = NULL; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static bool bt_supported = false; + +static void device_discovery_state_changed_cb_for_discovery_p(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +/** + * @function utc_bluetooth_device_discovery_positive_startup + * @description check if bluetooth is supported, initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_device_discovery_positive_cleanup + * @description check if bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then check the satuts of device discovery, + * and check for errors. + * @scenario Checks for the device discovery is in progress or not. + */ +int utc_bluetooth_bt_adapter_is_discovering_p(void) +{ + bool status = false; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback that + * will be invoked when device discovery state changes and check for errors. + * @scenario Registers a callback function to be invoked when the device discovery state changes. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_start_device_discovery_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, start the device discovery + * and check for errors. + * @scenario Starts the device discovery, asynchronously. + */ +int utc_bluetooth_bt_adapter_start_device_discovery_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister the callback set + * for device discovery state changes and check for errors. + * @scenario Unregisters a callback function to be invoked when the device discovery state changes. + */ +int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_stop_device_discovery_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then stop the device discovery + * and check for errors. + * @scenario Stops the device discovery, asynchronously. + */ +int utc_bluetooth_bt_adapter_stop_device_discovery_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_negative.c b/tests/unittest/utc_bluetooth_device_negative.c new file mode 100644 index 0000000..b2206cb --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_negative.c @@ -0,0 +1,685 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *remote_address = "B8:5E:7B:E7:92:7D"; +static bool bt_supported = false; + +static void bt_connection_state_changed_cb(bool connected, bt_device_connection_info_s *conn_info, void *user_data) +{ + +} + +static bool bonded_device_cb_for_device_p(bt_device_info_s *dev_info, void *user_data) +{ + return false; +} + +/** + * @function utc_bluetooth_device_negative_startup + * @description check if bluetooth is supported, Initialialize bluetooth. Here adapter state is not checked. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_device_negative_cleanup + * @description check if bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for bond creation with invalid paramters else check for errors. + * @scenario Try to register a callback function with invalid paramters for bond creation after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback + * for bond creation with invalid paramters and check for errors. + * @scenario Registers a callback function with invalid paramters for bond creation. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_destroyed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for bond destroy with invalid paramters and check for errors. + * @scenario Try to register a callback function with invalid paramters for bond destroy after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_bond_destroyed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_bond_destroyed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in device authorization with invalid paramters and check for errors. + * @scenario Try to register a callback function with invalid paramters for change in device authorizationafter bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change + * in device authorization with invalid paramters and check for errors. + * @scenario Registers a callback function with invalid paramters for change in device authorization. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_created_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for bond creation and check for errors. + * @scenario Try to unregister the callback function for bond creation after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_bond_created_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_destroyed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for bond destroy and check for errors. + * @scenario Try to unregister the callback function for bond destroyafter bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_bond_destroyed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_authorization_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for change in device authorization and check for errors. + * @scenario Try to unregisters the callback function for change in device authorization, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_authorization_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_create_bond_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * initiate bond creation to remote device and check for errors. + * @scenario Try to create a bond with a remote Bluetooth device, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_create_bond_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_create_bond_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then initiate bond creation + * with invalid paramters and check for errors. + * @scenario Creates a bond with invalid parameters. + */ +int utc_bluetooth_bt_device_create_bond_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_create_bond(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_create_bond(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_cancel_bonding_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * cancel the bond creation to remote device and check for errors. + * @scenario Try to cancel the bonding process after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_cancel_bonding_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_cancel_bonding(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_cancel_bonding(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_destroy_bond_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * initiate bond destroy procedure to remote device and check for errors. + * @scenario Try to destroy the bond, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_destroy_bond_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and all bonded + * device information is listed from the device list else all bonded device information is listed from the device list and checked for errors. + * scenario Try to retriev the device information of all bonded devices after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then all bonded device information + * is listed from the device list with invalid parameters and checked for errors. + * scenario Try to retriev the device information of all bonded devices with invalid parameters. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_foreach_bonded_device(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_alias_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * set device alias name and check for errors. + * scenario Try to sets an alias for the bonded device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_alias_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_alias(remote_address, "dts_alias"); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_alias(remote_address, "dts_alias"); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_alias_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then set device alias name + * with invalid parameters and check for errors. + * scenario Try to sets an alias for the bonded device with invalid parameter. + */ +int utc_bluetooth_bt_device_set_alias_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_alias(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_alias(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * set device authoriazation and check for errors. + * scenario Try to set the authorization of a bonded device, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_authorization_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_authorization(remote_address, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_authorization(remote_address, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then set device authoriazation + * with invalid parameters and check for errors. + * scenario Try to set authoriazation of a bonded device, asynchronously with invalid parameter. + */ +int utc_bluetooth_bt_device_set_authorization_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization(NULL, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_authorization(NULL, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * retrive the service class of the uuid from uuid list a and check for errors. + * @scenario Try to get the service mask from the uuid list after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n(void) +{ +#if defined(MOBILE) || defined(TIZENIOT) + char *uuid = "00001101-0000-1000-8000-00805f9b34fb"; + int no_of_service = 1; + bt_service_class_t service_mask_list; +#endif + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#if defined(MOBILE) || defined(TIZENIOT) + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#else + ret = bt_device_get_service_mask_from_uuid_list(NULL, 1, NULL); + + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#endif + } else { +#if defined(MOBILE) || defined(TIZENIOT) + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); +#else + ret = bt_device_get_service_mask_from_uuid_list(NULL, 1, NULL); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_is_profile_connected_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * retrive the profile connection state with respect to remote address and profile and check for errors + * @scenario Try to gets the profile connected status after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_is_profile_connected_n(void) +{ + bt_profile_e bt_profile = BT_PROFILE_RFCOMM; + bool is_connected; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_connection_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for change in connection state and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + + */ +int utc_bluetooth_bt_device_unset_connection_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool bt_device_connected_profiles_cb(bt_profile_e profile, void *user_data) +{ + return false; +} + +/** + * @testcase utc_bluetooth_bt_device_foreach_connected_profiles_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the profile connection state + * with respect to remote address and profile for all devices with invalid parameters and check for errors + * @scenario Try to gets the profile connected status with invalid parameters. + */ +int utc_bluetooth_bt_device_foreach_connected_profiles_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_foreach_connected_profiles(NULL, bt_device_connected_profiles_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_foreach_connected_profiles(NULL, bt_device_connected_profiles_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_update_le_connection_mode_n + * @since_tizen 3.0 + * @description check if bluetooth is supported and startup_flag is asserted then update device le connection mode + * with invalid parameters and check for errors. + * scenario Try to update device le connection mode with invalid parameter. + */ +int utc_bluetooth_bt_device_update_le_connection_mode_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_update_le_connection_mode(NULL, BT_DEVICE_LE_CONNECTION_MODE_BALANCED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_update_le_connection_mode(NULL, BT_DEVICE_LE_CONNECTION_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_positive.c b/tests/unittest/utc_bluetooth_device_positive.c new file mode 100644 index 0000000..89c1ef8 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_positive.c @@ -0,0 +1,434 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDevicePositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static bt_device_info_s *device_info = NULL; +static const char *remote_address = "B8:5E:7B:E7:92:7D"; +static bool bt_supported = false; +static GMainLoop *mainloop = NULL; + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +static void device_bonded_cb(int result, bt_device_info_s *device_info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void device_unbonded_cb(int result, char *remote_address, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void device_authorization_state_changed_cb(bt_device_authorization_e authorization_state, char *address, void *user_data) +{ + +} + +static bool bonded_device_cb_for_device_p(bt_device_info_s *dev_info, void *user_data) +{ + return false; +} + +static void bt_connection_state_changed_cb(bool connected, bt_device_connection_info_s *conn_info, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_device_positive_startup + * @description check if bluetooth is supported, initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_device_positive_cleanup + * @description check if bluetooth is supported, clear the device information resources and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_positive_cleanup(void) +{ + if (bt_supported) { + free(device_info); + device_info = NULL; + + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for bond creation + * and check for errors. + * @scenario Registers a callback function to be invoked when the bond creates. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_bond_created_cb(); + } else { + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_destroyed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for bond destroy + * and check for errors. + * @scenario Registers a callback function to be invoked when the bond destroys. + */ +int utc_bluetooth_bt_device_set_bond_destroyed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_bond_destroyed_cb(); + } else { + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in device authorization + * and check for errors. + * @scenario Registers a callback function to be invoked when the authorization of device changes. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_authorization_changed_cb(); + } else { + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the service class of the uuid from uuid list + * and check for errors. + * @scenario Get the service mask from the uuid list. + */ +int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p(void) +{ + char *uuid = "00001101-0000-1000-8000-00805f9b34fb"; + int no_of_service = 1; + bt_service_class_t service_mask_list; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_is_profile_connected_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the profile connection state with + * respect to remote address and profile and check for errors. + * @scenario Gets the profile connected status if bluetooth is supported else throws an error. + + */ +int utc_bluetooth_bt_device_is_profile_connected_p(void) +{ + bt_profile_e bt_profile = BT_PROFILE_RFCOMM; + bool is_connected = FALSE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_created_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for bond creation + * and check for errors. + * @scenario Unregisters the callback function for bond creation. + */ +int utc_bluetooth_bt_device_unset_bond_created_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then all bonded device information is listed from the device list + * and check for errors. + * scenario Retrieves the device information of all bonded devices. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_destroyed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for bond destroy + * and check for errors. + * @scenario Unregisters the callback function for bond destroy. + */ +int utc_bluetooth_bt_device_unset_bond_destroyed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_authorization_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in device authorization + * and check for errors. + * @scenraio Unregisters the callback function for device authorization changes. + */ +int utc_bluetooth_bt_device_unset_authorization_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in connection state + * and check for errors. + * scenario Registers a callback function to be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_device_set_connection_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_connection_state_changed_cb(); + } else { + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for change in connection state + * and check for errors. + * @scenario Unregisters the callback function to be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_device_unset_connection_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* Platform TCs */ +int utc_bluetooth_bt_device_create_bond_p() +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_device_destroy_bond_p() +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_gatt_negative.c b/tests/unittest/utc_bluetooth_gatt_negative.c new file mode 100644 index 0000000..e2892ae --- /dev/null +++ b/tests/unittest/utc_bluetooth_gatt_negative.c @@ -0,0 +1,1970 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothGattNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *remote_addr = "E4:32:CB:41:1F:A6"; +static bool le_supported = false; +static bool bt_supported = false; +static bool gatt_client_supported = false; +static bool gatt_server_supported = false; +static bool ipsp_supported = false; + +static void gatt_connection_state_changed_cb_p(int result, bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + fprintf(stderr, "Device is connected with remote address."); + } else { + fprintf(stderr, "Device is disconnected from remote address."); + } +} + +/** + * @function utc_bluetooth_gatt_negative_startup + * @description if bluetooth is supported and LE is supported, initialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + gatt_client_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.client", &gatt_client_supported); + + gatt_server_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.server", &gatt_server_supported); + + ipsp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.ipsp", &ipsp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_gatt_negative_cleanup + * @description If bluetooth is supported and LE is supported, release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_gatt_connect_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * connect to the remote device and check for errors. + * @scenario Try to connect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_connect_n(void) +{ + bool auto_connect = FALSE; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_connect(remote_addr, auto_connect); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_connect(remote_addr, auto_connect); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_disconnect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_disconnect_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * disconnect connection to the remote device and check for errors. + * @scenario Try to disconnect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_disconnect_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_connect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_connect_n1 + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then connect to the remote device + * with invalid parameters and check for errors. + * @scenario Try to connect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously with invalid parameters. + */ +int utc_bluetooth_bt_gatt_connect_n1(void) +{ + bool auto_connect = FALSE; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_connect(NULL, auto_connect); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_connect(NULL, auto_connect); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_disconnect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_disconnect_n1 + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then disconnect the connection to the remote device + * with invalid parameters and check for errors. + * @scenario Try to disconnect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously with invalid parameters. + */ +int utc_bluetooth_bt_gatt_disconnect_n1(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for LE connection change and check for errors. + * @scenario Registers a callback function that will be invoked when a LE connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback for LE connection change and check for errors. + * @scenario Try to unregister the callback function that will be invoked when a LE connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + char *value = NULL; + int len = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_value(gatt_handle, &value, &len); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_value(gatt_handle, &value, &len); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_int_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle of interger type by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle as an integer type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_int_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int *value = NULL; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_int_value(gatt_handle, BT_DATA_TYPE_SINT16, offset, value); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_int_value(gatt_handle, BT_DATA_TYPE_SINT16, offset, value); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_float_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle of float type by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle as an float type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_float_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + float *value = NULL; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, offset, value); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, offset, value); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then set the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to set the value of a characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + const char *value = NULL; + int value_length = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_value(gatt_handle, value, value_length); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_value(gatt_handle, value, value_length); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_int_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle of interger type by using the invalid parameters and check for errors. + * @scenario Try to update the value of a characteristic or descriptor's GATT handle as an integer type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_int_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int value = 0; + int value_length = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_int_value(gatt_handle, 0x02, value, value_length); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_int_value(gatt_handle, 0x02, value, value_length); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_float_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle of float type by using the invalid parameters and check for errors. + * @scenario Try to update the value of a characteristic or descriptor's GATT handle as an float type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_float_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int mantissa = 0; + int exponent = 0; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, mantissa, exponent, offset); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, mantissa, exponent, offset); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_uuid_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the uuid of given + * GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the UUID of a service, characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_uuid_n(void) +{ + bt_gatt_h gatt_handle = NULL; + char *uuid = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_uuid(gatt_handle, &uuid); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_uuid(gatt_handle, &uuid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the attribute type + * of given GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the type of GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_type_n(void) +{ + bt_gatt_h gatt_handle = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_type(gatt_handle, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_type(gatt_handle, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_client_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the client handle + * of given GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the GATT client handle which the specified service belongs to, using invalid paramters. + */ +int utc_bluetooth_bt_gatt_service_get_client_n(void) +{ + bt_gatt_h gatt_handle = NULL; + bt_gatt_client_h *client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_client(gatt_handle, client); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_client(gatt_handle, client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_characteristic_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the characteristic's GATT handle + * of the given UUID by using invalid paramters and check for errors. + * @scenario Try to get a characteristic's GATT handle which has specific UUID by using invalid paramters. + */ +int utc_bluetooth_bt_gatt_service_get_characteristic_n(void) +{ + bt_gatt_h service = NULL; + const char *uuid = NULL; + bt_gatt_h *characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_characteristic(service, uuid, characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_characteristic(service, uuid, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool __bt_gatt_client_foreach_chr_cb(int total, int index, bt_gatt_h chr_handle, void *data) +{ + return true; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_foreach_characteristics_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the characterisitcs those + * belong to a specific service by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each characteristic that belongs to the specified service + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_foreach_characteristics_n(void) +{ + int test_id = 0; + bt_gatt_h service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_foreach_characteristics(service, __bt_gatt_client_foreach_chr_cb, (void *)test_id); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_foreach_characteristics(service, __bt_gatt_client_foreach_chr_cb, (void *)test_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_included_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the included service's GATT handle + * of the given specific UUID by using the invalid parameters. and check for errors. + * @scenario Try to get a included service's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_get_included_service_n(void) +{ + bt_gatt_h service = NULL; + const char *uuid = NULL; + bt_gatt_h *included_service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_included_service(service, uuid, included_service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_included_service(service, uuid, included_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_foreach_included_services_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the included services those + * belong to a specific service by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each included services that belongs to the specified service + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_foreach_included_services_n(void) +{ + bt_gatt_h service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_foreach_included_services(service, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_foreach_included_services(service, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the service handle + * of the given characteristics handle using invalid paramters and check for errors. + * @scenario Try to get the service's GATT handle which the specified characteristic belongs to using invalid paramters. + */ +int utc_bluetooth_bt_gatt_characteristic_get_service_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_h *service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_service(characteristic, service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_service(characteristic, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_properties_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the properties of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to get the properties which a characteristic's GATT handle has, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_properties_n(void) +{ + bt_gatt_h characteristic = NULL; + int *properties = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_properties(characteristic, properties); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_properties(characteristic, properties); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_write_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the attribute write type of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to get the write type of the specified characteristic, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_write_type_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_write_type_e *write_type = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } else { + ret = bt_gatt_characteristic_get_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_set_write_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then set the attribute write type of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to set the write type of the specified characteristic, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_set_write_type_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_write_type_e write_type = BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_set_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_set_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_descriptor_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the descriptor's GATT handle + * of the given specific UUID by using the invalid parameters. and check for errors. + * @scenario Try to get a descriptor's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_descriptor_n(void) +{ + bt_gatt_h characteristic = NULL; + const char *uuid = NULL; + bt_gatt_h *descriptor = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_descriptor(characteristic, uuid, descriptor); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_descriptor(characteristic, uuid, descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the descriptors those + * belong to a specific characteristic by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each characteristic that belongs to the specified characteristic + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_foreach_descriptors(characteristic, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_foreach_descriptors(characteristic, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_characteristic_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the characteristic's handle + * of the given descriptor handle by using the invalid parameters and check for errors. + * @scenario Try to get the characteristic's GATT handle which the specified descriptor belongs to by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_descriptor_get_characteristic_n(void) +{ + bt_gatt_h descriptor = NULL; + bt_gatt_h *characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_characteristic(descriptor, characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_get_characteristic(descriptor, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_create_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * create the client for given remote device and check for errors. + * scenario Try to create the GATT client handle after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_create_n(void) +{ + const char *remote_address = "00:19:0E:01:61:17"; + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_address, &client); + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_create(remote_address, client); + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_destroy_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * destroy the client for given remote device and check for errors. + * scenario Try to destroy the GATT client handle after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_destroy_n(void) +{ + const char *remote_address = "00:19:0E:01:61:17"; + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_address, &client); + ret = bt_gatt_client_destroy(client); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_destroy(client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_get_remote_address_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * get the device address for given remote device for which client is create and check for errors. + * scenario Try to get the address of remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_get_remote_address_n(void) +{ + bt_gatt_client_h client = NULL; + char *remote_address = "00:19:0E:01:61:17"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_client_create(remote_address, &client); + + ret = bt_gatt_client_get_remote_address(client, &remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + } else { + ret = bt_gatt_client_get_remote_address(client, &remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_read_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then read the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to read the value of a characteristic or descriptor from the remote device asynchronously, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_read_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_read_value(gatt_handle, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_read_value(gatt_handle, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_request_completed_cb(int result, bt_gatt_h request_handle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_write_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to write the value of a characteristic or descriptor from the remote device asynchronously, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_write_value_n(void) +{ + bt_gatt_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_write_value(client, __bt_gatt_client_request_completed_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_write_value(client, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then register a callback for characterisitc value is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the characteristic value is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_set_characteristic_value_changed_cb(characteristic, __bt_gatt_client_value_changed_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_set_characteristic_value_changed_cb(characteristic, __bt_gatt_client_value_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then unregister a callback for characterisitc value is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the characteristic value is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_characteristic_value_changed_cb(characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_characteristic_value_changed_cb(characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_get_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the service's handle + * of the given specific UUId from the client created by using the invalid parameters and check for errors. + * @scenario Try to get a service's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_get_service_n(void) +{ + bt_gatt_client_h client = NULL; + const char *uuid = NULL; + bt_gatt_h *service = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_get_service(client, uuid, service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_get_service(client, uuid, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool __bt_gatt_foreach_cb(int total, int index, bt_gatt_h gatt_handle, void *user_data) +{ + return true; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_foreach_services_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the service those + * belong to a specific GATT client device by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each service that belongs to the specified GATT client + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_foreach_services_n(void) +{ + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_foreach_services(client, __bt_gatt_foreach_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_foreach_services(client, __bt_gatt_foreach_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the service handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the service handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the characteristic handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the characteristic handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the descriptor handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the descriptor handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_permissions_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the characteristic's permission, + * by using the invalid parameters and check for errors. + * @scenario Try to get the characteristic's permission, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_permissions_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_permissions_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the descriptor's permission, + * by using the invalid parameters and check for errors. + * @scenario Try to get the descriptor's permission, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_get_permissions_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT service, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_create_n(void) +{ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(NULL, service_type, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_create(NULL, service_type, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_characteristic_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the characteristic to the service, + * by using the invalid parameters and check for errors. + * @scenario Try to add the characteristic to the service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_add_characteristic_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_add_characteristic(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_add_characteristic(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_included_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the service to the specified service as included service, + * by using the invalid parameters and check for errors. + * @scenario Try to add the service to the specified service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_add_included_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_add_included_service(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_add_included_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_server_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the GATT server handle from the specified service, + * by using the invalid parameters and check for errors. + * @scenario Try to get the GATT server handle from the specified service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_get_server_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_server(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_server(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT characteristic, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT characteristic, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_create_n(void) +{ + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + char char_value[1] = { 80 }; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(NULL, permissions, properties, char_value, sizeof(char_value), NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_create(NULL, permissions, properties, char_value, sizeof(char_value), NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_add_descriptor_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the descriptor to the characteristic, + * by using the invalid parameters and check for errors. + * @scenario Try to add the descriptor to the characteristic, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_add_descriptor_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_add_descriptor(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_add_descriptor(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT descriptor, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT descriptor, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_create_n(void) +{ + char desc_value[2] = { 0, 0 }; + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(NULL, permissions, desc_value, sizeof(desc_value), NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_create(NULL, permissions, desc_value, sizeof(desc_value), NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_initialize_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * initialize the GATT server and check for errors. + * @scenario Try to initialize the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_initialize_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_deinitialize_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * deinitialize the GATT server and check for errors. + * @scenario Try to deinitialize the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_deinitialize_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * create the GATT server and check for errors. + * @scenario Try to create the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_create_n(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * destroy the GATT server and check for errors. + * @scenario Try to destroy the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_destroy_n(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a callback function to be invoked when a read request is issued and check for errors. + * @scenario Try to register a callback function to be invoked when a read request is issued after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, i + * then deinitialize the bluetooth and register a callback function to be invoked + * when the remote device enables or disables the Notification/Indication for particular characteristics and check for errors. + * @scenario Try to register a callback function to be invoked + * when the remote device enables or disables the Notification/Indication for particular characteristics and check for errors + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a callback function to be invoked when a write request is issued and check for errors. + * @scenario Try to register a callback function to be invoked when a write request is issued after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * notify value change of the characteristic to the remote device and check for errors. + * @scenario Try to notify value change of the characteristic to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_notify_characteristic_changed_value(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_notify_characteristic_changed_value(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * get a service's GATT handle which has a specific UUID and check for errors. + * @scenario Try to get a service's GATT handle which has a specific UUID after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_get_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_service(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_get_service(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_device_mtu_n + * @since_tizen 5.5 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * get the remote deivce's MTU value and check for errors. + * @scenario Try to get the remote deivce's MTU value after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_get_device_mtu_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_device_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_get_device_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_foreach_services_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * invoke a callback function on each service that belongs to be specified GATT server and check for errors. + * @scenario Try to invoke a callback function on each service that belongs to be specified GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_foreach_services_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_foreach_services(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_foreach_services(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_register_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a GATT service handle to GATT server and check for errors. + * @scenario Try to register a GATT service handle to GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_register_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_register_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * unregister a GATT service handle from the GATT server and check for errors. + * @scenario Try to unregister a GATT service handle from the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_unregister_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_unregister_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_all_services_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * unregister the all GATT services handle from the GATT server and check for errors. + * @scenario Try to unregister the all GATT services handle from the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_unregister_all_services_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_all_services(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_unregister_all_services(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_start_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * start a server and check for errors. + * @scenario Try to start a server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_start_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_send_response_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send response and check for errors. + * @scenario Try to send response after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_send_response_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_send_response(0, 0, 0, 0, NULL, -1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_send_response(0, 0, 0, 0, NULL, -1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_set_service_changed_cb_n + * @since_tizen 3.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for service change and check for errors. + * @scenario Registers a callback function that will be invoked when a service is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_set_service_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_service_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_set_service_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n + * @since_tizen 3.0 + * @description if bluetooth LE is supported and startup_flag is asserted then unregister a callback for service is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the service is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_service_changed_cb(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_service_changed_cb(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_initialize_n + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * initialize the IPSP server and check for errors. + * @scenario Try to initialize the IPSP server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_initialize_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_deinitialize_n + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * deinitialize the IPSP server and check for errors. + * @scenario Try to deinitialize the IPSP server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_deinitialize_n(void) +{ + if (ipsp_supported) { + ret = bt_deinitialize(); + + ret = bt_ipsp_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_ipsp_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_connect_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * connect to the remote device and check for errors. + * @scenario Try to connect to the IPSP service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_connect_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_disconnect_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * disconnect connection to the remote device and check for errors. + * @scenario Try to disconnect to the IPSP service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_disconnect_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for IPSP connection change and check for errors. + * @scenario Registers a callback function that will be invoked when a IPSP connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback for IPSP connection change and check for errors. + * @scenario Try to unregister the callback function that will be invoked when a IPSP connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n(void) +{ + if (ipsp_supported) { + ret = bt_deinitialize(); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_request_att_mtu_change_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_request_att_mtu_change(NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_request_att_mtu_change(NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_get_att_mtu_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_get_att_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_get_att_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_set_att_mtu_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_att_mtu_changed_cb(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_gatt_positive.c b/tests/unittest/utc_bluetooth_gatt_positive.c new file mode 100644 index 0000000..e8d6cb4 --- /dev/null +++ b/tests/unittest/utc_bluetooth_gatt_positive.c @@ -0,0 +1,1276 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothGattPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool le_supported = false; +static bool gatt_client_supported = false; +static bool gatt_server_supported = false; +static bool bt_supported = false; +static bool ipsp_supported = false; + +static void gatt_connection_state_changed_cb_p(int result, bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + fprintf(stderr, "Device is connected with remote address."); + } else { + fprintf(stderr, "Device is disconnected from remote address."); + } +} + +void __bt_ipsp_connection_state_changed_cb(int result, bool connected, const char *remote_address, const char *iface_name, void *user_data) +{ + +} + +static void __bt_gatt_client_att_mtu_changed_cb(bt_gatt_client_h client, const bt_gatt_client_att_mtu_info_s *mtu_info, void *user_data) +{ + +} + +static void __bt_gatt_server_read_value_requested_cb_p(const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_read_value_requested_cb"); +} + +static void __bt_gatt_server_notification_state_change_cb_p(bool notify, bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_notification_state_change_cb"); +} + +static void __bt_gatt_server_write_value_requested_cb_p(const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, bool response_needed, int offset, const char *value, int len, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_write_value_requested_cb"); +} + +static bool __bt_gatt_server_foreach_svc_cb_p(int total, int index, bt_gatt_h svc_handle, void *data) +{ + fprintf(stderr, "__bt_gatt_server_foreach_svc_cb"); + return true; +} + +/** + * @function utc_bluetooth_gatt_positive_startup + * @description check if bluetooth is supported and LE is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + gatt_client_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.client", &gatt_client_supported); + + gatt_server_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.server", &gatt_server_supported); + + ipsp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.ipsp", &ipsp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_gatt_positive_cleanup + * @description check If bluetooth is supported and LE is supported, release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth LE is supported and startup_flag is asserted then register a callback for change + * in LE connection state and checked for errors. + * scenario Registers a callback function that will be invoked when the LE connection state is changed. + */ +int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth LE is supported and startup_flag is asserted then the callback is unregistered for change + * in LE connection state and checked for errors. + * scenario Unregisters a callback function that will be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT service handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT service handle. + */ +int utc_bluetooth_bt_gatt_service_destroy_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_destroy(service); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_service_destroy(service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT characteristic handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT characteristic handle. + */ +int utc_bluetooth_bt_gatt_characteristic_destroy_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_destroy(characteristic); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_characteristic_destroy(characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT descriptor handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT descriptor handle. + */ +int utc_bluetooth_bt_gatt_descriptor_destroy_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_destroy(descriptor); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_descriptor_destroy(descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_permissions_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create characteristic's handle and get characteristic's permission then ensure there is no error. + * And then, destroy the characteristic's handle. + * Else, get characteristic's permission and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_characteristic_get_permissions and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_characteristic_get_permissions_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_permissions(characteristic, (int *)&permissions); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_get_permissions(characteristic, (int *)&permissions); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_permissions_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create descriptor's handle and get descriptor's permission then ensure there is no error. + * And then, destroy the descriptor's handle. + * Else, get descriptor's permission and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_descriptor_get_permissions and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_descriptor_get_permissions_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_permissions(descriptor, (int *)&permissions); + if (ret != BT_ERROR_NONE) { + bt_gatt_descriptor_destroy(descriptor); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_descriptor_destroy(descriptor); + } else { + ret = bt_gatt_descriptor_get_permissions(descriptor, (int *)&permissions); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT service is created + * for specific UUID/type and checked for errors. + * scenario Create the GATT service for specific UUID and service type. + */ +int utc_bluetooth_bt_gatt_service_create_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + } else { + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_characteristic_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT service handle and characteristic handle. + * Then, add the characteristic's handle to serivce's handle and ensure there is no error. + * Else, add the characteristic's handle to serivce's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_add_characteristic and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_add_characteristic_p(void) +{ + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + char *service_uuid = "180f"; /* Battery Service */ + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_add_characteristic(service, characteristic); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_service_destroy(service); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_service_destroy(service); + } else { + ret = bt_gatt_service_add_characteristic(service, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_included_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT service handle and included service handle. + * Then, add the included service handle to service handle and ensure there is no error. + * Else, add the included service handle to service handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_add_included_service and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_add_included_service_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + bt_gatt_h included_service = NULL; + char *included_service_uuid = "180d"; /* Heart Rate Service */ + bt_gatt_service_type_e included_service_type = BT_GATT_SERVICE_TYPE_SECONDARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(included_service_uuid, included_service_type, &included_service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_add_included_service(service, included_service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_service_destroy(included_service); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_service_destroy(included_service); + } else { + ret = bt_gatt_service_add_included_service(service, included_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_server_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and get server from service and ensure there is no error. + * Else, get GATT server handle from service and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_get_server on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_get_server_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_server_h get_server = NULL; + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_get_server(service, &get_server); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_service_get_server(service, &get_server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT characteristic is created + * for specific UUID/property and checked for errors. + * scenario Create the GATT characteristic for specific UUID and property. + */ +int utc_bluetooth_bt_gatt_characteristic_create_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_add_descriptor_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT characteristic's handle and descriptor's handle. + * Then, add the descriptor's handle to characteristic's handle and ensure there is no error. + * Else, add the descriptor's handle to characteristic's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_characteristic_add_descriptor and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_characteristic_add_descriptor_p(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char *desc_uuid = "2902"; + char char_value[1] = { 80 }; /* 80% */ + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + if (ret != BT_ERROR_NONE) { + bt_gatt_descriptor_destroy(descriptor); + bt_gatt_characteristic_destroy(characteristic); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_descriptor_destroy(descriptor); + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT descriptor is created + * for specific UUID/permissions and checked for errors. + * scenario Create the GATT descriptor for specific UUID and permissions. + */ +int utc_bluetooth_bt_gatt_descriptor_create_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_descriptor_destroy(descriptor); + } else { + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_initialize_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, deinitialize the GATT server and initialize the GATT server and ensure there is no error. + * Else, initialize the GATT server and verify the result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_initialize on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_initialize_p(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_deinitialize_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, deinitialize the GATT server and ensure there is no error. + * Else, deinitialize the GATT server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_deinitialize on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_deinitialize_p(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT server's handle and ensure there is no error. + * Else, create GATT server's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_create on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_create_p(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_server_destroy(server); + } else { + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT server's handle and destroy GATT server's handle then ensure there is no error. + * Else, destroy GATT server's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_destroy on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_destroy_p(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when a read request + * for a specified characteristic is issued and ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_read_value_requested_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when the remote device + * enables or disables the Notification/Indication for particular characteristics and ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_characteristic_notification_state_change_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when a value of + * characteristic has been changed cnd ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_write_value_requested_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, __bt_gatt_server_write_value_requested_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, __bt_gatt_server_write_value_requested_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and get service from servere and ensure there is no error. + * Else, get GATT service handle from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_get_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_get_service_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_h service = NULL; + bt_gatt_h get_service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_service(server, service_uuid, &get_service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_get_service(server, service_uuid, &get_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_foreach_services_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. + * Then, register service to server and invokes a callback function on each service that belongs to the GATT server and ensure there is no error. + * Else, invokes a callback function on each service and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_foreach_services on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_foreach_services_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_foreach_services(server, __bt_gatt_server_foreach_svc_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_foreach_services(server, __bt_gatt_server_foreach_svc_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_register_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and ensure there is no error. + * Else, register service to server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_register_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_register_service_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_register_service(server, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and unregister service and ensure there is no error. + * Else, unregister service from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_unregister_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_unregister_service_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_unregister_service(server, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_all_services_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and unregister all services and ensure there is no error. + * Else, unregister services from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_unregister_all_services on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_unregister_all_services_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_all_services(server); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_unregister_all_services(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_start_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and start server and ensure there is no error. + * Else, start server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_start on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_start_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_deinitialize(); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then register a callback for change + * in IPSP connection state and checked for errors. + * scenario Registers a callback function that will be invoked when the IPSP connection state is changed. + */ +int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p(void) +{ + if (ipsp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + } else { + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the callback is unregistered for change + * in IPSP connection state and checked for errors. + * scenario Unregisters a callback function that will be invoked when the IPSP connection state is changed. + */ +int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p(void) +{ + if (ipsp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p(void) +{ + bt_gatt_client_h client = NULL; + static const char *remote_addr = "E4:32:CB:41:1F:A6"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_addr, &client); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + + bt_gatt_client_destroy(client); + } else { + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p(void) +{ + bt_gatt_client_h client = NULL; + static const char *remote_addr = "E4:32:CB:41:1F:A6"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_addr, &client); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + bt_gatt_client_destroy(client); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hdp_negative.c b/tests/unittest/utc_bluetooth_hdp_negative.c new file mode 100644 index 0000000..a810953 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hdp_negative.c @@ -0,0 +1,413 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHDPNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hdp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_hdp_negative_startup + * @description check if bluetooth is supported and HDP is supported, initialize bluetooth + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hdp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.health", &hdp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_hdp_negative_cleanup + * @description If bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_n(void) +{ + if (hdp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then register a callback, + * that will be invoked when you receive the data, by using invalid parameters and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when HDP connection state is changed and check for errors. + * @scenario Try to register a callback function that will be invoked when the HDP connection state is changed, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then register a callback, + * that will be invoked when HDP connection state is changed, by using invalid parameters and check for errors. + * @scenario Try to register a callback function that will be invoked when the HDP connection state is changed, by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_disconnect_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and disconnect + * HDP connection and check for errors. + * @scenario Try to disconnect the remote device, asynchronously. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_disconnect_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_disconnect(NULL, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_disconnect(NULL, 1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_connect_to_source_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then disconnect HDP connection + * by using invalid parameters. and check for errors. + * @scenario Try to disconnect the remote device, asynchronously by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_connect_to_source_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); +#endif + ret = bt_hdp_connect_to_source(NULL, NULL); +#ifdef WEARABLE + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#else + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_connect_to_source_n2 + * @since_tizen 2.3 + * @description + */ +int utc_bluetooth_bt_hdp_connect_to_source_n2(void) +{ + if (!hdp_supported) { + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_register_sink_app_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register + * HDP app with sink role and check for errors. + * @scenario Try to register an application that acts as the @a Sink role of HDP(Health Device Profile), after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_register_sink_app_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_register_sink_app(1, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_register_sink_app(1, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister + * HDP app with sink role and check for errors. + * @scenario Try to unregister an application that acts as the @a Sink role of HDP(Health Device Profile), after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, unregister HDP app with sink role + * by using invalid parameters and check for errors. + * @scenario Try to unregister an application that acts as the @a Sink role of HDP(Health Device Profile) by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_send_data_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then send HDP data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_send_data_n(void) +{ +#ifdef WEARABLE + const char *data = "dts_test"; +#else + char *data = "dts_test"; +#endif + if (!hdp_supported) { +#ifdef WEARABLE + ret = bt_hdp_send_data(1, data, strlen(data)); +#else + ret = bt_hdp_send_data(1, data, sizeof(data)); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_hdp_send_data(1, data, strlen(data)); +#else + ret = bt_hdp_send_data(1, data, sizeof(data)); +#endif + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; + +} + +static void connected_cb_for_hdp_p(int result, const char *remote_address, const char *app_id, bt_hdp_channel_type_e type, unsigned int channel, void *user_data) +{ + +} + +static void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback set + * for HDP connection state change and check for errors. + * @scenario Try to unregister a callback function that will be invoked when the HDP connection state is changed, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_hdp_unset_connection_state_changed_cb(); + } + + return 0; +} + +static void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_data_received_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback + * set for receiving the data and check for errors. + * @scenario Try to unregister a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unset_data_received_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_hdp_unset_data_received_cb(); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hdp_positive.c b/tests/unittest/utc_bluetooth_hdp_positive.c new file mode 100644 index 0000000..19b77cb --- /dev/null +++ b/tests/unittest/utc_bluetooth_hdp_positive.c @@ -0,0 +1,254 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHDPPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hdp_supported = false; +static bool bt_supported = false; + +static void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data) +{ + +} + +static void connected_cb_for_hdp_p(int result, const char *remote_address, const char *app_id, bt_hdp_channel_type_e type, unsigned int channel, void *user_data) +{ + +} + +static void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hdp_positive_startup + * @description check if bluetooth is supported and HDP is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hdp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.health", &hdp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_hdp_positive_cleanup + * @description check If bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Registers a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_data_received_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister a callback + * that will be invoked when you receive the data and check for errors. + * @scenario unregisters a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hdp_unset_data_received_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register a callback that will be + * called when HDP connection state is changed and check for errors. + * scenario Registers a callback function that will be invoked when the HDP connection state is changed. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister the callback set for + * HDP connection state change and check for errors. + * scenario Unregisters a callback function that will be invoked when the HDP connection state is changed. + */ +int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister the app + * that acts as sink role for HDP and checked for errors. + * scenario Unregisters the given application that acts as the @a Sink role of HDP(Health Device Profile). + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_p(void) +{ + char *app_id = NULL; + + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); +#ifdef WEARABLE + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NONE); +#else + bt_hdp_register_sink_app(1, &app_id); +#endif + + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NONE); + + free(app_id); + app_id = NULL; + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_register_sink_app_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register the app + * that acts as sink role for HDP and checked for errors. + * scenario Registers the given application that acts as the @a Sink role of HDP(Health Device Profile). + */ +int utc_bluetooth_bt_hdp_register_sink_app_p(void) +{ + char *app_id = NULL; + + if (!hdp_supported) { + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NONE); +#else + bt_hdp_unregister_sink_app(app_id); +#endif + + free(app_id); + app_id = NULL; + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hid_negative.c b/tests/unittest/utc_bluetooth_hid_negative.c new file mode 100644 index 0000000..f94eca8 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hid_negative.c @@ -0,0 +1,441 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHIDNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hid_supported = false; +static bool hid_device_supported = false; +static bool bt_supported = false; +static char *remote_address = "D8:90:E8:EE:2B:3A"; + +static void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hid_negative_startup + * @description Check for the support of BT and HID features on the device and initialize the Bluetooth + * and HID(Human Interface Device) Host on the device. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#else + bt_supported = true; + hid_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#ifdef WEARABLE + hid_device_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid_device", &hid_device_supported); +#endif +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + if (hid_supported) { + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + } +} + +/** + * @function utc_bluetooth_hid_negative_cleanup + * @description Check for the support of BT and HID features on the device and deinitialize the HID(Human Interface Device) Host. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_negative_cleanup(void) +{ + if (hid_supported) { + bt_hid_host_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and initialize the Bluetooth HID(Human Interface Device) Host with NULL parameters. + * Check bt is initialized and deinitialize the bluetooth and initialize the HID host on the device. Check for expected error. + * @senario Initialize the HID host when HID feature is not supported. Denitialize the bt adapter and re-initialize hid host and check status. + */ +int utc_bluetooth_bt_hid_host_initialize_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_n1 + * @since_tizen 2.3 + * @description Check for the support of HID feature and initialize the Bluetooth HID(Human Interface Device) Host with NULL parameters. + * Confirm the bluetooth is initialzed and then initialize the HID host on the device. Check for expected error. + * @senario Initialize the HID host when HID feature is not supported. Ensure bt is initlaized and initialize HID host and check status. + */ +int utc_bluetooth_bt_hid_host_initialize_n1(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_connect_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform connect operation from HID(Human Interface Device) Host with NULL parameter. + * Confirm the bluetooth is initialized and perform connect operation from HID host with NULL parameter. Check for expected error. + * @senario Perform the connect operation from HID Host when HID feature is not supported. Ensure bt is initialized and perform HID host connect and check status. + */ +int utc_bluetooth_bt_hid_host_connect_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_disconnect_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform disconnect operation from HID(Human Interface Device) Host with NULL parameter. + * Confirm the bluetooth is initialized and perform disconnect operation from HID host with NULL parameter. Check for expected error. + * @senario Perform the disconnect operation from HID Host when HID feature is not supported. Ensure bt is initialized and perform HID host disconnect and check status. + */ +int utc_bluetooth_bt_hid_host_disconnect_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_deinitialize_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform HID host deinitialize. + * Confirm the bluetooth is initialized and perform HID host initialize and deinitialize and then deinitialize again. Check for expected error. + * @senario Perform the HID Host initialize and deinitialize operations mutiple times and for check for expected result. + */ +int utc_bluetooth_bt_hid_host_deinitialize_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_hid_device_activate_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and initialize the Bluetooth HID(Human Interface Device) DEVICE with NULL parameters. + * Check bt is initialized and deinitialize the bluetooth and initialize the HID device on the device. Check for expected error. + * @senario Activate the HID Device when HID DEVICE feature is not supported. Denitialize the bt adapter and re-activate hid device and check status. + */ +int utc_bluetooth_bt_hid_device_activate_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_activate(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_deactivate_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform HID device deactivate. + * Confirm the bluetooth is initialized and perform HID device activate and deactivate and then deactivate again. Check for expected error. + * @senario Perform the HID Device activate and deactivate operations mutiple times and for check for expected result. + */ +int utc_bluetooth_bt_hid_device_deactivate_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_connect_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform connect operation from HID(Human Interface Device) Device with NULL parameter. + * Confirm the bluetooth is initialized and perform connect operation from HID device with NULL parameter. Check for expected error. + * @senario Perform the connect operation from HID Device when HID DEVICE feature is not supported. Ensure bt is initialized and perform HID Device connect and check status. + */ +int utc_bluetooth_bt_hid_device_connect_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_connect(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_disconnect_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform disconnect operation from HID(Human Interface Device) Device with NULL parameter. + * Confirm the bluetooth is initialized and perform disconnect operation from HID Device with NULL parameter. Check for expected error. + * @senario Perform the disconnect operation from HID Device when HID Device feature is not supported. Ensure bt is initialized and perform HID Device disconnect and check status. + */ +int utc_bluetooth_bt_hid_device_disconnect_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_bt_hid_device_send_mouse_event_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then send the mouse event's data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hid_device_send_mouse_event_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_send_mouse_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_send_mouse_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_bt_hid_device_send_key_event_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then send the key event's data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hid_device_send_key_event_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_send_key_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_send_key_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_reply_to_report_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you respose reports and check for errors. + * @scenario Try to respose to reports from HID host, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_reply_to_report_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_reply_to_report(remote_address, 0x01, 0x01, "reply", 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_reply_to_report(remote_address, 0x01, 0x01, "reply", 8); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_set_data_received_cb_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_set_data_received_cb_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_unset_data_received_cb_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback + * set for receiving the data and check for errors. + * @scenario Try to unregister a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_unset_data_received_cb_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hid_positive.c b/tests/unittest/utc_bluetooth_hid_positive.c new file mode 100644 index 0000000..eb8aa24 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hid_positive.c @@ -0,0 +1,255 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHIDPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hid_supported = false; +static bool hid_device_supported = false; +static bool bt_supported = false; + +static void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ +} + +static void device_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +static void device_data_received_cb_for_hid_p(const bt_hid_device_received_data_s *data, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hid_positive_startup + * @description Get system information to check for the support of Bluetooth and HID feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#else + bt_supported = true; + hid_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#ifdef WEARABLE + hid_device_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid_device", &hid_device_supported); +#endif +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_hid_positive_cleanup + * @description Check the system if HID feature is supported and if so deinitialize the hid support on the device. + * Check if BT is supported on the system and then deinitliaze the bluetooth. All resources should be cleaned up. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_positive_cleanup(void) +{ + if (hid_supported) { + bt_hid_host_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_p + * @since_tizen 2.3 + * @description Check the system if HID feature is supported and if so initialize the HID host on the device. Check for expected result. + * Check if BT is supported on the system and then initliaze the HID host. Check for expected result. + * @senario Check for the support of BT and HID features and then initialze the HID host. + */ +int utc_bluetooth_bt_hid_host_initialize_p(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_deinitialize_p + * @since_tizen 2.3 + * @description Check if HID feature is supported and if so deinitialize the HID host on the device. Check for expected result. + * Check if BT is supported on the system and then initliaze and deinitalize the HID host. Check for expected result. + * @senario Check for the support of BT and HID features then initialze and deinitlaize the HID host. + */ +int utc_bluetooth_bt_hid_host_deinitialize_p(void) +{ + if (!hid_supported) { + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_hid_device_activate_p + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and activate the Bluetooth HID(Human Interface Device) DEVICE with registering call back. + * Check to activate the HID device. Check for expected error. + * @senario Activate the HID Device when HID DEVICE feature is supported. After finish to activate hid device successfully and deactivate hid device. + */ +int utc_bluetooth_bt_hid_device_activate_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_deactivate(); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_deactivate_p + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform HID device deactivate. + * Confirm the bluetooth is initialized and perform HID device activate and deactivate. Check for expected error. + * @senario Perform the HID Device activate and deactivate operations and for check for expected result. + */ +int utc_bluetooth_bt_hid_device_deactivate_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_set_data_received_cb_p + * @since_tizen 3.0 + * @description check if HID Device is supported and startup_flag is asserted then register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_set_data_received_cb_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_set_data_received_cb(device_data_received_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_unset_data_received_cb(); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_unset_data_received_cb_p + * @since_tizen 3.0 + * @description check if HID Device is supported and startup_flag is asserted then unregister a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Registers a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hid_device_unset_data_received_cb_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_set_data_received_cb(device_data_received_cb_for_hid_p, NULL); + + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_client_negative.c b/tests/unittest/utc_bluetooth_opp_client_negative.c new file mode 100644 index 0000000..6f6f43f --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_client_negative.c @@ -0,0 +1,268 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-clientNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool opp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_opp_client_negative_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. If OPP is supported, initialize opp client. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + if (opp_supported) { + ret = bt_opp_client_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_opp_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + } + } +} + +/** + * @function utc_bluetooth_opp_client_negative_cleanup + * @description Check if bluetooth and OPP featurse are supported. If OPP is supported then deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_negative_cleanup(void) +{ + if (opp_supported) { + bt_opp_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_client_initialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP featurse are supported. If OPP is supported then try to initialize opp client. + * If BT is supported then deinitialize bluetooth. Now try to initialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize bluetooth and initialize opp on the device. + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_initialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_deinitialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then try to deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Now try to deinitialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize opp client and bluetooth on the device. + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_deinitialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_add_file_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then do bt_opp_client_add_file(). + * If BT is supported then deinitialize bluetooth. Now try to call bt_opp_client_add_file(). Check for expected result. + * @senario Check if BT and OPP features are supported and deinitialize bluetooth on the device and call bt_opp_client_add_file (). + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_add_file_n(void) +{ + const char *file = "/tmp/image16.jpg"; + + if (!opp_supported) { + ret = bt_opp_client_add_file(file); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_add_file(file); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_add_file_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then do bt_opp_client_add_file(). + * If BT is initialzed then try to call bt_opp_client_add_file() with NULL parameter. Check for result BT_ERROR_INVALID_PARAMETER. + * @senario Check if BT is initalized and OPP features is supported and call bt_opp_client_add_file () with NULL parameters. + */ +int utc_bluetooth_bt_opp_client_add_file_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_client_add_file(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_add_file(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_clear_files_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then do bt_opp_client_clear_files(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_clear_files(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_clear_files () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_clear_files_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_push_files_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then call bt_opp_client_push_files(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_push_files(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_push_files () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_push_files_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_push_files(NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_push_files(NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_cancel_push_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then call bt_opp_client_cancel_push(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_cancel_push(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_cancel_push () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_cancel_push_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_cancel_push(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_cancel_push(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_client_positive.c b/tests/unittest/utc_bluetooth_opp_client_positive.c new file mode 100644 index 0000000..0203bde --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_client_positive.c @@ -0,0 +1,161 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-client_Positive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool opp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_opp_client_positive_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. If OPP is supported, initialize opp client. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_positive_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } + + if (opp_supported) { + ret = bt_opp_client_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_opp_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + } + } +} + +/** + * @function utc_bluetooth_opp_client_positive_cleanup + * @description Check if bluetooth and OPP feature is supported. If OPP is supported then deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_positive_cleanup(void) +{ + if (opp_supported) { + bt_opp_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_client_initialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then initialize OPP client. If bluetooth is initialized, + * deinitialize the opp client and then re-initialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then initialize and deinitialize the OPP client + */ +int utc_bluetooth_bt_opp_client_initialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_deinitialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is not supported then de-initialize the OPP client. If bluetooth is initialized, + * then deinitialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize the OPP client + */ +int utc_bluetooth_bt_opp_client_deinitialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_clear_files_p + * @since_tizen 2.3 + * @description Check for support of OPP feature and then clear all files received by the OPP client. If bluetooth is initialized, + * then clear all files received by the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_client_clear_files() from OPP client + */ +int utc_bluetooth_bt_opp_client_clear_files_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_server_negative.c b/tests/unittest/utc_bluetooth_opp_server_negative.c new file mode 100644 index 0000000..c973773 --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_server_negative.c @@ -0,0 +1,454 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-serverNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *dest = "/tmp"; +static bool opp_supported = false; +static bool bt_supported = false; + +static void transfer_finished_cb_for_opp_server_p(int result, const char *file, long long size, void *user_data) +{ + +} + +static void transfer_progress_cb_for_opp_server(const char *file, long long size, int percent, void *user_data) +{ + +} + +static void transfer_finished_cb_for_opp_server(int result, const char *file, long long size, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_bt_opp_server_negative_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_opp_server_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_bt_opp_server_negative_cleanup + * @description Check if bluetooth and OPP features are supported. If OPP is supported then deinitialize opp server. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_opp_server_negative_cleanup(void) +{ +#ifndef TV + if (opp_supported) { + bt_opp_server_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +#endif +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then deinitialize bluetooth and call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize the bluetooth and call bt_opp_server_accept. + * Verify the result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_accept. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n2 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_accept. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n2(void) +{ + int tid = 0; + const char *name = "abc"; + + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server_p, name, NULL, &tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server_p, name, NULL, &tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_reject_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_reject(). + * If BT is initialized then deinitialize bluetooth and call bt_opp_server_reject. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_reject. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_reject_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_reject_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_reject(). + * If BT is initialized then call bt_opp_server_reject. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_reject. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_reject_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then deinitialize bluetooth and set the destination for opp server with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then set the destination for opp server with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n2 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then set the destination for opp server with valid parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n2(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_initialize_by_connection_request(). + * If BT is initialized then deinitialize bluetooth and initialize opp server by connect request. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_initialize_by_connection_request. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_initialize_by_connection_request(). + * If BT is initialized then initialize opp server by connect request with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_initialize_by_connection_request with NULL params. + * Verify for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then deinitialize opp server. + * If BT is initialized then deinitialize bluetooth and deinitialize opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_deinitialize. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_deinitialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then deinitialize opp server. + * If BT is initialized then deinitialize opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_deinitialize. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_deinitialize_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_cancel_transfer_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_cancel_transfer(). + * If BT is initialized then deinitialize bluetooth and cancel the transfer of data from opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_cancel_transfer. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_cancel_transfer_n(void) +{ + int tid = 0; + + if (!opp_supported) { + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_cancel_transfer_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_cancel_transfer(). + * If BT is initialized then cancel the transfer of data from opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_cancel_transfer. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_cancel_transfer_n1(void) +{ + int tid = 0; + + if (!opp_supported) { + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_server_positive.c b/tests/unittest/utc_bluetooth_opp_server_positive.c new file mode 100644 index 0000000..fe7bb61 --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_server_positive.c @@ -0,0 +1,160 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-serverPositive + +static bool startup_flag = true; +static int ret = BT_ERROR_NONE; +static const char *dest = "/tmp"; +static bool opp_supported = false; +static bool bt_supported = false; + +static void push_requested_cb_for_opp_server_p(const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_opp_server_positive_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_server_positive_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_opp_server_positive_cleanup + * @description If BT is supported on the device, then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_server_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to initialize the opp server. + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). + * @senario check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() + * and check for expected result. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to deinitialize the opp server (bt_opp_server_deinitialize). + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). Then deinitialize opp server. + * @senario Check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() + * and bt_opp_server_deinitialize() and check for expected result. + */ +int utc_bluetooth_bt_opp_server_deinitialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to intialize the opp server. + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). Then set destination for opp server. + * @senario Check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() and + * then set destination(bt_opp_server_set_destination) and check for expected result. + */ +int utc_bluetooth_bt_opp_server_set_destination_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_pbap_negative.c b/tests/unittest/utc_bluetooth_pbap_negative.c new file mode 100644 index 0000000..e6b54b7 --- /dev/null +++ b/tests/unittest/utc_bluetooth_pbap_negative.c @@ -0,0 +1,389 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include + +//& set: BluetoothPBAPNegative + +static int startup_flag = BT_ERROR_NONE; +static bool pbap_supported = false; +static bool bt_supported = false; + +void get_phonebook_size_cb_for_pbap_n(int result, const char *remote_address, int size, void *user_data) +{ + +} + +void get_phonebook_pull_cb_pbap_n(int result, const char *remote_address, const char *vcf_file, void *user_data) +{ + +} + +void get_phonebook_list_cb_pbap_n(int result, const char *remote_address, const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_pbap_negative_startup + * @description check if bluetooth is supported and PBAP is supported, initialize bluetooth + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_negative_startup(void) +{ + int ret = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + pbap_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.phonebook.client", &pbap_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_pbap_negative_cleanup + * @description If bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_initialize_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the pbap client profiles and check for errors. + * scenario Try to initialize the Bluetooth profiles related with pbap client. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_initialize_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_deinitialize_n + * @since_tizen 3.0 + * @description check if pbap client is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the pbap client profiles and check for errors. + * scenario Try to deinitialize the Bluetooth profiles related with pbap client. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_deinitialize_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback set for connection state changes and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_connect_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given pbap client profile and check for errors. + * @scenario Try to connect the remote device with the given pbap client profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_connect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_disconnect_n + * @since_tizen 2.3 + * @description check if pbap client profile are supported and startup_flag is asserted, then deinitialize the bluetooth and + * disconnect to the remote device with given pbap client profile and check for errors. + * @scenario Try to disconnect the remote device with the given pbap client profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_disconnect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_phone_book_size_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_phone_book_size_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_phone_book_size(remote_addr, 0, 0, get_phonebook_size_cb_for_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_phone_book_size(remote_addr, 0, 0, get_phonebook_size_cb_for_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_phone_book_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_phone_book_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_phone_book(remote_addr, 0, 0, 0, 0, 0, 100, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_phone_book(remote_addr, 0, 0, 0, 0, 0, 100, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_list_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_list_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_list(remote_addr, 0, 0, 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_list(remote_addr, 0, 0, 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_pull_vcard_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_pull_vcard_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_pull_vcard(remote_addr, 0, 0, 0, 0, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_pull_vcard(remote_addr, 0, 0, 0, 0, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_search_phone_book_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_search_phone_book_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_search_phone_book(remote_addr, 0, 0, 0, "ff", 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_search_phone_book(remote_addr, 0, 0, 0, "ff", 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_pbap_positive.c b/tests/unittest/utc_bluetooth_pbap_positive.c new file mode 100644 index 0000000..fac9fc2 --- /dev/null +++ b/tests/unittest/utc_bluetooth_pbap_positive.c @@ -0,0 +1,199 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include + +//& set: BluetoothPBAPPositive + +static int startup_flag = BT_ERROR_NONE; +static bool pbap_supported = false; +static bool bt_supported = false; + +void connection_state_changed_cb_for_pbap_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_pbap_positive_startup + * @description check if bluetooth is supported and PABP is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + pbap_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.phonebook.client", &pbap_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } + + if (pbap_supported) { + ret = bt_pbap_client_initialize(); + if (BT_ERROR_NONE != ret && BT_ERROR_ALREADY_DONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_pbap_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_pbap_positive_cleanup + * @description check If bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_positive_cleanup(void) +{ + if (pbap_supported) { + bt_pbap_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_initialize_p + * @since_tizen 3.0 + * @description Check if bt, pbap features are supported. If yes, deinitialize pbap and initialize pbap and ensure there is no error. + * Else, initialize pbap and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and pbap is supported and then call bt_pbap_client_initialize on the device and check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_pbap_client_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_pbap_client_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_deinitialize_p + * @since_tizen 3.0 + * @description Check if bt, pbap features are supported. If yes, deinitialize audio and ensure there is no error. + * Else, deinitialize pbap and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Positive case to check for pbap deinitialize. Check if BT and pbap is supported and then deinitialize pbap. + * Check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_pbap_client_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p + * @since_tizen 3.0 + * @description check if PBAP is supported and startup_flag is asserted then register a callback that will be + * called when PBAP connection state is changed and check for errors. + * scenario Registers a callback function that will be invoked when the PBAP connection state is changed. + */ +int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + /* Don't check the error in this position */ + } else { + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p + * @since_tizen 3.0 + * @description check if PBAP is supported and startup_flag is asserted then unregister the callback set for + * PBAP connection state change and check for errors. + * scenario Unregisters a callback function that will be invoked when the PBAP connection state is changed. + */ +int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_service_search_negative.c b/tests/unittest/utc_bluetooth_service_search_negative.c new file mode 100644 index 0000000..fab9f1c --- /dev/null +++ b/tests/unittest/utc_bluetooth_service_search_negative.c @@ -0,0 +1,182 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothServiceSearchNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_service_search_negative_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_negative_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_service_search_negative_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, deinitialize bluetooth and set the service searched callback. + * @senario Check if BT is supported and then deinitialize bluetooth and set bt_device_set_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_n(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, set the service searched callback. + * @senario Check if BT is supported and then set bt_device_set_service_searched_cb with NULL parameters on the device. + * Check result BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_service_searched_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, unset the service + * searched callback and check for error. If bluetooth is initialized, deinitialize bluetooth and unset the service searched callback. + * @senario Check if BT is supported and then call bt_device_unset_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_unset_service_searched_cb_n(void) +{ + if (!bt_supported) { + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_start_service_search_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, start the service + * search on the device and check for error. If bluetooth is initialized, deinitialize bluetooth and call bt_device_start_service_search(). + * @senario Check if BT is supported and then call bt_device_unset_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_start_service_search_n(void) +{ + if (!bt_supported) { + ret = bt_device_start_service_search(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_start_service_search(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_service_search_positive.c b/tests/unittest/utc_bluetooth_service_search_positive.c new file mode 100644 index 0000000..cb6cd29 --- /dev/null +++ b/tests/unittest/utc_bluetooth_service_search_positive.c @@ -0,0 +1,137 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothServiceSearchPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +static void service_searched_cb_for_service_search_p(int result, bt_device_sdp_info_s *sdp_info, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_service_search_positive_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_service_search_positive_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, set and unset the service searched callback successfully. + * @senario Check if BT is supported and then set bt_device_set_service_searched_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_p(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_service_searched_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_service_searched_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, unset the service + * searched callback and check for error. If bluetooth is initialized, set and unset the service searched callback successfully. + * @senario Check if BT is supported and then set bt_device_unset_service_searched_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_device_unset_service_searched_cb_p(void) +{ + if (!bt_supported) { + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_socket_negative.c b/tests/unittest/utc_bluetooth_socket_negative.c new file mode 100644 index 0000000..ccdeb37 --- /dev/null +++ b/tests/unittest/utc_bluetooth_socket_negative.c @@ -0,0 +1,521 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothSocketNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *data = "dts_test"; +static char *address = "D8:90:E8:EE:2B:3A"; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_socket_negative_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_socket_negative_startup(void) +{ +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_socket_negative_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_socket_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set the data received callback with NULL parameters. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb with NULL params. Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set the data received callback with NULL parameters. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb with NULL params. Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set connection state changed callback with NULL params. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb with NULL parameters. + * Check for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set connection state changed callback with NULL params. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb with NULL parameters. + * Check for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_data_received_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the data received callback and check for error. If bluetooth is initialized, deinitialize bluetooth + * and unset data received callback. + * @senario Check if BT is supported and then set and unset data received callback on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_data_received_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection state changed callback and check for error. If bluetooth is initialized, deinitialize + * bluetooth and unset connection state changed callback. + * @senario Check if BT is supported and then deinitialize bt and unset connection state changed callback on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, deinitialize bt and create rfcomm socket with NULL parameters. + * @senario Check if BT is supported and then deinitialize bluetooth and create rfcomm socket on the device and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_create_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, create rfcomm socket with NULL parameters. + * @senario Check if BT is supported then create rfcomm socket on the device and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_create_rfcomm_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_destroy_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * destroy the rfcomm socket and check for error. If bluetooth is initialized, then destroy rfcomm socket + * with invalid parameter. + * @senario Check if BT is supported and then call bt_socket_destroy_rfcomm on the device with invalid parameter. + * Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_destroy_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_listen_and_accept_rfcomm and check for error. If bluetooth is initialized, then + * listen and accept for rfcomm connection with invalid paramters. + * @senario Check if BT is supported and then call bt_socket_listen_and_accept_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_listen_and_accept_rfcomm(1, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_listen_and_accept_rfcomm(-1, 1); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_listen_and_accept_rfcomm(1, 1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_connect_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_connect_rfcomm and check for error. If bluetooth is initialized, then + * call rfcomm connect api with invalid paramters. + * @senario Check if BT is supported and then call bt_socket_connect_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_connect_rfcomm_n(void) +{ + char *uuid = ""; + + if (!bt_supported) { +#ifdef TV + ret = bt_socket_connect_rfcomm(address, NULL); +#else + ret = bt_socket_connect_rfcomm(address, uuid); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_connect_rfcomm(address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_connect_rfcomm(address, uuid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_disconnect_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_disconnect_rfcomm and check for error. If bluetooth is initialized, then call + * rfcomm disconnect api with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_disconnect_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_disconnect_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_disconnect_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_disconnect_rfcomm(1); +#else + ret = bt_socket_disconnect_rfcomm(-1); +#endif + + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_send_data_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_send_data and check for error. If bluetooth is initialized, then call send data over bt socket + * with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_send_data on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_send_data_n(void) +{ + if (!bt_supported) { + ret = bt_socket_send_data(1, data, strlen(data)); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_send_data(1, data, strlen(data)); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_requested_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * set bt_socket_set_connection_requested_cb and check for error. If bluetooth is initialized, then + * set connected requested callback with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_set_connection_requested_cb on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_requested_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_requested_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +static void bt_socket_connection_requested_cb_func(int socket_fd, const char *remote_address, void *user_data) +{ +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_requested_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_unset_connection_requested_cb and check for error. If bluetooth is initialized, then deinitlaize bluetooth and + * unset connected requested callbackr. + * @senario Check if BT is supported then deinitialize bluetooth and call bt_socket_unset_connection_requested_cb on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_connection_requested_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_socket_unset_connection_requested_cb(); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_socket_positive.c b/tests/unittest/utc_bluetooth_socket_positive.c new file mode 100644 index 0000000..5a68743 --- /dev/null +++ b/tests/unittest/utc_bluetooth_socket_positive.c @@ -0,0 +1,348 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// 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 "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothSocketPositive + +static int startup_flag = BT_ERROR_NONE; +static int socket_fd = 0; +static int ret = BT_ERROR_NONE; +static const char *rfcomm_test_uuid_spp = "00001101-0000-1000-8000-00805F9B34FB"; +static bool bt_supported = false; + +static void socket_data_received_cb_for_socket_p(bt_socket_received_data_s *data, void *user_data) +{ +} + +static void socket_connection_state_changed_cb_for_socket_p(int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data) +{ +} + +/** + * @function utc_bluetooth_bt_socket_positive_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_socket_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + //disable_bluetooth_le_adapter(); + } + } +} + +/** + * @function utc_bluetooth_bt_socket_positive_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_socket_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set and unset the data received callback successfully. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_data_received_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set and unset connection state changed callback successfully. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_connection_state_changed_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, then create rfcomm socket successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm on the device and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_create_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(socket_fd); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_listen_and_accept_rfcomm and check for error. If bluetooth is initialized, then create rfcomm socket + * and listen and accept for rfcomm connection successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm and bt_socket_listen_and_accept_rfcomm on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_listen_and_accept_rfcomm(socket_fd, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_listen_and_accept_rfcomm(socket_fd, 1); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(socket_fd); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_destroy_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * destroy the rfcomm socket and check for error. If bluetooth is initialized, then create rfcomm socket + * and destroy rfcomm socket successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm and bt_socket_destroy_rfcomm on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_destroy_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_destroy_rfcomm(socket_fd); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_destroy_rfcomm(socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_data_received_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the data received callback and check for error. If bluetooth is initialized, then set data received callback + * and unset data received callback successfully. + * @senario Check if BT is supported and then set and unset data received callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_data_received_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection state changed callback and check for error. If bluetooth is initialized, then set + * connection state changed callback and unset connection state changed successfully. + * @senario Check if BT is supported and then set and unset connection state changed callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +static void bt_socket_connection_requested_cb_func(int socket_fd, const char *remote_address, void *user_data) +{ +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_requested_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * set the connection requested callback and check for error. If bluetooth is initialized, then set + * connection requested callback and unset connection requested callback successfully. + * @senario Check if BT is supported and then set and unset connection requested callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_set_connection_requested_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_connection_requested_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_requested_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection requested callback and check for error. If bluetooth is initialized, then set + * connection requested callback and unset connection requested callback successfully and check for error. + * @senario Check if BT is supported and then set and unset connection requested callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_connection_requested_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_convert.sh b/tests/unittest/utc_convert.sh new file mode 100755 index 0000000..083b352 --- /dev/null +++ b/tests/unittest/utc_convert.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for file in `find . -name "*.c"` +do + sed -i -e 's/\"assert.h\"/\"assert_local.h\"/g' $file +done +