[FRWK] Fix bt-service GAP agent conflict with HAL
[platform/core/connectivity/bluetooth-frwk.git] / test / bluetooth-frwk-test.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *              http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 /**
19  * @file       bluetooth-frwk-test.c
20  * @brief      This is the source file for bluetooth framework test suite.
21  */
22
23 #include <stdio.h>
24 #include <string.h>
25 #include <glib.h>
26 #include <gio/gio.h>
27 #include <pthread.h>
28 #include <stdint.h>
29
30 #include "bluetooth-api.h"
31 #include "bluetooth-hid-api.h"
32 #include "bluetooth-audio-api.h"
33
34
35 bluetooth_device_address_t searched_device = { {0} };
36
37 #define TC_TIMEOUT      30000
38
39 #define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
40 #define DISCOVER_TIMEOUT 20
41 #define DISCOVER_CANCEL_INTERVAL 3
42
43 #define PRT(format, args...) printf("%s:() "format, __FUNCTION__, ##args)
44 #define TC_PRT(format, args...) PRT(format"\n", ##args)
45
46 #define TC_PASS 1
47 #define TC_FAIL 0
48 int client_fd = 0;
49 int server_fd = 0;
50 int g_ret_client_fd1 = -1, g_ret_client_fd2 = -1;
51 const char *g_hdp_app_handle1 =  NULL;
52 const char *g_hdp_app_handle2 =  NULL;
53
54 char *svc_obj_path = NULL;
55 char *char_obj_path = NULL;
56 char *desc_obj_path = NULL;
57
58 int selection;
59 int hdp_manual_mode =  1;
60 const char *rfcomm_test_uuid_spp = "00001101-0000-1000-8000-00805F9B34FB";
61 const char *rfcomm_test_uuid_dun = "00001103-0000-1000-8000-00805F9B34FB";
62 const char *rfcomm_test_uuid_custom = "26b2831b-2c2d-4f9c-914a-c0ab142351b7";
63
64
65 GMainLoop *main_loop = NULL;
66
67 int current_transfer_id = 0;
68
69 typedef struct {
70         bluetooth_device_address_t address;
71         bt_oob_data_t oob_data;
72 } oob_data_t;
73
74 oob_data_t g_local_oob_data;
75 oob_data_t g_remote_oob_data;
76
77
78 typedef struct {
79         const char *tc_name;
80         int tc_code;
81 } tc_table_t;
82
83 void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
84 void bt_hid_event_callback(int event, hid_event_param_t* param, void *user_data);
85 void bt_audio_event_callback(int event, bt_audio_event_param_t* param, void *user_data);
86
87
88 tc_table_t tc_table[] = {
89         {"bluetooth_register_callback"          , 1},
90         {"bluetooth_unregister_callback"        , 2},
91         {"bluetooth_enable_adapter"             , 3},
92         {"bluetooth_disable_adapter"            , 4},
93         {"bluetooth_check_adapter"              , 5},
94         {"bluetooth_get_local_address"          , 6},
95         {"bluetooth_get_local_name"             , 7},
96         {"bluetooth_set_local_name"             , 8},
97         {"bluetooth_get_local_version"          , 90},
98         {"bluetooth_is_service_used"            , 9},
99         {"bluetooth_get_discoverable_mode"      , 10},
100         {"bluetooth_set_discoverable_mode(CONNECTABLE)"                 , 11},
101         {"bluetooth_set_discoverable_mode(GENERAL_DISCOVERABLE)"        , 12},
102         {"bluetooth_set_discoverable_mode(TIME_LIMITED_DISCOVERABLE)"   , 13},
103         {"bluetooth_start_discovery"            , 14},
104         {"bluetooth_cancel_discovery"           , 15},
105         {"bluetooth_is_discovering"             , 16},
106         {"bluetooth_get_bonded_device_list"     , 17},
107         {"bluetooth_bond_device"                , 18},
108         {"bluetooth_cancel_bonding"             , 19},
109         {"bluetooth_unbond_device"      , 20},
110         {"bluetooth_get_bonded_device"  , 21},
111         {"bluetooth_set_alias"  , 22},
112         {"bluetooth_authorize_device (TRUE)"    , 23},
113         {"bluetooth_authorize_device (FALSE)"   , 24},
114         {"bluetooth_search_service"     , 25},
115         {"bluetooth_cancel_service_search"      , 26},
116         {"bluetooth_is_device_connected"        , 27},
117         {"bluetooth_reset_adapter"              , 28},
118         {"bluetooth_set_manufacturer_data" , 91},
119
120         {"bluetooth_audio_init" , 29},
121         {"bluetooth_audio_deinit" , 30},
122         {"bluetooth_audio_connect"      , 31},
123         {"bluetooth_audio_disconnect"   , 32},
124         {"bluetooth_ag_connect" , 33},
125         {"bluetooth_ag_disconnect" , 34},
126         {"bluetooth_av_connect" , 35},
127         {"bluetooth_av_disconnect"      , 36},
128         {"bluetooth_ag_get_headset_volume" , 37},
129         {"bluetooth_ag_set_speaker_gain" , 38},
130
131         {"bluetooth_oob_read_local_data"        , 39},
132         {"bluetooth_oob_add_remote_data" , 40},
133         {"bluetooth_oob_remove_remote_data" , 41},
134
135         {"bluetooth_opc_init"   , 42},
136         {"bluetooth_opc_deinit" , 43},
137         {"bluetooth_opc_push_files" , 44},
138         {"bluetooth_opc_cancel_push" , 45},
139         {"bluetooth_opc_session_is_exist" , 46},
140
141         {"bluetooth_network_activate_server"    , 47},
142         {"bluetooth_network_deactivate_server" , 48},
143         {"bluetooth_network_connect" , 49},
144         {"bluetooth_network_disconnect" , 50},
145
146         {"bluetooth_obex_server_init"   , 51},
147         {"bluetooth_obex_server_deinit" , 52},
148         {"bluetooth_obex_server_init_without_agent"     , 53},
149         {"bluetooth_obex_server_deinit_without_agent"   , 54},
150         {"bluetooth_obex_server_is_activated"   , 55},
151         {"bluetooth_obex_server_accept_connection"      , 56},
152         {"bluetooth_obex_server_reject_connection"      , 57},
153         {"bluetooth_obex_server_accept_authorize"       , 58},
154         {"bluetooth_obex_server_reject_authorize"       , 59},
155         {"bluetooth_obex_server_set_destination_path"   , 60},
156         {"bluetooth_obex_server_set_root"               , 61},
157         {"bluetooth_obex_server_cancel_transfer"        , 62},
158         {"bluetooth_obex_server_cancel_all_transfers"   , 63},
159
160         {"bluetooth_hid_init"   , 65},
161         {"bluetooth_hid_deinit" , 66},
162         {"bluetooth_hid_connect"        , 67},
163         {"bluetooth_hid_disconnect"     , 68},
164
165         {"bluetooth_rfcomm_connect"     , 70},
166         {"bluetooth_rfcomm_disconnect (cancel)" , 71},
167         {"bluetooth_rfcomm_disconnect"  , 72},
168         {"bluetooth_rfcomm_write"       , 73},
169         {"bluetooth_rfcomm_is_client_connected" , 74},
170
171         {"bluetooth_rfcomm_create_socket"       , 80},
172         {"bluetooth_rfcomm_create_socket (Custom UUID)" , 81},
173         {"bluetooth_rfcomm_remove_socket"       , 82},
174         {"bluetooth_rfcomm_listen_and_accept"   , 83},
175         {"bluetooth_rfcomm_listen (OSP)"        , 84},
176         {"bluetooth_rfcomm_server_disconnect"   , 85},
177         {"bluetooth_rfcomm_is_server_uuid_available"    , 86},
178         {"bluetooth_rfcomm_accept_connection"   , 87},
179         {"bluetooth_rfcomm_reject_connection"   , 88},
180         {"bluetooth_start_custom_discovery"     , 89},
181
182         {"bluetooth_gatt_init", 92},
183         {"bluetooth_gatt_deinit", 93},
184         {"bluetooth_gatt_add_service", 94},
185         {"bluetooth_gatt_add_characteristics", 95},
186         {"bluetooth_gatt_add_descriptor", 96},
187         {"bluetooth_gatt_register_service", 97},
188         {"bluetooth_gatt_update_characteristic", 98},
189         {"bluetooth_gatt_unregister_service", 99},
190         {"bluetooth_gatt_delete_services", 100},
191
192 #if 0
193         {"bluetooth_rfcomm_is_server_uuid_available"    , 26},
194
195         {"bluetooth_hdp_activate"       , 30},
196         {"bluetooth_hdp_deactivate"     , 31},
197         {"bluetooth_hdp_connect"        , 32},
198         {"bluetooth_hdp_disconnect"     , 33},
199         {"bluetooth_hdp_send_data"      , 34},
200
201         {"bluetooth_opc_init"           , 35},
202         {"bluetooth_opc_push_file"      , 36},
203         {"bluetooth_opc_cancel_push"    , 37},
204         {"bluetooth_opc_deinit"         , 38},
205         {"bluetooth_obex_server_init"   , 39},
206         {"bluetooth_obex_server_deinit" , 40},
207         {"bluetooth_obex_server_accept_authorize"       , 41},
208         {"bluetooth_obex_server_reject_authorize"       , 42},
209         {"bluetooth_is_supported"       , 43},
210         {"bluetooth_opc_session_is_exist"       , 46},
211         {"bluetooth_obex_server_is_activated"   , 47},
212         {"bluetooth_obex_server_cancel_transfer"        , 48},
213
214         {"bluetooth_oob_read_local_data"        , 50},
215         {"bluetooth_oob_add_remote_data"        , 51},
216         {"bluetooth_oob_remove_remote_data"     , 52},
217
218         {"bluetooth_network_activate_server"    , 60},
219         {"bluetooth_network_deactivate_server"  , 61},
220         {"bluetooth_network_connect"    , 62},
221         {"bluetooth_network_disconnect" , 63},
222
223         {"bluetooth_gatt_discover_primary_services", 64},
224         {"bluetooth_gatt_discover_service_characteristics",     65},
225         {"bluetooth_gatt_get_service_property",         66},
226         {"bluetooth_gatt_get_characteristics_value",    67},
227         {"bluetooth_gatt_set_characteristics_value",    68},
228 #endif
229         /* -----------------------------------------*/
230         {"Finish"                                                       , 0x00ff},
231         {NULL                                                           , 0x0000},
232
233 };
234
235 #if 0
236 #define tc_result(success, tc_index) \
237         TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS) ? "Success" : "Failed"));
238 #else
239 #define tc_result(success, tc_index)
240 #endif
241
242 bluetooth_device_info_t bond_dev;
243 int is_bond_device = FALSE;
244
245 void tc_usage_print(void)
246 {
247         int i = 0;
248
249         while (tc_table[i].tc_name) {
250                 if (tc_table[i].tc_code != 0x00ff)
251                         TC_PRT("Key %d : usage %s", tc_table[i].tc_code, tc_table[i].tc_name);
252                 else
253                         TC_PRT("Key %d : usage %s\n\n", 0x00ff, tc_table[i].tc_name);
254
255                 i++;
256         }
257 }
258
259 int find_tc_number(int input)
260 {
261         int i = 0;
262
263         while (tc_table[i].tc_code != 0x0000) {
264                 if (tc_table[i].tc_code == input)
265                         return i;
266                 i++;
267         }
268
269         return -1;
270 }
271
272 int test_input_callback(void *data)
273 {
274         int ret = 0;
275         int test_id;
276
277 #ifdef ARCH64
278         test_id = find_tc_number((uintptr_t)data);
279 #else
280         test_id = find_tc_number((int)data);
281 #endif
282         if (test_id == -1)
283                 return 0;
284
285         TC_PRT("TC : %s[%d]", tc_table[test_id].tc_name, tc_table[test_id].tc_code);
286
287         switch (tc_table[test_id].tc_code) {
288         case 0x00ff:
289                 TC_PRT("Finished");
290                 g_main_loop_quit(main_loop);
291                 break;
292
293         case 1:
294                 ret = bluetooth_register_callback(bt_event_callback, NULL);
295                 if (ret < 0) {
296                         TC_PRT("%s failed with [0x%04x]", tc_table[0].tc_name, ret);
297                         tc_result(TC_FAIL, 1);
298                 }
299                 break;
300
301         case 2:
302                 ret = bluetooth_unregister_callback();
303                 if (ret < 0) {
304                         TC_PRT("%s failed with [0x%04x]", tc_table[1].tc_name, ret);
305                         tc_result(TC_FAIL, 1);
306                 }
307                 break;
308
309         case 3:
310         ret = bluetooth_enable_adapter();
311         if (ret < 0) {
312                         TC_PRT("%s failed with [0x%04x]", tc_table[2].tc_name, ret);
313                         tc_result(TC_FAIL, 1);
314                 }
315                 break;
316
317         case 4:
318                 ret = bluetooth_disable_adapter();
319                 if (ret < 0) {
320                         TC_PRT("%s failed with [0x%04x]", tc_table[3].tc_name, ret);
321                         tc_result(TC_FAIL, 2);
322                 }
323                 break;
324
325         case 5:
326         {
327                 ret = bluetooth_check_adapter();
328                 TC_PRT("state: %d", ret);
329                 break;
330         }
331
332         case 6:
333         {
334                 bluetooth_device_address_t address = { {0} };
335                 ret = bluetooth_get_local_address(&address);
336                 if (ret < 0) {
337                         TC_PRT("%s failed with [0x%04x]", tc_table[5].tc_name, ret);
338                 } else {
339                         TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
340                                 address.addr[0], address.addr[1], address.addr[2], \
341                                 address.addr[3], address.addr[4], address.addr[5]);
342                 }
343                 break;
344         }
345
346         case 7:
347         {
348                 bluetooth_device_name_t local_name = { {0} };
349                         ret = bluetooth_get_local_name(&local_name);
350                 if (ret < 0)
351                         TC_PRT("%s failed with [0x%04x]", tc_table[6].tc_name, ret);
352                 else
353                         TC_PRT("name: %s", local_name.name);
354
355                 break;
356         }
357
358         case 8:
359         {
360                 bluetooth_device_name_t local_name = { {0} };
361                 snprintf(local_name.name, sizeof(local_name.name),
362                         "bt-frwk-pid-%d", getpid());
363                 ret = bluetooth_set_local_name(&local_name);
364                 if (ret < 0)
365                         TC_PRT("%s failed with [0x%04x]", tc_table[7].tc_name, ret);
366
367                 break;
368         }
369
370         case 90:
371         {
372                 bluetooth_version_t local_version = { {0} };
373                 snprintf(local_version.version, sizeof(local_version.version),
374                                 "version%d", getpid());
375                         ret = bluetooth_get_local_version(&local_version);
376                 if (ret < 0)
377                         TC_PRT("%s failed with [0x%04x]", tc_table[89].tc_name, ret);
378                 else
379                         TC_PRT("version: %s", local_version.version);
380                 break;
381         }
382
383         case 9:
384         {
385                 gboolean used = FALSE;
386                         ret = bluetooth_is_service_used(rfcomm_test_uuid_spp, &used);
387                 if (ret < 0)
388                         TC_PRT("%s failed with [0x%04x]", tc_table[8].tc_name, ret);
389                 else
390                         TC_PRT("used: %d", used);
391                 break;
392         }
393
394         case 10:
395         {
396                 bluetooth_discoverable_mode_t mode;
397                 ret = bluetooth_get_discoverable_mode(&mode);
398                 if (ret < 0)
399                         TC_PRT("%s failed with [0x%04x]", tc_table[9].tc_name, ret);
400                 else
401                         TC_PRT("BT Get Discoverable mode [%d]", mode);
402                 break;
403         }
404
405         case 11:
406         {
407                 bluetooth_discoverable_mode_t mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
408                 ret = bluetooth_set_discoverable_mode(mode, 0);
409                 if (ret < 0)
410                         TC_PRT("%s failed with [0x%04x]", tc_table[10].tc_name, ret);
411                 else
412                         TC_PRT("BT Set Discoverable mode [%d]", mode);
413                 break;
414         }
415
416         case 12:
417         {
418                 bluetooth_discoverable_mode_t mode = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
419                 ret = bluetooth_set_discoverable_mode(mode, 0);
420                 if (ret < 0)
421                         TC_PRT("%s failed with [0x%04x]", tc_table[11].tc_name, ret);
422                 else
423                         TC_PRT("BT Set Discoverable mode [%d]", mode);
424                 break;
425         }
426
427         case 13:
428         {
429                 bluetooth_discoverable_mode_t mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
430                 ret = bluetooth_set_discoverable_mode(mode, 5);
431                 if (ret < 0)
432                         TC_PRT("%s failed with [0x%04x]", tc_table[12].tc_name, ret);
433                 else
434                         TC_PRT("BT Set Discoverable mode [%d]", mode);
435                 break;
436         }
437
438         case 14:
439                 ret = bluetooth_start_discovery(0, 0, 0);
440                 if (ret < 0)
441                         TC_PRT("%s failed with [0x%04x]", tc_table[13].tc_name, ret);
442                 break;
443
444         case 15:
445                 ret = bluetooth_cancel_discovery();
446                 if (ret < 0)
447                         TC_PRT("%s failed with [0x%04x]", tc_table[14].tc_name, ret);
448                 break;
449
450         case 16:
451         {
452                 ret = bluetooth_is_discovering();
453                 if (ret < 0)
454                         TC_PRT("%s failed with [0x%04x]", tc_table[15].tc_name, ret);
455                 else
456                         TC_PRT("Discovering [%d]", ret);
457                 break;
458         }
459
460         case 17: /*Get paired device list */
461         {
462                 GPtrArray *devinfo = NULL;
463                 devinfo = g_ptr_array_new();
464                 TC_PRT("g pointer arrary count : [%d]", devinfo->len);
465
466                 ret = bluetooth_get_bonded_device_list(&devinfo);
467                 if (ret < 0) {
468                         TC_PRT("%s failed with [0x%04x]", tc_table[16].tc_name, ret);
469                 } else {
470                         int i;
471                         bluetooth_device_info_t *ptr;
472                         TC_PRT("g pointer arrary count : [%d]", devinfo->len);
473                                 for (i = 0; i < devinfo->len; i++) {
474                                 ptr = g_ptr_array_index(devinfo, i);
475                                 if (ptr != NULL) {
476                                         TC_PRT("Name [%s]", ptr->device_name.name);
477                                         TC_PRT("Major Class [%d]", ptr->device_class.major_class);
478                                         TC_PRT("Minor Class [%d]", ptr->device_class.minor_class);
479                                         TC_PRT("Service Class [%d]", ptr->device_class.service_class);
480                                         TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]);
481                                         TC_PRT("\n");
482                                 }
483                         }
484                 }
485                 g_ptr_array_free(devinfo, TRUE);
486
487                 break;
488         }
489
490         case 18:
491         {
492                 bluetooth_device_address_t device_address = { {0xDC, 0x2C, 0x26, 0xD0, 0xF3, 0xC1} }; /* BT Keyboard */
493                         TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
494                         device_address.addr[0], device_address.addr[1], device_address.addr[2], \
495                         device_address.addr[3], device_address.addr[4], device_address.addr[5]);
496                         ret = bluetooth_bond_device(&device_address);
497                 if (ret < 0)
498                         TC_PRT("%s failed with [0x%04x]", tc_table[17].tc_name, ret);
499                         break;
500         }
501
502         case 19: /*Cancel bonding */
503         {
504                 ret = bluetooth_cancel_bonding();
505                 if (ret < 0)
506                         TC_PRT("%s failed with [0x%04x]", tc_table[18].tc_name, ret);
507                         break;
508         }
509
510         case 20: /*unbonding */
511         {
512                 bluetooth_device_address_t device_address = { {0x00, 0x19, 0x0E, 0x01, 0x61, 0x17} }; /* DO-DH79-PYUN04 */
513                 ret = bluetooth_unbond_device(&device_address);
514                 if (ret < 0)
515                         TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret);
516                         break;
517         }
518
519         case 21: /*Get paired device */
520         {
521                 bluetooth_device_info_t devinfo;
522                 bluetooth_device_address_t device_address = { {0x00, 0x16, 0x38, 0xC3, 0x1F, 0xD2} };
523                         memset(&devinfo, 0x00, sizeof(bluetooth_device_info_t));
524                         ret = bluetooth_get_bonded_device(&device_address, &devinfo);
525                 if (ret != BLUETOOTH_ERROR_NONE) {
526                         TC_PRT("bluetooth_get_bonded_device failed with [%d]", ret);
527                 } else {
528                         TC_PRT("Name [%s]", devinfo.device_name.name);
529                         TC_PRT("Major Class [%d]", devinfo.device_class.major_class);
530                         TC_PRT("Minor Class [%d]", devinfo.device_class.minor_class);
531                         TC_PRT("Service Class [%d]", devinfo.device_class.service_class);
532                         TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", devinfo.device_address.addr[0], devinfo.device_address.addr[1], devinfo.device_address.addr[2], devinfo.device_address.addr[3], devinfo.device_address.addr[4], devinfo.device_address.addr[5]);
533                 }
534
535                 break;
536         }
537
538         case 22: /*set alias for bonded device */
539         {
540                 bluetooth_device_address_t device_address = { {0x00, 0x16, 0x38, 0xC3, 0x1F, 0xD2} };
541
542                 ret = bluetooth_set_alias(&device_address, "Renamed device");
543                 if (ret < 0)
544                         TC_PRT("%s failed with [0x%04x]", tc_table[21].tc_name, ret);
545
546                 break;
547         }
548
549         case 23:
550         {
551                 bluetooth_device_address_t device_address = { {0x00, 0x16, 0x38, 0xC3, 0x1F, 0xD2} };
552                 ret = bluetooth_authorize_device(&device_address, TRUE);
553                 if (ret < 0)
554                         TC_PRT("%s failed with [0x%04x]", tc_table[22].tc_name, ret);
555
556                 break;
557         }
558
559         case 24:
560         {
561                 bluetooth_device_address_t device_address = { {0x00, 0x16, 0x38, 0xC3, 0x1F, 0xD2} };
562                 ret = bluetooth_authorize_device(&device_address, FALSE);
563                 if (ret < 0)
564                         TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret);
565                 break;
566         }
567         case 25:
568         {
569                 bluetooth_device_address_t device_address = { {0x00, 0x16, 0x38, 0xC3, 0x1F, 0xD2} };
570
571                 ret = bluetooth_search_service(&device_address);
572                 if (ret < 0)
573                         TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
574
575                 break;
576         }
577
578         case 26:
579         {
580                 ret = bluetooth_cancel_service_search();
581                 if (ret < 0)
582                         TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
583                 break;
584         }
585
586         case 27:
587         {
588                 gboolean connected = FALSE;
589                 bluetooth_device_address_t device_address = { {0x00, 0x1B, 0x66, 0x01, 0x23, 0x1C} }; /* Gennheiser PX210BT */
590
591                 ret = bluetooth_is_device_connected(&device_address, BLUETOOTH_A2DP_SERVICE, &connected);
592                 if (ret < 0) {
593                         TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
594                         TC_PRT("connected : %d", connected);
595                 }
596
597                 break;
598         }
599
600         case 28:
601         {
602                 ret = bluetooth_reset_adapter();
603                 if (ret < 0)
604                         TC_PRT("%s failed with [0x%04x]", tc_table[27].tc_name, ret);
605
606                 break;
607         }
608
609         case 91:
610         {
611                 bluetooth_manufacturer_data_t m_data;
612                 guint8 data[6]  = {0x05, 0xFF, 0x02, 0x03, 0x04, 0x05};
613                 TC_PRT("%x %x %x %x %x %x", data[0], data[1], data[2], data[3],
614                                 data[4], data[5]);
615
616                 memcpy(m_data.data, data, sizeof(data));
617                 m_data.data_len = sizeof(data) - 2;
618                 ret = bluetooth_set_manufacturer_data(&m_data);
619                 if (ret < 0)
620                         TC_PRT("%s failed with [0x%04x]", tc_table[90].tc_name, ret);
621                 break;
622         }
623
624         case 29:
625         {
626                 ret = bluetooth_audio_init(bt_audio_event_callback, NULL);
627                 if (ret < 0)
628                         TC_PRT("%s failed with [0x%04x]", tc_table[28].tc_name, ret);
629
630                 break;
631         }
632
633         case 30:
634         {
635                 ret = bluetooth_audio_deinit();
636                 if (ret < 0)
637                         TC_PRT("%s failed with [0x%04x]", tc_table[29].tc_name, ret);
638
639                 break;
640         }
641
642         case 31:
643         {
644                 bluetooth_device_address_t device_address = { {0x00, 0x0D, 0xFD, 0x24, 0x5E, 0xFF} }; /* Motorola S9 */
645
646                 ret = bluetooth_audio_connect(&device_address);
647                 if (ret < 0)
648                         TC_PRT("%s failed with [0x%04x]", tc_table[30].tc_name, ret);
649
650                 break;
651         }
652
653         case 32:
654         {
655                 bluetooth_device_address_t device_address = { {0x00, 0x0D, 0xFD, 0x24, 0x5E, 0xFF} }; /* Motorola S9 */
656
657                 ret = bluetooth_audio_disconnect(&device_address);
658                 if (ret < 0)
659                         TC_PRT("%s failed with [0x%04x]", tc_table[31].tc_name, ret);
660                 break;
661         }
662
663         case 33:
664         {
665                 /* MW600 */
666                 bluetooth_device_address_t device_address = { {0x58, 0x17, 0x0C, 0xEC, 0x6A, 0xF3} };
667
668                 ret = bluetooth_ag_connect(&device_address);
669                 if (ret < 0)
670                         TC_PRT("%s failed with [0x%04x]", tc_table[32].tc_name, ret);
671                 break;
672         }
673         case 34:
674         {
675                 /* MW600 */
676                 bluetooth_device_address_t device_address = { {0x58, 0x17, 0x0C, 0xEC, 0x6A, 0xF3} };
677
678                 ret = bluetooth_ag_disconnect(&device_address);
679                 if (ret < 0)
680                         TC_PRT("%s failed with [0x%04x]", tc_table[33].tc_name, ret);
681                 break;
682         }
683
684         case 35:
685         {
686                 /* MW600 */
687                 bluetooth_device_address_t device_address = { {0x58, 0x17, 0x0C, 0xEC, 0x6A, 0xF3} };
688
689                 ret = bluetooth_av_connect(&device_address);
690                 if (ret < 0)
691                         TC_PRT("%s failed with [0x%04x]", tc_table[34].tc_name, ret);
692                 break;
693         }
694
695         case 36:
696         {
697                 /* MW600 */
698                 bluetooth_device_address_t device_address = { {0x58, 0x17, 0x0C, 0xEC, 0x6A, 0xF3} };
699
700                 ret = bluetooth_av_disconnect(&device_address);
701                 if (ret < 0)
702                         TC_PRT("%s failed with [0x%04x]", tc_table[35].tc_name, ret);
703
704                 break;
705         }
706
707         case 37:
708         {
709                 unsigned int volume = 0;
710
711                 ret = bluetooth_ag_get_headset_volume(&volume);
712                 if (ret < 0) {
713                         TC_PRT("failed with [0x%04x]", ret);
714                         TC_PRT("volume: %d", volume);
715                 }
716
717                 break;
718         }
719
720         case 38:
721         {
722                 ret = bluetooth_ag_set_speaker_gain(10);
723                 if (ret < 0)
724                         TC_PRT("failed with [0x%04x]", ret);
725
726                 break;
727         }
728
729         case 39:
730         {
731                 if (bluetooth_oob_read_local_data(&g_local_oob_data.oob_data)) {
732                         TC_PRT("ERROR in bluetooth_oob_read_local_data\n");
733                 } else {
734                         TC_PRT("SUCESS in bluetooth_oob_read_local_data\n");
735                         TC_PRT("hash = [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
736                                 "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]\n",
737                                 g_local_oob_data.oob_data.hash[0],
738                                 g_local_oob_data.oob_data.hash[1],
739                                 g_local_oob_data.oob_data.hash[2],
740                                 g_local_oob_data.oob_data.hash[3],
741                                 g_local_oob_data.oob_data.hash[4],
742                                 g_local_oob_data.oob_data.hash[5],
743                                 g_local_oob_data.oob_data.hash[6],
744                                 g_local_oob_data.oob_data.hash[7],
745                                 g_local_oob_data.oob_data.hash[8],
746                                 g_local_oob_data.oob_data.hash[9],
747                                 g_local_oob_data.oob_data.hash[10],
748                                 g_local_oob_data.oob_data.hash[11],
749                                 g_local_oob_data.oob_data.hash[12],
750                                 g_local_oob_data.oob_data.hash[13],
751                                 g_local_oob_data.oob_data.hash[14],
752                                 g_local_oob_data.oob_data.hash[15]);
753
754                         TC_PRT("randomizer = [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
755                                 "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]\n",
756                                 g_local_oob_data.oob_data.randomizer[0],
757                                 g_local_oob_data.oob_data.randomizer[1],
758                                 g_local_oob_data.oob_data.randomizer[2],
759                                 g_local_oob_data.oob_data.randomizer[3],
760                                 g_local_oob_data.oob_data.randomizer[4],
761                                 g_local_oob_data.oob_data.randomizer[5],
762                                 g_local_oob_data.oob_data.randomizer[6],
763                                 g_local_oob_data.oob_data.randomizer[7],
764                                 g_local_oob_data.oob_data.randomizer[8],
765                                 g_local_oob_data.oob_data.randomizer[9],
766                                 g_local_oob_data.oob_data.randomizer[10],
767                                 g_local_oob_data.oob_data.randomizer[11],
768                                 g_local_oob_data.oob_data.randomizer[12],
769                                 g_local_oob_data.oob_data.randomizer[13],
770                                 g_local_oob_data.oob_data.randomizer[14],
771                                 g_local_oob_data.oob_data.randomizer[15]);
772
773                         TC_PRT("hash_len: %d\n", g_local_oob_data.oob_data.hash_len);
774                         TC_PRT("randomizer_len: %d\n", g_local_oob_data.oob_data.randomizer_len);
775                 }
776
777                 break;
778         }
779
780         case 40:
781         {
782                 ret = bluetooth_get_local_address(&g_local_oob_data.address);
783                 TC_PRT("hash_len: %d\n", g_local_oob_data.oob_data.hash_len);
784                 TC_PRT("randomizer_len: %d\n", g_local_oob_data.oob_data.randomizer_len);
785
786                 if (bluetooth_oob_add_remote_data(&g_local_oob_data.address,
787                         &g_local_oob_data.oob_data))
788                         TC_PRT("ERROR in bluetooth_oob_add_remote_data\n");
789                 else
790                         TC_PRT(" bluetooth_oob_add_remote_data SUCCESS\n");
791
792                 break;
793         }
794
795         case 41:
796         {
797                 if (bluetooth_oob_remove_remote_data(&g_local_oob_data.address))
798                         TC_PRT("ERROR in bluetooth_oob_remove_remote_data\n");
799                 else
800                         TC_PRT(" bluetooth_oob_remove_remote_data SUCCESS\n");
801                 break;
802         }
803
804         case 42:
805         {
806                 bluetooth_opc_init();
807                 break;
808         }
809
810         case 43:
811         {
812                 bluetooth_opc_deinit();
813                 break;
814         }
815
816         case 44:
817         {
818                 bluetooth_device_address_t remote_address = { {0} };
819
820                 /* Grey dongle */
821                 remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x02; remote_address.addr[2] = 0x70;
822                 remote_address.addr[3] = 0x2B; remote_address.addr[4] = 0xD3; remote_address.addr[5] = 0xAF;
823
824                 char *files[5] = {NULL};
825
826                 files[0] = "/opt/media/Images/image1.jpg";
827 //              files[1] = "/opt/media/Images/image2.jpg";
828 //              files[2] = "/opt/media/Images/image3.jpg";
829                 bluetooth_opc_push_files(&remote_address, files);
830                 break;
831         }
832
833         case 45:
834         {
835                 bluetooth_opc_cancel_push();
836                 break;
837         }
838
839         case 46:
840         {
841                 gboolean exist;
842                 exist = bluetooth_opc_session_is_exist();
843                 TC_PRT("exist: %d", exist);
844                 break;
845         }
846
847         case 47:
848         {
849                 bluetooth_network_activate_server();
850                 break;
851         }
852
853         case 48:
854         {
855                 bluetooth_network_deactivate_server();
856                 break;
857         }
858
859         case 49:
860         {
861                 bluetooth_device_address_t device_address = { {0x00, 0x02, 0xA2, 0x14, 0x40, 0x51} };
862                 bluetooth_network_connect(&device_address, BLUETOOTH_NETWORK_NAP_ROLE, NULL);
863                 break;
864         }
865
866         case 50:
867         {
868                 bluetooth_device_address_t device_address = { {0x00, 0x02, 0xA2, 0x14, 0x40, 0x51} };
869                 bluetooth_network_disconnect(&device_address);
870                 break;
871         }
872
873         case 51:
874         {
875                 bluetooth_obex_server_init("/opt/media/Downloads");
876                 break;
877         }
878
879         case 52:
880         {
881                 bluetooth_obex_server_deinit();
882                 break;
883         }
884
885         case 53:
886         {
887                 bluetooth_obex_server_init_without_agent("/opt/media/Downloads");
888                 break;
889         }
890
891         case 54:
892         {
893                 bluetooth_obex_server_deinit_without_agent();
894                 break;
895         }
896
897         case 55:
898         {
899                 bluetooth_obex_server_is_activated();
900                 break;
901         }
902
903         case 56:
904         {
905                 bluetooth_obex_server_accept_connection();
906                 TC_PRT(" bluetooth_obex_server_accept_connection SUCCESS\n");
907                 break;
908         }
909
910         case 57:
911         {
912                 bluetooth_obex_server_reject_connection();
913                 break;
914         }
915
916         case 58:
917         {
918                 bluetooth_obex_server_accept_authorize("abc");
919                 break;
920         }
921
922         case 59:
923         {
924                 bluetooth_obex_server_reject_authorize();
925                 break;
926         }
927
928         case 60:
929         {
930                 bluetooth_obex_server_set_destination_path("/opt/media");
931                 break;
932         }
933
934         case 61:
935         {
936                 bluetooth_obex_server_set_root("/opt/media");
937                 break;
938         }
939
940         case 62:
941         {
942                 bluetooth_obex_server_cancel_transfer(0);
943                 break;
944         }
945
946         case 63:
947         {
948                 bluetooth_obex_server_cancel_all_transfers();
949                 break;
950         }
951
952         case 65:
953         {
954                 ret = bluetooth_hid_init(bt_hid_event_callback, NULL);
955                 if (ret < 0)
956                         TC_PRT("Failed with [0x%04x]", ret);
957
958                 break;
959         }
960
961         case 66:
962         {
963                 ret = bluetooth_hid_deinit();
964                 if (ret < 0)
965                         TC_PRT("Failed with [0x%04x]", ret);
966
967                 break;
968         }
969
970         case 67:
971         {
972                 /* Apple wireless keyboard */
973                 hid_device_address_t device_address = { {0xE8, 0x06, 0x88, 0x3B, 0x18, 0xBA} };
974
975                 ret = bluetooth_hid_connect(&device_address);
976                 if (ret < 0)
977                         TC_PRT("Failed with [0x%04x]", ret);
978
979                 break;
980         }
981
982         case 68:
983         {
984                 /* Apple wireless keyboard */
985                 hid_device_address_t device_address = { {0xE8, 0x06, 0x88, 0x3B, 0x18, 0xBA} };
986
987                 ret = bluetooth_hid_disconnect(&device_address);
988                 if (ret < 0)
989                         TC_PRT("Failed with [0x%04x]", ret);
990
991                 break;
992         }
993
994         case 70:
995         {
996                 bluetooth_device_address_t device_address = { {0x00, 0x02, 0x2F, 0x92, 0x7B, 0xF5} };
997
998                 ret = bluetooth_rfcomm_connect(&device_address, rfcomm_test_uuid_spp);
999                 //ret = bluetooth_rfcomm_connect(&device_address, "1");
1000
1001                 if (ret < 0)
1002                         TC_PRT("Failed with [0x%04x]", ret);
1003
1004                 break;
1005         }
1006
1007         case 71:
1008         {
1009                 ret = bluetooth_rfcomm_disconnect(-1);
1010                 if (ret < 0)
1011                         TC_PRT("Failed with [0x%04x]", ret);
1012
1013                 break;
1014         }
1015
1016         case 72:
1017         {
1018                 ret = bluetooth_rfcomm_disconnect(g_ret_client_fd1);
1019                 if (ret < 0)
1020                         TC_PRT("Failed with [0x%04x]", ret);
1021
1022                 break;
1023         }
1024
1025         case 73:
1026         {
1027                 const char rd_data[] = "123456789 12345";
1028                 ret = bluetooth_rfcomm_write(g_ret_client_fd1, rd_data, sizeof(rd_data));
1029                 if (ret < 0)
1030                         TC_PRT("Failed with [0x%04x]", ret);
1031
1032                 break;
1033         }
1034
1035         case 74:
1036         {
1037                 gboolean is_connected;
1038                 is_connected = bluetooth_rfcomm_is_client_connected();
1039                 TC_PRT("Connected: %d", is_connected);
1040
1041                 break;
1042         }
1043
1044         case 80:
1045         {
1046                 ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
1047                 if (ret < 0) {
1048                         TC_PRT("Failed with [0x%04x]", ret);
1049                         TC_PRT("Returned FD = %d", ret);
1050                 }
1051                 server_fd = ret;
1052
1053                 break;
1054         }
1055
1056         case 81:
1057         {
1058                 ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_custom);
1059                 if (ret < 0) {
1060                         TC_PRT("Failed with [0x%04x]", ret);
1061                         TC_PRT("Returned FD = %d", ret);
1062                 }
1063                 server_fd = ret;
1064
1065                 break;
1066         }
1067
1068         case 82:
1069         {
1070                 ret = bluetooth_rfcomm_remove_socket(server_fd);
1071                 if (ret < 0)
1072                         TC_PRT("Failed with [0x%04x]", ret);
1073
1074                 break;
1075         }
1076
1077         case 83: /*Listen and accept */
1078         {
1079                 ret = bluetooth_rfcomm_listen_and_accept(server_fd, 1);
1080                 if (ret < 0) {
1081                         TC_PRT("Failed with [0x%04x]", ret);
1082                         TC_PRT("result = %d", ret);
1083                 }
1084
1085                 break;
1086         }
1087
1088         case 84: /*Listen */
1089         {
1090                 ret = bluetooth_rfcomm_listen(server_fd, 1);
1091                 if (ret < 0) {
1092                         TC_PRT("Failed with [0x%04x]", ret);
1093                         TC_PRT("result = %d", ret);
1094                 }
1095
1096                 break;
1097         }
1098
1099         case 85:
1100         {
1101                 ret = bluetooth_rfcomm_server_disconnect(client_fd);
1102                 if (ret < 0)
1103                         TC_PRT("Failed with [0x%04x]", ret);
1104
1105                 break;
1106         }
1107
1108         case 86:
1109         {
1110                 gboolean available;
1111                 available = bluetooth_rfcomm_is_server_uuid_available(rfcomm_test_uuid_spp);
1112                 TC_PRT("available: %d", available);
1113
1114                 break;
1115         }
1116
1117         case 87:
1118         {
1119                 ret = bluetooth_rfcomm_accept_connection(server_fd);
1120                 if (ret < 0) {
1121                         TC_PRT("Failed with [0x%04x]", ret);
1122                         TC_PRT("client fd: %d", client_fd);
1123                 }
1124
1125                 break;
1126         }
1127
1128         case 88:
1129         {
1130                 ret = bluetooth_rfcomm_reject_connection(server_fd);
1131                 if (ret < 0)
1132                         TC_PRT("Failed with [0x%04x]", ret);
1133                 break;
1134         }
1135
1136         case 89:
1137                 ret = bluetooth_start_custom_discovery(DISCOVERY_ROLE_LE,
1138                                                                 0, 0, 0);
1139                 if (ret < 0)
1140                         TC_PRT("failed with [0x%04x]", ret);
1141
1142                 break;
1143
1144         case 92:
1145         {
1146 #if TODO_40
1147                 ret = bluetooth_gatt_init();
1148                 if (ret < 0)
1149                         TC_PRT("gatt init failed with [0x%04x]", ret);
1150 #endif
1151                 break;
1152         }
1153
1154         case 93:
1155         {
1156 #if TODO_40
1157                 ret = bluetooth_gatt_deinit();
1158                 if (ret < 0)
1159                         TC_PRT("gatt deinit failed with [0x%04x]", ret);
1160 #endif
1161                 break;
1162         }
1163
1164         case 94:
1165         {
1166 #if TODO_40
1167                 char *service_uuid = g_strdup("00001802-0000-1000-8000-00805f9b34fb");
1168
1169                 ret = bluetooth_gatt_add_service(service_uuid,
1170                         &svc_obj_path);
1171
1172                 TC_PRT("service obj_path is %s", svc_obj_path);
1173 #endif
1174                 break;
1175         }
1176
1177         case 95:
1178         {
1179 #if TODO_40
1180                 /* testing with dummy values*/
1181                 char *char_uuid = g_strdup("00002a06-0000-1000-8000-00805f9b34fb");
1182                 bt_gatt_permission_t perms = 0;
1183                 bt_gatt_characteristic_property_t props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
1184                                 BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE |
1185                                 BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_NOTIFY |
1186                                 BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_INDICATE;
1187
1188                 ret = bluetooth_gatt_add_new_characteristic(
1189                         svc_obj_path, char_uuid,
1190                         perms, props, &char_obj_path);
1191
1192                 TC_PRT("characteristic obj_path is %s", char_obj_path);
1193 #endif
1194                 break;
1195         }
1196
1197         case 96: {
1198 #if TODO_40
1199                 char *desc_uuid = g_strdup("000026ff-0000-1000-8000-00805f9b34fb");
1200                 bt_gatt_permission_t perms = BLUETOOTH_GATT_PERMISSION_READ |
1201                                 BLUETOOTH_GATT_PERMISSION_WRITE;
1202
1203                 ret = bluetooth_gatt_add_descriptor(char_obj_path,
1204                         desc_uuid, perms, &desc_obj_path);
1205                 TC_PRT("add descriptor error is %d", ret);
1206 #endif
1207                 break;
1208         }
1209
1210         case 97: {
1211 #if TODO_40
1212                 ret = bluetooth_gatt_register_service(svc_obj_path);
1213                 TC_PRT("register service error is %d", ret);
1214 #endif
1215                 break;
1216         }
1217
1218         case 98: {
1219 #if TODO_40
1220                 ret = bluetooth_gatt_register_application();
1221
1222                 TC_PRT("register service error is %d", ret);
1223 #endif
1224                 break;
1225         }
1226
1227         case 99: {
1228 #if TODO_40
1229                 char char_data[4] = {10, 20, 30, 40};
1230                 int char_length = 4;
1231                 ret = bluetooth_gatt_update_characteristic(char_obj_path,
1232                                         char_data, char_length);
1233
1234                 TC_PRT("update_characteristic error is %d", ret);
1235 #endif
1236                 break;
1237         }
1238
1239         case 100: {
1240 #if TODO_40
1241                 ret = bluetooth_gatt_unregister_service(svc_obj_path);
1242                 TC_PRT("service removed with error is %d", ret);
1243 #endif
1244                 break;
1245         }
1246
1247         case 101:
1248 #if TODO_40
1249                 ret = bluetooth_gatt_delete_services();
1250                 TC_PRT("services deleted with error is %d", ret);
1251 #endif
1252                 break;
1253
1254         default:
1255                 break;
1256         }
1257         return 0;
1258 }
1259
1260 void startup()
1261 {
1262         TC_PRT("bluetooth framework TC startup");
1263
1264         main_loop = g_main_loop_new(NULL, FALSE);
1265 }
1266
1267 void cleanup()
1268 {
1269         TC_PRT("bluetooth framework TC cleanup");
1270         if (main_loop != NULL)
1271                 g_main_loop_unref(main_loop);
1272 }
1273
1274 void bt_hid_event_callback(int event, hid_event_param_t* param, void *user_data)
1275 {
1276         TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
1277         TC_PRT("bt event callback 0x%04x", event);
1278 }
1279
1280 void bt_audio_event_callback(int event, bt_audio_event_param_t* param, void *user_data)
1281 {
1282         TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
1283         TC_PRT("bt event callback 0x%04x", event);
1284
1285
1286
1287 }
1288
1289 void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
1290 {
1291         TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
1292         TC_PRT("bt event callback 0x%04x", event);
1293         switch (event) {
1294         case BLUETOOTH_EVENT_ENABLED:
1295                 TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
1296                 break;
1297
1298         case BLUETOOTH_EVENT_DISABLED:
1299                 TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
1300                 break;
1301
1302         case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
1303                 TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
1304                 if (param->result == BLUETOOTH_ERROR_NONE) {
1305                         bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
1306                         tc_result(TC_PASS, 6);
1307                         TC_PRT("Changed Name : [%s]", local_name->name);
1308                 } else {
1309                         tc_result(TC_FAIL, 6);
1310                 }
1311                 break;
1312
1313         case BLUETOOTH_EVENT_DISCOVERY_STARTED:
1314                 TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
1315                 break;
1316
1317         case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
1318         {
1319                 bluetooth_device_info_t *device_info = NULL;
1320                 TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
1321                 device_info  = (bluetooth_device_info_t *)param->param_data;
1322                 memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
1323                 TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
1324                         device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
1325                         device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
1326                 break;
1327         }
1328
1329         case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND:
1330         {
1331                 int i;
1332                 bluetooth_le_device_info_t *le_device_info = NULL;
1333                 TC_PRT("BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND, result [0x%04x]", param->result);
1334                 le_device_info  = (bluetooth_le_device_info_t *)param->param_data;
1335                 TC_PRT("dev[%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
1336                         le_device_info->device_address.addr[0], le_device_info->device_address.addr[1], le_device_info->device_address.addr[2], \
1337                         le_device_info->device_address.addr[3], le_device_info->device_address.addr[4], le_device_info->device_address.addr[5]);
1338                 TC_PRT("addr_type : %d", le_device_info->addr_type);
1339                 TC_PRT("rssi : %d", le_device_info->rssi);
1340                 TC_PRT("adv_ind_data_len :%d" , le_device_info->adv_ind_data.data_len);
1341                 TC_PRT("scan_resp_data_len :%d" , le_device_info->scan_resp_data.data_len);
1342                 for (i = 0; i < le_device_info->adv_ind_data.data_len; i++)
1343                         TC_PRT("adv_ind_data[%d] : [0x%x]", i, le_device_info->adv_ind_data.data.data[i]);
1344                 for (i = 0; i < le_device_info->scan_resp_data.data_len; i++)
1345                         TC_PRT("scan_resp_data[%d] : [0x%x]", i, le_device_info->scan_resp_data.data.data[i]);
1346                 break;
1347         }
1348
1349         case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
1350         {
1351                 bluetooth_device_info_t *device_info = NULL;
1352                 TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
1353                 device_info  = (bluetooth_device_info_t *)param->param_data;
1354                 memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
1355                 TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
1356                         device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
1357                         device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
1358                 break;
1359         }
1360
1361         case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1362                 TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
1363                 break;
1364
1365         case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED:
1366         {
1367                 int *mode = (int *)param->param_data;
1368                 TC_PRT("BT_DISCOVERABLE_MODE_CHANGED, result [0x%04x]", param->result);
1369                 TC_PRT("mode [%d]", *mode);
1370                 break;
1371         }
1372
1373         case BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED:
1374         {
1375                 int *timeout = (int *)param->param_data;
1376                 TC_PRT("BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED, result [0x%04x]", param->result);
1377                 TC_PRT("timeout [%d]", *timeout);
1378                 break;
1379         }
1380
1381         case BLUETOOTH_EVENT_BONDING_FINISHED:
1382         {
1383                 TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
1384                 if (param->result >= BLUETOOTH_ERROR_NONE) {
1385                         bluetooth_device_info_t *device_info = NULL;
1386                         tc_result(TC_PASS, 12);
1387                         device_info = (bluetooth_device_info_t *)param->param_data;
1388                 if (device_info == NULL)
1389                         break;
1390                         TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
1391                                 device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
1392                                 device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
1393                                 device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
1394                 } else {
1395                         tc_result(TC_FAIL, 12);
1396                 }
1397                         break;
1398         }
1399
1400         case BLUETOOTH_EVENT_BONDED_DEVICE_FOUND:
1401         {
1402                 // bluetooth_get_bonded_device_list is changed as synchronous API. This event is not used any more.
1403                 // 2011.01.06
1404 #if 0
1405 //              int i = 0;
1406                 TC_PRT("BLUETOOTH_EVENT_BONDED_DEVICE_FOUND, result [0x%04x]", param->result);
1407                 if (param->result >= BLUETOOTH_ERROR_NONE) {
1408                         ///tc_result(TC_PASS, 15);
1409                         bluetooth_device_info_t * bt_dev_info = (bluetooth_device_info_t*)param->param_data;
1410                                 TC_PRT("Dev Name = %s, Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X, COD (major,minor,service)= 0x%x:%x:%x\n", bt_dev_info->device_name.name,
1411                                 bt_dev_info->device_address.addr[0], bt_dev_info->device_address.addr[1], bt_dev_info->device_address.addr[2], \
1412                                 bt_dev_info->device_address.addr[3], bt_dev_info->device_address.addr[4], bt_dev_info->device_address.addr[5], \
1413                                 bt_dev_info->device_class.major_class, bt_dev_info->device_class.minor_class, bt_dev_info->device_class.service_class);
1414
1415                 } else if (param->result == BLUETOOTH_ERROR_END_OF_DEVICE_LIST) /*End of the Device found indication*/ {
1416                         tc_result(TC_PASS, 15);
1417                         TC_PRT("*****<<No more BLUETOOTH_EVENT_BONDED_DEVICE_FOUND indication>>***** ");
1418                 } else {
1419                         tc_result(TC_FAIL, 15);
1420                         TC_PRT("*****API failed ***** ");
1421                 }
1422 #endif
1423                 break;
1424         }
1425
1426         case BLUETOOTH_EVENT_SERVICE_SEARCHED:
1427         {
1428                 int i = 0;
1429                 TC_PRT("BLUETOOTH_EVENT_SERVICE_SEARCHED, result [0x%04x]", param->result);
1430                 if (param->result >= BLUETOOTH_ERROR_NONE) {
1431                         tc_result(TC_PASS, 18);
1432                         bt_sdp_info_t *bt_sdp_info = param->param_data;
1433
1434                         TC_PRT("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1435                                 bt_sdp_info->device_addr.addr[0], bt_sdp_info->device_addr.addr[1], bt_sdp_info->device_addr.addr[2], \
1436                                 bt_sdp_info->device_addr.addr[3], bt_sdp_info->device_addr.addr[4], bt_sdp_info->device_addr.addr[5]);
1437
1438                                 TC_PRT("Supported service list:\n");
1439                                 for (i = 0; i < bt_sdp_info->service_index; i++)
1440                                         TC_PRT("[%#x]\n", bt_sdp_info->service_list_array[i]);
1441
1442                 } else {
1443                         tc_result(TC_FAIL, 18);
1444                 }
1445                 break;
1446         }
1447
1448         case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
1449         {
1450                 TC_PRT("BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED, result [0x%04x]", param->result);
1451                 bluetooth_rfcomm_received_data_t *rx_data = param->param_data;
1452                 printf("\n FD = %d \nBuffer len = %d ", rx_data->socket_fd, rx_data->buffer_size);
1453                 if (rx_data->buffer_size < sizeof(oob_data_t))
1454                         TC_PRT("Complete oob data is not recivedn");
1455                 else
1456                         memcpy(&g_remote_oob_data, rx_data->buffer, sizeof(oob_data_t));
1457                 //tc_result(TC_PASS, 21);
1458                 break;
1459         }
1460
1461         case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
1462         {
1463                 bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data;
1464                 TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result,
1465                                                         con_ind->socket_fd,
1466                                                         con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2],
1467                                                         con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5],
1468                                                         (con_ind->device_role == RFCOMM_ROLE_SERVER) ? "SERVER" : "CLIENT");
1469                 //tc_result(TC_PASS, 22);
1470                 if ((con_ind->device_role == RFCOMM_ROLE_CLIENT) && (con_ind->socket_fd > 0))
1471                         g_ret_client_fd1 = con_ind->socket_fd;
1472
1473                 if ((con_ind->device_role == RFCOMM_ROLE_SERVER) && (con_ind->socket_fd > 0))
1474                         client_fd = con_ind->socket_fd;
1475
1476                 break;
1477         }
1478
1479         case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
1480         {
1481                 bluetooth_rfcomm_disconnection_t *disconnection_ind = (bluetooth_rfcomm_disconnection_t *)param->param_data;;
1482                 TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x] Fd = %d, device add = 0x%X:%X:%X:%X:%X:%X\n", param->result, disconnection_ind->socket_fd,
1483                                                                                                         disconnection_ind->device_addr.addr[0], disconnection_ind->device_addr.addr[1], disconnection_ind->device_addr.addr[2],
1484                                                                                                         disconnection_ind->device_addr.addr[3], disconnection_ind->device_addr.addr[4], disconnection_ind->device_addr.addr[5]);
1485                 //tc_result(TC_PASS, 22);
1486                 break;
1487         }
1488
1489         case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
1490         {
1491                 bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data;
1492
1493                 TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result);
1494                 TC_PRT("interface name: %s", dev_info->interface_name);
1495
1496                 TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1497                                                         dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2],
1498                                                         dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5]);
1499                 break;
1500         }
1501
1502         case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED:
1503         {
1504                 bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data;
1505
1506                 TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result);
1507                 TC_PRT("interface name: %s", dev_info->interface_name);
1508
1509                 TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1510                                                         dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2],
1511                                                         dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5]);
1512                 break;
1513         }
1514
1515         case BLUETOOTH_EVENT_HDP_CONNECTED:
1516         {
1517                 bt_hdp_connected_t *conn_ind = (bt_hdp_connected_t *)param->param_data;
1518
1519                 TC_PRT("BLUETOOTH_EVENT_HDP_CONNECTED, Result = %s\n", (param->result == 0) ? "BLUETOOTH_ERROR_NONE" : "BLUETOOTH_ERROR_XXXX");
1520                 TC_PRT("App handler = %s, channel id = %d, type = %s", conn_ind->app_handle, conn_ind->channel_id, (conn_ind->type == HDP_QOS_RELIABLE) ? "Reliable" : "Streaming");
1521                 TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1522                                                         conn_ind->device_address.addr[0], conn_ind->device_address.addr[1], conn_ind->device_address.addr[2],
1523                                                         conn_ind->device_address.addr[3], conn_ind->device_address.addr[4], conn_ind->device_address.addr[5]);
1524
1525                 g_ret_client_fd1 = conn_ind->channel_id;
1526                 break;
1527         }
1528
1529         case BLUETOOTH_EVENT_HDP_DISCONNECTED:
1530         {
1531                 bt_hdp_disconnected_t *dis_ind = (bt_hdp_disconnected_t *)param->param_data;
1532
1533                 TC_PRT("BLUETOOTH_EVENT_HDP_DISCONNECTED, Result = %s\n", (param->result == 0) ? "BLUETOOTH_ERROR_NONE" : "BLUETOOTH_ERROR_XXXX");
1534                 TC_PRT("Channel = %d, Add = device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", dis_ind->channel_id,
1535                                                         dis_ind->device_address.addr[0], dis_ind->device_address.addr[1], dis_ind->device_address.addr[2],
1536                                                         dis_ind->device_address.addr[3], dis_ind->device_address.addr[4], dis_ind->device_address.addr[5]);
1537                 break;
1538         }
1539
1540         case BLUETOOTH_EVENT_HDP_DATA_RECEIVED:
1541         {
1542                 bt_hdp_data_ind_t *data_ind = (bt_hdp_data_ind_t *)param->param_data;
1543
1544                 TC_PRT("BLUETOOTH_EVENT_HDP_DATA_RECEIVED, Result = %s\n", (param->result == 0) ? "BLUETOOTH_ERROR_NONE" : "BLUETOOTH_ERROR_XXXX");
1545                 TC_PRT("Data received from channel id = %d and  size =%d, buff =[%s]\n",  data_ind->channel_id, data_ind->size, data_ind->buffer);
1546
1547                 break;
1548         }
1549
1550         case BLUETOOTH_EVENT_OPC_CONNECTED:
1551                 TC_PRT("BLUETOOTH_EVENT_OPC_CONNECTED");
1552                 break;
1553
1554         case BLUETOOTH_EVENT_OPC_DISCONNECTED:
1555                 TC_PRT("BLUETOOTH_EVENT_OPC_DISCONNECTED");
1556                 break;
1557         case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED:
1558         {
1559                 TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
1560                 if (param->param_data) {
1561                         bt_opc_transfer_info_t *info = param->param_data;
1562                         TC_PRT("file %s", info->filename);
1563                         TC_PRT("size %ld", info->size);
1564                 }
1565                 break;
1566         }
1567         case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS:
1568         {
1569                 TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS");
1570                 break;
1571         }
1572         case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
1573         {
1574                 TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
1575                 bt_opc_transfer_info_t *info = param->param_data;
1576                 TC_PRT("file %s", info->filename);
1577                 TC_PRT("size %ld", info->size);
1578                 break;
1579         }
1580
1581         case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE:
1582                 TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE");
1583                 break;
1584
1585         case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE:
1586                 TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
1587                 break;
1588
1589         case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED:
1590                 TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
1591                 bt_obex_server_transfer_info_t *info = param->param_data;
1592                 current_transfer_id = info->transfer_id;
1593                 break;
1594
1595         case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS:
1596                 TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS");
1597                 break;
1598
1599         case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED:
1600                 TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
1601                 break;
1602         case BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED:
1603         {       TC_PRT("BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED");
1604                 break;
1605         }
1606 #if 0
1607         case BLUETOOTH_EVENT_GATT_PRIM_SVC_DISCOVERED:
1608         {
1609                 TC_PRT("BLUETOOTH_EVENT_GATT_PRIM_SVC_DISCOVERED");
1610                 bt_gatt_handle_info_t *prim_svc = param->param_data;
1611                 int i;
1612
1613                 if (prim_svc == NULL) {
1614                         TC_PRT("prim_svc is NULL");
1615                         break;
1616                 }
1617
1618                 for (i = 0; i < prim_svc->count; i++)
1619                         TC_PRT("prim_svc[%d] = %s\n", i, prim_svc->handle[i]);
1620
1621                 break;
1622         }
1623
1624         case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED:
1625         {
1626                 TC_PRT("BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED");
1627                 bt_gatt_discovered_char_t *svc_char = param->param_data;
1628                 int i = 0;
1629
1630                 if (svc_char == NULL) {
1631                         TC_PRT("svc_char is NULL");
1632                         break;
1633                 }
1634
1635                 if (svc_char->service_handle != NULL)
1636                         TC_PRT("svc_char->service_handle %s \n", svc_char->service_handle);
1637
1638                 for (i = 0; i < svc_char->handle_info.count; i++)
1639                         TC_PRT("svc_char.handle_info.handle[%d] = %s\n", i, svc_char->handle_info.handle[i]);
1640
1641                 break;
1642         }
1643
1644         case BLUETOOTH_EVENT_GATT_SVC_PROP_RECEIVED:
1645         {
1646                 TC_PRT("BLUETOOTH_EVENT_GATT_SVC_PROP_RECEIVED");
1647                 bt_gatt_service_property_t *svc_pty = param->param_data;
1648                 int i;
1649
1650                 if (svc_pty == NULL) {
1651                         TC_PRT("char_pty is NULL \n");
1652                         break;
1653                 }
1654
1655                 if (svc_pty->service_handle != NULL)
1656                         TC_PRT("svc_pty->service_handle %s \n", svc_pty->service_handle);
1657
1658                 if (svc_pty->uuid != NULL)
1659                         TC_PRT("svc_pty->uuid %s \n", svc_pty->uuid);
1660
1661                 for (i = 0; i < svc_pty->handle_info.count; i++)
1662                         TC_PRT("svc_char[%d] = %s\n", i, svc_pty->handle_info.handle[i]);
1663
1664                 break;
1665         }
1666
1667         case BLUETOOTH_EVENT_GATT_CHAR_PROP_RECEIVED:
1668         {
1669                 TC_PRT("BLUETOOTH_EVENT_GATT_CHAR_PROP_RECEIVED");
1670                 bt_gatt_char_property_t *char_pty = param->param_data;
1671                 int i = 0;
1672
1673                 if (char_pty->char_handle != NULL)
1674                         TC_PRT("char_pty->char_handle %s \n", char_pty->char_handle);
1675
1676                 if (char_pty->uuid != NULL)
1677                         TC_PRT("char_pty->uuid %s \n", char_pty->uuid);
1678
1679                 if (char_pty == NULL) {
1680                         TC_PRT("char_pty is NULL \n");
1681                         break;
1682                 }
1683
1684                 if (char_pty->name != NULL)
1685                         TC_PRT("char_pty->name %s \n", char_pty->name);
1686
1687                 if (char_pty->description != NULL)
1688                         TC_PRT("char_pty->description %s \n", char_pty->description);
1689
1690                 if (char_pty->val != NULL) {
1691                         TC_PRT("char_pty->val_len %d \n", char_pty->val_len);
1692
1693                         for (i = 0; i < char_pty->val_len; i++)
1694                                 TC_PRT("char_pty->val %02x \n", char_pty->val[i]);
1695                 }
1696
1697                 break;
1698         }
1699 #endif
1700         case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY:
1701         {
1702                 bluetooth_authentication_request_info_t *auth_info = param->param_data;
1703
1704                 TC_PRT("BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY");
1705                 TC_PRT("Device Address: [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1706                         auth_info->device_address.addr[0], auth_info->device_address.addr[1],
1707                         auth_info->device_address.addr[2], auth_info->device_address.addr[3],
1708                         auth_info->device_address.addr[4], auth_info->device_address.addr[5]);
1709                 TC_PRT("Device Name : [%s]", auth_info->device_name.name);
1710                 TC_PRT("Passkey: [%s]", auth_info->str_passkey);
1711                 break;
1712         }
1713         case BLUETOOTH_EVENT_PIN_REQUEST:
1714         {
1715                 bluetooth_authentication_request_info_t *auth_info = param->param_data;
1716
1717                 TC_PRT("BLUETOOTH_EVENT_PIN_REQUEST");
1718                 TC_PRT("Device Address: [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1719                         auth_info->device_address.addr[0], auth_info->device_address.addr[1],
1720                         auth_info->device_address.addr[2], auth_info->device_address.addr[3],
1721                         auth_info->device_address.addr[4], auth_info->device_address.addr[5]);
1722                 TC_PRT("Device Name : [%s]", auth_info->device_name.name);
1723
1724                 TC_PRT("bluetooth_passkey_reply(\"0000\", TRUE)");
1725                 bluetooth_passkey_reply("0000", TRUE);
1726                 break;
1727         }
1728         case BLUETOOTH_EVENT_PASSKEY_REQUEST:
1729         {
1730                 bluetooth_authentication_request_info_t *auth_info = param->param_data;
1731
1732                 TC_PRT("BLUETOOTH_EVENT_PASSKEY_REQUEST");
1733                 TC_PRT("Device Address: [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1734                         auth_info->device_address.addr[0], auth_info->device_address.addr[1],
1735                         auth_info->device_address.addr[2], auth_info->device_address.addr[3],
1736                         auth_info->device_address.addr[4], auth_info->device_address.addr[5]);
1737                 TC_PRT("Device Name : [%s]", auth_info->device_name.name);
1738
1739                 TC_PRT("bluetooth_passkey_reply(\"0000\", TRUE)");
1740                 bluetooth_passkey_reply("0000", TRUE);
1741                 break;
1742         }
1743         case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST:
1744         {
1745                 bluetooth_authentication_request_info_t *auth_info = param->param_data;
1746
1747                 TC_PRT("BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST");
1748                 TC_PRT("Device Address: [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1749                         auth_info->device_address.addr[0], auth_info->device_address.addr[1],
1750                         auth_info->device_address.addr[2], auth_info->device_address.addr[3],
1751                         auth_info->device_address.addr[4], auth_info->device_address.addr[5]);
1752                 TC_PRT("Device Name : [%s]", auth_info->device_name.name);
1753                 TC_PRT("Passkey: [%s]", auth_info->str_passkey);
1754
1755                 TC_PRT("bluetooth_passkey_confirmation_reply: TRUE");
1756                 bluetooth_passkey_confirmation_reply(TRUE);
1757                 break;
1758         }
1759         default:
1760                 TC_PRT("received event [0x%04x]", event);
1761                 break;
1762         }
1763         TC_PRT("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
1764 }
1765
1766 static gboolean key_event_cb(GIOChannel * chan, GIOCondition cond , gpointer data)
1767 {
1768         char buf[49] = {0};
1769
1770 #ifdef ARCH64
1771         unsigned long len = 0;
1772 #else
1773         unsigned int len = 0;
1774 #endif
1775         int test_id;
1776         memset(buf, 0, sizeof(buf));
1777
1778         if (g_io_channel_read_chars(chan, buf, sizeof(buf),
1779                                 &len, NULL) == G_IO_STATUS_ERROR) {
1780                 TC_PRT("IO Channel read error");
1781                 return FALSE;
1782         }
1783
1784         printf("%s\n", buf);
1785         tc_usage_print();
1786
1787         test_id = atoi(buf);
1788
1789 #ifdef ARCH64
1790         g_idle_add(test_input_callback, (void *)(uintptr_t)test_id);
1791 #else
1792         g_idle_add(test_input_callback, (void *)test_id);
1793 #endif
1794
1795         return TRUE;
1796 }
1797
1798 int main(void)
1799 {
1800         startup();
1801
1802         GIOChannel *key_io;
1803         key_io = g_io_channel_unix_new(fileno(stdin));
1804
1805         g_io_channel_set_encoding(key_io, NULL, NULL);
1806         g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL);
1807
1808         g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1809                         key_event_cb, NULL);
1810         g_io_channel_unref(key_io);
1811
1812         g_main_loop_run(main_loop);
1813
1814         cleanup();
1815         return 0;
1816 }
1817