Merge "A2DP profile multiple source support" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / test / gatt-test / bluetooth-gatt-test.c
old mode 100644 (file)
new mode 100755 (executable)
index 9aab4e8..cb7ef22
@@ -1,11 +1,5 @@
 /*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
+ * 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.
@@ -34,8 +28,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
-
 #include "bluetooth-api.h"
 
 
 
 GMainLoop *main_loop = NULL;
 
-typedef struct
-{
+typedef struct {
        const char *tc_name;
        int tc_code;
 } tc_table_t;
 
-tc_table_t tc_table[] =
-{
+tc_table_t tc_table[] = {
        {"Send alert to remote le device"               , 1},
        {"Set Link loss alert"          , 2},
 
@@ -65,7 +55,7 @@ tc_table_t tc_table[] =
 };
 
 #define tc_result(success, tc_index) \
-       TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS)?"Success":"Failed"));
+       TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS) ? "Success" : "Failed"));
 
 char *g_alert_char_handle = NULL;
 guint8 g_alert_level = 0;
@@ -120,11 +110,6 @@ char * get_bd_from_file(char *filename)
        }
 
        buf = g_malloc0(20);
-       /* Fix : NULL_RETURNS */
-       if (buf == NULL) {
-               close(fd);
-               return NULL;
-       }
 
        if (read(fd, buf, 17) < 17) {
                perror("Can't load firmware");
@@ -145,7 +130,7 @@ static void __accept_bdaddress(bluetooth_device_address_t *device_address)
 
        addr = get_bd_from_file(BD_ADDR_FILE);
        if (addr) {
-               TC_PRT("Remote bd adress from file: %s", addr);
+               TC_PRT("Remote bd address from file: %s", addr);
                convert_addr_string_to_addr_type(device_address, addr);
                g_free(addr);
                return;
@@ -231,19 +216,15 @@ void startup()
 {
        TC_PRT("bluetooth framework TC startup");
 
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-
-       dbus_g_thread_init();
+       dbus_threads_init_default();
 
-       g_type_init();
        main_loop = g_main_loop_new(NULL, FALSE);
 }
 
 void cleanup()
 {
        TC_PRT("bluetooth framework TC cleanup");
-       if ( main_loop != NULL)
+       if (main_loop != NULL)
                g_main_loop_unref(main_loop);
 }
 
@@ -282,7 +263,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param,
 {
        TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        TC_PRT("bt event callback 0x%04x", event);
-       switch(event) {
+       switch (event) {
        case BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID:
        {
                TC_PRT("BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID");
@@ -309,12 +290,12 @@ static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
        unsigned int len = 0;
        int test_id;
 
-       if (g_io_channel_read_chars(chan, buf, sizeof(buf), 
+       if (g_io_channel_read_chars(chan, buf, sizeof(buf),
                        &len, NULL) ==  G_IO_STATUS_ERROR) {
                printf("IO Channel read error");
                return FALSE;
        }
-       printf("%s\n",buf);
+       printf("%s\n", buf);
        tc_usage_print();
 
        test_id = atoi(buf);