diff options
Diffstat (limited to 'test/bt_unit_test.c')
-rw-r--r-- | test/bt_unit_test.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index ee3c185..dd9229a 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -239,6 +239,10 @@ tc_table_t tc_adapter[] = { , 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" @@ -643,6 +647,8 @@ tc_table_t tc_gatt[] = { , 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)" @@ -1467,6 +1473,23 @@ void __bt_adapter_state_changed_cb(int result, "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", + (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes); + } +} + static void __bt_adapter_device_visibility_mode_changed_cb(int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data) @@ -4243,6 +4266,22 @@ int test_input_callback(void *data) } 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]; @@ -6967,6 +7006,17 @@ int test_input_callback(void *data) 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, |